-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
executable file
·1720 lines (1720 loc) · 43.6 KB
/
index.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* AlloyTeam ESLint 规则
* https://alloyteam.github.io/eslint-config-alloy/
*
* 贡献者:
* xcatliu <[email protected]>
* heyli <[email protected]>
* DiamondYuan <[email protected]>
* Dash Chen <[email protected]>
* Swan <[email protected]>
*
* 依赖版本:
* eslint ^5.16.0
* eslint-plugin-react ^7.13.0
* eslint-plugin-vue ^5.2.2
* vue-eslint-parser ^5.0.0
* babel-eslint ^10.0.1
* @typescript-eslint/eslint-plugin ^1.10.2
* @typescript-eslint/parser ^1.10.2
*
* 此文件是由脚本 scripts/build.ts 自动生成
*
* @category 此规则属于哪种分类
* @reason 为什么要开启(关闭)此规则
* @fixable 支持自动修复
*/
module.exports = {
extends: ['./base.js'],
rules: {
/**
* 禁止 for 循环出现方向错误的循环,比如 for (i = 0; i < 10; i--)
* @category Possible Errors
*/
'for-direction': 'error',
/**
* getter 必须有返回值,并且禁止返回空,比如 return;
* @category Possible Errors
*/
'getter-return': [
'error',
{
allowImplicit: false
}
],
/**
* 禁止将 async 函数做为 new Promise 的回调函数
* @category Possible Errors
* @reason 出现这种情况时,一般不需要使用 new Promise 实现异步了
*/
'no-async-promise-executor': 'error',
/**
* 禁止将 await 写在循环里,因为这样就无法同时发送多个异步请求了
* @category Possible Errors
* @reason 要求太严格了,有时需要在循环中写 await
*/
'no-await-in-loop': 'off',
/**
* 禁止与负零进行比较
* @category Possible Errors
*/
'no-compare-neg-zero': 'error',
/**
* 禁止在测试表达式中使用赋值语句,除非这个赋值语句被括号包起来了
* @category Possible Errors
*/
'no-cond-assign': ['error', 'except-parens'],
/**
* 禁止使用 console
* @category Possible Errors
* @reason console 的使用很常见
*/
'no-console': 'off',
/**
* 禁止将常量作为分支条件判断中的测试表达式,但允许作为循环条件判断中的测试表达式
* @category Possible Errors
*/
'no-constant-condition': [
'error',
{
checkLoops: false
}
],
/**
* 禁止在正则表达式中出现 Ctrl 键的 ASCII 表示,即禁止使用 /\x1f/
* @category Possible Errors
* @reason 几乎不会遇到这种场景
*/
'no-control-regex': 'off',
/**
* 禁止使用 debugger
* @category Possible Errors
*/
'no-debugger': 'error',
/**
* 禁止在函数参数中出现重复名称的参数
* @category Possible Errors
* @reason 使用 babel 时,在编译阶段就会报错了
*/
'no-dupe-args': 'off',
/**
* 禁止在对象字面量中出现重复名称的键名
* @category Possible Errors
*/
'no-dupe-keys': 'error',
/**
* 禁止在 switch 语句中出现重复测试表达式的 case
* @category Possible Errors
*/
'no-duplicate-case': 'error',
/**
* 禁止出现空代码块,允许 catch 为空代码块
* @category Possible Errors
*/
'no-empty': [
'error',
{
allowEmptyCatch: true
}
],
/**
* 禁止在正则表达式中使用空的字符集 []
* @category Possible Errors
*/
'no-empty-character-class': 'error',
/**
* 禁止将 catch 的第一个参数 error 重新赋值
* @category Possible Errors
*/
'no-ex-assign': 'error',
/**
* 禁止不必要的布尔类型转换,比如 !! 或 Boolean
* @category Possible Errors
* @fixable
*/
'no-extra-boolean-cast': 'error',
/**
* 禁止函数表达式中出现多余的括号
* @category Possible Errors
* @fixable
*/
'no-extra-parens': ['error', 'functions'],
/**
* 禁止出现多余的分号
* @category Possible Errors
* @fixable
*/
'no-extra-semi': 'error',
/**
* 禁止将一个函数声明重新赋值,如:
* @category Possible Errors
*/
'no-func-assign': 'error',
/**
* 禁止在 if 代码块内出现函数声明
* @category Possible Errors
*/
'no-inner-declarations': ['error', 'both'],
/**
* 禁止在 RegExp 构造函数中出现非法的正则表达式
* @category Possible Errors
*/
'no-invalid-regexp': 'error',
/**
* 禁止使用特殊空白符(比如全角空格),除非是出现在字符串、正则表达式或模版字符串中
* @category Possible Errors
*/
'no-irregular-whitespace': [
'error',
{
skipStrings: true,
skipComments: false,
skipRegExps: true,
skipTemplates: true
}
],
/**
* 禁止正则表达式中使用肉眼无法区分的特殊字符
* @category Possible Errors
* @reason 某些特殊字符很难看出差异,最好不要在正则中使用
*/
'no-misleading-character-class': 'error',
/**
* 禁止将 Math, JSON 或 Reflect 直接作为函数调用
* @category Possible Errors
*/
'no-obj-calls': 'error',
/**
* 禁止使用 hasOwnProperty, isPrototypeOf 或 propertyIsEnumerable
* @category Possible Errors
* @reason hasOwnProperty 比较常用
*/
'no-prototype-builtins': 'off',
/**
* 禁止在正则表达式中出现连续的空格,必须使用 /foo {3}bar/ 代替
* @category Possible Errors
* @fixable
*/
'no-regex-spaces': 'error',
/**
* 禁止在数组中出现连续的逗号,如 let foo = [,,]
* @category Possible Errors
*/
'no-sparse-arrays': 'error',
/**
* 禁止在普通字符串中出现模版字符串里的变量形式,如 'Hello ${name}!'
* @category Possible Errors
*/
'no-template-curly-in-string': 'error',
/**
* 禁止出现难以理解的多行表达式
* @category Possible Errors
*/
'no-unexpected-multiline': 'error',
/**
* 禁止在 return, throw, break 或 continue 之后还有代码
* @category Possible Errors
*/
'no-unreachable': 'error',
/**
* 禁止在 finally 中出现 return, throw, break 或 continue
* @category Possible Errors
*/
'no-unsafe-finally': 'error',
/**
* 禁止在 in 或 instanceof 操作符的左侧使用感叹号,如 if (!key in object)
* @category Possible Errors
* @fixable
*/
'no-unsafe-negation': 'error',
/**
* 禁止将 await 或 yield 的结果做为运算符的后面项
* @category Possible Errors
* @reason 这样会导致不符合预期的结果
*/
'require-atomic-updates': 'error',
/**
* 必须使用 isNaN(foo) 而不是 foo === NaN
* @category Possible Errors
*/
'use-isnan': 'error',
/**
* typeof 表达式比较的对象必须是 'undefined', 'object', 'boolean', 'number', 'string', 'function' 或 'symbol'
* @category Possible Errors
*/
'valid-typeof': 'error',
/**
* setter 必须有对应的 getter,getter 可以没有对应的 setter
* @category Best Practices
*/
'accessor-pairs': [
'error',
{
setWithoutGet: true,
getWithoutSet: false
}
],
/**
* 数组的方法除了 forEach 之外,回调函数必须有返回值
* @category Best Practices
*/
'array-callback-return': 'error',
/**
* 将 var 定义的变量视为块作用域,禁止在块外使用
* @category Best Practices
*/
'block-scoped-var': 'error',
/**
* 在类的非静态方法中,必须存在对 this 的引用
* @category Best Practices
* @reason 太严格了
*/
'class-methods-use-this': 'off',
/**
* 禁止函数的循环复杂度超过 20,https://en.wikipedia.org/wiki/Cyclomatic_complexity
* @category Best Practices
*/
complexity: [
'error',
{
max: 50
}
],
/**
* 禁止函数在不同分支返回不同类型的值
* @category Best Practices
* @reason 太严格了
*/
'consistent-return': 'off',
/**
* if 后面必须要有 {,除非是单行 if
* @category Best Practices
* @fixable
*/
curly: ['error', 'multi-line', 'consistent'],
/**
* switch 语句必须有 default
* @category Best Practices
* @reason 太严格了
*/
'default-case': 'off',
/**
* 链式调用的时候,点号必须放在第二行开头处,禁止放在第一行结尾处
* @category Best Practices
* @fixable
*/
'dot-location': ['error', 'property'],
/**
* 禁止出现 foo['bar'],必须写成 foo.bar
* @category Best Practices
* @reason 当需要写一系列属性的时候,可以更统一
* @fixable
*/
'dot-notation': 'off',
/**
* 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
* @category Best Practices
* @fixable
*/
eqeqeq: [
'error',
'always',
{
null: 'ignore'
}
],
/**
* for in 内部必须有 hasOwnProperty
* @category Best Practices
*/
'guard-for-in': 'error',
/**
* 限制一个文件中类的数量
* @category Best Practices
*/
'max-classes-per-file': 'off',
/**
* 禁止使用 alert
* @category Best Practices
* @reason alert 很常用
*/
'no-alert': 'off',
/**
* 禁止使用 caller 或 callee
* @category Best Practices
*/
'no-caller': 'error',
/**
* switch 的 case 内有变量定义的时候,必须使用大括号将 case 内变成一个代码块
* @category Best Practices
*/
'no-case-declarations': 'error',
/**
* 禁止在正则表达式中出现形似除法操作符的开头,如 let a = /=foo/
* @category Best Practices
* @reason 有代码高亮的话,在阅读这种代码时,也完全不会产生歧义或理解上的困难
*/
'no-div-regex': 'off',
/**
* 禁止在 else 内使用 return,必须改为提前结束
* @category Best Practices
* @reason else 中使用 return 可以使代码结构更清晰
* @fixable
*/
'no-else-return': 'off',
/**
* 不允许有空函数,除非是将一个空函数设置为某个项的默认值
* @category Best Practices
*/
'no-empty-function': [
'error',
{
allow: ['functions', 'arrowFunctions']
}
],
/**
* 禁止解构中出现空 {} 或 []
* @category Best Practices
*/
'no-empty-pattern': 'error',
/**
* 禁止使用 foo == null,必须使用 foo === null
* @category Best Practices
* @reason foo == null 比较常用,可以用于判断 foo 不是 undefined 并且不是 null,故允许此写法
*/
'no-eq-null': 'off',
/**
* 禁止使用 eval
* @category Best Practices
*/
'no-eval': 'error',
/**
* 禁止修改原生对象
* @category Best Practices
*/
'no-extend-native': 'error',
/**
* 禁止出现没必要的 bind
* @category Best Practices
* @fixable
*/
'no-extra-bind': 'error',
/**
* 禁止出现没必要的 label
* @category Best Practices
* @fixable
*/
'no-extra-label': 'error',
/**
* switch 的 case 内必须有 break, return 或 throw
* @category Best Practices
*/
'no-fallthrough': 'error',
/**
* 表示小数时,禁止省略 0,比如 .5
* @category Best Practices
* @fixable
*/
'no-floating-decimal': 'error',
/**
* 禁止对全局变量赋值
* @category Best Practices
*/
'no-global-assign': 'error',
/**
* 禁止使用 !! ~ 等难以理解的运算符,仅允许使用 !!
* @category Best Practices
* @fixable
*/
'no-implicit-coercion': [
'off'
// 'error',
// {
// allow: ['!!']
// }
],
/**
* 禁止在全局作用域下定义变量或申明函数
* @category Best Practices
*/
'no-implicit-globals': 'error',
/**
* 禁止在 setTimeout 或 setInterval 中传入字符串,如 setTimeout('alert("Hi!")', 100);
* @category Best Practices
*/
'no-implied-eval': 'error',
/**
* 禁止在类之外的地方使用 this
* @category Best Practices
* @reason this 的使用很灵活,事件回调中可以表示当前元素,函数也可以先用 this,等以后被调用的时候再 call
*/
'no-invalid-this': 'off',
/**
* 禁止使用 __iterator__
* @category Best Practices
*/
'no-iterator': 'error',
/**
* 禁止使用 label
* @category Best Practices
*/
'no-labels': 'error',
/**
* 禁止使用没必要的 {} 作为代码块
* @category Best Practices
*/
'no-lone-blocks': 'error',
/**
* 禁止在循环内的函数中出现循环体条件语句中定义的变量
* @category Best Practices
*/
'no-loop-func': 'error',
/**
* 禁止使用 magic numbers
* @category Best Practices
*/
'no-magic-numbers': 'off',
/**
* 禁止出现连续的多个空格,除非是注释前,或对齐对象的属性、变量定义、import 等
* @category Best Practices
* @fixable
*/
'no-multi-spaces': [
'error',
{
ignoreEOLComments: true,
exceptions: {
Property: true,
BinaryExpression: false,
VariableDeclarator: true,
ImportDeclaration: true
}
}
],
/**
* 禁止使用 \ 来换行字符串
* @category Best Practices
*/
'no-multi-str': 'error',
/**
* 禁止直接 new 一个类而不赋值
* @category Best Practices
*/
'no-new': 'off',
/**
* 禁止使用 new Function,比如 let x = new Function("a", "b", "return a + b");
* @category Best Practices
*/
'no-new-func': 'error',
/**
* 禁止使用 new 来生成 String, Number 或 Boolean
* @category Best Practices
*/
'no-new-wrappers': 'error',
/**
* 禁止使用 0 开头的数字表示八进制数
* @category Best Practices
*/
'no-octal': 'error',
/**
* 禁止使用八进制的转义符
* @category Best Practices
*/
'no-octal-escape': 'error',
/**
* 禁止对函数的参数重新赋值
* @category Best Practices
*/
'no-param-reassign': 'error',
/**
* 禁止使用 __proto__
* @category Best Practices
*/
'no-proto': 'error',
/**
* 禁止重复定义变量
* @category Best Practices
*/
'no-redeclare': 'error',
/**
* 禁止使用指定的对象属性
* @category Best Practices
* @reason 它用于限制某个具体的 api 不能使用
*/
'no-restricted-properties': 'off',
/**
* 禁止在 return 语句里赋值
* @category Best Practices
*/
'no-return-assign': ['error', 'always'],
/**
* 禁止在 return 语句里使用 await
* @category Best Practices
*/
'no-return-await': 'error',
/**
* 禁止出现 location.href = 'javascript:void(0)';
* @category Best Practices
*/
'no-script-url': 'error',
/**
* 禁止将自己赋值给自己
* @category Best Practices
*/
'no-self-assign': 'error',
/**
* 禁止将自己与自己比较
* @category Best Practices
*/
'no-self-compare': 'error',
/**
* 禁止使用逗号操作符
* @category Best Practices
*/
'no-sequences': 'error',
/**
* 禁止 throw 字面量,必须 throw 一个 Error 对象
* @category Best Practices
*/
'no-throw-literal': 'error',
/**
* 循环内必须对循环条件的变量有修改
* @category Best Practices
*/
'no-unmodified-loop-condition': 'error',
/**
* 禁止无用的表达式
* @category Best Practices
*/
'no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true
}
],
/**
* 禁止出现没用的 label
* @category Best Practices
* @fixable
*/
'no-unused-labels': 'error',
/**
* 禁止出现没必要的 call 或 apply
* @category Best Practices
*/
'no-useless-call': 'error',
/**
* 禁止在 catch 中仅仅只是把错误 throw 出去
* @category Best Practices
* @reason 这样的 catch 是没有意义的,等价于直接执行 try 里的代码
*/
'no-useless-catch': 'error',
/**
* 禁止出现没必要的字符串连接
* @category Best Practices
*/
'no-useless-concat': 'error',
/**
* 禁止出现没必要的转义
* @category Best Practices
* @reason 转义可以使代码更易懂
*/
'no-useless-escape': 'off',
/**
* 禁止没必要的 return
* @category Best Practices
* @reason 没必要限制 return
* @fixable
*/
'no-useless-return': 'off',
/**
* 禁止使用 void
* @category Best Practices
*/
'no-void': 'error',
/**
* 禁止注释中出现 TODO 和 FIXME
* @category Best Practices
* @reason TODO 很常用
*/
'no-warning-comments': 'off',
/**
* 禁止使用 with
* @category Best Practices
*/
'no-with': 'error',
/**
* 使用 ES2018 中的正则表达式命名组
* @category Best Practices
* @reason 正则表达式已经较难理解了,没必要强制加上命名组
*/
'prefer-named-capture-group': 'off',
/**
* Promise 的 reject 中必须传入 Error 对象,而不是字面量
* @category Best Practices
*/
'prefer-promise-reject-errors': 'error',
/**
* parseInt 必须传入第二个参数
* @category Best Practices
*/
radix: 'error',
/**
* async 函数中必须存在 await 语句
* @category Best Practices
* @reason async function 中没有 await 的写法很常见,比如 koa 的示例中就有这种用法
*/
'require-await': 'off',
/**
* 正则表达式中必须要加上 u 标志
* @category Best Practices
*/
'require-unicode-regexp': 'off',
/**
* var 必须在作用域的最前面
* @category Best Practices
* @reason var 不在最前面也是很常见的用法
*/
'vars-on-top': 'off',
/**
* 立即执行的函数必须符合如下格式 (function () { alert('Hello') })()
* @category Best Practices
* @fixable
*/
'wrap-iife': [
'error',
'inside',
{
functionPrototypeMethods: true
}
],
/**
* 必须使用 if (foo === 5) 而不是 if (5 === foo)
* @category Best Practices
* @fixable
*/
yoda: [
'error',
'never',
{
onlyEquality: true
}
],
/**
* 禁止使用 'strict';
* @category Strict Mode
* @fixable
*/
strict: ['error', 'never'],
/**
* 变量必须在定义的时候赋值
* @category Variables
* @reason 先定义后赋值很常见
*/
'init-declarations': 'off',
/**
* 禁止使用 delete
* @category Variables
*/
'no-delete-var': 'error',
/**
* 禁止 label 名称与定义过的变量重复
* @category Variables
*/
'no-label-var': 'error',
/**
* 禁止使用指定的全局变量
* @category Variables
* @reason 它用于限制某个具体的变量名不能使用
*/
'no-restricted-globals': 'off',
/**
* 禁止变量名与上层作用域内的定义过的变量重复
* @category Variables
* @reason 很多时候函数的形参和传参是同名的
*/
'no-shadow': 'off',
/**
* 禁止使用保留字作为变量名
* @category Variables
*/
'no-shadow-restricted-names': 'error',
/**
* 禁止使用未定义的变量
* @category Variables
*/
'no-undef': [
'error',
{
typeof: false
}
],
/**
* 禁止将 undefined 赋值给变量
* @category Variables
* @fixable
*/
'no-undef-init': 'error',
/**
* 禁止使用 undefined
* @category Variables
*/
'no-undefined': 'off',
/**
* 定义过的变量必须使用
* @category Variables
*/
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'none',
caughtErrors: 'none',
ignoreRestSiblings: true
}
],
/**
* 变量必须先定义后使用
* @category Variables
*/
'no-use-before-define': [
'error',
{
functions: false,
classes: false,
variables: false
}
],
/**
* callback 之后必须立即 return
* @category Node.js and CommonJS
* @reason Limitations 太多了
*/
'callback-return': 'off',
/**
* require 必须在全局作用域下
* @category Node.js and CommonJS
* @reason 条件加载很常见
*/
'global-require': 'off',
/**
* callback 中的 error 必须被处理
* @category Node.js and CommonJS
*/
'handle-callback-err': 'error',
/**
* 禁止直接使用 Buffer
* @category Node.js and CommonJS
*/
'no-buffer-constructor': 'error',
/**
* 相同类型的 require 必须放在一起
* @category Node.js and CommonJS
* @reason 太严格了
*/
'no-mixed-requires': 'off',
/**
* 禁止直接 new require('foo')
* @category Node.js and CommonJS
*/
'no-new-require': 'error',
/**
* 禁止对 __dirname 或 __filename 使用字符串连接
* @category Node.js and CommonJS
*/
'no-path-concat': 'error',
/**
* 禁止使用 process.env.NODE_ENV
* @category Node.js and CommonJS
* @reason 使用很常见
*/
'no-process-env': 'off',
/**
* 禁止使用 process.exit(0)
* @category Node.js and CommonJS
* @reason 使用很常见
*/
'no-process-exit': 'off',
/**
* 禁止使用指定的模块
* @category Node.js and CommonJS
* @reason 它用于限制某个具体的模块不能使用
*/
'no-restricted-modules': 'off',
/**
* 禁止使用 node 中的同步的方法,比如 fs.readFileSync
* @category Node.js and CommonJS
* @reason 使用很常见
*/
'no-sync': 'off',
/**
* 配置数组的中括号内前后的换行格式
* @category Stylistic Issues
* @reason 配置项无法配制成想要的样子
* @fixable
*/
'array-bracket-newline': 'off',
/**
* 数组的括号内的前后禁止有空格
* @category Stylistic Issues
* @fixable
*/
'array-bracket-spacing': ['error', 'never'],
/**
* 配置数组的元素之间的换行格式
* @category Stylistic Issues
* @reason 允许一行包含多个元素,方便大数量的数组的书写
* @fixable
*/
'array-element-newline': 'off',
/**
* 代码块如果在一行内,那么大括号内的首尾必须有空格
* @category Stylistic Issues
* @fixable
*/
'block-spacing': ['error', 'always'],
/**
* if 与 else 的大括号风格必须一致
* @category Stylistic Issues
* @reason else 代码块可能前面需要有一行注释
* @fixable
*/
'brace-style': 'off',
/**
* 变量名必须是 camelcase 风格的
* @category Stylistic Issues
* @reason 很多 api 或文件名都不是 camelcase
*/
camelcase: 'off',
/**
* 注释的首字母必须大写
* @category Stylistic Issues
* @reason 没必要限制
* @fixable
*/
'capitalized-comments': 'off',
/**
* 对象的最后一个属性末尾必须有逗号
* @category Stylistic Issues
* @fixable
*/
'comma-dangle': 'off',
/**
* 逗号前禁止有空格,逗号后必须要有空格
* @category Stylistic Issues
* @fixable
*/
'comma-spacing': [
'error',
{
before: false,
after: true
}
],
/**
* 禁止在行首写逗号
* @category Stylistic Issues
* @fixable
*/
'comma-style': ['error', 'last'],
/**
* 用作对象的计算属性时,中括号内的首尾禁止有空格
* @category Stylistic Issues
* @fixable
*/
'computed-property-spacing': ['error', 'never'],
/**
* 限制 this 的别名
* @category Stylistic Issues
* @reason 没必要限制
*/
'consistent-this': 'off',
/**
* 文件最后一行必须有一个空行
* @category Stylistic Issues
* @reason 没必要限制
* @fixable
*/
'eol-last': 'off',
/**
* 函数名和执行它的括号之间禁止有空格
* @category Stylistic Issues
* @fixable
*/
'func-call-spacing': ['error', 'never'],
/**
* 函数赋值给变量的时候,函数名必须与变量名一致
* @category Stylistic Issues
*/
'func-name-matching': [
'error',
'always',
{
includeCommonJSModuleExports: false
}
],
/**
* 函数必须有名字
* @category Stylistic Issues
* @reason 没必要限制
*/
'func-names': 'off',
/**
* 必须只使用函数声明或只使用函数表达式
* @category Stylistic Issues
* @reason 没必要限制
*/
'func-style': 'off',
/**
* 函数参数要么同在一行要么每行一个
* @category Stylistic Issues
* @fixable
*/
'function-paren-newline': ['error', 'multiline'],
/**
* 禁止使用指定的标识符
* @category Stylistic Issues
* @reason 它用于限制某个具体的标识符不能使用
*/
'id-blacklist': 'off',
/**
* 限制变量名长度
* @category Stylistic Issues
* @reason 没必要限制变量名长度
*/
'id-length': 'off',
/**
* 限制变量名必须匹配指定的正则表达式
* @category Stylistic Issues
* @reason 没必要限制变量名
*/
'id-match': 'off',
/**
* 箭头函数的函数体必须与箭头在同一行,或者被括号包裹
* @category Stylistic Issues
* @autofix
*/
'implicit-arrow-linebreak': ['error', 'beside'],
/**