@gitlab/eslint-plugin 21.1.0 → 21.2.1

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