Skip to content

Commit cddb7f3

Browse files
committed
Merge branch 'jest-community:main' into prefer-jest-globals
2 parents fa44e3b + a5ca480 commit cddb7f3

15 files changed

+1192
-466
lines changed

.DS_Store

-6 KB
Binary file not shown.

.eslint-doc-generatorrc.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ const { prettier: prettierRC } = require('./package.json');
33

44
/** @type {import('eslint-doc-generator').GenerateOptions} */
55
const config = {
6-
ignoreConfig: ['all'],
6+
ignoreConfig: [
7+
'all',
8+
'flat/all',
9+
'flat/recommended',
10+
'flat/style',
11+
'flat/snapshots',
12+
],
713
ruleDocTitleFormat: 'desc-parens-name',
814
ruleDocSectionInclude: ['Rule details'],
915
ruleListColumns: [

.github/workflows/nodejs.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,23 @@ jobs:
7373
matrix:
7474
node-version: [14.x, 16.x, 18.x, 19.x, 20.x, 21.x]
7575
eslint-version: [7, 8]
76-
ts-eslint-plugin-version: [5, 6]
76+
ts-eslint-plugin-version: [5, 6, 7]
7777
exclude:
7878
# ts-eslint/plugin@6 doesn't support node@14
7979
- node-version: 14.x
8080
ts-eslint-plugin-version: 6
81+
# ts-eslint/plugin@7 doesn't support node@14
82+
- node-version: 14.x
83+
ts-eslint-plugin-version: 7
84+
# ts-eslint/plugin@7 doesn't support node@16
85+
- node-version: 16.x
86+
ts-eslint-plugin-version: 7
87+
# ts-eslint/plugin@7 doesn't support node@19
88+
- node-version: 19.x
89+
ts-eslint-plugin-version: 7
90+
# ts-eslint/plugin@7 doesn't support eslint@7
91+
- eslint-version: 7
92+
ts-eslint-plugin-version: 7
8193
runs-on: ubuntu-latest
8294

8395
steps:

CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# [27.9.0](https://github.com/jest-community/eslint-plugin-jest/compare/v27.8.0...v27.9.0) (2024-02-16)
2+
3+
4+
### Features
5+
6+
* add should-be-fine support for flat configs ([#1505](https://github.com/jest-community/eslint-plugin-jest/issues/1505)) ([4cc2a1b](https://github.com/jest-community/eslint-plugin-jest/commit/4cc2a1b680507ff006b5d2b02fa6d262584bb263))
7+
8+
# [27.8.0](https://github.com/jest-community/eslint-plugin-jest/compare/v27.7.0...v27.8.0) (2024-02-13)
9+
10+
11+
### Features
12+
13+
* support `failing.each` ([#1499](https://github.com/jest-community/eslint-plugin-jest/issues/1499)) ([9e9cf83](https://github.com/jest-community/eslint-plugin-jest/commit/9e9cf8302ae182402da853a11b05e1560ccc63ee))
14+
15+
# [27.7.0](https://github.com/jest-community/eslint-plugin-jest/compare/v27.6.3...v27.7.0) (2024-02-13)
16+
17+
18+
### Features
19+
20+
* allow `[@typescript-eslint](https://github.com/typescript-eslint)` v7 ([#1500](https://github.com/jest-community/eslint-plugin-jest/issues/1500)) ([6be2928](https://github.com/jest-community/eslint-plugin-jest/commit/6be2928816c69afca88a598e302910b113068ee9))
21+
122
## [27.6.3](https://github.com/jest-community/eslint-plugin-jest/compare/v27.6.2...v27.6.3) (2024-01-12)
223

324

README.md

+117-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ yarn add --dev eslint eslint-plugin-jest
2222

2323
## Usage
2424

25+
> [!NOTE]
26+
>
27+
> `eslint.config.js` is supported, though most of the plugin documentation still
28+
> currently uses `.eslintrc` syntax.
29+
>
30+
> Refer to the
31+
> [ESLint documentation on the new configuration file format](https://eslint.org/docs/latest/use/configure/configuration-files-new)
32+
> for more.
33+
2534
Add `jest` to the plugins section of your `.eslintrc` configuration file. You
2635
can omit the `eslint-plugin-` prefix:
2736

@@ -85,7 +94,7 @@ test-related. This means it's generally not suitable to include them in your
8594
top-level configuration as that applies to all files being linted which can
8695
include source files.
8796

88-
You can use
97+
For `.eslintrc` configs you can use
8998
[overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work)
9099
to have ESLint apply additional rules to specific files:
91100

@@ -106,6 +115,30 @@ to have ESLint apply additional rules to specific files:
106115
}
107116
```
108117

118+
For `eslint.config.js` you can use
119+
[`files` and `ignores`](https://eslint.org/docs/latest/use/configure/configuration-files-new#specifying-files-and-ignores):
120+
121+
```js
122+
const jest = require('eslint-plugin-jest');
123+
124+
module.exports = [
125+
...require('@eslint/js').configs.recommended,
126+
{
127+
files: ['test/**'],
128+
...jest.configs['flat/recommended'],
129+
rules: {
130+
...jest.configs['flat/recommended'].rules,
131+
'jest/prefer-expect-assertions': 'off',
132+
},
133+
},
134+
// you can also configure jest rules in other objects, so long as some of the `files` match
135+
{
136+
files: ['test/**'],
137+
rules: { 'jest/prefer-expect-assertions': 'off' },
138+
},
139+
];
140+
```
141+
109142
### Jest `version` setting
110143

111144
The behaviour of some rules (specifically [`no-deprecated-functions`][]) change
@@ -145,20 +178,41 @@ module.exports = {
145178

146179
## Shareable configurations
147180

181+
> [!NOTE]
182+
>
183+
> `eslint.config.js` compatible versions of configs are available prefixed with
184+
> `flat/` and may be subject to small breaking changes while ESLint v9 is being
185+
> finalized.
186+
148187
### Recommended
149188

150189
This plugin exports a recommended configuration that enforces good testing
151190
practices.
152191

153-
To enable this configuration use the `extends` property in your `.eslintrc`
154-
config file:
192+
To enable this configuration with `.eslintrc`, use the `extends` property:
155193

156194
```json
157195
{
158196
"extends": ["plugin:jest/recommended"]
159197
}
160198
```
161199

200+
To enable this configuration with `eslint.config.js`, use
201+
`jest.configs['flat/recommended']`:
202+
203+
```js
204+
const jest = require('eslint-plugin-jest');
205+
206+
module.exports = [
207+
{
208+
files: [
209+
/* glob matching your test files */
210+
],
211+
...jest.configs['flat/recommended'],
212+
},
213+
];
214+
```
215+
162216
### Style
163217

164218
This plugin also exports a configuration named `style`, which adds some
@@ -174,9 +228,21 @@ config file:
174228
}
175229
```
176230

177-
See
178-
[ESLint documentation](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files)
179-
for more information about extending configuration files.
231+
To enable this configuration with `eslint.config.js`, use
232+
`jest.configs['flat/style']`:
233+
234+
```js
235+
const jest = require('eslint-plugin-jest');
236+
237+
module.exports = [
238+
{
239+
files: [
240+
/* glob matching your test files */
241+
],
242+
...jest.configs['flat/style'],
243+
},
244+
];
245+
```
180246

181247
### All
182248

@@ -189,10 +255,55 @@ If you want to enable all rules instead of only some you can do so by adding the
189255
}
190256
```
191257

258+
To enable this configuration with `eslint.config.js`, use
259+
`jest.configs['flat/all']`:
260+
261+
```js
262+
const jest = require('eslint-plugin-jest');
263+
264+
module.exports = [
265+
{
266+
files: [
267+
/* glob matching your test files */
268+
],
269+
...jest.configs['flat/all'],
270+
},
271+
];
272+
```
273+
192274
While the `recommended` and `style` configurations only change in major versions
193275
the `all` configuration may change in any release and is thus unsuited for
194276
installations requiring long-term consistency.
195277

278+
## Snapshot processing
279+
280+
> [!NOTE]
281+
>
282+
> This is only relevant for `eslint.config.js`
283+
284+
This plugin provides a
285+
[custom processor](https://eslint.org/docs/latest/extend/custom-processors) to
286+
allow rules to "lint" snapshot files.
287+
288+
For `.eslintrc` based configs, this is automatically enabled out of the box but
289+
must be opted into for `eslint.config.js` using the `flat/snapshots` config:
290+
291+
```js
292+
const jest = require('eslint-plugin-jest');
293+
294+
module.exports = [
295+
{
296+
...jest.configs['flat/snapshots'],
297+
rules: {
298+
'jest/no-large-snapshots': ['error', { maxSize: 1 }],
299+
},
300+
},
301+
];
302+
```
303+
304+
Unlike other configs, this includes a `files` array that matches `.snap` files
305+
meaning you can use it directly
306+
196307
## Rules
197308

198309
<!-- begin auto-generated rules list -->

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-jest",
3-
"version": "27.6.3",
3+
"version": "27.9.0",
44
"description": "ESLint rules for Jest",
55
"keywords": [
66
"eslint",
@@ -142,7 +142,7 @@
142142
"typescript": "^5.0.4"
143143
},
144144
"peerDependencies": {
145-
"@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0",
145+
"@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0 || ^7.0.0",
146146
"eslint": "^7.0.0 || ^8.0.0",
147147
"jest": "*"
148148
},

0 commit comments

Comments
 (0)