eslint-plugin-jest 29.12.0 → 29.12.2

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 (73) hide show
  1. package/docs/rules/consistent-test-it.md +3 -1
  2. package/docs/rules/expect-expect.md +3 -1
  3. package/docs/rules/max-expects.md +3 -1
  4. package/docs/rules/max-nested-describe.md +3 -1
  5. package/docs/rules/no-alias-methods.md +3 -1
  6. package/docs/rules/no-commented-out-tests.md +3 -1
  7. package/docs/rules/no-conditional-expect.md +3 -1
  8. package/docs/rules/no-conditional-in-test.md +3 -1
  9. package/docs/rules/no-confusing-set-timeout.md +3 -1
  10. package/docs/rules/no-deprecated-functions.md +3 -1
  11. package/docs/rules/no-disabled-tests.md +3 -1
  12. package/docs/rules/no-done-callback.md +3 -1
  13. package/docs/rules/no-duplicate-hooks.md +3 -1
  14. package/docs/rules/no-error-equal.md +3 -1
  15. package/docs/rules/no-export.md +3 -1
  16. package/docs/rules/no-focused-tests.md +3 -1
  17. package/docs/rules/no-hooks.md +3 -1
  18. package/docs/rules/no-identical-title.md +3 -1
  19. package/docs/rules/no-interpolation-in-snapshots.md +3 -1
  20. package/docs/rules/no-jasmine-globals.md +3 -1
  21. package/docs/rules/no-large-snapshots.md +3 -1
  22. package/docs/rules/no-mocks-import.md +3 -1
  23. package/docs/rules/no-restricted-jest-methods.md +3 -1
  24. package/docs/rules/no-restricted-matchers.md +3 -1
  25. package/docs/rules/no-standalone-expect.md +3 -1
  26. package/docs/rules/no-test-prefixes.md +3 -1
  27. package/docs/rules/no-test-return-statement.md +3 -1
  28. package/docs/rules/no-unnecessary-assertion.md +3 -1
  29. package/docs/rules/no-unneeded-async-expect-function.md +3 -1
  30. package/docs/rules/no-untyped-mock-factory.md +3 -1
  31. package/docs/rules/padding-around-after-all-blocks.md +3 -1
  32. package/docs/rules/padding-around-after-each-blocks.md +3 -1
  33. package/docs/rules/padding-around-all.md +3 -1
  34. package/docs/rules/padding-around-before-all-blocks.md +3 -1
  35. package/docs/rules/padding-around-before-each-blocks.md +3 -1
  36. package/docs/rules/padding-around-describe-blocks.md +3 -1
  37. package/docs/rules/padding-around-expect-groups.md +3 -1
  38. package/docs/rules/padding-around-test-blocks.md +3 -1
  39. package/docs/rules/prefer-called-with.md +3 -1
  40. package/docs/rules/prefer-comparison-matcher.md +3 -1
  41. package/docs/rules/prefer-each.md +3 -1
  42. package/docs/rules/prefer-ending-with-an-expect.md +3 -1
  43. package/docs/rules/prefer-equality-matcher.md +3 -1
  44. package/docs/rules/prefer-expect-assertions.md +3 -1
  45. package/docs/rules/prefer-expect-resolves.md +3 -1
  46. package/docs/rules/prefer-hooks-in-order.md +3 -1
  47. package/docs/rules/prefer-hooks-on-top.md +3 -1
  48. package/docs/rules/prefer-importing-jest-globals.md +3 -1
  49. package/docs/rules/prefer-jest-mocked.md +3 -1
  50. package/docs/rules/prefer-lowercase-title.md +3 -1
  51. package/docs/rules/prefer-mock-promise-shorthand.md +3 -1
  52. package/docs/rules/prefer-mock-return-shorthand.md +3 -1
  53. package/docs/rules/prefer-snapshot-hint.md +3 -1
  54. package/docs/rules/prefer-spy-on.md +3 -1
  55. package/docs/rules/prefer-strict-equal.md +3 -1
  56. package/docs/rules/prefer-to-be.md +3 -1
  57. package/docs/rules/prefer-to-contain.md +3 -1
  58. package/docs/rules/prefer-to-have-been-called-times.md +3 -1
  59. package/docs/rules/prefer-to-have-been-called.md +3 -1
  60. package/docs/rules/prefer-to-have-length.md +3 -1
  61. package/docs/rules/prefer-todo.md +3 -1
  62. package/docs/rules/require-hook.md +3 -1
  63. package/docs/rules/require-to-throw-message.md +3 -1
  64. package/docs/rules/require-top-level-describe.md +3 -1
  65. package/docs/rules/unbound-method.md +3 -1
  66. package/docs/rules/valid-describe-callback.md +3 -1
  67. package/docs/rules/valid-expect-in-promise.md +3 -1
  68. package/docs/rules/valid-expect-with-promise.md +4 -1
  69. package/docs/rules/valid-expect.md +3 -1
  70. package/docs/rules/valid-mock-module-path.md +3 -1
  71. package/docs/rules/valid-title.md +3 -1
  72. package/lib/rules/no-unnecessary-assertion.js +13 -9
  73. package/package.json +8 -4
