-
Notifications
You must be signed in to change notification settings - Fork 29
/
.eslintrc.js
120 lines (113 loc) · 3.34 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
const { resolve } = require;
const OFF = 0;
const ERROR = 2;
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'airbnb',
'airbnb/hooks',
'plugin:eslint-comments/recommended',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020,
sourceType: 'module',
},
settings: {
'import/resolver': {
node: {
// import 模块时,不写后缀将尝试导入的后缀,出现频率高的文件类型放前面
extensions: ['.tsx', '.ts', '.js', '.json'],
},
typescript: {
directory: [resolve('./src/tsconfig.json'), resolve('./scripts/tsconfig.json')],
},
},
},
plugins: ['react', '@typescript-eslint', 'unicorn', 'promise'],
rules: {
'eslint-comments/disable-enable-pair': [ERROR, { allowWholeFile: true }],
'import/extensions': [
ERROR,
'ignorePackages',
{
ts: 'never',
tsx: 'never',
json: 'never',
js: 'never',
},
],
'unicorn/filename-case': [
ERROR,
{
cases: {
// 中划线
kebabCase: false,
// 小驼峰
camelCase: true,
// 下划线
snakeCase: false,
// 大驼峰
pascalCase: true,
},
},
],
'unicorn/import-style': OFF,
'unicorn/no-null': OFF,
'unicorn/prevent-abbreviations': OFF,
'unicorn/no-process-exit': OFF,
'@typescript-eslint/explicit-function-return-type': OFF,
'@typescript-eslint/no-explicit-any': OFF,
'@typescript-eslint/no-non-null-assertion': OFF,
'@typescript-eslint/no-use-before-define': ERROR,
'@typescript-eslint/no-useless-constructor': ERROR,
'react/jsx-filename-extension': [ERROR, { extensions: ['.tsx'] }],
'react/jsx-indent-props': [ERROR, 4],
'react/jsx-indent': [ERROR, 4],
'react/require-default-props': OFF,
'func-names': OFF,
'lines-between-class-members': OFF,
'max-classes-per-file': OFF,
'no-console': OFF,
'no-empty': OFF,
'no-param-reassign': OFF,
'no-plusplus': OFF,
'no-underscore-dangle': OFF,
'no-unused-expressions': OFF,
'no-use-before-define': OFF,
'no-useless-constructor': OFF,
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'import/no-duplicates': OFF,
},
},
{
files: ['scripts/**/*.ts'],
rules: {
'import/no-extraneous-dependencies': OFF,
},
},
],
};