-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
100 lines (84 loc) · 2.57 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
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import path from 'path';
import { fileURLToPath } from 'url';
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const compat = new FlatCompat({
baseDirectory: dirname,
resolvePluginsRelativeTo: dirname,
});
const appConfigs = compat.config({
env: {
browser: true,
es2020: 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',
],
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',
'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 }],
},
}).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,
];