Skip to content

Commit

Permalink
docs: add section about using overrides to apply rules to just test-r…
Browse files Browse the repository at this point in the history
…elated files (#1080)
  • Loading branch information
G-Rath authored Apr 20, 2022
1 parent a450d6e commit 70ad558
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@ doing:
This is included in all configs shared by this plugin, so can be omitted if
extending them.

### Running rules only on test-related files

The rules provided by this plugin assume that the files they are checking are
test-related. This means it's generally not suitable to include them in your
top-level configuration as that applies to all files being linted which can
include source files.

You can use
[overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work)
to have ESLint apply additional rules to specific files:

```json
{
"extends": ["eslint:recommended"],
"overrides": [
{
"files": ["test/**"],
"plugins": ["jest"],
"extends": ["plugin:jest/recommended"],
"rules": { "jest/prefer-expect-assertions": "off" }
}
],
"rules": {
"indent": ["error", 2]
}
}
```

### Jest `version` setting

The behaviour of some rules (specifically [`no-deprecated-functions`][]) change
Expand Down

0 comments on commit 70ad558

Please sign in to comment.