-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc
182 lines (182 loc) · 6.56 KB
/
.eslintrc
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{
parserOptions: {
ecmaVersion: 8,
sourceType: module,
ecmaFeatures: {
experimentalObjectRestSpread: true
}
},
env: {
browser: true,
es6: true,
node: true
},
globals: {
atom: true,
},
rules: {
//句尾强制加分号
semi: [error, always],
//不允许空格和tab混用
no-mixed-spaces-and-tabs: error,
//不允许使用tab
no-tabs: error,
//缩进一律四个空格
indent: [error, 4, {
// case用一个缩进
SwitchCase: 1 ,
// 变量声明用一个缩进
VariableDeclarator: 1 ,
outerIIFEBody: 1 ,
MemberExpression: 1 ,
FunctionDeclaration: { body: 1, parameters: 1 },
FunctionExpression: { body: 1, parameters: 1 },
CallExpression: { arguments: 1 }
}
],
//不允许多个空行
no-multiple-empty-lines: error,
//禁止在 function的左括号之前使用空格
space-before-function-paren: [error, never],
//禁止在圆括号内使用空格, ( 左括号右边和右括号左边 )
space-in-parens: [error, never],
//禁止在数组的方括号内使用空格, 同上
array-bracket-spacing: [error, never],
//在一元操作符前后使用空格: 保留字允许空格, 操作符不允许空格
space-unary-ops: [
error, {
words: true,
nonwords: false
}],
//逗号前禁止有空格, 逗号后必须有空格
comma-spacing: [error, { before: false, after: true }],
//禁止逗号前置
comma-style: [error, last],
//禁止在在计算的属性的方括号中使用空格
computed-property-spacing: [error, never],
//强制使用1tbs风格的代码块括号 见http://eslint.cn/docs/rules/brace-style
brace-style: [error, 1tbs],
//禁止函数调用时括号左边有空格
func-call-spacing: [error, never],
//关键字前后必须有空格, (function后必须无空格)
keyword-spacing: [error,
{ before: true, after: true }
],
//对象名值对的冒号前禁止有空格, 冒号后必须有空格
key-spacing: [error, {
beforeColon: false,
afterColon: true,
mode: strict
}],
//禁止条件表达式中出现赋值操作符
no-cond-assign: error,
//禁止使用嵌套的三元表达式
no-nested-ternary: error,
//禁止可以表达为更简单结构的三元操作符
no-unneeded-ternary: error,
//强制使用驼峰命名 MY_FAVORITE_COLOR 这种常量命名是允许的
camelcase: warn,
//禁止对 Function 对象使用 new 操作符
no-new-func: error,
//禁止对 String,Number 和 Boolean 使用 new 操作符
no-new-wrappers: error,
//禁止用对Array使用 new 操作符
no-array-constructor: error,
//禁止对symbol使用new操作符
no-new-symbol: error,
//尽可能使用点号取属性
dot-notation: error,
//当没有严格要求时,禁止对象字面量属性名称使用引号
quote-props: [error, as-needed],
//iife必须用括号包起来
wrap-iife: error,
//禁用 arguments.caller 或 arguments.callee
no-caller: error,
//禁止不必要的 .call() 和 .apply()
no-useless-call: error,
//this的别名强制使用self
consistent-this: [error, self],
//禁止使用eval
no-eval: error,
//禁止使用__proto__
no-proto: error,
//禁止使用with语句
no-with: error,
//禁用 __iterator__ 属性
no-iterator: error,
//禁用void操作符
no-void: error,
//禁用标签语句
no-labels: error,
//要求使用 isNaN() 检查 NaN
use-isnan: error,
//不建议使用位运算符
no-bitwise: error,
//禁止抛出异常字面量 必须用new Error
no-throw-literal: error,
//禁止在条件中使用常量表达式
no-constant-condition: error,
//禁止不必要的布尔转换
no-extra-boolean-cast: error,
//要求调用无参构造函数时有圆括号
new-parens: error,
// 禁用 debugger
no-debugger: 2,
// 禁止 function 定义中出现重名参数
no-dupe-args: 2,
// 禁止对象字面量中出现重复的 key
no-dupe-keys: 2,
// 禁止对 function 声明重新赋值
no-func-assign: 2,
// 警告未使用的变量
no-unused-vars: 1,
// 花括号前加空格
space-before-blocks: error,
// 禁止使用未声明的变量
no-undef: 2,
arrow-spacing: error,
// let和const优先使用const
prefer-const: error,
// 注释双斜杠后加一个空格, ----和++++例外
spaced-comment: [error, always, {
exceptions: ["-", "+"]
}],
// 代码块花括号内不允许有空行
padded-blocks: [error, never],
// 要求花括号内有空格 (除了 {})
object-curly-spacing: [error, always],
// 一行最大长度
max-len: [error, 100, {
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true
}],
// 要求中缀操作符周围有空格 a + b
space-infix-ops: error,
// 避免使用不必要的字符串拼接 var a = '1' + '0';
no-useless-concat: 2,
// 多行字符串要相加,而不是用链接符
no-multi-str: 1,
// 字符串使用单引号
quotes: [2, single, { allowTemplateLiterals: true }],
// 禁止同名导入/导出
// import { foo as foo } from "bar";
// export { foo as foo };
no-useless-rename: [error, {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false
}],
// 禁止 var a = 1,
// b = 2;
// 必须 var a = 1;
// var b = 2;
one-var: [error, never],
// Disallow arrow functions where they could be confused with comparisons
no-confusing-arrow: [error, {allowParens: true}],
arrow-parens: [error, always],
no-var: error,
}
}