-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
137 lines (131 loc) · 3.49 KB
/
.eslintrc.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
134
135
136
137
const esRules = {
'no-var': 'error',
'no-undef': 'error',
'no-unused-vars': 'error',
'no-unused-expressions': 'error',
'no-param-reassign': 'error',
'no-shadow': 'error',
'no-else-return': 'error',
'no-useless-escape': 'error',
'no-return-await': 'error',
'default-case': 'error',
'no-fallthrough': 'error',
'prettier/prettier': ['error', { usePrettierrc: true }],
}
// React
const reactRules = {
'react/no-children-prop': 'off',
'react/self-closing-comp': 'error',
'react/no-unused-prop-types': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'error',
// { additionalHooks: '(useLifecycledEffect|useMyOtherCustomHook)' },
],
}
// Typescript
const tsRules = {
'no-undef': 'off',
'no-shadow': 'off',
'no-unused-vars': 'off',
'react/jsx-no-undef': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-redeclare': ['error'],
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as' },
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/require-await': 'error',
}
// Import
const importRules = {
// 'import/no-unresolved': ['error', { ignore: ['.svg'] }],
'import/no-dynamic-require': 'error',
'import/no-self-import': 'error',
'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
'import/no-duplicates': 'error',
'import/extensions': [
'error',
'never',
{
ignorePackages: true,
svg: 'always',
},
],
'import/export': 'error',
'import/newline-after-import': 'error',
'import/first': 'error',
'import/no-mutable-exports': 'error',
'import/no-cycle': 'error',
'import/order': 'off',
}
const env = { browser: true, node: true }
const settings = {
react: { version: 'detect' },
'import/resolver': {
node: {
paths: ['src/'],
},
},
}
module.exports = {
overrides: [
{
env,
files: ['**/*.js', '**/*.jsx', '**/*.json'],
extends: ['react-app', 'prettier'],
plugins: ['prettier', 'react', 'react-hooks', 'import'],
settings,
rules: {
...esRules,
...reactRules,
...importRules,
},
},
{
env,
files: ['**/*.d.ts', '**/*.ts', '**/*.tsx'],
extends: [
'react-app',
'plugin:import/typescript',
'plugin:css-modules/recommended',
'prettier',
],
plugins: [
'css-modules',
'prettier',
'@typescript-eslint',
'react',
'react-hooks',
'import',
],
settings,
rules: {
...esRules,
...tsRules,
...reactRules,
...importRules,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
},
},
],
}