-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.js
83 lines (83 loc) · 2.61 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
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
// 禁止在循环中出现 await
'no-await-in-loop': 1,
// 禁用 debugger
'no-debugger': 0,
// 要求使用 === 和 !==
eqeqeq: 1,
// 要求 for-in 循环中有一个 if 语句
'guard-for-in': 1,
// 强制每个文件中包含的的类的最大数量
'max-classes-per-file': [1, 1],
// 禁止扩展原生类型
'no-extend-native': 1,
// 禁用一成不变的循环条件
'no-unmodified-loop-condition': 1,
// 2 个空格缩进
indent: ['error', 2],
// 强制在 JSX 属性中一致地使用双引号
'jsx-quotes': ['error', 'prefer-double'],
// 要求在对象字面量的冒号和值之间存在至少有一个空格
'key-spacing': ['error', { afterColon: true }],
// 强制行注释只在代码上方,单独成行。
'line-comment-position': ['error', { position: 'above' }],
// 强制块语句的最大可嵌套深度
'max-depth': [1, 4],
// 强制行的最大长度
'max-len': ['error', { code: 80 }],
// 强制行的最大行数
'max-lines': ['error', 300],
// 强制在函数中的最大行数。
'max-lines-per-function': ['error', 300],
// 强制回调函数最大可嵌套深度
'max-nested-callbacks': ['error', 3],
// 强制三元操作数之间有换行。
// 'multiline-ternary': ['error', 'always'],
// 要求调用 new 操作符时有首字母大小的函数
'new-cap': 1,
// 单引号
quotes: ['error', 'single'],
// 无分号
semi: ['error', 'never'],
// 该规则禁止在 return、throw、continue 和 break 语句后出现不可达代码。
'no-unreachable': 1,
// 要求操作符周围有空格
'space-infix-ops': 'error',
// 强制在一元操作符前后使用一致的空格
'space-unary-ops': 'error',
// 强制在 switch 的冒号左右有空格
'switch-colon-spacing': 'error',
// 禁止 any 但是提交是没起作用
'@typescript-eslint/no-explicit-any': 'error',
},
overrides: [
{
files: ['*.ts'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': ['error'],
},
},
],
}