-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
898 lines (889 loc) · 37.8 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
import jsdocPlugin from 'eslint-plugin-jsdoc';
export default [
{
plugins: {jsdoc: jsdocPlugin},
rules: {
/**
* Possible Errors
*/
// ケツカンマスタイル
// http://eslint.org/docs/rules/comma-dangle
'comma-dangle': 2,
// for文の比較と更新方向の相違を指摘
// https://eslint.org/docs/rules/for-direction
'for-direction': 2,
// returnしないコードパスを持つGetterを指摘
// https://eslint.org/docs/rules/getter-return
'getter-return': 2,
// ループ内でのawait禁止
// https://eslint.org/docs/rules/no-await-in-loop
'no-await-in-loop': 2,
// マイナスゼロとの比較禁止
// https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 2,
// 評価文内の変数代入禁止
// http://eslint.org/docs/rules/no-cond-assign
'no-cond-assign': 2,
// console 禁止
// http://eslint.org/docs/rules/no-console
'no-console': 1,
// 条件としての定数使用禁止
// http://eslint.org/docs/rules/no-constant-condition
'no-constant-condition': [2, {checkLoops: false}], // 無限ループ用は許容
// 正規表現内の不可視範囲 ASCII コントロール文字使用禁止
// http://eslint.org/docs/rules/no-control-regex
'no-control-regex': 2,
// debugger 禁止
// http://eslint.org/docs/rules/no-debugger
'no-debugger': 2,
// 引数名重複禁止
// http://eslint.org/docs/rules/no-dupe-args
'no-dupe-args': 2,
// キー名重複禁止
// http://eslint.org/docs/rules/no-dupe-keys
'no-dupe-keys': 2,
// case 重複禁止
// http://eslint.org/docs/rules/no-duplicate-case
'no-duplicate-case': 2,
// 空の文字クラス (正規表現内の []) 禁止
// http://eslint.org/docs/rules/no-empty-character-class
'no-empty-character-class': 2,
// 空ブロック禁止
// http://eslint.org/docs/rules/no-empty
'no-empty': 2,
// 例外引数への再代入禁止
// http://eslint.org/docs/rules/no-ex-assign
'no-ex-assign': 2,
// 条件評価用途での余分な !! キャスト禁止
// http://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 2,
// 余分な括弧を禁止
// http://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': [2, 'functions'],
// 余分なセミコロン禁止
// http://eslint.org/docs/rules/no-extra-semi
'no-extra-semi': 2,
// 関数への再代入禁止
// http://eslint.org/docs/rules/no-func-assign
'no-func-assign': 2,
// top-level 以外の関数定義禁止 (ES2015 or later)
// http://eslint.org/docs/rules/no-inner-declarations
'no-inner-declarations': 2,
// 不正な正規表現を禁止
// http://eslint.org/docs/rules/no-invalid-regexp
'no-invalid-regexp': 2,
// イレギュラーな空白禁止
// http://eslint.org/docs/rules/no-irregular-whitespace
'no-irregular-whitespace': [2, {skipRegExps: true, skipStrings: true}], // 正規表現とテンプレートリテラル内は許容する
// 意図しないNOT演算子を禁止
// http://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 2,
// Math, JSON の関数呼び出し禁止
// http://eslint.org/docs/rules/no-obj-calls
'no-obj-calls': 2,
// Object.prototypeのメソッド利用禁止
// http://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 2,
// 正規表現内の連続空白禁止
// http://eslint.org/docs/rules/no-regex-spaces
'no-regex-spaces': 2,
// 要素のないカンマのみの配列禁止
// http://eslint.org/docs/rules/no-sparse-arrays
'no-sparse-arrays': 2,
// 文字列中のテンプレートリテラル埋め込み式を禁止
// http://eslint.org/docs/rules/no-template-curly-in-string
'no-template-curly-in-string': 2,
// 不正な複数行記述の禁止 (semi が off の場合のみ有効)
// http://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 0,
// 到達不能コード禁止
// http://eslint.org/docs/rules/no-unreachable
'no-unreachable': 2,
// finally内でのreturn, throw, break, continueを禁止
// http://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 2,
// isNaN() の使用強制
// http://eslint.org/docs/rules/use-isnan
'use-isnan': 2,
// 不正な type 文字列を禁止
// http://eslint.org/docs/rules/valid-typeof
'valid-typeof': 2,
/**
* Best Practices
*/
// getter / setter の組み合わせを強制
// http://eslint.org/docs/rules/accessor-pairs
'accessor-pairs': 0,
// Array系メソッドのコールバック関数で適切にreturnを使用することを強制
// http://eslint.org/docs/rules/array-callback-return
'array-callback-return': 2,
// C-style なブロック scope var を強制
// http://eslint.org/docs/rules/block-scoped-var
'block-scoped-var': 0,
// thisを参照していないメソッドを警告
// http://eslint.org/docs/rules/class-methods-use-this
'class-methods-use-this': 2,
// 複雑度
// http://eslint.org/docs/rules/complexity
complexity: [1, 8], // テスタブル JavaScript には 10 以下が適切とある
// 一貫性のある return 必須化
// http://eslint.org/docs/rules/consistent-return
'consistent-return': [2, {treatUndefinedAsUnspecified: true}], // undefinedを返す場合は省略可能
// ブロック用途の中括弧スタイル
// http://eslint.org/docs/rules/curly
curly: [2, 'all'],
// switch 文の default を強制
// http://eslint.org/docs/rules/default-case
'default-case': 2,
// 改行時のドットの位置を強制
// http://eslint.org/docs/rules/dot-location
'dot-location': [2, 'property'], // プロパティと同じ行
// プロパティアクセス用途のドット表記スタイル
// http://eslint.org/docs/rules/dot-notation
'dot-notation': [2, {allowKeywords: true}],
// ===, !== 必須化
// http://eslint.org/docs/rules/eqeqeq
eqeqeq: 2,
// for-in ループで prototype チェーンのキーの使用防止
// http://eslint.org/docs/rules/guard-for-in
'guard-for-in': 0,
// alert 禁止
// http://eslint.org/docs/rules/no-alert
'no-alert': 2,
// case/default 文内での変数宣言にブロック構文を強制
// http://eslint.org/docs/rules/no-case-declarations
'no-case-declarations': 2,
// caller, callee 禁止
// http://eslint.org/docs/rules/no-caller
'no-caller': 2,
// 正規表現内の /= な表現禁止
// http://eslint.org/docs/rules/no-div-regex
'no-div-regex': 2,
// else 内 return 禁止
// http://eslint.org/docs/rules/no-else-return
'no-else-return': 2,
// コメントのない空関数禁止
// http://eslint.org/docs/rules/no-empty-function
'no-empty-function': 2,
// 変数が空になるような destructuring pattern を禁止
// http://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 2,
// null と == / != な比較演算子使用禁止
// http://eslint.org/docs/rules/no-eq-null
'no-eq-null': 2,
// eval 禁止
// http://eslint.org/docs/rules/no-eval
'no-eval': 2,
// native オブジェクト拡張禁止
// http://eslint.org/docs/rules/no-extend-native
'no-extend-native': 2,
// 不要な bind 禁止
// http://eslint.org/docs/rules/no-extra-bind
'no-extra-bind': 2,
// 不要なラベルの禁止
// http://eslint.org/docs/rules/no-extra-label
'no-extra-label': 2,
// case 文の意図しない fallthrough を禁止
// http://eslint.org/docs/rules/no-fallthrough
'no-fallthrough': 2,
// 読み取り専用グローバル変数への代入禁止
// http://eslint.org/docs/rules/no-global-assign
'no-global-assign': 2,
// 数字なしの小数点禁止
// http://eslint.org/docs/rules/no-floating-decimal
'no-floating-decimal': 2,
// 省略型キャスト表記禁止
// http://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': [
2,
{
allow: ['!!'],
'boolean': true,
number: true,
string: true
}
],
// 暗黙の eval 禁止
// http://eslint.org/docs/rules/no-implied-eval
'no-implied-eval': 2,
// グルーバルスコープへのvar, named functionの禁止
// http://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 2,
// 不正な this 禁止
// http://eslint.org/docs/rules/no-invalid-this
'no-invalid-this': 2,
// __iterator__ 禁止
// http://eslint.org/docs/rules/no-iterator
'no-iterator': 2,
// label 禁止
// http://eslint.org/docs/rules/no-labels
'no-labels': 2,
// 不要なブロック禁止
// http://eslint.org/docs/rules/no-lone-blocks
'no-lone-blocks': 2,
// ループ内関数禁止
// http://eslint.org/docs/rules/no-loop-func
'no-loop-func': 2,
// マジックナンバー禁止
// http://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': [
2,
{
enforceConst: true, // const に縛りたい
ignore: [-2, -1, 0, 1, 2],
ignoreArrayIndexes: true // 配列の添字は許可
}
],
// 複数空白禁止
// http://eslint.org/docs/rules/no-multi-spaces
'no-multi-spaces': 2,
// 複数行文字列禁止
// http://eslint.org/docs/rules/no-multi-str
'no-multi-str': 2,
// 変数代入しない new 禁止
// http://eslint.org/docs/rules/no-new
'no-new': 2,
// Function コンストラクタ禁止
// http://eslint.org/docs/rules/no-new-func
'no-new-func': 2,
// String, Number, Boolean のプリミティブ値での new 禁止
// http://eslint.org/docs/rules/no-new-wrappers
'no-new-wrappers': 2,
// 8 進数リテラル禁止
// http://eslint.org/docs/rules/no-octal
'no-octal': 2,
// 8 進数エスケープ禁止
// http://eslint.org/docs/rules/no-octal-escape
'no-octal-escape': 2,
// 引数への再代入禁止
// http://eslint.org/docs/rules/no-param-reassign
'no-param-reassign': [2, {props: true}],
// process.env 禁止
// http://eslint.org/docs/rules/no-process-env
'no-process-env': 0,
// __proto__ 禁止
// http://eslint.org/docs/rules/no-proto
'no-proto': 2,
// 変数の再定義禁止
// http://eslint.org/docs/rules/no-redeclare
'no-redeclare': [2, {builtinGlobals: true}],
// 指定名称のプロパティアクセスを禁止
// http://eslint.org/docs/rules/no-restricted-properties
'no-restricted-properties': 0,
// return 文での変数代入禁止
// http://eslint.org/docs/rules/no-return-assign
'no-return-assign': 2,
// 不要なawait文の禁止
// http://eslint.org/docs/rules/no-return-await
'no-return-await': 2,
// URL 用途の javascript: 禁止
// http://eslint.org/docs/rules/no-script-url
'no-script-url': 2,
// 自己代入(同名変数への再代入)を禁止
// http://eslint.org/docs/rules/no-self-assign
'no-self-assign': [2, {props: true}], // プロパティについても禁止
// 同変数比較禁止 (x === x)
// http://eslint.org/docs/rules/no-self-compare
'no-self-compare': 2,
// 演算子用途のカンマ禁止
// http://eslint.org/docs/rules/no-sequences
'no-sequences': 2,
// リテラル例外禁止
// http://eslint.org/docs/rules/no-throw-literal
'no-throw-literal': 2,
// whileやforの条件式に変更されない変数の指定禁止
// http://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 2,
// 未使用の式禁止
// http://eslint.org/docs/rules/no-unused-expressions
'no-unused-expressions': 2,
// 未使用ラベルの禁止
// http://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 2,
// 不要な .call() / .apply() の禁止
// http://eslint.org/docs/rules/no-useless-call
'no-useless-call': 2,
// 不要な文字列連結の禁止
// http://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 2,
// 不要なエスケープの禁止
// http://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 2,
// 不要なreturn文の禁止
// http://eslint.org/docs/rules/no-useless-return
'no-useless-return': 2,
// void 禁止
// http://eslint.org/docs/rules/no-void
'no-void': 2,
// TODO / FIXME などのコメント禁止
// http://eslint.org/docs/rules/no-warning-comments
'no-warning-comments': 0,
// with 禁止
// http://eslint.org/docs/rules/no-with
'no-with': 2,
// Promiseのreject時にErrorの使用推奨
// https://eslint.org/docs/rules/prefer-promise-reject-errors
'prefer-promise-reject-errors': 2,
// parseInt() の基数パラメータ必須化
// http://eslint.org/docs/rules/radix
radix: 2,
// awaitのないasync関数禁止
// https://eslint.org/docs/rules/require-await
'require-await': 2,
// var をスコープ最上部に強制
// http://eslint.org/docs/rules/vars-on-top
'vars-on-top': 0,
// 即時関数の括弧のスタイル
// http://eslint.org/docs/rules/wrap-iife
'wrap-iife': [2, 'inside', {functionPrototypeMethods: true}],
// 評価式内のリテラルと変数の記述順スタイル
// http://eslint.org/docs/rules/yoda
yoda: [2, 'never'],
/**
* Strict Mode
*/
// Strict Mode のスタイル
// http://eslint.org/docs/rules/strict
strict: [2, 'global'],
/**
* Variables
*/
// 変数定義のスタイル
// http://eslint.org/docs/rules/init-declarations
'init-declarations': 2,
// catch 句のパラメータに同名変数使用禁止
// http://eslint.org/docs/rules/no-catch-shadow
'no-catch-shadow': 2,
// オブジェクトプロパティ以外への delete 禁止
// http://eslint.org/docs/rules/no-delete-var
'no-delete-var': 2,
// 既存変数の label 使用禁止
// http://eslint.org/docs/rules/no-label-var
'no-label-var': 2,
// 指定グローバル変数の使用禁止
// http://eslint.org/docs/rules/no-restricted-globals
'no-restricted-globals': 0, // いったん指定するものなし
// scope 内の同名変数定義禁止
// http://eslint.org/docs/rules/no-shadow
'no-shadow': 2,
// 予約語の使用禁止
// http://eslint.org/docs/rules/no-shadow-restricted-names
'no-shadow-restricted-names': 2,
// 未定義変数禁止
// http://eslint.org/docs/rules/no-undef
'no-undef': 2,
// 不要な undefined 初期化禁止
// http://eslint.org/docs/rules/no-undef-init
'no-undef-init': 2,
// undefined 禁止
// http://eslint.org/docs/rules/no-undefined
'no-undefined': 0,
// 未使用変数禁止
// http://eslint.org/docs/rules/no-unused-vars
'no-unused-vars': 2,
// 定義前変数の使用禁止
// http://eslint.org/docs/rules/no-use-before-define
'no-use-before-define': [2, 'nofunc'], // 関数の場合は hoisting 有効
/**
* Node.js
*/
// callback の return 強制
// http://eslint.org/docs/rules/callback-return
'callback-return': 2,
// top-level 以外での require を禁止
// http://eslint.org/docs/rules/global-require
'global-require': 2,
// callback のエラーハンドリング強制
// http://eslint.org/docs/rules/handle-callback-err
'handle-callback-err': 2,
// 非推奨のBufferコンストラク使用禁止
// https://eslint.org/docs/rules/no-buffer-constructor
'no-buffer-constructor': 2,
// require 内のモジュール形式 / 通常変数の混在禁止
// http://eslint.org/docs/rules/no-mixed-requires
'no-mixed-requires': [2, {grouping: true}],
// new require の禁止
// http://eslint.org/docs/rules/no-new-require
'no-new-require': 2,
// __dirname / __filename の直接連結禁止
// http://eslint.org/docs/rules/no-path-concat
'no-path-concat': 2,
// process.exit 禁止
// http://eslint.org/docs/rules/no-process-exit
'no-process-exit': 2,
// 制限モジュールの使用禁止 (module構文)
// http://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': 0,
// 制限モジュールの使用禁止 (require関数)
// http://eslint.org/docs/rules/no-restricted-modules
'no-restricted-modules': 0,
// 同期メソッド禁止
// http://eslint.org/docs/rules/no-sync
'no-sync': 0,
/**
* Stylistic Issues
*/
// 配列括弧の改行スタイル
// https://eslint.org/docs/rules/array-bracket-newline
'array-bracket-newline': [2, 'consistent'],
// 配列括弧の空白スタイル
// http://eslint.org/docs/rules/array-bracket-spacing
'array-bracket-spacing': 2,
// 配列要素の改行スタイル
// https://eslint.org/docs/rules/array-element-newline
'array-element-newline': 0, // 行の長さによって改行要否を変えたりしたい
// 1行ブロック内の空白スタイル
// http://eslint.org/docs/rules/block-spacing
'block-spacing': 0, // brace-style で 1 行ブロックを制限しているため不要
// 波括弧の書き方
// http://eslint.org/docs/rules/brace-style
'brace-style': [2, '1tbs', {allowSingleLine: false}],
// キャメルケース必須化
// http://eslint.org/docs/rules/camelcase
camelcase: 2,
// コメントの英文の大文字小文字ルール
// https://eslint.org/docs/rules/capitalized-comments
'capitalized-comments': 0,
// カンマまわりの空白スタイル
// http://eslint.org/docs/rules/comma-spacing
'comma-spacing': 2,
// カンマの配置
// http://eslint.org/docs/rules/comma-style
'comma-style': [2, 'last'],
// computed property の空白スタイル
// http://eslint.org/docs/rules/computed-property-spacing
'computed-property-spacing': 2,
// this の逃避変数名
// http://eslint.org/docs/rules/consistent-this
'consistent-this': [2, 'self'],
// ファイル末尾の空白行必須化
// http://eslint.org/docs/rules/eol-last
'eol-last': 2,
// 関数呼び出しの括弧前の空白スタイル
// http://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': 2,
// 関数名と代入先の変数・プロパティ名が合致
// http://eslint.org/docs/rules/func-name-matching
'func-name-matching': 0,
// 関数名を持たせるための function 式を強制
// http://eslint.org/docs/rules/func-names
'func-names': 2,
// 関数定義スタイル
// http://eslint.org/docs/rules/func-style
'func-style': [2, 'declaration', {allowArrowFunctions: true}],
// 関数の括弧まわりの改行スタイル
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': [2, 'multiline'],
// 変数名に使用禁止な名前リスト
// http://eslint.org/docs/rules/id-blacklist
'id-blacklist': 0,
// identifier (変数, 引数, プロパティ) の長さを制限
// http://eslint.org/docs/rules/id-length
'id-length': 0,
// identifier の形式を制限
// http://eslint.org/docs/rules/id-match
'id-match': 0,
// Arrow関数の本体の改行ルール
// https://eslint.org/docs/rules/implicit-arrow-linebreak
'implicit-arrow-linebreak': [2, 'beside'],
// インデントスタイル
// http://eslint.org/docs/rules/indent
indent: [2, 2, {MemberExpression: 1, SwitchCase: 1}], // プロパティアクセスのインデントを指定
// JSX 属性のクオートスタイル
// http://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': 0, // moqada/react 側で有効化
// オブジェクトリテラルのキーまわり空白スタイル
// http://eslint.org/docs/rules/key-spacing
'key-spacing': [2, {beforeColon: false, afterColon: true}],
// キーワードまわりの空白スタイル
// http://eslint.org/docs/rules/keyword-spacing
'keyword-spacing': [2, {before: true, after: true}],
// クラスメソッドの空白行スタイル
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': [
2,
'always',
{exceptAfterSingleLine: true}
], // 1行の場合はチェック除外
// 行コメントの位置スタイル
// http://eslint.org/docs/rules/line-comment-position
'line-comment-position': 0, // 状況によって変えたい
// 改行コードを指定
// http://eslint.org/docs/rules/linebreak-style
'linebreak-style': [2, 'unix'],
// コメントまわりの改行スタイル
// http://eslint.org/docs/rules/lines-around-comment
'lines-around-comment': [
2,
{
beforeBlockComment: true,
allowBlockStart: true,
allowObjectStart: true,
allowArrayStart: true,
allowClassEnd: true,
allowClassStart: true
}
],
// 1ファイルの最大行を制限
// http://eslint.org/docs/rules/max-lines
'max-lines': 0,
// callback ネスト数の制限
// http://eslint.org/docs/rules/max-nested-callbacks
'max-nested-callbacks': [1, 3],
// 1行の文の数を制限
// http://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': 0, // ここまで厳密にしなくてもよさそう
// 複数行のコメントスタイル
// https://eslint.org/docs/rules/multiline-comment-style
'multiline-comment-style': 0, // 連続でラインコメント使いたい場合もある
// 三項演算子を仕様時に改行を強制
// http://eslint.org/docs/rules/multiline-ternary
'multiline-ternary': 0,
// コンストラクタの new 必須化
// http://eslint.org/docs/rules/new-cap
'new-cap': 2,
// new 時の括弧必須化
// http://eslint.org/docs/rules/new-parens
'new-parens': 2,
// 1行あたりのchain呼出回数を制限
// http://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': [0, {ignoreChainWithDepth: 3}], // moment等まとまったほうが嬉しいパターンもあるので無効/ 1行に3つ以上のchainを警告
// Array コンストラクタでの配列要素作成禁止
// http://eslint.org/docs/rules/no-array-constructor
'no-array-constructor': 2,
// continue 禁止
// http://eslint.org/docs/rules/no-continue
'no-continue': 0,
// インラインコメント禁止
// http://eslint.org/docs/rules/no-inline-comments
'no-inline-comments': 0,
// else 内の if 禁止
// http://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 2,
// 特定の演算子の組み合わせに括弧を強制
// http://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': [
2,
{
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['&&', '||']
]
}
],
// 空白とタブの混在禁止
// http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
'no-mixed-spaces-and-tabs': 2,
// 代入の連鎖記法を禁止 (ex. a = b = 2)
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': 2,
// 連続空白行数の制限
// http://eslint.org/docs/rules/no-multiple-empty-lines
'no-multiple-empty-lines': [2, {max: 2}],
// 条件分岐での否定表現禁止
// http://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 0, // 否定で簡潔に書けるならそのほうが好き
// ネストした三項演算子禁止
// http://eslint.org/docs/rules/no-nested-ternary
'no-nested-ternary': 2,
// Object コンストラクタ禁止
// http://eslint.org/docs/rules/no-new-object
'no-new-object': 2,
// 制限された構文を禁止
// http://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': 0, // no-with, func-style で同様の制限をしているので無視
// タブの使用禁止
// http://eslint.org/docs/rules/no-tabs
'no-tabs': 2,
// 行末の空白禁止
// http://eslint.org/docs/rules/no-trailing-spaces
'no-trailing-spaces': 2,
// 識別子としてのアンダースコアの使用を禁止
// http://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': [2, {allowAfterThis: true}], // thisのみ許可
// 無駄な三項演算子の禁止
// http://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': 2,
// オブジェクトプロパティアクセスのドット前の空白を禁止
// http://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 2,
// 本文がブロックではない制御構文の本文の位置ルール
// https://eslint.org/docs/rules/nonblock-statement-body-position
'nonblock-statement-body-position': 2,
// オブジェクトリテラル括弧内の改行スタイル
// http://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': [2, {minProperties: 3, multiline: true}], // 3属性以上で改行必須、
// オブジェクトの中括弧内の空白
// http://eslint.org/docs/rules/object-curly-spacing
'object-curly-spacing': [2, 'never'],
// オブジェクトプロパティ毎の改行を強制する
// http://eslint.org/docs/rules/object-property-newline
'object-property-newline': [2, {allowMultiplePropertiesPerLine: true}], // 1行に全てのプロパティが収まる場合は許可
// 変数定義初期化スタイル
// http://eslint.org/docs/rules/one-var
'one-var': [2, {uninitialized: 'always', initialized: 'never'}], // 値なしで初期化する場合はvarを1つにまとめ、値ありで初期化する場合はvarを変数分
// 1行変数定義スタイル
// http://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': 0, // 1行で複数変数を定義することを許可する
// 変数代入のスタイル
// http://eslint.org/docs/rules/operator-assignment
'operator-assignment': 0,
// 改行時の演算子位置スタイル
// http://eslint.org/docs/rules/operator-linebreak
'operator-linebreak': [2, 'before'],
// ブロック先頭末尾の空白行
// http://eslint.org/docs/rules/padded-blocks
'padded-blocks': [2, 'never'],
// 特定の文の前後の改行スタイル
// https://eslint.org/docs/rules/padding-line-between-statements
'padding-line-between-statements': [
2,
{
blankLine: 'always',
next: '*',
prev: 'directive'
}
], // "use strict" の後に改行
// プロパティキー定義のクォート
// http://eslint.org/docs/rules/quote-props
'quote-props': [2, 'as-needed', {keywords: true}],
// 文字列のクォート
// http://eslint.org/docs/rules/quotes
quotes: [2, 'single'],
// セミコロン強制
// http://eslint.org/docs/rules/semi
semi: 2,
// セミコロンまわりの空白スタイル
// http://eslint.org/docs/rules/semi-spacing
'semi-spacing': [2, {before: false, after: true}],
// セミコロンの位置スタイル
// https://eslint.org/docs/rules/semi-style
'semi-style': 2,
// importをアルファベット順に制限
// http://eslint.org/docs/rules/sort-imports
'sort-imports': 0, // 期待するソートじゃない
// オブジェクトプロパティををアルファベット順に制限
// http://eslint.org/docs/rules/sort-keys
'sort-keys': [2, 'asc', {caseSensitive: true, natural: true}],
// 変数定義をアルファベット順に制限
// http://eslint.org/docs/rules/sort-vars
'sort-vars': 2,
// ブロックの前の空白
// http://eslint.org/docs/rules/space-before-blocks
'space-before-blocks': [2, 'always'],
// 関数の括弧前の空白
// http://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': [
2,
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}
],
// 括弧内の空白
// http://eslint.org/docs/rules/space-in-parens
'space-in-parens': [2, 'never'],
// 演算子まわりの空白スタイル
// http://eslint.org/docs/rules/space-infix-ops
'space-infix-ops': 2,
// 演算子まわりの空白
// http://eslint.org/docs/rules/space-unary-ops
'space-unary-ops': [2, {words: true, nonwords: false}],
// コメント内の空白
// http://eslint.org/docs/rules/spaced-comment
'spaced-comment': [
2,
'always',
{exceptions: ['-', '+'], block: {balanced: true}}
],
// switch文のコロンの前後空白スタイル
// https://eslint.org/docs/rules/switch-colon-spacing
'switch-colon-spacing': 2,
// タグ付きテンプレート式の空白ルール
// https://eslint.org/docs/rules/template-tag-spacing
'template-tag-spacing': [2, 'never'],
// BOMの扱い
// http://eslint.org/docs/rules/unicode-bom
'unicode-bom': [2, 'never'],
// 正規表現を括弧で囲むことを強制
// http://eslint.org/docs/rules/wrap-regex
'wrap-regex': 0,
/**
* ECMAScript 6
*/
// arrow function body の中括弧スタイル
// http://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': 0, // 1文が長くなってしまう場合には中括弧で改行したい
// arrow function の括弧スタイル
// http://eslint.org/docs/rules/arrow-parens
'arrow-parens': [2, 'as-needed'],
// arrow function の空白スタイル
// http://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': 2,
// コンストラクタの super 有無
// http://eslint.org/docs/rules/constructor-super
'constructor-super': 2,
// generator の * の空白スタイル
// http://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': 2,
// class への再代入禁止
// http://eslint.org/docs/rules/no-class-assign
'no-class-assign': 2,
// 条件式とまぎらわしいarrow functionを警告
// http://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': 2,
// const への再代入禁止
// http://eslint.org/docs/rules/no-const-assign
'no-const-assign': 2,
// importの重複禁止
// http://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 2,
// クラスメンバ名の重複禁止
// http://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 2,
// コンストラクタ内 super の前の this 禁止
// http://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 2,
// 不要なcomputed propertiesを禁止
// http://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 2,
// 不要なコンストラクタ関数の禁止
// http://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 2,
// import/export/destructuredでの不要なリネーム禁止
// http://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': 2,
// var 禁止
// http://eslint.org/docs/rules/no-var
'no-var': 2,
// ES6 のオブジェクト省略表現
// http://eslint.org/docs/rules/object-shorthand
'object-shorthand': [2, 'always'],
// コールバックに arrow function の利用提案
// http://eslint.org/docs/rules/prefer-arrow-callback
'prefer-arrow-callback': 2,
// const の利用提案
// http://eslint.org/docs/rules/prefer-const
'prefer-const': 2,
// 分割代入の利用提案
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': 2,
// 定数値のparseIntで数値リテラルの利用を提案
// http://eslint.org/docs/rules/prefer-numeric-literals
'prefer-numeric-literals': 2,
// Reflect メソッドの利用提案
// http://eslint.org/docs/rules/prefer-reflect
'prefer-reflect': 0, // babel-runtime なしで delete とか使いたいときがある
// rest-paramsの利用提案 (arguments禁止)
// http://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 2,
// Spread オペレータの利用提案
// http://eslint.org/docs/rules/prefer-spread
'prefer-spread': 2,
// 文字列連結にテンプレートリテラルの利用提案
// http://eslint.org/docs/rules/prefer-template
'prefer-template': 2,
// yield の必須化
// http://eslint.org/docs/rules/require-yield
'require-yield': 2,
// spread演算子とrest演算子の空白スタイル
// http://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': [2, 'never'], // 空白禁止
// Symbolの第一引数(説明)を強制
// http://eslint.org/docs/rules/symbol-description
'symbol-description': 2,
// テンプレートリテラルの`${..}`の空白スタイル
// http://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': [2, 'never'],
// yieldの*まわりの空白スタイル
// http://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': [2, 'after'],
/**
* Legacy
*/
// ブロックのネスト数
// http://eslint.org/docs/rules/max-depth
'max-depth': [1, 3],
// 1行の長さ
// http://eslint.org/docs/rules/max-len
'max-len': [
1,
{
code: 100,
tabWidth: 2,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreUrls: true
}
], // 文字列、テンプレートリテラル、URLは無視
// 引数の数
// http://eslint.org/docs/rules/max-params
'max-params': [1, 3],
// 関数内の文の数
// http://eslint.org/docs/rules/max-statements
'max-statements': [1, 10],
// ビット演算子禁止
// http://eslint.org/docs/rules/no-bitwise
'no-bitwise': 2,
// ++ / -- 禁止
// http://eslint.org/docs/rules/no-plusplus
'no-plusplus': 0,
/**
* JSDoc
*/
// https://github.com/gajus/eslint-plugin-jsdoc#check-param-names
// @paramと引数名の一致を確認
'jsdoc/check-param-names': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
// タグの名前(@param, @returns, etc...)が正しいか確認
'jsdoc/check-tag-names': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#check-types
// 型名(number, string, etc...)が正しいか確認
'jsdoc/check-types': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-description-complete-sentence
// descriptionを文章形式にすることを強制
'jsdoc/require-description-complete-sentence': 0,
// https://github.com/gajus/eslint-plugin-jsdoc#require-example
// @exampleを強制
'jsdoc/require-example': 0,
// https://github.com/gajus/eslint-plugin-jsdoc#require-hyphen-before-param-description
// @paramの説明の前にハイフンを強制
'jsdoc/require-hyphen-before-param-description': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-param
// @paramを強制
'jsdoc/require-param': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-param-description
// @paramにdescriptionを強制
'jsdoc/require-param-description': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-param-name
// @paramにnameを強制
'jsdoc/require-param-name': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-param-type
// @paramにtypeを強制
'jsdoc/require-param-type': 2,
// https://github.com/gajus/eslint-plugin-jsdoc#require-returns-description
// @returnsにdescriptionを強制
'jsdoc/require-returns-description': 0,
// https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type
// @returnsにtypeを強制
'jsdoc/require-returns-type': 0,
// https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.README/rules/tag-lines.md
// タグ間の空行スタイル
'jsdoc/tag-lines': [
2,
'never',
{
// 最初のタグの前に空行を入れる
startLines: 1
}
]
},
settings: {
jsdoc: {
// タグ名のエイリアスを定義
tagNamePreference: {returns: 'return'}
}
}
}
];