Skip to content

Commit 6727301

Browse files
committed
docs: switch to automatic rule notice generation
1 parent a16aa6a commit 6727301

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+377
-99
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ installations requiring long-term consistency.
215215
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
216216
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
217217
| [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][] | |
218219
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
219220
| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
220221
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
@@ -308,4 +309,5 @@ https://github.com/istanbuljs/eslint-plugin-istanbul
308309
[suggest]: https://img.shields.io/badge/-suggest-yellow.svg
309310
[fixable]: https://img.shields.io/badge/-fixable-green.svg
310311
[style]: https://img.shields.io/badge/-style-blue.svg
312+
[deprecated]: https://img.shields.io/badge/-deprecated-red.svg
311313
[`no-deprecated-functions`]: docs/rules/no-deprecated-functions.md

docs/rules/consistent-test-it.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Have control over `test` and `it` usages (`consistent-test-it`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
Jest allows you to choose how you want to define your tests, using the `it` or
1014
the `test` keywords, with multiple permutations for each:
1115

docs/rules/expect-expect.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Enforce assertion to be made in a test body (`expect-expect`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Ensure that there is at least one `expect` call made in a test.
711

812
## Rule Details

docs/rules/max-expects.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Enforces a maximum number assertion calls in a test body (`max-expects`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
As more assertions are made, there is a possible tendency for the test to be
711
more likely to mix multiple objectives. To avoid this, this rule reports when
812
the maximum number of assertions is exceeded.

docs/rules/max-nested-describe.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Enforces a maximum depth to nested describe calls (`max-nested-describe`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
While it's useful to be able to group your tests together within the same file
711
using `describe()`, having too many levels of nesting throughout your tests make
812
them difficult to read.

docs/rules/no-alias-methods.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Disallow alias methods (`no-alias-methods`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
> These aliases are going to be removed in the next major version of Jest - see
1014
> https://github.com/facebook/jest/issues/13164 for more
1115

docs/rules/no-commented-out-tests.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow commented out tests (`no-commented-out-tests`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
This rule raises a warning about commented out tests. It's similar to
711
no-disabled-tests rule.
812

docs/rules/no-conditional-expect.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Prevent calling `expect` conditionally (`no-conditional-expect`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
This rule prevents the use of `expect` in conditional blocks, such as `if`s &
711
`catch`s.
812

docs/rules/no-conditional-in-test.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow conditional logic in tests (`no-conditional-in-test`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Conditional logic in tests is usually an indication that a test is attempting to
711
cover too much, and not testing the logic it intends to. Each branch of code
812
executing within a conditional statement will usually be better served by a test

docs/rules/no-deprecated-functions.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Disallow use of deprecated functions (`no-deprecated-functions`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
Over the years Jest has accrued some debt in the form of functions that have
1014
either been renamed for clarity, or replaced with more powerful APIs.
1115

docs/rules/no-disabled-tests.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow disabled tests (`no-disabled-tests`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Jest has a feature that allows you to temporarily mark tests as disabled. This
711
feature is often helpful while debugging or to create placeholders for future
812
tests. Before committing changes we may want to check that all tests are

docs/rules/no-done-callback.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Avoid using a callback in asynchronous tests and hooks (`no-done-callback`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
💡 This rule is manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
810

11+
<!-- /RULE_NOTICE -->
12+
913
When calling asynchronous code in hooks and tests, `jest` needs to know when the
1014
asynchronous work is complete to progress the current run.
1115

docs/rules/no-duplicate-hooks.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow duplicate setup and teardown hooks (`no-duplicate-hooks`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
A `describe` block should not contain duplicate hooks.
711

812
## Rule Details

docs/rules/no-export.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow using `exports` in files containing tests (`no-export`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Prevents using `exports` if a file has one or more tests in it.
711

812
## Rule Details

docs/rules/no-focused-tests.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Disallow focused tests (`no-focused-tests`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
💡 This rule is manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
810

11+
<!-- /RULE_NOTICE -->
12+
13+
<!-- prettier-ignore -->
914
Jest has a feature that allows you to focus tests by appending `.only` or
1015
prepending `f` to a test-suite or a test-case. This feature is really helpful to
1116
debug a failing test, so you don’t have to execute all of your tests. After you

docs/rules/no-hooks.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow setup and teardown hooks (`no-hooks`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Jest provides global functions for setup and teardown tasks, which are called
711
before/after each test case and each test suite. The use of these hooks promotes
812
shared state between tests.

docs/rules/no-identical-title.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow identical titles (`no-identical-title`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Having identical titles for two different tests or test suites may create
711
confusion. For example, when a test with the same title as another test in the
812
same test suite fails, it is harder to know which one failed and thus harder to

docs/rules/no-if.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Disallow conditional logic (`no-if`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
❌ This rule is deprecated.
46

7+
<!-- /RULE_NOTICE -->
8+
59
This rule has been deprecated in favor of
610
[`no-conditional-in-test`](no-conditional-in-test.md).
711

docs/rules/no-interpolation-in-snapshots.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Prevents the use of string interpolations in snapshots.
711

812
## Rule Details

docs/rules/no-jasmine-globals.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Disallow Jasmine globals (`no-jasmine-globals`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
`jest` uses `jasmine` as a test runner. A side effect of this is that both a
1014
`jasmine` object, and some jasmine-specific globals, are exposed to the test
1115
environment. Most functionality offered by Jasmine has been ported to Jest, and

docs/rules/no-large-snapshots.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# disallow large snapshots (`no-large-snapshots`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
When using Jest's snapshot capability one should be mindful of the size of
711
created snapshots. As a general best practice snapshots should be limited in
812
size in order to be more manageable and reviewable. A stored snapshot is only as

docs/rules/no-mocks-import.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow manually importing from `__mocks__` (`no-mocks-import`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
When using `jest.mock`, your tests (just like the code being tested) should
711
import from `./x`, not `./__mocks__/x`. Not following this rule can lead to
812
confusion, because you will have multiple instances of the mocked module:

docs/rules/no-restricted-matchers.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow specific matchers & modifiers (`no-restricted-matchers`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
You may want to ban specific matchers & modifiers from being used.
711

812
## Rule Details

docs/rules/no-standalone-expect.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow using `expect` outside of `it` or `test` blocks (`no-standalone-expect`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Prevents `expect` statements outside of a `test` or `it` block. An `expect`
711
within a helper function (but outside of a `test` or `it` block) will not
812
trigger this rule.

docs/rules/no-test-prefixes.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Use `.only` and `.skip` over `f` and `x` (`no-test-prefixes`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
Jest allows you to choose how you want to define focused and skipped tests, with
1014
multiple permutations for each:
1115

docs/rules/no-test-return-statement.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Disallow explicitly returning from tests (`no-test-return-statement`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
Tests in Jest should be void and not return values.
711

812
If you are returning Promises then you should update the test to use

docs/rules/prefer-called-with.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` (`prefer-called-with`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

8+
<!-- /RULE_NOTICE -->
9+
610
The `toBeCalled()` matcher is used to assert that a mock function has been
711
called one or more times, without checking the arguments passed. The assertion
812
is stronger when arguments are also validated using the `toBeCalledWith()`

docs/rules/prefer-comparison-matcher.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Suggest using the built-in comparison matchers (`prefer-comparison-matcher`)
22

3+
<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->
4+
35
<!-- prettier-ignore -->
46
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.
57

68
<!-- prettier-ignore -->
79
🔧 This rule is automatically fixable using the `--fix` [option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
810

11+
<!-- /RULE_NOTICE -->
12+
913
Jest has a number of built-in matchers for comparing numbers, which allow for
1014
more readable tests and error messages if an expectation fails.
1115

0 commit comments

Comments
 (0)