Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ With
just import the plugin and away you go:

```js
const { defineConfig } = require('@eslint/config');
const pluginJest = require('eslint-plugin-jest');

module.exports = [
module.exports = defineConfig([
{
// update this to match your test files
files: ['**/*.spec.js', '**/*.test.js'],
Expand All @@ -47,7 +48,7 @@ module.exports = [
'jest/valid-expect': 'error',
},
},
];
]);
```

With legacy configuration, add `jest` to the plugins section of your `.eslintrc`
Expand Down Expand Up @@ -146,15 +147,15 @@ For `eslint.config.js` you can use
[`files` and `ignores`](https://eslint.org/docs/latest/use/configure/configuration-files-new#specifying-files-and-ignores):

```js
const { defineConfig } = require('@eslint/config');
const jest = require('eslint-plugin-jest');

module.exports = [
module.exports = defaultConfig([
...require('@eslint/js').configs.recommended,
{
files: ['test/**'],
...jest.configs['flat/recommended'],
extends: [jest.configs['flat/recommended']],
rules: {
...jest.configs['flat/recommended'].rules,
'jest/prefer-expect-assertions': 'off',
},
},
Expand All @@ -163,7 +164,7 @@ module.exports = [
files: ['test/**'],
rules: { 'jest/prefer-expect-assertions': 'off' },
},
];
]);
```

### Jest `version` setting
Expand Down Expand Up @@ -228,16 +229,17 @@ To enable this configuration with `eslint.config.js`, use
`jest.configs['flat/recommended']`:

```js
const { defineConfig } = require('@eslint/config');
const jest = require('eslint-plugin-jest');

module.exports = [
module.exports = defineConfig([
{
files: [
/* glob matching your test files */
],
...jest.configs['flat/recommended'],
extends: [jest.configs['flat/recommended']],
},
];
]);
```

### Style
Expand All @@ -259,16 +261,17 @@ To enable this configuration with `eslint.config.js`, use
`jest.configs['flat/style']`:

```js
const { defineConfig } = require('@eslint/config');
const jest = require('eslint-plugin-jest');

module.exports = [
module.exports = defineConfig([
{
files: [
/* glob matching your test files */
],
...jest.configs['flat/style'],
extends: [jest.configs['flat/style']],
},
];
]);
```

### All
Expand All @@ -286,16 +289,17 @@ To enable this configuration with `eslint.config.js`, use
`jest.configs['flat/all']`:

```js
const { defineConfig } = require('@eslint/config');
const jest = require('eslint-plugin-jest');

module.exports = [
module.exports = defineConfig([
{
files: [
/* glob matching your test files */
],
...jest.configs['flat/all'],
extends: [jest.configs['flat/all']],
},
];
]);
```

While the `recommended` and `style` configurations only change in major versions
Expand Down
Loading