Skip to content

Commit

Permalink
docs: switch to automatic rule notice generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Sep 2, 2022
1 parent a16aa6a commit d1f6e55
Show file tree
Hide file tree
Showing 54 changed files with 377 additions and 99 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -215,6 +215,7 @@ installations requiring long-term consistency.
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
| [no-if](docs/rules/no-if.md) | Disallow conditional logic | ![deprecated][] | |
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
Expand Down Expand Up @@ -308,4 +309,5 @@ https://github.com/istanbuljs/eslint-plugin-istanbul
[suggest]: https://img.shields.io/badge/-suggest-yellow.svg
[fixable]: https://img.shields.io/badge/-fixable-green.svg
[style]: https://img.shields.io/badge/-style-blue.svg
[deprecated]: https://img.shields.io/badge/-deprecated-red.svg
[`no-deprecated-functions`]: docs/rules/no-deprecated-functions.md
4 changes: 4 additions & 0 deletions docs/rules/consistent-test-it.md
@@ -1,11 +1,15 @@
# Have control over `test` and `it` usages (`consistent-test-it`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

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

<!-- /RULE_NOTICE -->

Jest allows you to choose how you want to define your tests, using the `it` or
the `test` keywords, with multiple permutations for each:

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/expect-expect.md
@@ -1,8 +1,12 @@
# Enforce assertion to be made in a test body (`expect-expect`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

Ensure that there is at least one `expect` call made in a test.

## Rule Details
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/max-expects.md
@@ -1,8 +1,12 @@
# Enforces a maximum number assertion calls in a test body (`max-expects`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

As more assertions are made, there is a possible tendency for the test to be
more likely to mix multiple objectives. To avoid this, this rule reports when
the maximum number of assertions is exceeded.
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/max-nested-describe.md
@@ -1,8 +1,12 @@
# Enforces a maximum depth to nested describe calls (`max-nested-describe`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

While it's useful to be able to group your tests together within the same file
using `describe()`, having too many levels of nesting throughout your tests make
them difficult to read.
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-alias-methods.md
@@ -1,11 +1,15 @@
# Disallow alias methods (`no-alias-methods`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

> These aliases are going to be removed in the next major version of Jest - see
> https://github.com/facebook/jest/issues/13164 for more
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-commented-out-tests.md
@@ -1,8 +1,12 @@
# Disallow commented out tests (`no-commented-out-tests`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

This rule raises a warning about commented out tests. It's similar to
no-disabled-tests rule.

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-conditional-expect.md
@@ -1,8 +1,12 @@
# Prevent calling `expect` conditionally (`no-conditional-expect`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

This rule prevents the use of `expect` in conditional blocks, such as `if`s &
`catch`s.

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-conditional-in-test.md
@@ -1,8 +1,12 @@
# Disallow conditional logic in tests (`no-conditional-in-test`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

Conditional logic in tests is usually an indication that a test is attempting to
cover too much, and not testing the logic it intends to. Each branch of code
executing within a conditional statement will usually be better served by a test
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-deprecated-functions.md
@@ -1,11 +1,15 @@
# Disallow use of deprecated functions (`no-deprecated-functions`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

Over the years Jest has accrued some debt in the form of functions that have
either been renamed for clarity, or replaced with more powerful APIs.

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-disabled-tests.md
@@ -1,8 +1,12 @@
# Disallow disabled tests (`no-disabled-tests`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

Jest has a feature that allows you to temporarily mark tests as disabled. This
feature is often helpful while debugging or to create placeholders for future
tests. Before committing changes we may want to check that all tests are
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-done-callback.md
@@ -1,11 +1,15 @@
# Avoid using a callback in asynchronous tests and hooks (`no-done-callback`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

When calling asynchronous code in hooks and tests, `jest` needs to know when the
asynchronous work is complete to progress the current run.

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-duplicate-hooks.md
@@ -1,8 +1,12 @@
# Disallow duplicate setup and teardown hooks (`no-duplicate-hooks`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

A `describe` block should not contain duplicate hooks.

## Rule Details
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-export.md
@@ -1,8 +1,12 @@
# Disallow using `exports` in files containing tests (`no-export`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

Prevents using `exports` if a file has one or more tests in it.

## Rule Details
Expand Down
5 changes: 5 additions & 0 deletions docs/rules/no-focused-tests.md
@@ -1,11 +1,16 @@
# Disallow focused tests (`no-focused-tests`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

