@@ -25,16 +25,21 @@ 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 { "recommended"|"all"|"jsx-runtime" } ConfigKey */
37
+ /** @typedef {{ plugins: Plugins, rules: import('eslint').Linter.RulesRecord, parserOptions: import('eslint').Linter.ParserOptions } } ReactLegacyConfig */
38
+ /** @typedef {{ deprecatedRules: typeof deprecatedRules, rules: typeof allRules, configs: Configs } } FlatConfigPlugin */
39
+ /** @typedef {{ plugins: { react: FlatConfigPlugin }, rules: import('eslint').Linter.RulesRecord, languageOptions: { parserOptions: import('eslint').Linter.ParserOptions } } } ReactFlatConfig */
40
+ /** @typedef { Record<ConfigKey, ReactLegacyConfig> & { flat: Record<ConfigKey, ReactFlatConfig> } } Configs */
41
+
42
+ /** @type { Configs } */
38
43
const configs = {
39
44
recommended : {
40
45
plugins,
@@ -90,21 +95,17 @@ const configs = {
90
95
'react/jsx-uses-react' : SEVERITY_OFF ,
91
96
} ,
92
97
} ,
93
- flat : /** @type {Record<string, ReactFlatConfig> } */ ( {
94
- __proto__ : null ,
95
- } ) ,
98
+ flat : { } ,
96
99
} ;
97
100
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> }} } */
101
+ /** @type { FlatConfigPlugin } */
101
102
const plugin = {
102
103
deprecatedRules,
103
104
rules : allRules ,
104
105
configs,
105
106
} ;
106
107
107
- Object . assign ( configs . flat , {
108
+ configs . flat = {
108
109
recommended : {
109
110
plugins : { react : plugin } ,
110
111
rules : configs . recommended . rules ,
@@ -120,6 +121,6 @@ Object.assign(configs.flat, {
120
121
rules : configs [ 'jsx-runtime' ] . rules ,
121
122
languageOptions : { parserOptions : configs [ 'jsx-runtime' ] . parserOptions } ,
122
123
} ,
123
- } ) ;
124
+ } ;
124
125
125
126
module . exports = plugin ;
0 commit comments