# Environment `env.vitest`

Creates configuration objects with global symbols and linter rules for unit tests using Vitest. Adds the following plugins and their recommended rules:

- [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest)
- [eslint-plugin-jest-extended](https://github.com/jest-community/eslint-plugin-jest-extended) (optional)
- [eslint-plugin-jest-dom](https://github.com/testing-library/eslint-plugin-jest-dom) (optional)
- [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) (optional)

## Signature

```ts
function vitest(options: EnvVitestOptions): ConfigArg
```

## Options

| Name | Type | Default | Description |
| - | - | - | - |
| `basePath` | `string` | `'.'` | Path to a sub directory to apply the environment preset to. |
| `files` | `Array<string\|string[]>` | _required_ | Glob patterns for source files to be included. Use embedded arrays for AND patterns. |
| `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
| `rules` | `RulesConfig` | `{}` | Additional linter rules to be added to the configuration. |
| `jestExtended` | `boolean` | `false` | Activate plugin `eslint-plugin-jest-extended`. |
| `jestDom` | `boolean` | `false` | Activate plugin `eslint-plugin-jest-dom`. |
| `testingLib` | `'angular'\|'dom'\|'marko'\|'react'\|'vue'` | _none_ | Add plugin `eslint-plugin-testing-library` for the specified environment. |

## Example

```ts
// eslint.config.ts
import { defineConfig, env } from '@open-xchange/linter-presets/eslint'

export default defineConfig(

  // project configuration options
  { /* ... */ },

  // Vitest environment
  env.vitest({
    files: ['test/**/*.{js,ts}'],
    testingLib: 'react',
    rules: { /* ... */ },
  }),
)
```