<!-- prettier-ignore -->
Jest has a feature that allows you to focus tests by appending `.only` or
prepending `f` to a test-suite or a test-case. This feature is really helpful to
debug a failing test, so you don’t have to execute all of your tests. After you
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-hooks.md
@@ -1,8 +1,12 @@
# Disallow setup and teardown hooks (`no-hooks`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

Jest provides global functions for setup and teardown tasks, which are called
before/after each test case and each test suite. The use of these hooks promotes
shared state between tests.
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-identical-title.md
@@ -1,8 +1,12 @@
# Disallow identical titles (`no-identical-title`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

Having identical titles for two different tests or test suites may create
confusion. For example, when a test with the same title as another test in the
same test suite fails, it is harder to know which one failed and thus harder to
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-if.md
@@ -1,7 +1,11 @@
# Disallow conditional logic (`no-if`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

❌ This rule is deprecated.

<!-- /RULE_NOTICE -->

This rule has been deprecated in favor of
[`no-conditional-in-test`](no-conditional-in-test.md).

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-interpolation-in-snapshots.md
@@ -1,8 +1,12 @@
# Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

Prevents the use of string interpolations in snapshots.

## Rule Details
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-jasmine-globals.md
@@ -1,11 +1,15 @@
# Disallow Jasmine globals (`no-jasmine-globals`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

`jest` uses `jasmine` as a test runner. A side effect of this is that both a
`jasmine` object, and some jasmine-specific globals, are exposed to the test
environment. Most functionality offered by Jasmine has been ported to Jest, and
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-large-snapshots.md
@@ -1,8 +1,12 @@
# disallow large snapshots (`no-large-snapshots`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

When using Jest's snapshot capability one should be mindful of the size of
created snapshots. As a general best practice snapshots should be limited in
size in order to be more manageable and reviewable. A stored snapshot is only as
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-mocks-import.md
@@ -1,8 +1,12 @@
# Disallow manually importing from `__mocks__` (`no-mocks-import`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

When using `jest.mock`, your tests (just like the code being tested) should
import from `./x`, not `./__mocks__/x`. Not following this rule can lead to
confusion, because you will have multiple instances of the mocked module:
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-restricted-matchers.md
@@ -1,8 +1,12 @@
# Disallow specific matchers & modifiers (`no-restricted-matchers`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

You may want to ban specific matchers & modifiers from being used.

## Rule Details
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-standalone-expect.md
@@ -1,8 +1,12 @@
# Disallow using `expect` outside of `it` or `test` blocks (`no-standalone-expect`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

<!-- /RULE_NOTICE -->

Prevents `expect` statements outside of a `test` or `it` block. An `expect`
within a helper function (but outside of a `test` or `it` block) will not
trigger this rule.
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-test-prefixes.md
@@ -1,11 +1,15 @@
# Use `.only` and `.skip` over `f` and `x` (`no-test-prefixes`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`, `recommended`.

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

<!-- /RULE_NOTICE -->

Jest allows you to choose how you want to define focused and skipped tests, with
multiple permutations for each:

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-test-return-statement.md
@@ -1,8 +1,12 @@
# Disallow explicitly returning from tests (`no-test-return-statement`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

Tests in Jest should be void and not return values.

If you are returning Promises then you should update the test to use
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/prefer-called-with.md
@@ -1,8 +1,12 @@
# Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` (`prefer-called-with`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

<!-- /RULE_NOTICE -->

The `toBeCalled()` matcher is used to assert that a mock function has been
called one or more times, without checking the arguments passed. The assertion
is stronger when arguments are also validated using the `toBeCalledWith()`
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/prefer-comparison-matcher.md
@@ -1,11 +1,15 @@
# Suggest using the built-in comparison matchers (`prefer-comparison-matcher`)

<!-- RULE_NOTICE -- Generated by `yarn tools:regenerate-docs` -->

<!-- prettier-ignore -->
💼 This rule is enabled in the following [configs](https://github.com/jest-community/eslint-plugin-jest#shareable-configurations): `all`.

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

<!-- /RULE_NOTICE -->

Jest has a number of built-in matchers for comparing numbers, which allow for
more readable tests and error messages if an expectation fails.

Expand Down

0 comments on commit d1f6e55

Please sign in to comment.