eslint-plugin-jest 27.1.2 → 27.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +81 -80
  2. package/docs/rules/consistent-test-it.md +4 -11
  3. package/docs/rules/expect-expect.md +3 -4
  4. package/docs/rules/max-expects.md +1 -5
  5. package/docs/rules/max-nested-describe.md +1 -5
  6. package/docs/rules/no-alias-methods.md +8 -10
  7. package/docs/rules/no-commented-out-tests.md +3 -4
  8. package/docs/rules/no-conditional-expect.md +4 -5
  9. package/docs/rules/no-conditional-in-test.md +1 -5
  10. package/docs/rules/no-deprecated-functions.md +5 -7
  11. package/docs/rules/no-disabled-tests.md +3 -4
  12. package/docs/rules/no-done-callback.md +6 -8
  13. package/docs/rules/no-duplicate-hooks.md +1 -5
  14. package/docs/rules/no-export.md +3 -4
  15. package/docs/rules/no-focused-tests.md +5 -7
  16. package/docs/rules/no-hooks.md +1 -5
  17. package/docs/rules/no-identical-title.md +3 -4
  18. package/docs/rules/no-if.md +2 -2
  19. package/docs/rules/no-interpolation-in-snapshots.md +3 -4
  20. package/docs/rules/no-jasmine-globals.md +6 -8
  21. package/docs/rules/no-large-snapshots.md +2 -6
  22. package/docs/rules/no-mocks-import.md +3 -4
  23. package/docs/rules/no-restricted-jest-methods.md +1 -5
  24. package/docs/rules/no-restricted-matchers.md +1 -5
  25. package/docs/rules/no-standalone-expect.md +3 -4
  26. package/docs/rules/no-test-prefixes.md +6 -8
  27. package/docs/rules/no-test-return-statement.md +1 -5
  28. package/docs/rules/prefer-called-with.md +1 -5
  29. package/docs/rules/prefer-comparison-matcher.md +3 -8
  30. package/docs/rules/prefer-each.md +1 -5
  31. package/docs/rules/prefer-equality-matcher.md +3 -8
  32. package/docs/rules/prefer-expect-assertions.md +3 -10
  33. package/docs/rules/prefer-expect-resolves.md +3 -8
  34. package/docs/rules/prefer-hooks-in-order.md +1 -5
  35. package/docs/rules/prefer-hooks-on-top.md +1 -5
  36. package/docs/rules/prefer-lowercase-title.md +3 -8
  37. package/docs/rules/prefer-mock-promise-shorthand.md +3 -8
  38. package/docs/rules/prefer-snapshot-hint.md +1 -5
  39. package/docs/rules/prefer-spy-on.md +3 -10
  40. package/docs/rules/prefer-strict-equal.md +3 -10
  41. package/docs/rules/prefer-to-be.md +5 -7
  42. package/docs/rules/prefer-to-contain.md +5 -9
  43. package/docs/rules/prefer-to-have-length.md +5 -9
  44. package/docs/rules/prefer-todo.md +3 -10
  45. package/docs/rules/require-hook.md +1 -5
  46. package/docs/rules/require-to-throw-message.md +1 -7
  47. package/docs/rules/require-top-level-describe.md +1 -5
  48. package/docs/rules/unbound-method.md +2 -4
  49. package/docs/rules/valid-describe-callback.md +3 -4
  50. package/docs/rules/valid-expect-in-promise.md +4 -5
  51. package/docs/rules/valid-expect.md +3 -6
  52. package/docs/rules/valid-title.md +5 -7
  53. package/lib/index.js +8 -16
  54. package/lib/processors/snapshot-processor.js +3 -5
  55. package/lib/rules/consistent-test-it.js +1 -19
  56. package/lib/rules/expect-expect.js +0 -15
  57. package/lib/rules/max-expects.js +0 -16
  58. package/lib/rules/max-nested-describe.js +0 -13
  59. package/lib/rules/no-alias-methods.js +0 -9
  60. package/lib/rules/no-commented-out-tests.js +0 -10
  61. package/lib/rules/no-conditional-expect.js +1 -20
  62. package/lib/rules/no-conditional-in-test.js +0 -9
  63. package/lib/rules/no-deprecated-functions.js +2 -18
  64. package/lib/rules/no-disabled-tests.js +2 -18
  65. package/lib/rules/no-done-callback.js +2 -31
  66. package/lib/rules/no-duplicate-hooks.js +0 -12
  67. package/lib/rules/no-export.js +0 -12
  68. package/lib/rules/no-focused-tests.js +0 -15
  69. package/lib/rules/no-hooks.js +0 -7
  70. package/lib/rules/no-identical-title.js +0 -19
  71. package/lib/rules/no-if.js +0 -24
  72. package/lib/rules/no-interpolation-in-snapshots.js +0 -9
  73. package/lib/rules/no-jasmine-globals.js +0 -22
  74. package/lib/rules/no-large-snapshots.js +3 -21
  75. package/lib/rules/no-mocks-import.js +0 -12
  76. package/lib/rules/no-restricted-jest-methods.js +1 -11
  77. package/lib/rules/no-restricted-matchers.js +0 -11
  78. package/lib/rules/no-standalone-expect.js +7 -33
  79. package/lib/rules/no-test-prefixes.js +1 -13
  80. package/lib/rules/no-test-return-statement.js +0 -12
  81. package/lib/rules/prefer-called-with.js +0 -10
  82. package/lib/rules/prefer-comparison-matcher.js +8 -33
  83. package/lib/rules/prefer-each.js +0 -18
  84. package/lib/rules/prefer-equality-matcher.js +11 -23
  85. package/lib/rules/prefer-expect-assertions.js +4 -51
  86. package/lib/rules/prefer-expect-resolves.js +0 -12
  87. package/lib/rules/prefer-hooks-in-order.js +2 -16
  88. package/lib/rules/prefer-hooks-on-top.js +0 -9
  89. package/lib/rules/prefer-lowercase-title.js +0 -23
  90. package/lib/rules/prefer-mock-promise-shorthand.js +5 -26
  91. package/lib/rules/prefer-snapshot-hint.js +7 -31
  92. package/lib/rules/prefer-spy-on.js +0 -17
  93. package/lib/rules/prefer-strict-equal.js +0 -9
  94. package/lib/rules/prefer-to-be.js +1 -30
  95. package/lib/rules/prefer-to-contain.js +11 -21
  96. package/lib/rules/prefer-to-have-length.js +4 -16
  97. package/lib/rules/prefer-todo.js +2 -18
  98. package/lib/rules/require-hook.js +0 -22
  99. package/lib/rules/require-to-throw-message.js +0 -9
  100. package/lib/rules/require-top-level-describe.js +0 -15
  101. package/lib/rules/unbound-method.js +2 -21
  102. package/lib/rules/utils/accessors.js +6 -18
  103. package/lib/rules/utils/detectJestVersion.js +2 -7
  104. package/lib/rules/utils/followTypeAssertionChain.js +0 -4
  105. package/lib/rules/utils/index.js +0 -10
  106. package/lib/rules/utils/misc.js +2 -46
  107. package/lib/rules/utils/parseJestFnCall.js +62 -118
  108. package/lib/rules/valid-describe-callback.js +0 -17
  109. package/lib/rules/valid-expect-in-promise.js +27 -94
  110. package/lib/rules/valid-expect.js +5 -48
  111. package/lib/rules/valid-title.js +0 -33
  112. package/package.json +3 -2
