-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
65 lines (64 loc) · 1.93 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
const path = require('path');
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ['plugin:react/recommended', 'plugin:prettier/recommended', 'airbnb', 'airbnb/hooks', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
rules: {
'no-var': 'error',
// 优先使用 interface 而不是 type
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'react/button-has-type': 'off',
'react/prop-types': 'off',
'react/sort-comp': 'off',
'import/extensions': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
// 取消 .d.ts 声明文件中使用了 constructor 报错 问题
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: 'useRecoilCallback',
},
],
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'import/no-duplicates': 0,
},
},
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.less', '.jsx', '.json', '.jsonc', '.wasm'],
},
alias: {
map: [
['_src', path.resolve(__dirname, './src/')],
['_components', path.resolve(__dirname, './src/components/')],
['_containers', path.resolve(__dirname, './src/containers/')],
['_constants', path.resolve(__dirname, './src/constants/')],
['_utils', path.resolve(__dirname, './src/utils/')],
['_assets', path.resolve(__dirname, 'src/assets/')],
['_abis', path.resolve(__dirname, 'src/abis/')],
],
extensions: ['.js', '.less', '.jsx', '.json', '.jsonc', '.wasm'],
},
},
},
};