Skip to content

Commit 70ad558

Browse files
authored
docs: add section about using overrides to apply rules to just test-related files (#1080)
1 parent a450d6e commit 70ad558

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: README.md

+28
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,34 @@ doing:
5959
This is included in all configs shared by this plugin, so can be omitted if
6060
extending them.
6161

62+
### Running rules only on test-related files
63+
64+
The rules provided by this plugin assume that the files they are checking are
65+
test-related. This means it's generally not suitable to include them in your
66+
top-level configuration as that applies to all files being linted which can
67+
include source files.
68+
69+
You can use
70+
[overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work)
71+
to have ESLint apply additional rules to specific files:
72+
73+
```json
74+
{
75+
"extends": ["eslint:recommended"],
76+
"overrides": [
77+
{
78+
"files": ["test/**"],
79+
"plugins": ["jest"],
80+
"extends": ["plugin:jest/recommended"],
81+
"rules": { "jest/prefer-expect-assertions": "off" }
82+
}
83+
],
84+
"rules": {
85+
"indent": ["error", 2]
86+
}
87+
}
88+
```
89+
6290
### Jest `version` setting
6391

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

0 commit comments

Comments
 (0)