-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
155 lines (149 loc) · 4.45 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const { resolve } = require;
const OFF = 0;
const ERROR = 2;
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
jest: 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',
],
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', 'scss'],
},
typescript: {
project: [
resolve('./tsconfig.base.json'),
resolve('./client/app/tsconfig.json'),
resolve('./scripts/tsconfig.json'),
resolve('./server/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',
},
],
'import/prefer-default-export': OFF,
'unicorn/prevent-abbreviations': OFF,
'unicorn/filename-case': [
ERROR,
{
cases: {
// 中划线
kebabCase: true,
// 小驼峰
camelCase: true,
// 下划线
snakeCase: true,
// 大驼峰
pascalCase: true,
},
},
],
'unicorn/no-process-exit': OFF,
'unicorn/explicit-length-check': OFF,
'@typescript-eslint/explicit-function-return-type': OFF,
'@typescript-eslint/no-explicit-any': OFF,
'@typescript-eslint/no-non-null-assertion': OFF,
'@typescript-eslint/no-useless-constructor': ERROR,
'@typescript-eslint/camelcase': OFF,
'@typescript-eslint/no-use-before-define': [ERROR],
'@typescript-eslint/no-shadow': [ERROR],
'react/jsx-filename-extension': [ERROR, { extensions: ['.tsx'] }],
'react/jsx-indent-props': [ERROR, 4],
'react/jsx-indent': [ERROR, 4],
'react/state-in-constructor': OFF,
'react/jsx-props-no-spreading': OFF,
'react/prop-types': OFF,
'react/require-default-props': OFF,
'promise/always-return': OFF,
'func-names': OFF,
'lines-between-class-members': OFF,
'max-classes-per-file': OFF,
'class-methods-use-this': OFF,
'no-console': OFF,
'no-empty': OFF,
'no-param-reassign': OFF,
'no-plusplus': OFF,
'no-underscore-dangle': OFF,
'no-unused-expressions': OFF,
'no-useless-constructor': OFF,
'no-bitwise': OFF,
'consistent-return': OFF,
'no-unsafe-finally': OFF,
'no-restricted-syntax': OFF,
'no-use-before-define': OFF,
'no-return-assign': OFF,
'no-shadow': OFF,
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'import/no-duplicates': OFF,
},
},
{
files: [
'scripts/**/*.*s',
'Gulpfile.ts',
'**/test/**/*.ts',
'**/*.test.js',
'**/*.spec.js',
],
rules: {
'import/no-extraneous-dependencies': OFF,
},
},
{
files: ['scripts/**/*.js'],
rules: {
'@typescript-eslint/no-var-requires': OFF,
},
},
{
files: ['server/**/*.ts', 'scripts/**/*.ts'],
rules: {
'react-hooks/rules-of-hooks': OFF,
},
},
],
};