@lumelabs/eslint-config 0.1.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,616 @@
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": "off",
225
+
226
+ // enforces empty lines around comments
227
+ "lines-around-comment": "off",
228
+
229
+ // require or disallow newlines around directives
230
+ // https://eslint.org/docs/rules/lines-around-directive
231
+ "lines-around-directive": [
232
+ "error",
233
+ {
234
+ before: "always",
235
+ after: "always",
236
+ },
237
+ ],
238
+
239
+ // Require or disallow logical assignment logical operator shorthand
240
+ // https://eslint.org/docs/latest/rules/logical-assignment-operators
241
+ // TODO, semver-major: enable
242
+ "logical-assignment-operators": [
243
+ "off",
244
+ "always",
245
+ {
246
+ enforceForIfStatements: true,
247
+ },
248
+ ],
249
+
250
+ // specify the maximum depth that blocks can be nested
251
+ "max-depth": ["off", 4],
252
+
253
+ // specify the maximum length of a line in your program
254
+ // https://eslint.org/docs/rules/max-len
255
+ "max-len": [
256
+ "error",
257
+ 100,
258
+ 2,
259
+ {
260
+ ignoreUrls: true,
261
+ ignoreComments: false,
262
+ ignoreRegExpLiterals: true,
263
+ ignoreStrings: true,
264
+ ignoreTemplateLiterals: true,
265
+ },
266
+ ],
267
+
268
+ // specify the max number of lines in a file
269
+ // https://eslint.org/docs/rules/max-lines
270
+ "max-lines": [
271
+ "off",
272
+ {
273
+ max: 300,
274
+ skipBlankLines: true,
275
+ skipComments: true,
276
+ },
277
+ ],
278
+
279
+ // enforce a maximum function length
280
+ // https://eslint.org/docs/rules/max-lines-per-function
281
+ "max-lines-per-function": [
282
+ "off",
283
+ {
284
+ max: 50,
285
+ skipBlankLines: true,
286
+ skipComments: true,
287
+ IIFEs: true,
288
+ },
289
+ ],
290
+
291
+ // specify the maximum depth callbacks can be nested
292
+ "max-nested-callbacks": "off",
293
+
294
+ // limits the number of parameters that can be used in the function declaration.
295
+ "max-params": ["off", 3],
296
+
297
+ // specify the maximum number of statement allowed in a function
298
+ "max-statements": ["off", 10],
299
+
300
+ // restrict the number of statements per line
301
+ // https://eslint.org/docs/rules/max-statements-per-line
302
+ "max-statements-per-line": ["off", { max: 1 }],
303
+
304
+ // enforce a particular style for multiline comments
305
+ // https://eslint.org/docs/rules/multiline-comment-style
306
+ "multiline-comment-style": ["off", "starred-block"],
307
+
308
+ // require multiline ternary
309
+ // https://eslint.org/docs/rules/multiline-ternary
310
+ // TODO: enable?
311
+ "multiline-ternary": ["off", "never"],
312
+
313
+ // require a capital letter for constructors
314
+ "new-cap": [
315
+ "error",
316
+ {
317
+ newIsCap: true,
318
+ newIsCapExceptions: [],
319
+ capIsNew: false,
320
+ capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
321
+ },
322
+ ],
323
+
324
+ // disallow the omission of parentheses when invoking a constructor with no arguments
325
+ // https://eslint.org/docs/rules/new-parens
326
+ "new-parens": "error",
327
+
328
+ // allow/disallow an empty newline after var statement
329
+ "newline-after-var": "off",
330
+
331
+ // https://eslint.org/docs/rules/newline-before-return
332
+ "newline-before-return": "off",
333
+
334
+ // enforces new line after each method call in the chain to make it
335
+ // more readable and easy to maintain
336
+ // https://eslint.org/docs/rules/newline-per-chained-call
337
+ "newline-per-chained-call": ["error", { ignoreChainWithDepth: 4 }],
338
+
339
+ // disallow use of the Array constructor
340
+ "no-array-constructor": "error",
341
+
342
+ // disallow use of bitwise operators
343
+ // https://eslint.org/docs/rules/no-bitwise
344
+ "no-bitwise": "off",
345
+
346
+ // disallow use of the continue statement
347
+ // https://eslint.org/docs/rules/no-continue
348
+ "no-continue": "off",
349
+
350
+ // disallow comments inline after code
351
+ "no-inline-comments": "off",
352
+
353
+ // disallow if as the only statement in an else block
354
+ // https://eslint.org/docs/rules/no-lonely-if
355
+ "no-lonely-if": "off",
356
+
357
+ // disallow un-paren'd mixes of different operators
358
+ // https://eslint.org/docs/rules/no-mixed-operators
359
+ "no-mixed-operators": [
360
+ "error",
361
+ {
362
+ // the list of arithmetic groups disallows mixing `%` and `**`
363
+ // with other arithmetic operators.
364
+ groups: [
365
+ ["%", "**"],
366
+ ["%", "+"],
367
+ ["%", "-"],
368
+ ["%", "*"],
369
+ ["%", "/"],
370
+ ["/", "*"],
371
+ ["&", "|", "<<", ">>", ">>>"],
372
+ ["==", "!=", "===", "!=="],
373
+ ["&&", "||"],
374
+ ],
375
+ allowSamePrecedence: false,
376
+ },
377
+ ],
378
+
379
+ // disallow mixed spaces and tabs for indentation
380
+ "no-mixed-spaces-and-tabs": "error",
381
+
382
+ // disallow use of chained assignment expressions
383
+ // https://eslint.org/docs/rules/no-multi-assign
384
+ "no-multi-assign": "off",
385
+
386
+ // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
387
+ // https://eslint.org/docs/rules/no-multiple-empty-lines
388
+ "no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
389
+
390
+ // disallow negated conditions
391
+ // https://eslint.org/docs/rules/no-negated-condition
392
+ "no-negated-condition": "off",
393
+
394
+ // disallow nested ternary expressions
395
+ "no-nested-ternary": "off",
396
+
397
+ // disallow use of the Object constructor
398
+ "no-new-object": "error",
399
+
400
+ // disallow use of unary operators, ++ and --
401
+ // https://eslint.org/docs/rules/no-plusplus
402
+ "no-plusplus": "off",
403
+
404
+ // disallow certain syntax forms
405
+ // https://eslint.org/docs/rules/no-restricted-syntax
406
+ "no-restricted-syntax": [
407
+ "error",
408
+ {
409
+ selector: "ForInStatement",
410
+ message:
411
+ "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.",
412
+ },
413
+ {
414
+ selector: "LabeledStatement",
415
+ message:
416
+ "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
417
+ },
418
+ {
419
+ selector: "WithStatement",
420
+ message:
421
+ "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
422
+ },
423
+ ],
424
+
425
+ // disallow space between function identifier and application
426
+ // deprecated in favor of func-call-spacing
427
+ "no-spaced-func": "off",
428
+
429
+ // disallow tab characters entirely
430
+ "no-tabs": "error",
431
+
432
+ // disallow the use of ternary operators
433
+ "no-ternary": "off",
434
+
435
+ // disallow trailing whitespace at the end of lines
436
+ "no-trailing-spaces": [
437
+ "error",
438
+ {
439
+ skipBlankLines: false,
440
+ ignoreComments: false,
441
+ },
442
+ ],
443
+
444
+ // disallow dangling underscores in identifiers
445
+ // https://eslint.org/docs/rules/no-underscore-dangle
446
+ "no-underscore-dangle": "off",
447
+
448
+ // disallow the use of Boolean literals in conditional expressions
449
+ // also, prefer `a || b` over `a ? a : b`
450
+ // https://eslint.org/docs/rules/no-unneeded-ternary
451
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
452
+
453
+ // disallow whitespace before properties
454
+ // https://eslint.org/docs/rules/no-whitespace-before-property
455
+ "no-whitespace-before-property": "error",
456
+
457
+ // enforce the location of single-line statements
458
+ // https://eslint.org/docs/rules/nonblock-statement-body-position
459
+ "nonblock-statement-body-position": ["error", "beside", { overrides: {} }],
460
+
461
+ // require padding inside curly braces
462
+ "object-curly-spacing": ["error", "always"],
463
+
464
+ // enforce line breaks between braces
465
+ // https://eslint.org/docs/rules/object-curly-newline
466
+ "object-curly-newline": [
467
+ "error",
468
+ {
469
+ ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
470
+ ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
471
+ ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
472
+ ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
473
+ },
474
+ ],
475
+
476
+ // enforce "same line" or "multiple line" on object properties.
477
+ // https://eslint.org/docs/rules/object-property-newline
478
+ "object-property-newline": [
479
+ "error",
480
+ {
481
+ allowAllPropertiesOnSameLine: true,
482
+ },
483
+ ],
484
+
485
+ // allow just one var statement per function
486
+ "one-var": ["error", "never"],
487
+
488
+ // require a newline around variable declaration
489
+ // https://eslint.org/docs/rules/one-var-declaration-per-line
490
+ "one-var-declaration-per-line": ["error", "always"],
491
+
492
+ // require assignment operator shorthand where possible or prohibit it entirely
493
+ // https://eslint.org/docs/rules/operator-assignment
494
+ "operator-assignment": ["error", "always"],
495
+
496
+ // Requires operator at the beginning of the line in multiline statements
497
+ // https://eslint.org/docs/rules/operator-linebreak
498
+ "operator-linebreak": ["error", "before", { overrides: { "=": "none" } }],
499
+
500
+ // disallow padding within blocks
501
+ "padded-blocks": [
502
+ "error",
503
+ {
504
+ blocks: "never",
505
+ classes: "never",
506
+ switches: "never",
507
+ },
508
+ {
509
+ allowSingleLineBlocks: true,
510
+ },
511
+ ],
512
+
513
+ // Require or disallow padding lines between statements
514
+ // https://eslint.org/docs/rules/padding-line-between-statements
515
+ "padding-line-between-statements": "off",
516
+
517
+ // Disallow the use of Math.pow in favor of the ** operator
518
+ // https://eslint.org/docs/rules/prefer-exponentiation-operator
519
+ "prefer-exponentiation-operator": "error",
520
+
521
+ // Prefer use of an object spread over Object.assign
522
+ // https://eslint.org/docs/rules/prefer-object-spread
523
+ "prefer-object-spread": "error",
524
+
525
+ // require quotes around object literal property names
526
+ // https://eslint.org/docs/rules/quote-props.html
527
+ "quote-props": ["error", "as-needed", { keywords: false, unnecessary: true, numbers: false }],
528
+
529
+ // specify whether double or single quotes should be used
530
+ quotes: ["error", "single", { avoidEscape: true }],
531
+
532
+ // do not require jsdoc
533
+ // https://eslint.org/docs/rules/require-jsdoc
534
+ "require-jsdoc": "off",
535
+
536
+ // require or disallow use of semicolons instead of ASI
537
+ semi: ["error", "always"],
538
+
539
+ // enforce spacing before and after semicolons
540
+ "semi-spacing": ["error", { before: false, after: true }],
541
+
542
+ // Enforce location of semicolons
543
+ // https://eslint.org/docs/rules/semi-style
544
+ "semi-style": ["error", "last"],
545
+
546
+ // requires object keys to be sorted
547
+ "sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
548
+
549
+ // sort variables within the same declaration block
550
+ "sort-vars": "off",
551
+
552
+ // require or disallow space before blocks
553
+ "space-before-blocks": "error",
554
+
555
+ // require or disallow space before function opening parenthesis
556
+ // https://eslint.org/docs/rules/space-before-function-paren
557
+ "space-before-function-paren": [
558
+ "error",
559
+ {
560
+ anonymous: "always",
561
+ named: "never",
562
+ asyncArrow: "always",
563
+ },
564
+ ],
565
+
566
+ // require or disallow spaces inside parentheses
567
+ "space-in-parens": ["error", "never"],
568
+
569
+ // require spaces around operators
570
+ "space-infix-ops": "error",
571
+
572
+ // Require or disallow spaces before/after unary operators
573
+ // https://eslint.org/docs/rules/space-unary-ops
574
+ "space-unary-ops": [
575
+ "error",
576
+ {
577
+ words: true,
578
+ nonwords: false,
579
+ overrides: {},
580
+ },
581
+ ],
582
+
583
+ // require or disallow a space immediately following the // or /* in a comment
584
+ // https://eslint.org/docs/rules/spaced-comment
585
+ "spaced-comment": [
586
+ "error",
587
+ "always",
588
+ {
589
+ line: {
590
+ exceptions: ["-", "+"],
591
+ markers: ["=", "!", "/"], // space here to support sprockets directives, slash for TS /// comments
592
+ },
593
+ block: {
594
+ exceptions: ["-", "+"],
595
+ markers: ["=", "!", ":", "::"], // space here to support sprockets directives and flow comment types
596
+ balanced: true,
597
+ },
598
+ },
599
+ ],
600
+
601
+ // Enforce spacing around colons of switch statements
602
+ // https://eslint.org/docs/rules/switch-colon-spacing
603
+ "switch-colon-spacing": ["error", { after: true, before: false }],
604
+
605
+ // Require or disallow spacing between template tags and their literals
606
+ // https://eslint.org/docs/rules/template-tag-spacing
607
+ "template-tag-spacing": ["error", "never"],
608
+
609
+ // require or disallow the Unicode Byte Order Mark
610
+ // https://eslint.org/docs/rules/unicode-bom
611
+ "unicode-bom": ["error", "never"],
612
+
613
+ // require regex literals to be wrapped in parentheses
614
+ "wrap-regex": "off",
615
+ },
616
+ }
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ plugins: ["@typescript-eslint"],
3
+
4
+ extends: ["plugin:@typescript-eslint/recommended"],
5
+
6
+ rules: {
7
+ // TypeScript
8
+ "@typescript-eslint/explicit-member-accessibility": "off",
9
+ "@typescript-eslint/explicit-function-return-type": "off",
10
+ "@typescript-eslint/no-var-requires": "off",
11
+ "@typescript-eslint/no-non-null-assertion": "off",
12
+ "@typescript-eslint/no-empty-interface": "off",
13
+ "@typescript-eslint/naming-convention": "off",
14
+ "@typescript-eslint/no-use-before-define": ["error", { functions: false }],
15
+ "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
16
+ "@typescript-eslint/no-explicit-any": "warn",
17
+ "@typescript-eslint/no-shadow": ["warn"],
18
+ "@typescript-eslint/explicit-module-boundary-types": "off",
19
+ "@typescript-eslint/ban-ts-comment": "off",
20
+ "@typescript-eslint/no-unsafe-function-type": "off",
21
+ "@typescript-eslint/no-empty-object-type": "off",
22
+ "@typescript-eslint/no-wrapper-object-types": "warn",
23
+ // "@typescript-eslint/consistent-type-imports": [
24
+ // "error",
25
+ // { prefer: "type-imports", fixStyle: "inline-type-imports" },
26
+ // ],
27
+ // "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
28
+ },
29
+ }