Skip to content

Commit e90e64c

Browse files
committed
docs: mention flat configs
1 parent 349f2c8 commit e90e64c

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

README.md

+90
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ Another approach for customizing ESLint config by paths is through [ESLint Casca
108108

109109
## Shareable configurations
110110

111+
> [!NOTE]
112+
>
113+
> `eslint.config.js` compatible versions of configs are available prefixed with
114+
> `flat/`, though most of the plugin documentation still currently uses
115+
> `.eslintrc` syntax.
116+
>
117+
> Refer to the
118+
> [ESLint documentation on the new configuration file format](https://eslint.org/docs/latest/use/configure/configuration-files-new)
119+
> for more.
120+
111121
This plugin exports several recommended configurations that enforce good practices for specific Testing Library packages.
112122
You can find more info about enabled rules in the [Supported Rules section](#supported-rules), under the `Configurations` column.
113123

@@ -140,6 +150,22 @@ module.exports = {
140150
};
141151
```
142152

153+
To enable this configuration with `eslint.config.js`, use
154+
`testingLibrary.configs['flat/dom']`:
155+
156+
```js
157+
const testingLibrary = require('eslint-plugin-testing-library');
158+
159+
module.exports = [
160+
{
161+
files: [
162+
/* glob matching your test files */
163+
],
164+
...testingLibrary.configs['flat/dom'],
165+
},
166+
];
167+
```
168+
143169
### Angular
144170

145171
Enforces recommended rules for Angular Testing Library.
@@ -153,6 +179,22 @@ module.exports = {
153179
};
154180
```
155181

182+
To enable this configuration with `eslint.config.js`, use
183+
`testingLibrary.configs['flat/angular']`:
184+
185+
```js
186+
const testingLibrary = require('eslint-plugin-testing-library');
187+
188+
module.exports = [
189+
{
190+
files: [
191+
/* glob matching your test files */
192+
],
193+
...testingLibrary.configs['flat/angular'],
194+
},
195+
];
196+
```
197+
156198
### React
157199

158200
Enforces recommended rules for React Testing Library.
@@ -166,6 +208,22 @@ module.exports = {
166208
};
167209
```
168210

211+
To enable this configuration with `eslint.config.js`, use
212+
`testingLibrary.configs['flat/react']`:
213+
214+
```js
215+
const testingLibrary = require('eslint-plugin-testing-library');
216+
217+
module.exports = [
218+
{
219+
files: [
220+
/* glob matching your test files */
221+
],
222+
...testingLibrary.configs['flat/react'],
223+
},
224+
];
225+
```
226+
169227
### Vue
170228

171229
Enforces recommended rules for Vue Testing Library.
@@ -179,6 +237,22 @@ module.exports = {
179237
};
180238
```
181239

240+
To enable this configuration with `eslint.config.js`, use
241+
`testingLibrary.configs['flat/vue']`:
242+
243+
```js
244+
const testingLibrary = require('eslint-plugin-testing-library');
245+
246+
module.exports = [
247+
{
248+
files: [
249+
/* glob matching your test files */
250+
],
251+
...testingLibrary.configs['flat/vue'],
252+
},
253+
];
254+
```
255+
182256
### Marko
183257

184258
Enforces recommended rules for Marko Testing Library.
@@ -192,6 +266,22 @@ module.exports = {
192266
};
193267
```
194268

269+
To enable this configuration with `eslint.config.js`, use
270+
`testingLibrary.configs['flat/marko']`:
271+
272+
```js
273+
const testingLibrary = require('eslint-plugin-testing-library');
274+
275+
module.exports = [
276+
{
277+
files: [
278+
/* glob matching your test files */
279+
],
280+
...testingLibrary.configs['flat/marko'],
281+
},
282+
];
283+
```
284+
195285
## Supported Rules
196286

197287
> Remember that all rules from this plugin are prefixed by `"testing-library/"`

0 commit comments

Comments
 (0)