You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-10Lines changed: 17 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -72,28 +72,35 @@ Then configure the rules you want to use within `rules` property of your `.eslin
72
72
73
73
### Run the plugin only against test files
74
74
75
-
With the default setup mentioned before `eslint-plugin-testing-library` will be run against your whole codebase. If want to run this plugin only against your tests files, you can do that by using [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns).
75
+
With the default setup mentioned before, `eslint-plugin-testing-library` will be run against your whole codebase. If you want to run this plugin only against your tests files, you have the following options:
76
+
77
+
**ESLint `overrides`**
78
+
One way of restricting ESLint config by file patterns is by using [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns).
76
79
77
80
Assuming you are using the same pattern for your test files as [Jest by default](https://jestjs.io/docs/configuration#testmatch-arraystring), the following config would run `eslint-plugin-testing-library` only against your test files:
78
81
79
-
```javascript
82
+
```json
80
83
// .eslintrc
81
84
{
82
-
// here you have your usual config which applies to the whole project...
Another approach for customizing ESLint config by paths is through [ESLint Cascading and Hierachy](https://eslint.org/docs/user-guide/configuring/configuration-files#cascading-and-hierarchy). This is useful if all your tests are placed under the same folder, so you can place there another `.eslintrc` where you enable `eslint-plugin-testing-library` for applying it only to the files under such folder, rather than enabling it on your global `.eslintrc` which would apply to your whole project.
103
+
97
104
## Shareable configurations
98
105
99
106
This plugin exports several recommended configurations that enforce good practices for specific Testing Library packages.
0 commit comments