-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslint.config.mjs
54 lines (53 loc) · 1.43 KB
/
eslint.config.mjs
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
import optimizeRegex from 'npm:eslint-plugin-optimize-regex'
import UnusedImports from 'npm:eslint-plugin-unused-imports'
import html from 'npm:eslint-plugin-html'
export default [
{
plugins: {
'optimize-regex': optimizeRegex,
'unused-imports': UnusedImports,
'html': html
},
files: ['**/*.html', '**/*.js', '**/*.mjs'],
ignores: ['**/dist/*'],
rules: {
// 移除多余的分号
semi: [
'error', 'never'
],
// 当块内容只有一行时,移除块的大括号
curly: ['error', 'multi'],
// tab 缩进
indent: ['error', 'tab', {
VariableDeclarator: 1,
MemberExpression: 1,
SwitchCase: 1,
ignoredNodes: [
'ConditionalExpression'
]
}],
// 鼓励单引号
quotes: ['error', 'single'],
// 去除不必要小括号
'no-extra-parens': ['error', 'all', {
nestedBinaryExpressions: false, // 允许嵌套二元表达式中有括号
returnAssign: false // 允许 return 语句中的赋值表达式中有括号
}],
// if中的没有await的promise
'no-constant-condition': ['error', { checkLoops: false }],
// 优化正则
'optimize-regex/optimize-regex': 'warn',
// 禁用未使用的导入
'unused-imports/no-unused-imports': 'error',
// 禁用未使用的变量
'no-unused-vars': 'off',
// 不要 var
'no-var': 'error',
// 偏好 const
'prefer-const': ['error', {
'destructuring': 'all',
'ignoreReadBeforeAssign': true
}]
}
}
]