@@ -25,16 +25,21 @@ const activeRulesConfig = configureAsError(activeRules);
2525/** @type {Partial<typeof allRules> } */
2626const deprecatedRules = filterRules ( allRules , ( rule ) => rule . meta . deprecated ) ;
2727
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
3331
3432// TODO: with TS 4.5+, inline this
3533const SEVERITY_ERROR = /** @type {2 } */ ( 2 ) ;
3634const SEVERITY_OFF = /** @type {0 } */ ( 0 ) ;
3735
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 } */
3843const configs = {
3944 recommended : {
4045 plugins,
@@ -90,21 +95,17 @@ const configs = {
9095 'react/jsx-uses-react' : SEVERITY_OFF ,
9196 } ,
9297 } ,
93- flat : /** @type {Record<string, ReactFlatConfig> } */ ( {
94- __proto__ : null ,
95- } ) ,
98+ flat : { } ,
9699} ;
97100
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 } */
101102const plugin = {
102103 deprecatedRules,
103104 rules : allRules ,
104105 configs,
105106} ;
106107
107- Object . assign ( configs . flat , {
108+ configs . flat = {
108109 recommended : {
109110 plugins : { react : plugin } ,
110111 rules : configs . recommended . rules ,
@@ -120,6 +121,6 @@ Object.assign(configs.flat, {
120121 rules : configs [ 'jsx-runtime' ] . rules ,
121122 languageOptions : { parserOptions : configs [ 'jsx-runtime' ] . parserOptions } ,
122123 } ,
123- } ) ;
124+ } ;
124125
125126module . exports = plugin ;
0 commit comments