@@ -25,16 +25,22 @@ const activeRulesConfig = configureAsError(activeRules);
25
25
/** @type {Partial<typeof allRules> } */
26
26
const deprecatedRules = filterRules ( allRules , ( rule ) => rule . meta . deprecated ) ;
27
27
28
- /** @type {['react'] } */
29
- // for legacy config system
30
- const plugins = [
31
- 'react' ,
32
- ] ;
28
+ /** @typedef {['react'] } Plugins */
29
+ /** @type {Plugins } */
30
+ const plugins = [ 'react' ] ; // for legacy config system
33
31
34
32
// TODO: with TS 4.5+, inline this
35
33
const SEVERITY_ERROR = /** @type {2 } */ ( 2 ) ;
36
34
const SEVERITY_OFF = /** @type {0 } */ ( 0 ) ;
37
35
36
+ /** @typedef {{ plugins: Plugins, rules: import('eslint').Linter.RulesRecord, parserOptions: import('eslint').Linter.ParserOptions } } ReactLegacyConfig */
37
+ /** @typedef {{ deprecatedRules: typeof deprecatedRules, rules: typeof allRules, configs: Configs } } FlatConfigPlugin */
38
+ /** @typedef {{ plugins: { react: FlatConfigPlugin }, rules: import('eslint').Linter.RulesRecord, languageOptions: { parserOptions: import('eslint').Linter.ParserOptions } } } ReactFlatConfig */
39
+ /** @typedef { "recommended"|"all"|"jsx-runtime" } ConfigKey */
40
+ /** @typedef { Record<ConfigKey, ReactFlatConfig> } FlatConfigs */
41
+ /** @typedef { Record<ConfigKey, ReactLegacyConfig> & { flat: FlatConfigs } } Configs */
42
+
43
+ /** @type { Configs } */
38
44
const configs = {
39
45
recommended : {
40
46
plugins,
@@ -90,21 +96,17 @@ const configs = {
90
96
'react/jsx-uses-react' : SEVERITY_OFF ,
91
97
} ,
92
98
} ,
93
- flat : /** @type {Record<string, ReactFlatConfig> } */ ( {
94
- __proto__ : null ,
95
- } ) ,
99
+ flat : /** @type { FlatConfigs } */ ( { } ) ,
96
100
} ;
97
101
98
- /** @typedef {{ plugins: { react: typeof plugin }, rules: import('eslint').Linter.RulesRecord, languageOptions: { parserOptions: import('eslint').Linter.ParserOptions } } } ReactFlatConfig */
99
-
100
- /** @type {{ deprecatedRules: typeof deprecatedRules, rules: typeof allRules, configs: typeof configs & { flat: Record<string, ReactFlatConfig> }} } */
102
+ /** @type { FlatConfigPlugin } */
101
103
const plugin = {
102
104
deprecatedRules,
103
105
rules : allRules ,
104
106
configs,
105
107
} ;
106
108
107
- Object . assign ( configs . flat , {
109
+ configs . flat = {
108
110
recommended : {
109
111
plugins : { react : plugin } ,
110
112
rules : configs . recommended . rules ,
@@ -120,6 +122,6 @@ Object.assign(configs.flat, {
120
122
rules : configs [ 'jsx-runtime' ] . rules ,
121
123
languageOptions : { parserOptions : configs [ 'jsx-runtime' ] . parserOptions } ,
122
124
} ,
123
- } ) ;
125
+ } ;
124
126
125
127
module . exports = plugin ;
0 commit comments