@@ -1,4 +1,6 @@
1
- # Enforce `test` and `it` usage conventions (`consistent-test-it`)
1
+ # jest/consistent-test-it
2
+
3
+ 📝 Enforce `test` and `it` usage conventions.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce assertion to be made in a test body (`expect-expect`)
1
+ # jest/expect-expect
2
+
3
+ 📝 Enforce assertion to be made in a test body.
2
4
 
3
5
  ⚠️ This rule _warns_ in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Enforces a maximum number assertion calls in a test body (`max-expects`)
1
+ # jest/max-expects
2
+
3
+ 📝 Enforces a maximum number assertion calls in a test body.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Enforces a maximum depth to nested describe calls (`max-nested-describe`)
1
+ # jest/max-nested-describe
2
+
3
+ 📝 Enforces a maximum depth to nested describe calls.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow alias methods (`no-alias-methods`)
1
+ # jest/no-alias-methods
2
+
3
+ 📝 Disallow alias methods.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow commented out tests (`no-commented-out-tests`)
1
+ # jest/no-commented-out-tests
2
+
3
+ 📝 Disallow commented out tests.
2
4
 
3
5
  ⚠️ This rule _warns_ in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow calling `expect` conditionally (`no-conditional-expect`)
1
+ # jest/no-conditional-expect
2
+
3
+ 📝 Disallow calling `expect` conditionally.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow conditional logic in tests (`no-conditional-in-test`)
1
+ # jest/no-conditional-in-test
2
+
3
+ 📝 Disallow conditional logic in tests.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow confusing usages of jest.setTimeout (`no-confusing-set-timeout`)
1
+ # jest/no-confusing-set-timeout
2
+
3
+ 📝 Disallow confusing usages of jest.setTimeout.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow use of deprecated functions (`no-deprecated-functions`)
1
+ # jest/no-deprecated-functions
2
+
3
+ 📝 Disallow use of deprecated functions.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow disabled tests (`no-disabled-tests`)
1
+ # jest/no-disabled-tests
2
+
3
+ 📝 Disallow disabled tests.
2
4
 
3
5
  ⚠️ This rule _warns_ in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow using a callback in asynchronous tests and hooks (`no-done-callback`)
1
+ # jest/no-done-callback
2
+
3
+ 📝 Disallow using a callback in asynchronous tests and hooks.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow duplicate setup and teardown hooks (`no-duplicate-hooks`)
1
+ # jest/no-duplicate-hooks
2
+
3
+ 📝 Disallow duplicate setup and teardown hooks.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using equality matchers on error types (`no-error-equal`)
1
+ # jest/no-error-equal
2
+
3
+ 📝 Disallow using equality matchers on error types.
2
4
 
