@@ -38,81 +38,84 @@ const commonAtReactNativePluginRules = {
38
38
} ,
39
39
} ;
40
40
41
- function createRNConfig ( bFlatConfig ) {
42
- if ( bFlatConfig ) {
43
- const reactConfig = require ( './react.flat.js' ) ;
44
- const pluginA11y = require ( 'eslint-plugin-react-native-a11y' ) ;
45
- const eslintPluginReactNative = require ( 'eslint-plugin-react-native' ) ;
46
- const rnPluginEslint = require ( '@react-native/eslint-plugin' ) ;
47
- const { fixupPluginRules } = require ( '@eslint/compat' ) ;
41
+ function createFlatRNConfig ( ) {
42
+ const reactConfig = require ( './react.flat.js' ) ;
43
+ const pluginA11y = require ( 'eslint-plugin-react-native-a11y' ) ;
44
+ const eslintPluginReactNative = require ( 'eslint-plugin-react-native' ) ;
45
+ const rnPluginEslint = require ( '@react-native/eslint-plugin' ) ;
46
+ const { fixupPluginRules } = require ( '@eslint/compat' ) ;
48
47
49
- // TODO: strip the below as soon as eslint-plugin-react-native-a11y supports eslint@9
50
- const pluginA11yConfigBase = { ...pluginA11y . configs . all } ;
51
- delete pluginA11yConfigBase . parserOptions ;
48
+ // TODO: strip the below as soon as eslint-plugin-react-native-a11y supports eslint@9
49
+ const pluginA11yConfigBase = { ...pluginA11y . configs . all } ;
50
+ delete pluginA11yConfigBase . parserOptions ;
52
51
53
- return [
54
- ...reactConfig ,
55
- {
56
- ...pluginA11yConfigBase ,
57
- // eslint-plugin-react-native-a11y does not support eslint@9 yet and: specifies plugins in array form & parserOptions in root, which we patch this here
58
- // TODO: strip the below as soon as eslint-plugin-react-native-a11y supports eslint@9
59
- plugins : {
60
- 'react-native-a11y' : pluginA11y ,
61
- } ,
62
- languageOptions : {
63
- parserOptions : pluginA11y . configs . all . parserOptions ,
64
- } ,
52
+ return [
53
+ ...reactConfig ,
54
+ {
55
+ ...pluginA11yConfigBase ,
56
+ // eslint-plugin-react-native-a11y does not support eslint@9 yet and: specifies plugins in array form & parserOptions in root, which we patch this here
57
+ // TODO: strip the below as soon as eslint-plugin-react-native-a11y supports eslint@9
58
+ plugins : {
59
+ 'react-native-a11y' : pluginA11y ,
65
60
} ,
66
- {
67
- plugins : { '@react-native' : rnPluginEslint } ,
68
- rules : commonAtReactNativePluginRules ,
61
+ languageOptions : {
62
+ parserOptions : pluginA11y . configs . all . parserOptions ,
69
63
} ,
70
- {
71
- languageOptions : {
72
- // below globals listed manually - as in https://github.com/Intellicode/eslint-plugin- react-native/blob/master/index.js
73
- // since the plugin does not support eslint@9 yet
74
- // TODO: strip the below as soon as eslint-plugin-react-native-globals supports eslint@9
75
- globals : require ( 'eslint-plugin-react-native-globals' ) . environments
76
- . all . globals ,
77
- } ,
78
- plugins : {
79
- ' react-native' : fixupPluginRules ( eslintPluginReactNative ) ,
80
- } ,
81
- rules : commonReactNativePluginRules ,
64
+ } ,
65
+ {
66
+ plugins : { '@ react-native' : rnPluginEslint } ,
67
+ rules : commonAtReactNativePluginRules ,
68
+ } ,
69
+ {
70
+ languageOptions : {
71
+ // below globals listed manually - as in https://github.com/Intellicode/eslint-plugin-react-native/blob/master/index.js
72
+ // since the plugin does not support eslint@9 yet
73
+ // TODO: strip the below as soon as eslint-plugin- react-native-globals supports eslint@9
74
+ globals : require ( 'eslint-plugin-react-native-globals' ) . environments . all
75
+ . globals ,
82
76
} ,
83
- // below two objects: ported 'overrides' from the above object
77
+ plugins : {
78
+ 'react-native' : fixupPluginRules ( eslintPluginReactNative ) ,
79
+ } ,
80
+ rules : commonReactNativePluginRules ,
81
+ } ,
82
+ // below two objects: ported 'overrides' from the above object
83
+ {
84
+ files : [ '**/*.js' , '**/*.jsx' ] ,
85
+ settings : jsFilesCommonSettings ,
86
+ } ,
87
+ {
88
+ files : [ '**/*.ts' , '**/*.tsx' ] ,
89
+ settings : tsFilesCommonSettings ,
90
+ } ,
91
+ ] ;
92
+ }
93
+
94
+ function createLegacyRNConfig ( ) {
95
+ return {
96
+ extends : [ require . resolve ( './react.js' ) , 'plugin:react-native-a11y/all' ] ,
97
+ env : {
98
+ 'react-native/react-native' : true ,
99
+ } ,
100
+ plugins : [ 'react-native' , '@react-native' ] ,
101
+ rules : {
102
+ ...commonAtReactNativePluginRules ,
103
+ ...commonReactNativePluginRules ,
104
+ } ,
105
+ overrides : [
84
106
{
85
- files : [ '**/* .js' , '**/ *.jsx' ] ,
107
+ files : [ '*.js' , '*.jsx' ] ,
86
108
settings : jsFilesCommonSettings ,
87
109
} ,
88
110
{
89
- files : [ '**/* .ts' , '**/ *.tsx' ] ,
111
+ files : [ '*.ts' , '*.tsx' ] ,
90
112
settings : tsFilesCommonSettings ,
91
113
} ,
92
- ] ;
93
- } else {
94
- return {
95
- extends : [ require . resolve ( './react.js' ) , 'plugin:react-native-a11y/all' ] ,
96
- env : {
97
- 'react-native/react-native' : true ,
98
- } ,
99
- plugins : [ 'react-native' , '@react-native' ] ,
100
- rules : {
101
- ...commonAtReactNativePluginRules ,
102
- ...commonReactNativePluginRules ,
103
- } ,
104
- overrides : [
105
- {
106
- files : [ '*.js' , '*.jsx' ] ,
107
- settings : jsFilesCommonSettings ,
108
- } ,
109
- {
110
- files : [ '*.ts' , '*.tsx' ] ,
111
- settings : tsFilesCommonSettings ,
112
- } ,
113
- ] ,
114
- } ;
115
- }
114
+ ] ,
115
+ } ;
116
116
}
117
117
118
- module . exports = createRNConfig ;
118
+ module . exports = {
119
+ createFlatRNConfig,
120
+ createLegacyRNConfig,
121
+ } ;
0 commit comments