@@ -42,7 +42,9 @@ You should also specify settings that will be shared across all the plugin rules
42
42
" fragment" : " Fragment" , // Fragment to use (may be a property of <pragma>), default to "Fragment"
43
43
" version" : " detect" , // React version. "detect" automatically picks the version you have installed.
44
44
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
45
- // It will default to "latest" and warn if missing, and to "detect" in the future
45
+ // Defaults to the "defaultVersion" setting and warns if missing, and to "detect" in the future
46
+ " defaultVersion" : " " , // Default React version to use when the version you have installed cannot be detected.
47
+ // If not provided, defaults to the latest React version.
46
48
" flowVersion" : " 0.53" // Flow version
47
49
},
48
50
" propWrapperFunctions" : [
@@ -203,27 +205,22 @@ Refer to the [official docs](https://eslint.org/docs/latest/user-guide/configuri
203
205
The schema of the ` settings.react ` object would be identical to that of what's already described above in the legacy config section.
204
206
205
207
<!-- markdownlint-disable-next-line no-duplicate-heading -->
206
- ### Shareable configs
207
-
208
- There're also 3 shareable configs.
209
-
210
- - ` eslint-plugin-react/configs/all `
211
- - ` eslint-plugin-react/configs/recommended `
212
- - ` eslint-plugin-react/configs/jsx-runtime `
208
+ ### Flat Configs
213
209
214
- If your eslint.config.js is ESM, include the ` .js ` extension (e.g. ` eslint- plugin-react/recommended.js ` ). Note that the next semver-major will require omitting the extension for these imports.
210
+ This plugin exports 3 flat configs:
215
211
216
- ** Note** : These configurations will import ` eslint-plugin-react ` and enable JSX in [ ` languageOptions.parserOptions ` ] ( https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuration-objects ) .
212
+ - ` flat.all `
213
+ - ` flat.recommended `
214
+ - ` flat['jsx-runtime'] `
217
215
218
- In the new config system, ` plugin: ` protocol(e.g. ` plugin:react/recommended ` ) is no longer valid.
219
- As eslint does not automatically import the preset config (shareable config), you explicitly do it by yourself.
216
+ The flat configs are available via the root plugin import. They will configure the plugin under the ` react/ ` namespace and enable JSX in [ ` languageOptions.parserOptions ` ] ( https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options ) .
220
217
221
218
``` js
222
- const reactRecommended = require (' eslint-plugin-react/configs/recommended ' );
219
+ const reactPlugin = require (' eslint-plugin-react' );
223
220
224
221
module .exports = [
225
222
…
226
- reactRecommended , // This is not a plugin object, but a shareable config object
223
+ reactPlugin . configs . flat . recommended , // This is not a plugin object, but a shareable config object
227
224
…
228
225
];
229
226
```
@@ -234,16 +231,16 @@ You can of course add/override some properties.
234
231
For most of the cases, you probably want to configure some properties by yourself.
235
232
236
233
``` js
237
- const reactRecommended = require (' eslint-plugin-react/configs/recommended ' );
234
+ const reactPlugin = require (' eslint-plugin-react' );
238
235
const globals = require (' globals' );
239
236
240
237
module .exports = [
241
238
…
242
239
{
243
240
files: [' **/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}' ],
244
- ... reactRecommended ,
241
+ ... reactPlugin . configs . flat . recommended ,
245
242
languageOptions: {
246
- ... reactRecommended .languageOptions ,
243
+ ... reactPlugin . configs . flat . recommended .languageOptions ,
247
244
globals: {
248
245
... globals .serviceworker ,
249
246
... globals .browser ,
@@ -257,14 +254,14 @@ module.exports = [
257
254
The above example is same as the example below, as the new config system is based on chaining.
258
255
259
256
``` js
260
- const reactRecommended = require (' eslint-plugin-react/configs/recommended ' );
257
+ const reactPlugin = require (' eslint-plugin-react' );
261
258
const globals = require (' globals' );
262
259
263
260
module .exports = [
264
261
…
265
262
{
266
263
files: [' **/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}' ],
267
- ... reactRecommended ,
264
+ ... reactPlugin . configs . flat . recommended ,
268
265
},
269
266
{
270
267
files: [' **/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}' ],
@@ -338,6 +335,7 @@ module.exports = [
338
335
| [ jsx-one-expression-per-line] ( docs/rules/jsx-one-expression-per-line.md ) | Require one JSX element per line | | | 🔧 | | |
339
336
| [ jsx-pascal-case] ( docs/rules/jsx-pascal-case.md ) | Enforce PascalCase for user-defined JSX components | | | | | |
340
337
| [ jsx-props-no-multi-spaces] ( docs/rules/jsx-props-no-multi-spaces.md ) | Disallow multiple spaces between inline JSX props | | | 🔧 | | |
338
+ | [ jsx-props-no-spread-multi] ( docs/rules/jsx-props-no-spread-multi.md ) | Disallow JSX prop spreading the same identifier multiple times | | | | | |
341
339
| [ jsx-props-no-spreading] ( docs/rules/jsx-props-no-spreading.md ) | Disallow JSX prop spreading | | | | | |
342
340
| [ jsx-sort-default-props] ( docs/rules/jsx-sort-default-props.md ) | Enforce defaultProps declarations alphabetical sorting | | | | | ❌ |
343
341
| [ jsx-sort-props] ( docs/rules/jsx-sort-props.md ) | Enforce props alphabetical sorting | | | 🔧 | | |
0 commit comments