Skip to content

Commit 450bb63

Browse files
committed
Split react and non-react configs
1 parent e963a9c commit 450bb63

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

index.js

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
66
import simpleImportSort from 'eslint-plugin-simple-import-sort';
77
import tseslint from 'typescript-eslint';
88

9-
export default tseslint.config(
9+
export const baseConfig = tseslint.config(
1010
{
1111
extends: [
1212
eslint.configs.recommended,
@@ -15,26 +15,8 @@ export default tseslint.config(
1515
plugins: {
1616
'@stylistic': stylistic,
1717
'simple-import-sort': simpleImportSort,
18-
'jsx-a11y': pluginJsxA11y,
19-
react,
20-
'react-hooks': eslintPluginReactHooks, // TODO Check if eslint/compat is needed here
21-
},
22-
languageOptions: {
23-
parserOptions: {
24-
ecmaFeatures: {
25-
jsx: true,
26-
},
27-
},
28-
},
29-
settings: {
30-
react: {
31-
version: 'detect'
32-
}
3318
},
3419
rules: {
35-
...pluginJsxA11y.configs.recommended.rules,
36-
...eslintPluginReactHooks.configs.recommended.rules,
37-
3820
'@stylistic/arrow-parens': 'error',
3921
'@stylistic/arrow-spacing': 'error',
4022
'@stylistic/block-spacing': 'error',
@@ -77,8 +59,6 @@ export default tseslint.config(
7759
}],
7860

7961
// Disabled rules from presets
80-
'react/display-name': ['off', { 'ignoreTranspilerName': false }],
81-
'react/prop-types': 'off',
8262
'@typescript-eslint/ban-types': 'off',
8363
'@typescript-eslint/no-explicit-any': 'off',
8464
},
@@ -88,8 +68,48 @@ export default tseslint.config(
8868
rules: {
8969
'prefer-promise-reject-errors': 'off',
9070
'no-param-reassign': 'off',
71+
'@typescript-eslint/no-shadow': 'off',
72+
},
73+
},
74+
);
75+
76+
export const reactConfig = tseslint.config(
77+
{
78+
plugins: {
79+
'jsx-a11y': pluginJsxA11y,
80+
react,
81+
'react-hooks': eslintPluginReactHooks,
82+
},
83+
languageOptions: {
84+
parserOptions: {
85+
ecmaFeatures: {
86+
jsx: true,
87+
},
88+
},
89+
},
90+
settings: {
91+
react: {
92+
version: 'detect'
93+
}
94+
},
95+
rules: {
96+
...pluginJsxA11y.configs.recommended.rules,
97+
...eslintPluginReactHooks.configs.recommended.rules,
98+
99+
// Disabled rules from presets
100+
'react/display-name': ['off', { 'ignoreTranspilerName': false }],
101+
'react/prop-types': 'off',
102+
},
103+
},
104+
{
105+
files: ['*.test.*', '*.spec.*'],
106+
rules: {
91107
'react/no-children-prop': 'off',
92-
'@typescript-eslint/no-shadow': 'off'
93-
}
108+
},
94109
},
95110
);
111+
112+
export default tseslint.config(
113+
...baseConfig,
114+
...reactConfig,
115+
);

0 commit comments

Comments
 (0)