1 | /* eslint-enable */
|
2 | {
|
3 | "globals": {
|
4 | "cml": false
|
5 | },
|
6 | "env": {
|
7 | "browser": true,
|
8 | "node": true,
|
9 | "commonjs": true,
|
10 | "amd": true,
|
11 | "es6": true,
|
12 | "mocha": true
|
13 | },
|
14 | "parserOptions": {
|
15 | "ecmaVersion": 6,
|
16 | "sourceType": "module",
|
17 | "ecmaFeatures": {
|
18 | "globalReturn": true,
|
19 | "impliedStrict": true,
|
20 | "jsx": true,
|
21 | "modules": true
|
22 | }
|
23 | },
|
24 | "plugins": [
|
25 |
|
26 | ],
|
27 | "extends": [
|
28 | "eslint:recommended"
|
29 | ],
|
30 |
|
31 |
|
32 | "rules": {
|
33 |
|
34 |
|
35 | "no-cond-assign": 2,
|
36 | "no-console": 0,
|
37 |
|
38 | "no-constant-condition": 2,
|
39 | "no-control-regex": 2,
|
40 | "comma-dangle": [1, "never"],
|
41 | "no-debugger": 2,
|
42 | "no-dupe-args": 2,
|
43 | "no-dupe-keys": 2,
|
44 | "no-duplicate-case": 2,
|
45 | "no-empty": 2,
|
46 | "no-empty-character-class": 2,
|
47 | "no-ex-assign": 2,
|
48 | "no-extra-boolean-cast": 2,
|
49 | "no-extra-parens": 0,
|
50 | "no-extra-semi": 2,
|
51 | "no-func-assign": 2,
|
52 | "no-inner-declarations": [2, "functions"],
|
53 | "no-invalid-regexp": 2,
|
54 | "no-irregular-whitespace": 2,
|
55 | "no-negated-in-lhs": 2,
|
56 | "no-obj-calls": 2,
|
57 | "no-prototype-builtins": 0,
|
58 | "no-regex-spaces": 2,
|
59 | "no-sparse-arrays": 2,
|
60 | "no-unexpected-multiline": 2,
|
61 | "no-unreachable": 2,
|
62 | "use-isnan": 2,
|
63 | "valid-jsdoc": 0,
|
64 | "valid-typeof": 2,
|
65 |
|
66 |
|
67 | "accessor-pairs": 2,
|
68 | "array-callback-return": 0,
|
69 | "block-scoped-var": 0,
|
70 | "complexity": [2, 30],
|
71 | "consistent-return": 0,
|
72 | "curly": [2, "all"],
|
73 | "default-case": 2,
|
74 | "dot-location": [2, "property"],
|
75 | "dot-notation": [2, {
|
76 | "allowKeywords": false
|
77 | }],
|
78 | "eqeqeq": [0, "allow-null"],
|
79 | "guard-for-in": 2,
|
80 | "no-alert": 0,
|
81 | "no-caller": 2,
|
82 | "no-case-declarations": 2,
|
83 | "no-div-regex": 2,
|
84 | "no-else-return": 0,
|
85 | "no-empty-function": 2,
|
86 | "no-empty-pattern": 2,
|
87 | "no-eq-null": 1,
|
88 | "no-eval": 2,
|
89 | "no-extend-native": 2,
|
90 | "no-extra-bind": 2,
|
91 | "no-extra-label:": 0,
|
92 | "no-fallthrough": 2,
|
93 | "no-floating-decimal": 2,
|
94 | "no-implicit-coercion": 0,
|
95 | "no-implicit-globals": 1,
|
96 | "no-implied-eval": 2,
|
97 | "no-invalid-this": 0,
|
98 | "no-iterator": 2,
|
99 | "no-labels": 2,
|
100 | "no-lone-blocks": 2,
|
101 | "no-loop-func": 1,
|
102 | "no-magic-numbers": [1, {
|
103 | "ignore": [0, -1, 1]
|
104 | }],
|
105 | "no-multi-spaces": 2,
|
106 | "no-multi-str": 2,
|
107 | "no-native-reassign": 2,
|
108 | "no-new": 2,
|
109 | // 禁止对 Function 对象使用 new 操作符
|
110 | "no-new-func": 0,
|
111 | // 禁止对 String,Number 和 Boolean 使用 new 操作符
|
112 | "no-new-wrappers": 2,
|
113 | // 禁用八进制字面量
|
114 | "no-octal": 2,
|
115 | // 禁止在字符串中使用八进制转义序列
|
116 | "no-octal-escape": 2,
|
117 | // 不允许对 function 的参数进行重新赋值
|
118 | "no-param-reassign": 0,
|
119 | // 禁用 __proto__ 属性
|
120 | "no-proto": 2,
|
121 | // 禁止使用 var 多次声明同一变量
|
122 | "no-redeclare": 2,
|
123 | // 禁用指定的通过 require 加载的模块
|
124 | "no-return-assign": 0,
|
125 | // 禁止使用 javascript: url
|
126 | "no-script-url": 0,
|
127 | // 禁止自我赋值
|
128 | "no-self-assign": 2,
|
129 | // 禁止自身比较
|
130 | "no-self-compare": 2,
|
131 | // 禁用逗号操作符
|
132 | "no-sequences": 2,
|
133 | // 禁止抛出非异常字面量
|
134 | "no-throw-literal": 2,
|
135 | // 禁用一成不变的循环条件
|
136 | "no-unmodified-loop-condition": 2,
|
137 | // 禁止出现未使用过的表达式
|
138 | "no-unused-expressions": 0,
|
139 | // 禁用未使用过的标签
|
140 | "no-unused-labels": 2,
|
141 | // 禁止不必要的 .call() 和 .apply()
|
142 | "no-useless-call": 2,
|
143 | // 禁止不必要的字符串字面量或模板字面量的连接
|
144 | "no-useless-concat": 0,
|
145 | // 禁用不必要的转义字符
|
146 | "no-useless-escape": 0,
|
147 | // 禁用 void 操作符
|
148 | "no-void": 0,
|
149 | // 禁止在注释中使用特定的警告术语
|
150 | "no-warning-comments": 0,
|
151 | // 禁用 with 语句
|
152 | "no-with": 2,
|
153 | // 强制在parseInt()使用基数参数
|
154 | "radix": 2,
|
155 | // 要求所有的 var 声明出现在它们所在的作用域顶部
|
156 | "vars-on-top": 0,
|
157 | // 要求 IIFE 使用括号括起来
|
158 | "wrap-iife": [2, "any"],
|
159 | // 要求或禁止 “Yoda” 条件
|
160 | "yoda": [2, "never"],
|
161 | // 要求或禁止使用严格模式指令
|
162 | "strict": 0,
|
163 |
|
164 |
|
165 | //////////////
|
166 | // 变量声明 //
|
167 | //////////////
|
168 |
|
169 | // 要求或禁止 var 声明中的初始化(初值)
|
170 | "init-declarations": 0,
|
171 | // 不允许 catch 子句的参数与外层作用域中的变量同名
|
172 | "no-catch-shadow": 0,
|
173 | // 禁止删除变量
|
174 | "no-delete-var": 2,
|
175 | // 不允许标签与变量同名
|
176 | "no-label-var": 2,
|
177 | // 禁用特定的全局变量
|
178 | "no-restricted-globals": 0,
|
179 | // 禁止 var 声明 与外层作用域的变量同名
|
180 | "no-shadow": 0,
|
181 | // 禁止覆盖受限制的标识符
|
182 | "no-shadow-restricted-names": 2,
|
183 | // 禁用未声明的变量,除非它们在 /*global */ 注释中被提到
|
184 | "no-undef": 2,
|
185 | // 禁止将变量初始化为 undefined
|
186 | "no-undef-init": 2,
|
187 | // 禁止将 undefined 作为标识符
|
188 | "no-undefined": 0,
|
189 | // 禁止出现未使用过的变量
|
190 | "no-unused-vars": [2, {
|
191 | "vars": "all",
|
192 | "args": "none"
|
193 | }],
|
194 | // 不允许在变量定义之前使用它们
|
195 | "no-use-before-define": 0,
|
196 |
|
197 | //////////////////////////
|
198 | // Node.js and CommonJS //
|
199 | //////////////////////////
|
200 |
|
201 | // require return statements after callbacks
|
202 | "callback-return": 0,
|
203 | // 要求 require() 出现在顶层模块作用域中
|
204 | "global-require": 1,
|
205 | // 要求回调函数中有容错处理
|
206 | "handle-callback-err": [2, "^(err|error)$"],
|
207 | // 禁止混合常规 var 声明和 require 调用
|
208 | "no-mixed-requires": 0,
|
209 | // 禁止调用 require 时使用 new 操作符
|
210 | "no-new-require": 2,
|
211 | // 禁止对 __dirname 和 __filename进行字符串连接
|
212 | "no-path-concat": 0,
|
213 | // 禁用 process.env
|
214 | "no-process-env": 0,
|
215 | // 禁用 process.exit()
|
216 | "no-process-exit": 0,
|
217 | // 禁用同步方法
|
218 | "no-sync": 0,
|
219 |
|
220 | //////////////
|
221 | // 风格指南 //
|
222 | //////////////
|
223 |
|
224 | // 指定数组的元素之间要以空格隔开(, 后面), never参数:[ 之前和 ] 之后不能带空格,always参数:[ 之前和 ] 之后必须带空格
|
225 | "array-bracket-spacing": [2, "never"],
|
226 | // 禁止或强制在单行代码块中使用空格(禁用)
|
227 | "block-spacing": [1, "never"],
|
228 | //强制使用一致的缩进 第二个参数为 "tab" 时,会使用tab,
|
229 | // if while function 后面的{必须与if在同一行,java风格。
|
230 | "brace-style": [2, "1tbs", {
|
231 | "allowSingleLine": true
|
232 | }],
|
233 | // 双峰驼命名格式
|
234 | "camelcase": 2,
|
235 | // 控制逗号前后的空格
|
236 | "comma-spacing": [2, {
|
237 | "before": false,
|
238 | "after": true
|
239 | }],
|
240 | // 控制逗号在行尾出现还是在行首出现 (默认行尾)
|
241 | // http://eslint.org/docs/rules/comma-style
|
242 | "comma-style": [2, "last"],
|
243 | //"SwitchCase" (默认:0) 强制 switch 语句中的 case 子句的缩进水平
|
244 | // 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always
|
245 | "computed-property-spacing": [2, "never"],
|
246 | // 用于指统一在回调函数中指向this的变量名,箭头函数中的this已经可以指向外层调用者,应该没卵用了
|
247 | // e.g [0,"that"] 指定只能 var that = this. that不能指向其他任何值,this也不能赋值给that以外的其他值
|
248 | "consistent-this": [1, "that"],
|
249 | // 强制使用命名的 function 表达式
|
250 | "func-names": 0,
|
251 | // 文件末尾强制换行
|
252 | "eol-last": 2,
|
253 | "indent": [2, 2, {
|
254 | "SwitchCase": 1
|
255 | }],
|
256 | // 强制在对象字面量的属性中键和值之间使用一致的间距
|
257 | "key-spacing": [2, {
|
258 | "beforeColon": false,
|
259 | "afterColon": true
|
260 | }],
|
261 | // 强制使用一致的换行风格
|
262 | "linebreak-style": [1, "unix"],
|
263 | // 要求在注释周围有空行 ( 要求在块级注释之前有一空行)
|
264 | "lines-around-comment": [1, {
|
265 | "beforeBlockComment": true
|
266 | }],
|
267 | // 强制一致地使用函数声明或函数表达式,方法定义风格,参数:
|
268 | // declaration: 强制使用方法声明的方式,function f(){} e.g [2, "declaration"]
|
269 | // expression:强制使用方法表达式的方式,var f = function() {} e.g [2, "expression"]
|
270 | // allowArrowFunctions: declaration风格中允许箭头函数。 e.g [2, "declaration", { "allowArrowFunctions": true }]
|
271 | "func-style": 0,
|
272 | // 强制回调函数最大嵌套深度 5层
|
273 | "max-nested-callbacks": [1, 5],
|
274 | // 禁止使用指定的标识符
|
275 | "id-blacklist": 0,
|
276 | // 强制标识符的最新和最大长度
|
277 | "id-length": 0,
|
278 | // 要求标识符匹配一个指定的正则表达式
|
279 | "id-match": 0,
|
280 | // 强制在 JSX 属性中一致地使用双引号或单引号
|
281 | "jsx-quotes": 0,
|
282 | // 强制在关键字前后使用一致的空格 (前后腰需要)
|
283 | "keyword-spacing": 2,
|
284 | // 强制一行的最大长度
|
285 | "max-len": [1, 200],
|
286 | // 强制最大行数
|
287 | "max-lines": 0,
|
288 | // 强制 function 定义中最多允许的参数数量
|
289 | "max-params": [1, 7],
|
290 | // 强制 function 块最多允许的的语句数量
|
291 | "max-statements": [1, 200],
|
292 | // 强制每一行中所允许的最大语句数量
|
293 | "max-statements-per-line": 0,
|
294 | // 要求构造函数首字母大写 (要求调用 new 操作符时有首字母大小的函数,允许调用首字母大写的函数时没有 new 操作符。)
|
295 | "new-cap": [2, {
|
296 | "newIsCap": true,
|
297 | "capIsNew": false
|
298 | }],
|
299 | // 要求调用无参构造函数时有圆括号
|
300 | "new-parens": 2,
|
301 | // 要求或禁止 var 声明语句后有一行空行
|
302 | "newline-after-var": 0,
|
303 | // 禁止使用 Array 构造函数
|
304 | "no-array-constructor": 2,
|
305 | // 禁用按位运算符
|
306 | "no-bitwise": 0,
|
307 | // 要求 return 语句之前有一空行
|
308 | "newline-before-return": 0,
|
309 | // 要求方法链中每个调用都有一个换行符
|
310 | "newline-per-chained-call": 1,
|
311 | // 禁用 continue 语句
|
312 | "no-continue": 0,
|
313 | // 禁止在代码行后使用内联注释
|
314 | "no-inline-comments": 0,
|
315 | // 禁止 if 作为唯一的语句出现在 else 语句中
|
316 | "no-lonely-if": 0,
|
317 | // 禁止混合使用不同的操作符
|
318 | "no-mixed-operators": 0,
|
319 | // 不允许空格和 tab 混合缩进
|
320 | "no-mixed-spaces-and-tabs": 2,
|
321 | // 不允许多个空行
|
322 | "no-multiple-empty-lines": [2, {
|
323 | "max": 2
|
324 | }],
|
325 | // 不允许否定的表达式
|
326 | "no-negated-condition": 0,
|
327 | // 不允许使用嵌套的三元表达式
|
328 | "no-nested-ternary": 0,
|
329 | // 禁止使用 Object 的构造函数
|
330 | "no-new-object": 2,
|
331 | // 禁止使用一元操作符 ++ 和 --
|
332 | "no-plusplus": 0,
|
333 | // 禁止使用特定的语法
|
334 | "no-restricted-syntax": 0,
|
335 | // 禁止 function 标识符和括号之间出现空格
|
336 | "no-spaced-func": 2,
|
337 | // 不允许使用三元操作符
|
338 | "no-ternary": 0,
|
339 | // 禁用行尾空格
|
340 | "no-trailing-spaces": 2,
|
341 | // 禁止标识符中有悬空下划线_bar
|
342 | "no-underscore-dangle": 0,
|
343 | // 禁止可以在有更简单的可替代的表达式时使用三元操作符
|
344 | "no-unneeded-ternary": 2,
|
345 | // 禁止属性前有空白
|
346 | "no-whitespace-before-property": 0,
|
347 | // 强制花括号内换行符的一致性
|
348 | "object-curly-newline": 0,
|
349 | // 强制在花括号中使用一致的空格
|
350 | "object-curly-spacing": 0,
|
351 | // 强制将对象的属性放在不同的行上
|
352 | "object-property-newline": 0,
|
353 | // 强制函数中的变量要么一起声明要么分开声明
|
354 | "one-var": [2, {
|
355 | "initialized": "never"
|
356 | }],
|
357 | // 要求或禁止在 var 声明周围换行
|
358 | "one-var-declaration-per-line": 0,
|
359 | // 要求或禁止在可能的情况下要求使用简化的赋值操作符
|
360 | "operator-assignment": 0,
|
361 | // 强制操作符使用一致的换行符
|
362 | "operator-linebreak": [2, "after", {
|
363 | "overrides": {
|
364 | "?": "before",
|
365 | ":": "before"
|
366 | }
|
367 | }],
|
368 | // 要求或禁止块内填充
|
369 | "padded-blocks": 0,
|
370 | // 要求对象字面量属性名称用引号括起来
|
371 | "quote-props": 0,
|
372 | // 强制使用一致的反勾号、双引号或单引号
|
373 | // "quotes": [2, "single", "avoid-escape"],
|
374 | // 要求使用 JSDoc 注释
|
375 | "require-jsdoc": 0,
|
376 | // 要求或禁止使用分号而不是 ASI(这个才是控制行尾部分号的,)
|
377 | "semi": [0, "always"],
|
378 | // 强制分号之前和之后使用一致的空格
|
379 | "semi-spacing": 0,
|
380 | // 要求同一个声明块中的变量按顺序排列
|
381 | "sort-vars": 0,
|
382 | // 强制在块之前使用一致的空格
|
383 | "space-before-blocks": [2, "always"],
|
384 | // 强制在 function的左括号之前使用一致的空格
|
385 | "space-before-function-paren": [0, "always"],
|
386 | // 强制在圆括号内使用一致的空格
|
387 | "space-in-parens": [2, "never"],
|
388 | // 要求操作符周围有空格
|
389 | "space-infix-ops": 2,
|
390 | // 强制在一元操作符前后使用一致的空格
|
391 | "space-unary-ops": [2, {
|
392 | "words": true,
|
393 | "nonwords": false
|
394 | }],
|
395 | // 强制在注释中 // 或 /* 使用一致的空格
|
396 | "spaced-comment": [2, "always", {
|
397 | "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"]
|
398 | }],
|
399 | // 要求或禁止 Unicode BOM
|
400 | "unicode-bom": 0,
|
401 | // 要求正则表达式被括号括起来
|
402 | "wrap-regex": 0,
|
403 |
|
404 | //////////////
|
405 | // ES6.相关 //
|
406 | //////////////
|
407 |
|
408 | // 要求箭头函数体使用大括号
|
409 | "arrow-body-style": 2,
|
410 | // 要求箭头函数的参数使用圆括号
|
411 | "arrow-parens": 0,
|
412 | "arrow-spacing": [2, {
|
413 | "before": true,
|
414 | "after": true
|
415 | }],
|
416 | // 强制在子类构造函数中用super()调用父类构造函数,TypeScrip的编译器也会提示
|
417 | "constructor-super": 0,
|
418 | // 强制 generator 函数中 * 号周围使用一致的空格
|
419 | "generator-star-spacing": [2, {
|
420 | "before": true,
|
421 | "after": true
|
422 | }],
|
423 | // 禁止修改类声明的变量
|
424 | "no-class-assign": 2,
|
425 | // 不允许箭头功能,在那里他们可以混淆的比较
|
426 | "no-confusing-arrow": 0,
|
427 | // 禁止修改 const 声明的变量
|
428 | "no-const-assign": 2,
|
429 | // 禁止类成员中出现重复的名称
|
430 | "no-dupe-class-members": 2,
|
431 | // 不允许复制模块的进口
|
432 | "no-duplicate-imports": 0,
|
433 | // 禁止 Symbol 的构造函数
|
434 | "no-new-symbol": 2,
|
435 | // 允许指定模块加载时的进口
|
436 | "no-restricted-imports": 0,
|
437 | // 禁止在构造函数中,在调用 super() 之前使用 this 或 super
|
438 | "no-this-before-super": 2,
|
439 | // 禁止不必要的计算性能键对象的文字
|
440 | "no-useless-computed-key": 0,
|
441 | // 要求使用 let 或 const 而不是 var
|
442 | "no-var": 0,
|
443 | // 要求或禁止对象字面量中方法和属性使用简写语法
|
444 | "object-shorthand": 0,
|
445 | // 要求使用箭头函数作为回调
|
446 | "prefer-arrow-callback": 0,
|
447 | // 要求使用 const 声明那些声明后不再被修改的变量
|
448 | "prefer-const": 0,
|
449 | // 要求在合适的地方使用 Reflect 方法
|
450 | "prefer-reflect": 0,
|
451 | // 要求使用扩展运算符而非 .apply()
|
452 | "prefer-spread": 0,
|
453 | // 要求使用模板字面量而非字符串连接
|
454 | "prefer-template": 0,
|
455 | // Suggest using the rest parameters instead of arguments
|
456 | "prefer-rest-params": 0,
|
457 | // 要求generator 函数内有 yield
|
458 | "require-yield": 0,
|
459 | // enforce spacing between rest and spread operators and their expressions
|
460 | "rest-spread-spacing": 0,
|
461 | // 强制模块内的 import 排序
|
462 | "sort-imports": 0,
|
463 | // 要求或禁止模板字符串中的嵌入表达式周围空格的使用
|
464 | "template-curly-spacing": 1,
|
465 | // 强制在 yield* 表达式中 * 周围使用空格
|
466 | "yield-star-spacing": 2
|
467 | }
|
468 | }
|
469 | /* eslint-enable */ |
\ | No newline at end of file |