@generatech/eslint-config-base 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/rules/style.js ADDED
@@ -0,0 +1,653 @@
1
+ module.exports = {
2
+ rules: {
3
+ // enforce line breaks after opening and before closing array brackets
4
+ // https://eslint.org/docs/rules/array-bracket-newline
5
+ // TODO: enable? semver-major
6
+ "array-bracket-newline": ["off", "consistent"], // object option alternative: { multiline: true, minItems: 3 }
7
+
8
+ // enforce line breaks between array elements
9
+ // https://eslint.org/docs/rules/array-element-newline
10
+ // TODO: enable? semver-major
11
+ "array-element-newline": ["off", { multiline: true, minItems: 3 }],
12
+
13
+ // enforce spacing inside array brackets
14
+ "array-bracket-spacing": ["error", "never"],
15
+
16
+ // enforce spacing inside single-line blocks
17
+ // https://eslint.org/docs/rules/block-spacing
18
+ "block-spacing": ["error", "always"],
19
+
20
+ // enforce one true brace style
21
+ "brace-style": ["error", "1tbs", { allowSingleLine: true }],
22
+
23
+ // require camel case names
24
+ camelcase: ["error", { properties: "never", ignoreDestructuring: false }],
25
+
26
+ // enforce or disallow capitalization of the first letter of a comment
27
+ // https://eslint.org/docs/rules/capitalized-comments
28
+ "capitalized-comments": [
29
+ "off",
30
+ "never",
31
+ {
32
+ line: {
33
+ ignorePattern: ".*",
34
+ ignoreInlineComments: true,
35
+ ignoreConsecutiveComments: true,
36
+ },
37
+ block: {
38
+ ignorePattern: ".*",
39
+ ignoreInlineComments: true,
40
+ ignoreConsecutiveComments: true,
41
+ },
42
+ },
43
+ ],
44
+
45
+ // require trailing commas in multiline object literals
46
+ "comma-dangle": [
47
+ "error",
48
+ {
49
+ arrays: "always-multiline",
50
+ objects: "always-multiline",
51
+ imports: "always-multiline",
52
+ exports: "always-multiline",
53
+ functions: "always-multiline",
54
+ },
55
+ ],
56
+
57
+ // enforce spacing before and after comma
58
+ "comma-spacing": ["error", { before: false, after: true }],
59
+
60
+ // enforce one true comma style
61
+ "comma-style": [
62
+ "error",
63
+ "last",
64
+ {
65
+ exceptions: {
66
+ ArrayExpression: false,
67
+ ArrayPattern: false,
68
+ ArrowFunctionExpression: false,
69
+ CallExpression: false,
70
+ FunctionDeclaration: false,
71
+ FunctionExpression: false,
72
+ ImportDeclaration: false,
73
+ ObjectExpression: false,
74
+ ObjectPattern: false,
75
+ VariableDeclaration: false,
76
+ NewExpression: false,
77
+ },
78
+ },
79
+ ],
80
+
81
+ // disallow padding inside computed properties
82
+ "computed-property-spacing": ["error", "never"],
83
+
84
+ // enforces consistent naming when capturing the current execution context
85
+ "consistent-this": "off",
86
+
87
+ // enforce newline at the end of file, with no multiple empty lines
88
+ "eol-last": ["error", "always"],
89
+
90
+ // https://eslint.org/docs/rules/function-call-argument-newline
91
+ "function-call-argument-newline": ["error", "consistent"],
92
+
93
+ // enforce spacing between functions and their invocations
94
+ // https://eslint.org/docs/rules/func-call-spacing
95
+ "func-call-spacing": ["error", "never"],
96
+
97
+ // requires function names to match the name of the variable or property to which they are
98
+ // assigned
99
+ // https://eslint.org/docs/rules/func-name-matching
100
+ "func-name-matching": [
101
+ "off",
102
+ "always",
103
+ {
104
+ includeCommonJSModuleExports: false,
105
+ considerPropertyDescriptor: true,
106
+ },
107
+ ],
108
+
109
+ // require function expressions to have a name
110
+ // https://eslint.org/docs/rules/func-names
111
+ "func-names": "warn",
112
+
113
+ // enforces use of function declarations or expressions
114
+ // https://eslint.org/docs/rules/func-style
115
+ // TODO: enable
116
+ "func-style": ["off", "expression"],
117
+
118
+ // require line breaks inside function parentheses if there are line breaks between parameters
119
+ // https://eslint.org/docs/rules/function-paren-newline
120
+ "function-paren-newline": ["error", "multiline-arguments"],
121
+
122
+ // disallow specified identifiers
123
+ // https://eslint.org/docs/rules/id-denylist
124
+ "id-denylist": "off",
125
+
126
+ // this option enforces minimum and maximum identifier lengths
127
+ // (variable names, property names etc.)
128
+ "id-length": "off",
129
+
130
+ // require identifiers to match the provided regular expression
131
+ "id-match": "off",
132
+
133
+ // Enforce the location of arrow function bodies with implicit returns
134
+ // https://eslint.org/docs/rules/implicit-arrow-linebreak
135
+ "implicit-arrow-linebreak": ["error", "beside"],
136
+
137
+ // this option sets a specific tab width for your code
138
+ // https://eslint.org/docs/rules/indent
139
+ indent: [
140
+ "error",
141
+ 2,
142
+ {
143
+ SwitchCase: 1,
144
+ VariableDeclarator: 1,
145
+ outerIIFEBody: 1,
146
+ // MemberExpression: null,
147
+ FunctionDeclaration: {
148
+ parameters: 1,
149
+ body: 1,
150
+ },
151
+ FunctionExpression: {
152
+ parameters: 1,
153
+ body: 1,
154
+ },
155
+ CallExpression: {
156
+ arguments: 1,
157
+ },
158
+ ArrayExpression: 1,
159
+ ObjectExpression: 1,
160
+ ImportDeclaration: 1,
161
+ flatTernaryExpressions: false,
162
+ // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
163
+ ignoredNodes: [
164
+ "JSXElement",
165
+ "JSXElement > *",
166
+ "JSXAttribute",
167
+ "JSXIdentifier",
168
+ "JSXNamespacedName",
169
+ "JSXMemberExpression",
170
+ "JSXSpreadAttribute",
171
+ "JSXExpressionContainer",
172
+ "JSXOpeningElement",
173
+ "JSXClosingElement",
174
+ "JSXFragment",
175
+ "JSXOpeningFragment",
176
+ "JSXClosingFragment",
177
+ "JSXText",
178
+ "JSXEmptyExpression",
179
+ "JSXSpreadChild",
180
+ ],
181
+ ignoreComments: false,
182
+ },
183
+ ],
184
+
185
+ // specify whether double or single quotes should be used in JSX attributes
186
+ // https://eslint.org/docs/rules/jsx-quotes
187
+ "jsx-quotes": ["off", "prefer-double"],
188
+
189
+ // enforces spacing between keys and values in object literal properties
190
+ "key-spacing": ["error", { beforeColon: false, afterColon: true }],
191
+
192
+ // require a space before & after certain keywords
193
+ "keyword-spacing": [
194
+ "error",
195
+ {
196
+ before: true,
197
+ after: true,
198
+ overrides: {
199
+ return: { after: true },
200
+ throw: { after: true },
201
+ case: { after: true },
202
+ },
203
+ },
204
+ ],
205
+
206
+ // enforce position of line comments
207
+ // https://eslint.org/docs/rules/line-comment-position
208
+ // TODO: enable?
209
+ "line-comment-position": [
210
+ "off",
211
+ {
212
+ position: "above",
213
+ ignorePattern: "",
214
+ applyDefaultPatterns: true,
215
+ },
216
+ ],
217
+
218
+ // disallow mixed 'LF' and 'CRLF' as linebreaks
219
+ // https://eslint.org/docs/rules/linebreak-style
220
+ "linebreak-style": ["error", "unix"],
221
+
222
+ // require or disallow an empty line between class members
223
+ // https://eslint.org/docs/rules/lines-between-class-members
224
+ "lines-between-class-members": [
225
+ "error",
226
+ "always",
227
+ { exceptAfterSingleLine: false },
228
+ ],
229
+
230
+ // enforces empty lines around comments
231
+ "lines-around-comment": "off",
232
+
233
+ // require or disallow newlines around directives
234
+ // https://eslint.org/docs/rules/lines-around-directive
235
+ "lines-around-directive": [
236
+ "error",
237
+ {
238
+ before: "always",
239
+ after: "always",
240
+ },
241
+ ],
242
+
243
+ // Require or disallow logical assignment logical operator shorthand
244
+ // https://eslint.org/docs/latest/rules/logical-assignment-operators
245
+ // TODO, semver-major: enable
246
+ "logical-assignment-operators": [
247
+ "off",
248
+ "always",
249
+ {
250
+ enforceForIfStatements: true,
251
+ },
252
+ ],
253
+
254
+ // specify the maximum depth that blocks can be nested
255
+ "max-depth": ["off", 4],
256
+
257
+ // specify the maximum length of a line in your program
258
+ // https://eslint.org/docs/rules/max-len
259
+ "max-len": [
260
+ "error",
261
+ 100,
262
+ 2,
263
+ {
264
+ ignoreUrls: true,
265
+ ignoreComments: false,
266
+ ignoreRegExpLiterals: true,
267
+ ignoreStrings: true,
268
+ ignoreTemplateLiterals: true,
269
+ },
270
+ ],
271
+
272
+ // specify the max number of lines in a file
273
+ // https://eslint.org/docs/rules/max-lines
274
+ "max-lines": [
275
+ "off",
276
+ {
277
+ max: 300,
278
+ skipBlankLines: true,
279
+ skipComments: true,
280
+ },
281
+ ],
282
+
283
+ // enforce a maximum function length
284
+ // https://eslint.org/docs/rules/max-lines-per-function
285
+ "max-lines-per-function": [
286
+ "off",
287
+ {
288
+ max: 50,
289
+ skipBlankLines: true,
290
+ skipComments: true,
291
+ IIFEs: true,
292
+ },
293
+ ],
294
+
295
+ // specify the maximum depth callbacks can be nested
296
+ "max-nested-callbacks": "off",
297
+
298
+ // limits the number of parameters that can be used in the function declaration.
299
+ "max-params": ["off", 3],
300
+
301
+ // specify the maximum number of statement allowed in a function
302
+ "max-statements": ["off", 10],
303
+
304
+ // restrict the number of statements per line
305
+ // https://eslint.org/docs/rules/max-statements-per-line
306
+ "max-statements-per-line": ["off", { max: 1 }],
307
+
308
+ // enforce a particular style for multiline comments
309
+ // https://eslint.org/docs/rules/multiline-comment-style
310
+ "multiline-comment-style": ["off", "starred-block"],
311
+
312
+ // require multiline ternary
313
+ // https://eslint.org/docs/rules/multiline-ternary
314
+ // TODO: enable?
315
+ "multiline-ternary": ["off", "never"],
316
+
317
+ // require a capital letter for constructors
318
+ "new-cap": [
319
+ "error",
320
+ {
321
+ newIsCap: true,
322
+ newIsCapExceptions: [],
323
+ capIsNew: false,
324
+ capIsNewExceptions: [
325
+ "Immutable.Map",
326
+ "Immutable.Set",
327
+ "Immutable.List",
328
+ ],
329
+ },
330
+ ],
331
+
332
+ // disallow the omission of parentheses when invoking a constructor with no arguments
333
+ // https://eslint.org/docs/rules/new-parens
334
+ "new-parens": "error",
335
+
336
+ // allow/disallow an empty newline after var statement
337
+ "newline-after-var": "off",
338
+
339
+ // https://eslint.org/docs/rules/newline-before-return
340
+ "newline-before-return": "off",
341
+
342
+ // enforces new line after each method call in the chain to make it
343
+ // more readable and easy to maintain
344
+ // https://eslint.org/docs/rules/newline-per-chained-call
345
+ "newline-per-chained-call": ["error", { ignoreChainWithDepth: 4 }],
346
+
347
+ // disallow use of the Array constructor
348
+ "no-array-constructor": "error",
349
+
350
+ // disallow use of bitwise operators
351
+ // https://eslint.org/docs/rules/no-bitwise
352
+ "no-bitwise": "error",
353
+
354
+ // disallow use of the continue statement
355
+ // https://eslint.org/docs/rules/no-continue
356
+ "no-continue": "error",
357
+
358
+ // disallow comments inline after code
359
+ "no-inline-comments": "off",
360
+
361
+ // disallow if as the only statement in an else block
362
+ // https://eslint.org/docs/rules/no-lonely-if
363
+ "no-lonely-if": "error",
364
+
365
+ // disallow un-paren'd mixes of different operators
366
+ // https://eslint.org/docs/rules/no-mixed-operators
367
+ "no-mixed-operators": [
368
+ "error",
369
+ {
370
+ // the list of arithmetic groups disallows mixing `%` and `**`
371
+ // with other arithmetic operators.
372
+ groups: [
373
+ ["%", "**"],
374
+ ["%", "+"],
375
+ ["%", "-"],
376
+ ["%", "*"],
377
+ ["%", "/"],
378
+ ["/", "*"],
379
+ ["&", "|", "<<", ">>", ">>>"],
380
+ ["==", "!=", "===", "!=="],
381
+ ["&&", "||"],
382
+ ],
383
+ allowSamePrecedence: false,
384
+ },
385
+ ],
386
+
387
+ // disallow mixed spaces and tabs for indentation
388
+ "no-mixed-spaces-and-tabs": "error",
389
+
390
+ // disallow use of chained assignment expressions
391
+ // https://eslint.org/docs/rules/no-multi-assign
392
+ "no-multi-assign": ["error"],
393
+
394
+ // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
395
+ // https://eslint.org/docs/rules/no-multiple-empty-lines
396
+ "no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
397
+
398
+ // disallow negated conditions
399
+ // https://eslint.org/docs/rules/no-negated-condition
400
+ "no-negated-condition": "off",
401
+
402
+ // disallow nested ternary expressions
403
+ "no-nested-ternary": "error",
404
+
405
+ // disallow use of the Object constructor
406
+ "no-new-object": "error",
407
+
408
+ // disallow use of unary operators, ++ and --
409
+ // https://eslint.org/docs/rules/no-plusplus
410
+ "no-plusplus": "error",
411
+
412
+ // disallow certain syntax forms
413
+ // https://eslint.org/docs/rules/no-restricted-syntax
414
+ "no-restricted-syntax": [
415
+ "error",
416
+ {
417
+ selector: "ForInStatement",
418
+ message:
419
+ "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
420
+ },
421
+ {
422
+ selector: "ForOfStatement",
423
+ message:
424
+ "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
425
+ },
426
+ {
427
+ selector: "LabeledStatement",
428
+ message:
429
+ "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
430
+ },
431
+ {
432
+ selector: "WithStatement",
433
+ message:
434
+ "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
435
+ },
436
+ ],
437
+
438
+ // disallow space between function identifier and application
439
+ // deprecated in favor of func-call-spacing
440
+ "no-spaced-func": "off",
441
+
442
+ // disallow tab characters entirely
443
+ "no-tabs": "error",
444
+
445
+ // disallow the use of ternary operators
446
+ "no-ternary": "off",
447
+
448
+ // disallow trailing whitespace at the end of lines
449
+ "no-trailing-spaces": [
450
+ "error",
451
+ {
452
+ skipBlankLines: false,
453
+ ignoreComments: false,
454
+ },
455
+ ],
456
+
457
+ // disallow dangling underscores in identifiers
458
+ // https://eslint.org/docs/rules/no-underscore-dangle
459
+ "no-underscore-dangle": [
460
+ "error",
461
+ {
462
+ allow: [],
463
+ allowAfterThis: false,
464
+ allowAfterSuper: false,
465
+ enforceInMethodNames: true,
466
+ },
467
+ ],
468
+
469
+ // disallow the use of Boolean literals in conditional expressions
470
+ // also, prefer `a || b` over `a ? a : b`
471
+ // https://eslint.org/docs/rules/no-unneeded-ternary
472
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
473
+
474
+ // disallow whitespace before properties
475
+ // https://eslint.org/docs/rules/no-whitespace-before-property
476
+ "no-whitespace-before-property": "error",
477
+
478
+ // enforce the location of single-line statements
479
+ // https://eslint.org/docs/rules/nonblock-statement-body-position
480
+ "nonblock-statement-body-position": ["error", "beside", { overrides: {} }],
481
+
482
+ // require padding inside curly braces
483
+ "object-curly-spacing": ["error", "always"],
484
+
485
+ // enforce line breaks between braces
486
+ // https://eslint.org/docs/rules/object-curly-newline
487
+ "object-curly-newline": [
488
+ "error",
489
+ {
490
+ ObjectExpression: {
491
+ minProperties: 4,
492
+ multiline: true,
493
+ consistent: true,
494
+ },
495
+ ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
496
+ ImportDeclaration: {
497
+ minProperties: 4,
498
+ multiline: true,
499
+ consistent: true,
500
+ },
501
+ ExportDeclaration: {
502
+ minProperties: 4,
503
+ multiline: true,
504
+ consistent: true,
505
+ },
506
+ },
507
+ ],
508
+
509
+ // enforce "same line" or "multiple line" on object properties.
510
+ // https://eslint.org/docs/rules/object-property-newline
511
+ "object-property-newline": [
512
+ "error",
513
+ {
514
+ allowAllPropertiesOnSameLine: true,
515
+ },
516
+ ],
517
+
518
+ // allow just one var statement per function
519
+ "one-var": ["error", "never"],
520
+
521
+ // require a newline around variable declaration
522
+ // https://eslint.org/docs/rules/one-var-declaration-per-line
523
+ "one-var-declaration-per-line": ["error", "always"],
524
+
525
+ // require assignment operator shorthand where possible or prohibit it entirely
526
+ // https://eslint.org/docs/rules/operator-assignment
527
+ "operator-assignment": ["error", "always"],
528
+
529
+ // Requires operator at the beginning of the line in multiline statements
530
+ // https://eslint.org/docs/rules/operator-linebreak
531
+ "operator-linebreak": ["error", "before", { overrides: { "=": "none" } }],
532
+
533
+ // disallow padding within blocks
534
+ "padded-blocks": [
535
+ "error",
536
+ {
537
+ blocks: "never",
538
+ classes: "never",
539
+ switches: "never",
540
+ },
541
+ {
542
+ allowSingleLineBlocks: true,
543
+ },
544
+ ],
545
+
546
+ // Require or disallow padding lines between statements
547
+ // https://eslint.org/docs/rules/padding-line-between-statements
548
+ "padding-line-between-statements": "off",
549
+
550
+ // Disallow the use of Math.pow in favor of the ** operator
551
+ // https://eslint.org/docs/rules/prefer-exponentiation-operator
552
+ "prefer-exponentiation-operator": "error",
553
+
554
+ // Prefer use of an object spread over Object.assign
555
+ // https://eslint.org/docs/rules/prefer-object-spread
556
+ "prefer-object-spread": "error",
557
+
558
+ // require quotes around object literal property names
559
+ // https://eslint.org/docs/rules/quote-props.html
560
+ "quote-props": [
561
+ "error",
562
+ "as-needed",
563
+ { keywords: false, unnecessary: true, numbers: false },
564
+ ],
565
+
566
+ // specify whether double or single quotes should be used
567
+ quotes: ["error", "double", { avoidEscape: true }],
568
+
569
+ // do not require jsdoc
570
+ // https://eslint.org/docs/rules/require-jsdoc
571
+ "require-jsdoc": "off",
572
+
573
+ // require or disallow use of semicolons instead of ASI
574
+ semi: ["error", "always"],
575
+
576
+ // enforce spacing before and after semicolons
577
+ "semi-spacing": ["error", { before: false, after: true }],
578
+
579
+ // Enforce location of semicolons
580
+ // https://eslint.org/docs/rules/semi-style
581
+ "semi-style": ["error", "last"],
582
+
583
+ // requires object keys to be sorted
584
+ "sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
585
+
586
+ // sort variables within the same declaration block
587
+ "sort-vars": "off",
588
+
589
+ // require or disallow space before blocks
590
+ "space-before-blocks": "error",
591
+
592
+ // require or disallow space before function opening parenthesis
593
+ // https://eslint.org/docs/rules/space-before-function-paren
594
+ "space-before-function-paren": [
595
+ "error",
596
+ {
597
+ anonymous: "always",
598
+ named: "never",
599
+ asyncArrow: "always",
600
+ },
601
+ ],
602
+
603
+ // require or disallow spaces inside parentheses
604
+ "space-in-parens": ["error", "never"],
605
+
606
+ // require spaces around operators
607
+ "space-infix-ops": "error",
608
+
609
+ // Require or disallow spaces before/after unary operators
610
+ // https://eslint.org/docs/rules/space-unary-ops
611
+ "space-unary-ops": [
612
+ "error",
613
+ {
614
+ words: true,
615
+ nonwords: false,
616
+ overrides: {},
617
+ },
618
+ ],
619
+
620
+ // require or disallow a space immediately following the // or /* in a comment
621
+ // https://eslint.org/docs/rules/spaced-comment
622
+ "spaced-comment": [
623
+ "error",
624
+ "always",
625
+ {
626
+ line: {
627
+ exceptions: ["-", "+"],
628
+ markers: ["=", "!", "/"], // space here to support sprockets directives, slash for TS /// comments
629
+ },
630
+ block: {
631
+ exceptions: ["-", "+"],
632
+ markers: ["=", "!", ":", "::"], // space here to support sprockets directives and flow comment types
633
+ balanced: true,
634
+ },
635
+ },
636
+ ],
637
+
638
+ // Enforce spacing around colons of switch statements
639
+ // https://eslint.org/docs/rules/switch-colon-spacing
640
+ "switch-colon-spacing": ["error", { after: true, before: false }],
641
+
642
+ // Require or disallow spacing between template tags and their literals
643
+ // https://eslint.org/docs/rules/template-tag-spacing
644
+ "template-tag-spacing": ["error", "never"],
645
+
646
+ // require or disallow the Unicode Byte Order Mark
647
+ // https://eslint.org/docs/rules/unicode-bom
648
+ "unicode-bom": ["error", "never"],
649
+
650
+ // require regex literals to be wrapped in parentheses
651
+ "wrap-regex": "off",
652
+ },
653
+ };