-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.js
133 lines (117 loc) · 3.77 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import process from 'process';
const dirname = process.cwd();
const compat = new FlatCompat({
baseDirectory: dirname,
resolvePluginsRelativeTo: dirname,
});
const appConfigs = compat.config({
env: {
node: true,
browser: true,
es2020: true,
},
root: true,
extends: [
'airbnb',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
'react-refresh',
'simple-import-sort',
'import-newlines'
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
typescript: {
project: [
'./tsconfig.json',
],
},
},
},
rules: {
'react-refresh/only-export-components': 'warn',
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 1,
'no-use-before-define': 0,
'@typescript-eslint/no-use-before-define': 1,
'no-shadow': 0,
'@typescript-eslint/no-shadow': ['error'],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.test.{ts,tsx}',
'eslint.config.js',
'postcss.config.cjs',
'stylelint.config.cjs',
'vite.config.ts',
],
optionalDependencies: false,
},
],
indent: ['error', 4, { SwitchCase: 1 }],
'import/no-cycle': ['error', { allowUnsafeDynamicCyclicDependency: true }],
'react/react-in-jsx-scope': 'off',
'camelcase': 'off',
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'import/extensions': ['off', 'never'],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/require-default-props': ['warn', { ignoreFunctionalComponents: true }],
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'import-newlines/enforce': ['warn', 1]
},
overrides: [
{
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
rules: {
'simple-import-sort/imports': [
'error',
{
'groups': [
// side effect imports
['^\\u0000'],
// packages `react` related packages come first
['^react', '^@?\\w'],
// internal packages
['^#.+$'],
// parent imports. Put `..` last
// other relative imports. Put same-folder imports and `.` last
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// style imports
['^.+\\.json$', '^.+\\.module.css$'],
]
}
]
}
}
]
}).map((conf) => ({
...conf,
files: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts', 'src/**/*.js'],
}));
const otherConfig = {
files: ['*.js', '*.ts', '*.cjs'],
...js.configs.recommended,
};
export default [
...appConfigs,
otherConfig,
];