3
5
  💭 This rule requires
4
6
  [type information](https://typescript-eslint.io/linting/typed-linting).
@@ -1,4 +1,6 @@
1
- # Disallow using `exports` in files containing tests (`no-export`)
1
+ # jest/no-export
2
+
3
+ 📝 Disallow using `exports` in files containing tests.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow focused tests (`no-focused-tests`)
1
+ # jest/no-focused-tests
2
+
3
+ 📝 Disallow focused tests.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow setup and teardown hooks (`no-hooks`)
1
+ # jest/no-hooks
2
+
3
+ 📝 Disallow setup and teardown hooks.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow identical titles (`no-identical-title`)
1
+ # jest/no-identical-title
2
+
3
+ 📝 Disallow identical titles.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`)
1
+ # jest/no-interpolation-in-snapshots
2
+
3
+ 📝 Disallow string interpolation inside snapshots.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow Jasmine globals (`no-jasmine-globals`)
1
+ # jest/no-jasmine-globals
2
+
3
+ 📝 Disallow Jasmine globals.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow large snapshots (`no-large-snapshots`)
1
+ # jest/no-large-snapshots
2
+
3
+ 📝 Disallow large snapshots.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow manually importing from `__mocks__` (`no-mocks-import`)
1
+ # jest/no-mocks-import
2
+
3
+ 📝 Disallow manually importing from `__mocks__`.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow specific `jest.` methods (`no-restricted-jest-methods`)
1
+ # jest/no-restricted-jest-methods
2
+
3
+ 📝 Disallow specific `jest.` methods.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow specific matchers & modifiers (`no-restricted-matchers`)
1
+ # jest/no-restricted-matchers
2
+
3
+ 📝 Disallow specific matchers & modifiers.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `expect` outside of `it` or `test` blocks (`no-standalone-expect`)
1
+ # jest/no-standalone-expect
2
+
3
+ 📝 Disallow using `expect` outside of `it` or `test` blocks.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Require using `.only` and `.skip` over `f` and `x` (`no-test-prefixes`)
1
+ # jest/no-test-prefixes
2
+
3
+ 📝 Require using `.only` and `.skip` over `f` and `x`.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow explicitly returning from tests (`no-test-return-statement`)
1
+ # jest/no-test-return-statement
2
+
3
+ 📝 Disallow explicitly returning from tests.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow unnecessary assertions based on types (`no-unnecessary-assertion`)
1
+ # jest/no-unnecessary-assertion
2
+
3
+ 📝 Disallow unnecessary assertions based on types.
2
4
 
3
5
  💭 This rule requires
4
6
  [type information](https://typescript-eslint.io/linting/typed-linting).
@@ -1,4 +1,6 @@
1
- # Disallow unnecessary async function wrapper for expected promises (`no-unneeded-async-expect-function`)
1
+ # jest/no-unneeded-async-expect-function
2
+
3
+ 📝 Disallow unnecessary async function wrapper for expected promises.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Disallow using `jest.mock()` factories without an explicit type parameter (`no-untyped-mock-factory`)
1
+ # jest/no-untyped-mock-factory
2
+
3
+ 📝 Disallow using `jest.mock()` factories without an explicit type parameter.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `afterAll` blocks (`padding-around-after-all-blocks`)
1
+ # jest/padding-around-after-all-blocks
2
+
3
+ 📝 Enforce padding around `afterAll` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `afterEach` blocks (`padding-around-after-each-blocks`)
1
+ # jest/padding-around-after-each-blocks
2
+
3
+ 📝 Enforce padding around `afterEach` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around Jest functions (`padding-around-all`)
1
+ # jest/padding-around-all
2
+
3
+ 📝 Enforce padding around Jest functions.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `beforeAll` blocks (`padding-around-before-all-blocks`)
1
+ # jest/padding-around-before-all-blocks
2
+
3
+ 📝 Enforce padding around `beforeAll` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `beforeEach` blocks (`padding-around-before-each-blocks`)
1
+ # jest/padding-around-before-each-blocks
2
+
3
+ 📝 Enforce padding around `beforeEach` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `describe` blocks (`padding-around-describe-blocks`)
1
+ # jest/padding-around-describe-blocks
2
+
3
+ 📝 Enforce padding around `describe` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `expect` groups (`padding-around-expect-groups`)
1
+ # jest/padding-around-expect-groups
2
+
3
+ 📝 Enforce padding around `expect` groups.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce padding around `test` and `it` blocks (`padding-around-test-blocks`)
1
+ # jest/padding-around-test-blocks
2
+
3
+ 📝 Enforce padding around `test` and `it` blocks.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Suggest using `toHaveBeenCalledWith()` (`prefer-called-with`)
1
+ # jest/prefer-called-with
2
+
3
+ 📝 Suggest using `toHaveBeenCalledWith()`.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Suggest using the built-in comparison matchers (`prefer-comparison-matcher`)
1
+ # jest/prefer-comparison-matcher
2
+
3
+ 📝 Suggest using the built-in comparison matchers.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer using `.each` rather than manual loops (`prefer-each`)
1
+ # jest/prefer-each
2
+
3
+ 📝 Prefer using `.each` rather than manual loops.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Prefer having the last statement in a test be an assertion (`prefer-ending-with-an-expect`)
1
+ # jest/prefer-ending-with-an-expect
2
+
3
+ 📝 Prefer having the last statement in a test be an assertion.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Suggest using the built-in equality matchers (`prefer-equality-matcher`)
1
+ # jest/prefer-equality-matcher
2
+
3
+ 📝 Suggest using the built-in equality matchers.
2
4
 
3
5
  💡 This rule is manually fixable by
4
6
  [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
@@ -1,4 +1,6 @@
1
- # Suggest using `expect.assertions()` OR `expect.hasAssertions()` (`prefer-expect-assertions`)
1
+ # jest/prefer-expect-assertions
2
+
3
+ 📝 Suggest using `expect.assertions()` OR `expect.hasAssertions()`.
2
4
 
3
5
  💡 This rule is manually fixable by
4
6
  [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
@@ -1,4 +1,6 @@
1
- # Prefer `await expect(...).resolves` over `expect(await ...)` syntax (`prefer-expect-resolves`)
1
+ # jest/prefer-expect-resolves
2
+
3
+ 📝 Prefer `await expect(...).resolves` over `expect(await ...)` syntax.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer having hooks in a consistent order (`prefer-hooks-in-order`)
1
+ # jest/prefer-hooks-in-order
2
+
3
+ 📝 Prefer having hooks in a consistent order.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Suggest having hooks before any test cases (`prefer-hooks-on-top`)
1
+ # jest/prefer-hooks-on-top
2
+
3
+ 📝 Suggest having hooks before any test cases.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Prefer importing Jest globals (`prefer-importing-jest-globals`)
1
+ # jest/prefer-importing-jest-globals
2
+
3
+ 📝 Prefer importing Jest globals.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer `jest.mocked()` over `fn as jest.Mock` (`prefer-jest-mocked`)
1
+ # jest/prefer-jest-mocked
2
+
3
+ 📝 Prefer `jest.mocked()` over `fn as jest.Mock`.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Enforce lowercase test names (`prefer-lowercase-title`)
1
+ # jest/prefer-lowercase-title
2
+
3
+ 📝 Enforce lowercase test names.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer mock resolved/rejected shorthands for promises (`prefer-mock-promise-shorthand`)
1
+ # jest/prefer-mock-promise-shorthand
2
+
3
+ 📝 Prefer mock resolved/rejected shorthands for promises.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer mock return shorthands (`prefer-mock-return-shorthand`)
1
+ # jest/prefer-mock-return-shorthand
2
+
3
+ 📝 Prefer mock return shorthands.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Prefer including a hint with external snapshots (`prefer-snapshot-hint`)
1
+ # jest/prefer-snapshot-hint
2
+
3
+ 📝 Prefer including a hint with external snapshots.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Suggest using `jest.spyOn()` (`prefer-spy-on`)
1
+ # jest/prefer-spy-on
2
+
3
+ 📝 Suggest using `jest.spyOn()`.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Suggest using `toStrictEqual()` (`prefer-strict-equal`)
1
+ # jest/prefer-strict-equal
2
+
3
+ 📝 Suggest using `toStrictEqual()`.
2
4
 
3
5
  💡 This rule is manually fixable by
4
6
  [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
@@ -1,4 +1,6 @@
1
- # Suggest using `toBe()` for primitive literals (`prefer-to-be`)
1
+ # jest/prefer-to-be
2
+
3
+ 📝 Suggest using `toBe()` for primitive literals.
2
4
 
3
5
  💼 This rule is enabled in the 🎨 `style`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Suggest using `toContain()` (`prefer-to-contain`)
1
+ # jest/prefer-to-contain
2
+
3
+ 📝 Suggest using `toContain()`.
2
4
 
3
5
  💼 This rule is enabled in the 🎨 `style`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Suggest using `toHaveBeenCalledTimes()` (`prefer-to-have-been-called-times`)
1
+ # jest/prefer-to-have-been-called-times
2
+
3
+ 📝 Suggest using `toHaveBeenCalledTimes()`.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Suggest using `toHaveBeenCalled` (`prefer-to-have-been-called`)
1
+ # jest/prefer-to-have-been-called
2
+
3
+ 📝 Suggest using `toHaveBeenCalled`.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Suggest using `toHaveLength()` (`prefer-to-have-length`)
1
+ # jest/prefer-to-have-length
2
+
3
+ 📝 Suggest using `toHaveLength()`.
2
4
 
3
5
  💼 This rule is enabled in the 🎨 `style`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Suggest using `test.todo` (`prefer-todo`)
1
+ # jest/prefer-todo
2
+
3
+ 📝 Suggest using `test.todo`.
2
4
 
3
5
  🔧 This rule is automatically fixable by the
4
6
  [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
@@ -1,4 +1,6 @@
1
- # Require setup and teardown code to be within a hook (`require-hook`)
1
+ # jest/require-hook
2
+
3
+ 📝 Require setup and teardown code to be within a hook.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Require a message for `toThrow()` (`require-to-throw-message`)
1
+ # jest/require-to-throw-message
2
+
3
+ 📝 Require a message for `toThrow()`.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Require test cases and hooks to be inside a `describe` block (`require-top-level-describe`)
1
+ # jest/require-top-level-describe
2
+
3
+ 📝 Require test cases and hooks to be inside a `describe` block.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Enforce unbound methods are called with their expected scope (`unbound-method`)
1
+ # jest/unbound-method
2
+
3
+ 📝 Enforce unbound methods are called with their expected scope.
2
4
 
3
5
  💭 This rule requires
4
6
  [type information](https://typescript-eslint.io/linting/typed-linting).
@@ -1,4 +1,6 @@
1
- # Enforce valid `describe()` callback (`valid-describe-callback`)
1
+ # jest/valid-describe-callback
2
+
3
+ 📝 Enforce valid `describe()` callback.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Require promises that have expectations in their chain to be valid (`valid-expect-in-promise`)
1
+ # jest/valid-expect-in-promise
2
+
3
+ 📝 Require promises that have expectations in their chain to be valid.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,7 @@
1
- # Require that `resolve` and `reject` modifiers are present (and only) for promise-like types (`valid-expect-with-promise`)
1
+ # jest/valid-expect-with-promise
2
+
3
+ 📝 Require that `resolve` and `reject` modifiers are present (and only) for
4
+ promise-like types.
2
5
 
3
6
  💭 This rule requires
4
7
  [type information](https://typescript-eslint.io/linting/typed-linting).
@@ -1,4 +1,6 @@
1
- # Enforce valid `expect()` usage (`valid-expect`)
1
+ # jest/valid-expect
2
+
3
+ 📝 Enforce valid `expect()` usage.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -1,4 +1,6 @@
1
- # Disallow mocking of non-existing module paths (`valid-mock-module-path`)
1
+ # jest/valid-mock-module-path
2
+
3
+ 📝 Disallow mocking of non-existing module paths.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Enforce valid titles (`valid-title`)
1
+ # jest/valid-title
2
+
3
+ 📝 Enforce valid titles.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended`
4
6
  [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations).
@@ -67,16 +67,20 @@ var _default = exports.default = (0, _utils2.createRule)({
67
67
  return;
68
68
  }
69
69
  const [argument] = jestFnCall.head.node.parent.arguments;
70
- const isTypePossible = canBe(services.getTypeAtLocation(argument), matcherName === 'toBeNaN' ? TypeFlags.NumberLike : matcherName === 'toBeNull' ? TypeFlags.Null : TypeFlags.Undefined);
71
- if (!isTypePossible) {
72
- context.report({
73
- messageId: 'unnecessaryAssertion',
74
- data: {
75
- thing: matcherName === 'toBeNaN' ? 'a number' : matcherName === 'toBeNull' ? 'null' : 'undefined'
76
- },
77
- node
78
- });
70
+ let desiredType = TypeFlags.Any | TypeFlags.Unknown;
71
+
72
+ // add in the appropriate type flag based on the matcher being used
73
+ desiredType |= matcherName === 'toBeNaN' ? TypeFlags.NumberLike : matcherName === 'toBeNull' ? TypeFlags.Null : TypeFlags.Undefined;
74
+ if (canBe(services.getTypeAtLocation(argument), desiredType)) {
75
+ return;
79
76
  }
77
+ context.report({
78
+ messageId: 'unnecessaryAssertion',
79
+ data: {
80
+ thing: matcherName === 'toBeNaN' ? 'a number' : matcherName === 'toBeNull' ? 'null' : 'undefined'
81
+ },
82
+ node
83
+ });
80
84
  }
81
85
  };
82
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "29.12.0",
3
+ "version": "29.12.2",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -83,7 +83,7 @@
83
83
  "@babel/preset-typescript": "^7.3.3",
84
84
  "@commitlint/cli": "^20.0.0",
85
85
  "@commitlint/config-conventional": "^20.0.0",
86
- "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
86
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
87
87
  "@schemastore/package": "^0.0.10",
88
88
  "@semantic-release/changelog": "^6.0.0",
89
89
  "@semantic-release/git": "^10.0.0",
@@ -100,7 +100,7 @@
100
100
  "dedent": "^1.5.0",
101
101
  "eslint": "^9.0.0",
102
102
  "eslint-config-prettier": "^10.0.0",
103
- "eslint-doc-generator": "^2.0.0",
103
+ "eslint-doc-generator": "^3.0.0",
104
104
  "eslint-plugin-eslint-plugin": "^6.0.0",
105
105
  "eslint-plugin-import": "^2.25.1",
106
106
  "eslint-plugin-n": "^17.0.0",
@@ -124,7 +124,8 @@
124
124
  "peerDependencies": {
125
125
  "@typescript-eslint/eslint-plugin": "^8.0.0",
126
126
  "eslint": "^8.57.0 || ^9.0.0",
127
- "jest": "*"
127
+ "jest": "*",
128
+ "typescript": ">=4.8.4 <6.0.0"
128
129
  },
129
130
  "peerDependenciesMeta": {
130
131
  "@typescript-eslint/eslint-plugin": {
@@ -132,6 +133,9 @@
132
133
  },
133
134
  "jest": {
134
135
  "optional": true
136
+ },
137
+ "typescript": {
138
+ "optional": true
135
139
  }
136
140
  },
137
141
  "packageManager": "yarn@4.12.0",