Skip to content

Commit 4e60c61

Browse files
committed
Update eslint-plugin-jest v29.12.1
- Enable the `jest/no-error-equal` rule as an error. - Enable the `jest/no-unnecessary-assertion` rule as an error. - Enable the `jest/no-unneeded-async-expect-function` rule as a warning. - Enable the `jest/prefer-mock-return-shorthand` rule as a warning. - Enable the `jest/prefer-to-have-been-called` rule as a warning. - Enable the `jest/prefer-to-have-been-called-times` rule as a warning. - Enable the `jest/valid-expect-with-promise` rule as an error. - Enable the `jest/valid-mock-module-path` rule as an error.
1 parent 1aecbfd commit 4e60c61

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"eslint-plugin-array-func": "^5.1.0",
4242
"eslint-plugin-cypress": "^5.2.1",
4343
"eslint-plugin-import": "^2.32.0",
44-
"eslint-plugin-jest": "^29.0.1",
44+
"eslint-plugin-jest": "^29.12.1",
4545
"eslint-plugin-jest-dom": "^5.5.0",
4646
"eslint-plugin-jsdoc": "^54.1.1",
4747
"eslint-plugin-n": "^17.21.3",
@@ -84,7 +84,7 @@
8484
"eslint-plugin-array-func": "5.1.0",
8585
"eslint-plugin-cypress": "5.2.1",
8686
"eslint-plugin-import": "2.32.0",
87-
"eslint-plugin-jest": "29.0.1",
87+
"eslint-plugin-jest": "29.12.1",
8888
"eslint-plugin-jest-dom": "5.5.0",
8989
"eslint-plugin-jsdoc": "54.1.1",
9090
"eslint-plugin-n": "17.21.3",

src/config/jest/index.adoc

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ Class → Method → Method Signature → Precondition ("When").
149149
|
150150
| Error
151151

152+
| `link:{eslint-jest-rules}/no-unneeded-async-expect-function.md[jest/no-unneeded-async-expect-function]`
153+
|
154+
| Yes
155+
| Warning
156+
152157
| `link:{eslint-jest-rules}/no-untyped-mock-factory.md[jest/no-untyped-mock-factory]`
153158
|
154159
| Yes
@@ -260,6 +265,11 @@ Class → Method → Method Signature → Precondition ("When").
260265
| Yes
261266
| Warning
262267

268+
| `link:{eslint-jest-rules}/prefer-mock-return-shorthand.md[jest/prefer-mock-return-shorthand]`
269+
|
270+
| Yes
271+
| Warning
272+
263273
| `link:{eslint-jest-rules}/prefer-snapshot-hint.md[jest/prefer-snapshot-hint]`
264274
|
265275
|
@@ -285,6 +295,16 @@ Class → Method → Method Signature → Precondition ("When").
285295
| Yes
286296
| Warning
287297

298+
| `link:{eslint-jest-rules}/prefer-to-have-been-called.md[jest/prefer-to-have-been-called]`
299+
|
300+
| Yes
301+
| Warning
302+
303+
| `link:{eslint-jest-rules}/prefer-to-have-been-called-times.md[jest/prefer-to-have-been-called-times]`
304+
|
305+
| Yes
306+
| Warning
307+
288308
| `link:{eslint-jest-rules}/prefer-to-have-length.md[jest/prefer-to-have-length]`
289309
|
290310
| Yes
@@ -325,6 +345,11 @@ Class → Method → Method Signature → Precondition ("When").
325345
|
326346
| Error
327347

348+
| `link:{eslint-jest-rules}/valid-mock-module-path.md[jest/valid-mock-module-path]`
349+
|
350+
|
351+
| Error
352+
328353
| `link:{eslint-jest-rules}/valid-title.md[jest/valid-title]`
329354
| Yes
330355
| Yes
@@ -339,10 +364,25 @@ Class → Method → Method Signature → Precondition ("When").
339364
|===
340365
| Rule | Recommended | Fixable | Config
341366

342-
| `link:{eslint-jest-rules}/unbound-method.md[jest/valid-title]`
367+
| `link:{eslint-jest-rules}/no-error-equal.md[jest/no-error-equal]`
368+
|
369+
|
370+
| Error
371+
372+
| `link:{eslint-jest-rules}/no-unnecessary-assertion.md[jest/no-unnecessary-assertion]`
373+
|
374+
|
375+
| Error
376+
377+
| `link:{eslint-jest-rules}/unbound-method.md[jest/unbound-method]`
343378
|
344379
|
345380
| Error
346381
4+| Extends the base `@typescript-eslint/unbound-method` rule to support `expect` calls.
347382

383+
| `link:{eslint-jest-rules}/valid-expect-with-promise.md[jest/valid-expect-with-promise]`
384+
|
385+
|
386+
| Error
387+
348388
|===

src/config/jest/jest-config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function jestConfig(files: Glob[] = jestFiles): Linter.Config {
6464
'jest/no-standalone-expect': 'error',
6565
'jest/no-test-prefixes': 'warn',
6666
'jest/no-test-return-statement': 'error',
67+
'jest/no-unneeded-async-expect-function': 'warn',
6768
'jest/no-untyped-mock-factory': 'warn',
6869
'jest/padding-around-after-all-blocks': 'warn',
6970
'jest/padding-around-after-each-blocks': 'warn',
@@ -87,14 +88,18 @@ export function jestConfig(files: Glob[] = jestFiles): Linter.Config {
8788
'jest/prefer-lowercase-title': ['error', {
8889
allowedPrefixes: [],
8990
ignore: [],
91+
ignoreTodos: false,
9092
ignoreTopLevelDescribe: true,
9193
}],
9294
'jest/prefer-mock-promise-shorthand': 'warn',
95+
'jest/prefer-mock-return-shorthand': 'warn',
9396
'jest/prefer-snapshot-hint': ['error', 'always'],
9497
'jest/prefer-spy-on': 'warn',
9598
'jest/prefer-strict-equal': 'warn',
9699
'jest/prefer-to-be': 'warn',
97100
'jest/prefer-to-contain': 'warn',
101+
'jest/prefer-to-have-been-called': 'warn',
102+
'jest/prefer-to-have-been-called-times': 'warn',
98103
'jest/prefer-to-have-length': 'warn',
99104
'jest/prefer-todo': 'warn',
100105
'jest/require-hook': ['error', {
@@ -105,6 +110,7 @@ export function jestConfig(files: Glob[] = jestFiles): Linter.Config {
105110
'jest/valid-describe-callback': 'error',
106111
'jest/valid-expect-in-promise': 'error',
107112
'jest/valid-expect': 'error',
113+
'jest/valid-mock-module-path': 'error',
108114
'jest/valid-title': ['warn', {
109115
ignoreTypeOfDescribeName: true,
110116
ignoreTypeOfTestName: false,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Linter } from 'eslint';
22

33
export const typescriptEslintJestRules: Linter.RulesRecord = {
4+
'jest/no-error-equal': 'error',
5+
'jest/no-unnecessary-assertion': 'error',
46
'jest/unbound-method': ['error', {
57
ignoreStatic: false,
68
}],
9+
'jest/valid-expect-with-promise': 'error',
710
};

0 commit comments

Comments
 (0)