package/README.md CHANGED
@@ -195,70 +195,84 @@ installations requiring long-term consistency.
195
195
 
196
196
  ## Rules
197
197
 
198
- <!-- begin base rules list -->
199
-
200
- | Rule | Description | Configurations | Fixable |
201
- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------- | ------------ |
202
- | [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] |
203
- | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
204
- | [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | |
205
- | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
206
- | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
207
- | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
208
- | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
209
- | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | |
210
- | [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | ![recommended][] | ![fixable][] |
211
- | [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | |
212
- | [no-done-callback](docs/rules/no-done-callback.md) | Avoid using a callback in asynchronous tests and hooks | ![recommended][] | ![suggest][] |
213
- | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | |
214
- | [no-export](docs/rules/no-export.md) | Disallow using `exports` in files containing tests | ![recommended][] | |
215
- | [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
216
- | [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
217
- | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
218
- | [no-if](docs/rules/no-if.md) | Disallow conditional logic | ![deprecated][] | |
219
- | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
220
- | [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
221
- | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
222
- | [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | |
223
- | [no-restricted-jest-methods](docs/rules/no-restricted-jest-methods.md) | Disallow specific `jest.` methods | | |
224
- | [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | |
225
- | [no-standalone-expect](docs/rules/no-standalone-expect.md) | Disallow using `expect` outside of `it` or `test` blocks | ![recommended][] | |
226
- | [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] |
227
- | [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | |
228
- | [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | |
229
- | [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | Suggest using the built-in comparison matchers | | ![fixable][] |
230
- | [prefer-each](docs/rules/prefer-each.md) | Prefer using `.each` rather than manual loops | | |
231
- | [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | Suggest using the built-in equality matchers | | ![suggest][] |
232
- | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] |
233
- | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | Prefer `await expect(...).resolves` over `expect(await ...)` syntax | | ![fixable][] |
234
- | [prefer-hooks-in-order](docs/rules/prefer-hooks-in-order.md) | Prefer having hooks in a consistent order | | |
235
- | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | |
236
- | [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names | | ![fixable][] |
237
- | [prefer-mock-promise-shorthand](docs/rules/prefer-mock-promise-shorthand.md) | Prefer mock resolved/rejected shorthands for promises | | ![fixable][] |
238
- | [prefer-snapshot-hint](docs/rules/prefer-snapshot-hint.md) | Prefer including a hint with external snapshots | | |
239
- | [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] |
240
- | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] |
241
- | [prefer-to-be](docs/rules/prefer-to-be.md) | Suggest using `toBe()` for primitive literals | ![style][] | ![fixable][] |
242
- | [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] |
243
- | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] |
244
- | [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] |
245
- | [require-hook](docs/rules/require-hook.md) | Require setup and teardown code to be within a hook | | |
246
- | [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | |
247
- | [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | |
248
- | [valid-describe-callback](docs/rules/valid-describe-callback.md) | Enforce valid `describe()` callback | ![recommended][] | |
249
- | [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | |
250
- | [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Ensure promises that have expectations in their chain are valid | ![recommended][] | |
251
- | [valid-title](docs/rules/valid-title.md) | Enforce valid titles | ![recommended][] | ![fixable][] |
252
-
253
- <!-- end base rules list -->
254
-
255
- ## TypeScript Rules
256
-
257
- In addition to the above rules, this plugin also includes a few advanced rules
258
- that are powered by type-checking information provided by TypeScript.
259
-
260
- In order to use these rules, you must be using `@typescript-eslint/parser` &
261
- adjust your eslint config as outlined
198
+ <!-- begin auto-generated rules list -->
199
+
200
+ 💼
201
+ [Configurations](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations)
202
+ enabled in.\
203
+ ⚠️ [Configurations](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations)
204
+ set to warn in.\
205
+ Set in the `recommended`
206
+ [configuration](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).\
207
+ 🎨 Set in the `style` [configuration](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).\
208
+ 🔧 Automatically fixable by the
209
+ [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
210
+ 💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).\
211
+ Deprecated.
212
+
213
+ | Name                          | Description | 💼 | ⚠️ | 🔧 | 💡 | |
214
+ | :--------------------------------------------------------------------------- | :------------------------------------------------------------------ | :-- | :-- | :-- | :-- | :-- |
215
+ | [consistent-test-it](docs/rules/consistent-test-it.md) | Enforce `test` and `it` usage conventions | | | 🔧 | | |
216
+ | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | || | | |
217
+ | [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | | | | |
218
+ | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | | | | |
219
+ | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ✅ | 🎨 | 🔧 | | |
220
+ | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | | | | | |
221
+ | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Disallow calling `expect` conditionally || | | | |
222
+ | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | | | | |
223
+ | [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions || | 🔧 | | |
224
+ | [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | | | | | |
225
+ | [no-done-callback](docs/rules/no-done-callback.md) | Disallow using a callback in asynchronous tests and hooks | ✅ | | | 💡 | |
226
+ | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | | | |
227
+ | [no-export](docs/rules/no-export.md) | Disallow using `exports` in files containing tests || | | | |
228
+ | [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ✅ | | | 💡 | |
229
+ | [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | | | |
230
+ | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | | | | | |
231
+ | [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | | | |
232
+ | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ✅ | | | | |
233
+ | [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | | | 🔧 | | |
234
+ | [no-large-snapshots](docs/rules/no-large-snapshots.md) | Disallow large snapshots | | | | | |
235
+ | [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | | | | | |
236
+ | [no-restricted-jest-methods](docs/rules/no-restricted-jest-methods.md) | Disallow specific `jest.` methods | | | | | |
237
+ | [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | | | |
238
+ | [no-standalone-expect](docs/rules/no-standalone-expect.md) | Disallow using `expect` outside of `it` or `test` blocks || | | | |
239
+ | [no-test-prefixes](docs/rules/no-test-prefixes.md) | Require using `.only` and `.skip` over `f` and `x` | ✅ | | 🔧 | | |
240
+ | [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | | | |
241
+ | [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | | | | |
242
+ | [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | Suggest using the built-in comparison matchers | | | 🔧 | | |
243
+ | [prefer-each](docs/rules/prefer-each.md) | Prefer using `.each` rather than manual loops | | | | | |
244
+ | [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | Suggest using the built-in equality matchers | | | | 💡 | |
245
+ | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | | | 💡 | |
246
+ | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | Prefer `await expect(...).resolves` over `expect(await ...)` syntax | | | 🔧 | | |
247
+ | [prefer-hooks-in-order](docs/rules/prefer-hooks-in-order.md) | Prefer having hooks in a consistent order | | | | | |
248
+ | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | | | | |
249
+ | [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names | | | 🔧 | | |
250
+ | [prefer-mock-promise-shorthand](docs/rules/prefer-mock-promise-shorthand.md) | Prefer mock resolved/rejected shorthands for promises | | | 🔧 | | |
251
+ | [prefer-snapshot-hint](docs/rules/prefer-snapshot-hint.md) | Prefer including a hint with external snapshots | | | | | |
252
+ | [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | | 🔧 | | |
253
+ | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | | | 💡 | |
254
+ | [prefer-to-be](docs/rules/prefer-to-be.md) | Suggest using `toBe()` for primitive literals | 🎨 | | 🔧 | | |
255
+ | [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | 🎨 | | 🔧 | | |
256
+ | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | 🎨 | | 🔧 | | |
257
+ | [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | | 🔧 | | |
258
+ | [require-hook](docs/rules/require-hook.md) | Require setup and teardown code to be within a hook | | | | | |
259
+ | [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | | | |
260
+ | [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | | | | |
261
+ | [valid-describe-callback](docs/rules/valid-describe-callback.md) | Enforce valid `describe()` callback | ✅ | | | | |
262
+ | [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ✅ | | | | |
263
+ | [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Require promises that have expectations in their chain to be valid | ✅ | | | | |
264
+ | [valid-title](docs/rules/valid-title.md) | Enforce valid titles | ✅ | | 🔧 | | |
265
+
266
+ ### Requires Type Checking
267
+
268
+ | Name           | Description | 💼 | ⚠️ | 🔧 | 💡 | ❌ |
269
+ | :--------------------------------------------- | :----------------------------------------------------------- | :-- | :-- | :-- | :-- | :-- |
270
+ | [unbound-method](docs/rules/unbound-method.md) | Enforce unbound methods are called with their expected scope | | | | | |
271
+
272
+ <!-- end auto-generated rules list -->
273
+
274
+ In order to use the rules powered by TypeScript type-checking, you must be using
275
+ `@typescript-eslint/parser` & adjust your eslint config as outlined
262
276
  [here](https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TYPED_LINTING.md).
263
277
 
264
278
  Note that unlike the type-checking rules in `@typescript-eslint/eslint-plugin`,
@@ -269,14 +283,6 @@ used on JavaScript and TypeScript projects.
269
283
  Also note that `unbound-method` depends on `@typescript-eslint/eslint-plugin`,
270
284
  as it extends the original `unbound-method` rule from that plugin.
271
285
 
272
- <!-- begin type rules list -->
273
-
274
- | Rule | Description | Configurations | Fixable |
275
- | ---------------------------------------------- | ------------------------------------------------------------ | -------------- | ------- |
276
- | [unbound-method](docs/rules/unbound-method.md) | Enforce unbound methods are called with their expected scope | | |
277
-
278
- <!-- end type rules list -->
279
-
280
286
  ## Credit
281
287
 
282
288
  - [eslint-plugin-mocha](https://github.com/lo1tuma/eslint-plugin-mocha)
@@ -290,25 +296,20 @@ This is a sister plugin to `eslint-plugin-jest` that provides support for the
290
296
  matchers provided by
291
297
  [`jest-extended`](https://github.com/jest-community/jest-extended).
292
298
 
293
- https://github.com/jest-community/eslint-plugin-jest-extended
299
+ <https://github.com/jest-community/eslint-plugin-jest-extended>
294
300
 
295
301
  ### eslint-plugin-jest-formatting
296
302
 
297
303
  This project aims to provide formatting rules (auto-fixable where possible) to
298
304
  ensure consistency and readability in jest test suites.
299
305
 
300
- https://github.com/dangreenisrael/eslint-plugin-jest-formatting
306
+ <https://github.com/dangreenisrael/eslint-plugin-jest-formatting>
301
307
 
302
308
  ### eslint-plugin-istanbul
303
309
 
304
310
  A set of rules to enforce good practices for Istanbul, one of the code coverage
305
311
  tools used by Jest.
306
312
 
307
- https://github.com/istanbuljs/eslint-plugin-istanbul
313
+ <https://github.com/istanbuljs/eslint-plugin-istanbul>
308
314
 
309
- [recommended]: https://img.shields.io/badge/-recommended-lightgrey.svg
310
- [suggest]: https://img.shields.io/badge/-suggest-yellow.svg
311
- [fixable]: https://img.shields.io/badge/-fixable-green.svg
312
- [style]: https://img.shields.io/badge/-style-blue.svg
313
- [deprecated]: https://img.shields.io/badge/-deprecated-red.svg
314
315
  [`no-deprecated-functions`]: docs/rules/no-deprecated-functions.md
@@ -1,14 +1,9 @@
1
- # Have control over `test` and `it` usages (`consistent-test-it`)
1
+ # Enforce `test` and `it` usage conventions (`consistent-test-it`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
3
+ 🔧 This rule is automatically fixable by the
4
+ [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
5
 
7
- 🔧 This rule is automatically fixable using the `--fix`
8
- [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix)
9
- on the command line.
10
-
11
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
12
7
 
13
8
  Jest allows you to choose how you want to define your tests, using the `it` or
14
9
  the `test` keywords, with multiple permutations for each:
@@ -81,8 +76,6 @@ describe('foo', function () {
81
76
  });
82
77
  ```
83
78
 
84
- ### Default configuration
85
-
86
79
  The default configuration forces all top-level tests to use `test` and all tests
87
80
  nested within `describe` to use `it`.
88
81
 
@@ -1,10 +1,9 @@
1
1
  # Enforce assertion to be made in a test body (`expect-expect`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
3
+ ⚠️ This rule _warns_ in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  Ensure that there is at least one `expect` call made in a test.
10
9
 
@@ -1,10 +1,6 @@
1
1
  # Enforces a maximum number assertion calls in a test body (`max-expects`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  As more assertions are made, there is a possible tendency for the test to be
10
6
  more likely to mix multiple objectives. To avoid this, this rule reports when
@@ -1,10 +1,6 @@
1
1
  # Enforces a maximum depth to nested describe calls (`max-nested-describe`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  While it's useful to be able to group your tests together within the same file
10
6
  using `describe()`, having too many levels of nesting throughout your tests make
@@ -1,17 +1,17 @@
1
1
  # Disallow alias methods (`no-alias-methods`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼⚠️ This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
5
+ This rule _warns_ in the 🎨 `style`
6
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
7
 
7
- 🔧 This rule is automatically fixable using the `--fix`
8
- [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix)
9
- on the command line.
8
+ 🔧 This rule is automatically fixable by the
9
+ [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
10
10
 
11
- <!-- end rule header -->
11
+ <!-- end auto-generated rule header -->
12
12
 
13
13
  > These aliases are going to be removed in the next major version of Jest - see
14
- > https://github.com/facebook/jest/issues/13164 for more
14
+ > <https://github.com/facebook/jest/issues/13164> for more
15
15
 
16
16
  Several Jest methods have alias names, such as `toThrow` having the alias of
17
17
  `toThrowError`. This rule ensures that only the canonical name as used in the
@@ -24,8 +24,6 @@ method names used.
24
24
  This rule triggers a warning if the alias name, rather than the canonical name,
25
25
  of a method is used.
26
26
 
27
- ### Default configuration
28
-
29
27
  The following patterns are considered warnings:
30
28
 
31
29
  ```js
@@ -1,10 +1,9 @@
1
1
  # Disallow commented out tests (`no-commented-out-tests`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
3
+ ⚠️ This rule _warns_ in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  This rule raises a warning about commented out tests. It's similar to
10
9
  no-disabled-tests rule.
@@ -1,10 +1,9 @@
1
- # Prevent calling `expect` conditionally (`no-conditional-expect`)
1
+ # Disallow calling `expect` conditionally (`no-conditional-expect`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  This rule prevents the use of `expect` in conditional blocks, such as `if`s &
10
9
  `catch`s.
@@ -1,10 +1,6 @@
1
1
  # Disallow conditional logic in tests (`no-conditional-in-test`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  Conditional logic in tests is usually an indication that a test is attempting to
10
6
  cover too much, and not testing the logic it intends to. Each branch of code
@@ -1,14 +1,12 @@
1
1
  # Disallow use of deprecated functions (`no-deprecated-functions`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- 🔧 This rule is automatically fixable using the `--fix`
8
- [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix)
9
- on the command line.
6
+ 🔧 This rule is automatically fixable by the
7
+ [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
10
8
 
11
- <!-- end rule header -->
9
+ <!-- end auto-generated rule header -->
12
10
 
13
11
  Over the years Jest has accrued some debt in the form of functions that have
14
12
  either been renamed for clarity, or replaced with more powerful APIs.
@@ -1,10 +1,9 @@
1
1
  # Disallow disabled tests (`no-disabled-tests`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
3
+ ⚠️ This rule _warns_ in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  Jest has a feature that allows you to temporarily mark tests as disabled. This
10
9
  feature is often helpful while debugging or to create placeholders for future
@@ -1,14 +1,12 @@
1
- # Avoid using a callback in asynchronous tests and hooks (`no-done-callback`)
1
+ # Disallow using a callback in asynchronous tests and hooks (`no-done-callback`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- 💡 This rule provides
8
- [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
9
- that can be applied manually.
6
+ 💡 This rule is manually fixable by
7
+ [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
10
8
 
11
- <!-- end rule header -->
9
+ <!-- end auto-generated rule header -->
12
10
 
13
11
  When calling asynchronous code in hooks and tests, `jest` needs to know when the
14
12
  asynchronous work is complete to progress the current run.
@@ -1,10 +1,6 @@
1
1
  # Disallow duplicate setup and teardown hooks (`no-duplicate-hooks`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  A `describe` block should not contain duplicate hooks.
10
6
 
@@ -1,10 +1,9 @@
1
1
  # Disallow using `exports` in files containing tests (`no-export`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  Prevents using `exports` if a file has one or more tests in it.
10
9
 
@@ -1,14 +1,12 @@
1
1
  # Disallow focused tests (`no-focused-tests`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- 💡 This rule provides
8
- [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
9
- that can be applied manually.
6
+ 💡 This rule is manually fixable by
7
+ [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
10
8
 
11
- <!-- end rule header -->
9
+ <!-- end auto-generated rule header -->
12
10
 
13
11
  <!-- prettier-ignore -->
14
12
  Jest has a feature that allows you to focus tests by appending `.only` or
@@ -1,10 +1,6 @@
1
1
  # Disallow setup and teardown hooks (`no-hooks`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  Jest provides global functions for setup and teardown tasks, which are called
10
6
  before/after each test case and each test suite. The use of these hooks promotes
@@ -1,10 +1,9 @@
1
1
  # Disallow identical titles (`no-identical-title`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  Having identical titles for two different tests or test suites may create
10
9
  confusion. For example, when a test with the same title as another test in the
@@ -1,9 +1,9 @@
1
1
  # Disallow conditional logic (`no-if`)
2
2
 
3
3
  ❌ This rule is deprecated. It was replaced by
4
- [no-conditional-in-test](no-conditional-in-test.md).
4
+ [`no-conditional-in-test`](no-conditional-in-test.md).
5
5
 
6
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
7
7
 
8
8
  Conditional logic in tests is usually an indication that a test is attempting to
9
9
  cover too much, and not testing the logic it intends to. Each branch of code
@@ -1,10 +1,9 @@
1
1
  # Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  Prevents the use of string interpolations in snapshots.
10
9
 
@@ -1,14 +1,12 @@
1
1
  # Disallow Jasmine globals (`no-jasmine-globals`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- 🔧 This rule is automatically fixable using the `--fix`
8
- [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix)
9
- on the command line.
6
+ 🔧 This rule is automatically fixable by the
7
+ [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
10
8
 
11
- <!-- end rule header -->
9
+ <!-- end auto-generated rule header -->
12
10
 
13
11
  `jest` uses `jasmine` as a test runner. A side effect of this is that both a
14
12
  `jasmine` object, and some jasmine-specific globals, are exposed to the test
@@ -22,7 +20,7 @@ API.
22
20
  This rule reports on any usage of Jasmine globals, which is not ported to Jest,
23
21
  and suggests alternatives from Jest's own API.
24
22
 
25
- ### Default configuration
23
+ ## Examples
26
24
 
27
25
  The following patterns are considered warnings:
28
26
 
@@ -1,10 +1,6 @@
1
- # disallow large snapshots (`no-large-snapshots`)
1
+ # Disallow large snapshots (`no-large-snapshots`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`.
6
-
7
- <!-- end rule header -->
3
+ <!-- end auto-generated rule header -->
8
4
 
9
5
  When using Jest's snapshot capability one should be mindful of the size of
10
6
  created snapshots. As a general best practice snapshots should be limited in
@@ -1,10 +1,9 @@
1
1
  # Disallow manually importing from `__mocks__` (`no-mocks-import`)
2
2
 
3
- 💼 This rule is enabled in the following
4
- [configs](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations):
5
- `all`, `recommended`.
3
+ 💼 This rule is enabled in the ✅ `recommended`
4
+ [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
6
5
 
7
- <!-- end rule header -->
6
+ <!-- end auto-generated rule header -->
8
7
 
9
8
  When using `jest.mock`, your tests (just like the code being tested) should
10
9
  import from `./x`, not `./__mocks__/x`. Not following this rule can lead to