@gitlab/eslint-plugin 21.2.0 → 21.3.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.
@@ -1,447 +0,0 @@
1
- module.exports = {
2
- parserOptions: {
3
- ecmaVersion: 2018,
4
- sourceType: 'module',
5
- },
6
- rules: {
7
- // enforces getter/setter pairs in objects
8
- // https://eslint.org/docs/rules/accessor-pairs
9
- 'accessor-pairs': 'off',
10
-
11
- // enforces return statements in callbacks of array's methods
12
- // https://eslint.org/docs/rules/array-callback-return
13
- 'array-callback-return': ['error', { allowImplicit: true }],
14
-
15
- // treat var statements as if they were block scoped
16
- // https://eslint.org/docs/rules/block-scoped-var
17
- 'block-scoped-var': 'error',
18
-
19
- // specify the maximum cyclomatic complexity allowed in a program
20
- // https://eslint.org/docs/rules/complexity
21
- complexity: ['off', 20],
22
-
23
- // enforce that class methods use "this"
24
- // https://eslint.org/docs/rules/class-methods-use-this
25
- 'class-methods-use-this': [
26
- 'error',
27
- {
28
- exceptMethods: [],
29
- },
30
- ],
31
-
32
- // require return statements to either always or never specify values
33
- // https://eslint.org/docs/rules/consistent-return
34
- 'consistent-return': 'error',
35
-
36
- // specify curly brace conventions for all control statements
37
- // https://eslint.org/docs/rules/curly
38
- curly: ['error', 'multi-line'], // multiline
39
-
40
- // require default case in switch statements
41
- // https://eslint.org/docs/rules/default-case
42
- 'default-case': ['error', { commentPattern: '^no default$' }],
43
-
44
- // Enforce default clauses in switch statements to be last
45
- // https://eslint.org/docs/rules/default-case-last
46
- 'default-case-last': 'error',
47
-
48
- // https://eslint.org/docs/rules/default-param-last
49
- 'default-param-last': 'error',
50
-
51
- // encourages use of dot notation whenever possible
52
- // https://eslint.org/docs/rules/dot-notation
53
- 'dot-notation': ['error', { allowKeywords: true }],
54
-
55
- // enforces consistent newlines before or after dots
56
- // https://eslint.org/docs/rules/dot-location
57
- 'dot-location': ['error', 'property'],
58
-
59
- // require the use of === and !==
60
- // https://eslint.org/docs/rules/eqeqeq
61
- eqeqeq: ['error', 'always', { null: 'ignore' }],
62
-
63
- // Require grouped accessor pairs in object literals and classes
64
- // https://eslint.org/docs/rules/grouped-accessor-pairs
65
- 'grouped-accessor-pairs': 'error',
66
-
67
- // make sure for-in loops have an if statement
68
- // https://eslint.org/docs/rules/guard-for-in
69
- 'guard-for-in': 'error',
70
-
71
- // enforce a maximum number of classes per file
72
- // https://eslint.org/docs/rules/max-classes-per-file
73
- 'max-classes-per-file': ['error', 1],
74
-
75
- // disallow the use of alert, confirm, and prompt
76
- // https://eslint.org/docs/rules/no-alert
77
- 'no-alert': 'warn',
78
-
79
- // disallow use of arguments.caller or arguments.callee
80
- // https://eslint.org/docs/rules/no-caller
81
- 'no-caller': 'error',
82
-
83
- // disallow lexical declarations in case/default clauses
84
- // https://eslint.org/docs/rules/no-case-declarations
85
- 'no-case-declarations': 'error',
86
-
87
- // Disallow returning value in constructor
88
- // https://eslint.org/docs/rules/no-constructor-return
89
- 'no-constructor-return': 'error',
90
-
91
- // disallow division operators explicitly at beginning of regular expression
92
- // https://eslint.org/docs/rules/no-div-regex
93
- 'no-div-regex': 'off',
94
-
95
- // disallow else after a return in an if
96
- // https://eslint.org/docs/rules/no-else-return
97
- 'no-else-return': ['error', { allowElseIf: false }],
98
-
99
- // disallow empty functions, except for standalone funcs/arrows
100
- // https://eslint.org/docs/rules/no-empty-function
101
- 'no-empty-function': [
102
- 'error',
103
- {
104
- allow: ['arrowFunctions', 'functions', 'methods'],
105
- },
106
- ],
107
-
108
- // disallow empty destructuring patterns
109
- // https://eslint.org/docs/rules/no-empty-pattern
110
- 'no-empty-pattern': 'error',
111
-
112
- // disallow comparisons to null without a type-checking operator
113
- // https://eslint.org/docs/rules/no-eq-null
114
- 'no-eq-null': 'off',
115
-
116
- // disallow use of eval()
117
- // https://eslint.org/docs/rules/no-eval
118
- 'no-eval': 'error',
119
-
120
- // disallow adding to native types
121
- // https://eslint.org/docs/rules/no-extend-native
122
- 'no-extend-native': 'error',
123
-
124
- // disallow unnecessary function binding
125
- // https://eslint.org/docs/rules/no-extra-bind
126
- 'no-extra-bind': 'error',
127
-
128
- // disallow Unnecessary Labels
129
- // https://eslint.org/docs/rules/no-extra-label
130
- 'no-extra-label': 'error',
131
-
132
- // disallow fallthrough of case statements
133
- // https://eslint.org/docs/rules/no-fallthrough
134
- 'no-fallthrough': 'error',
135
-
136
- // disallow the use of leading or trailing decimal points in numeric literals
137
- // https://eslint.org/docs/rules/no-floating-decimal
138
- 'no-floating-decimal': 'error',
139
-
140
- // disallow reassignments of native objects or read-only globals
141
- // https://eslint.org/docs/rules/no-global-assign
142
- 'no-global-assign': ['error', { exceptions: [] }],
143
-
144
- // deprecated in favor of no-global-assign
145
- // https://eslint.org/docs/rules/no-native-reassign
146
- 'no-native-reassign': 'off',
147
-
148
- // disallow implicit type conversions
149
- // https://eslint.org/docs/rules/no-implicit-coercion
150
- 'no-implicit-coercion': [
151
- 'off',
152
- {
153
- boolean: false,
154
- number: true,
155
- string: true,
156
- allow: [],
157
- },
158
- ],
159
-
160
- // disallow var and named functions in global scope
161
- // https://eslint.org/docs/rules/no-implicit-globals
162
- 'no-implicit-globals': 'off',
163
-
164
- // disallow use of eval()-like methods
165
- // https://eslint.org/docs/rules/no-implied-eval
166
- 'no-implied-eval': 'error',
167
-
168
- // disallow this keywords outside of classes or class-like objects
169
- // https://eslint.org/docs/rules/no-invalid-this
170
- 'no-invalid-this': 'off',
171
-
172
- // disallow usage of __iterator__ property
173
- // https://eslint.org/docs/rules/no-iterator
174
- 'no-iterator': 'error',
175
-
176
- // disallow use of labels for anything other than loops and switches
177
- // https://eslint.org/docs/rules/no-labels
178
- 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
179
-
180
- // disallow unnecessary nested blocks
181
- // https://eslint.org/docs/rules/no-lone-blocks
182
- 'no-lone-blocks': 'error',
183
-
184
- // disallow creation of functions within loops
185
- // https://eslint.org/docs/rules/no-loop-func
186
- 'no-loop-func': 'error',
187
-
188
- // disallow magic numbers
189
- // https://eslint.org/docs/rules/no-magic-numbers
190
- 'no-magic-numbers': [
191
- 'off',
192
- {
193
- ignore: [],
194
- ignoreArrayIndexes: true,
195
- enforceConst: true,
196
- detectObjects: false,
197
- },
198
- ],
199
-
200
- // disallow use of multiple spaces
201
- // https://eslint.org/docs/rules/no-multi-spaces
202
- 'no-multi-spaces': [
203
- 'error',
204
- {
205
- ignoreEOLComments: false,
206
- },
207
- ],
208
-
209
- // disallow use of multiline strings
210
- // https://eslint.org/docs/rules/no-multi-str
211
- 'no-multi-str': 'error',
212
-
213
- // disallow use of new operator when not part of the assignment or comparison
214
- // https://eslint.org/docs/rules/no-new
215
- 'no-new': 'error',
216
-
217
- // disallow use of new operator for Function object
218
- // https://eslint.org/docs/rules/no-new-func
219
- 'no-new-func': 'error',
220
-
221
- // disallows creating new instances of String, Number, and Boolean
222
- // https://eslint.org/docs/rules/no-new-wrappers
223
- 'no-new-wrappers': 'error',
224
-
225
- // Disallow \8 and \9 escape sequences in string literals
226
- // https://eslint.org/docs/rules/no-nonoctal-decimal-escape
227
- 'no-nonoctal-decimal-escape': 'error',
228
-
229
- // disallow use of (old style) octal literals
230
- // https://eslint.org/docs/rules/no-octal
231
- 'no-octal': 'error',
232
-
233
- // disallow use of octal escape sequences in string literals, such as
234
- // var foo = 'Copyright \251';
235
- // https://eslint.org/docs/rules/no-octal-escape
236
- 'no-octal-escape': 'error',
237
-
238
- // disallow reassignment of function parameters
239
- // disallow parameter object manipulation except for specific exclusions
240
- // rule: https://eslint.org/docs/rules/no-param-reassign.html
241
- 'no-param-reassign': [
242
- 'error',
243
- {
244
- props: true,
245
- ignorePropertyModificationsFor: [
246
- 'acc', // for reduce accumulators
247
- 'accumulator', // for reduce accumulators
248
- 'e', // for e.returnvalue
249
- 'ctx', // for Koa routing
250
- 'context', // for Koa routing
251
- 'req', // for Express requests
252
- 'request', // for Express requests
253
- 'res', // for Express responses
254
- 'response', // for Express responses
255
- '$scope', // for Angular 1 scopes
256
- 'staticContext', // for ReactRouter context
257
- ],
258
- },
259
- ],
260
-
261
- // disallow usage of __proto__ property
262
- // https://eslint.org/docs/rules/no-proto
263
- 'no-proto': 'error',
264
-
265
- // disallow declaring the same variable more than once
266
- // https://eslint.org/docs/rules/no-redeclare
267
- 'no-redeclare': 'error',
268
-
269
- // disallow certain object properties
270
- // https://eslint.org/docs/rules/no-restricted-properties
271
- 'no-restricted-properties': [
272
- 'error',
273
- {
274
- object: 'arguments',
275
- property: 'callee',
276
- message: 'arguments.callee is deprecated',
277
- },
278
- {
279
- object: 'global',
280
- property: 'isFinite',
281
- message: 'Please use Number.isFinite instead',
282
- },
283
- {
284
- object: 'self',
285
- property: 'isFinite',
286
- message: 'Please use Number.isFinite instead',
287
- },
288
- {
289
- object: 'window',
290
- property: 'isFinite',
291
- message: 'Please use Number.isFinite instead',
292
- },
293
- {
294
- object: 'global',
295
- property: 'isNaN',
296
- message: 'Please use Number.isNaN instead',
297
- },
298
- {
299
- object: 'self',
300
- property: 'isNaN',
301
- message: 'Please use Number.isNaN instead',
302
- },
303
- {
304
- object: 'window',
305
- property: 'isNaN',
306
- message: 'Please use Number.isNaN instead',
307
- },
308
- {
309
- property: '__defineGetter__',
310
- message: 'Please use Object.defineProperty instead.',
311
- },
312
- {
313
- property: '__defineSetter__',
314
- message: 'Please use Object.defineProperty instead.',
315
- },
316
- {
317
- object: 'Math',
318
- property: 'pow',
319
- message: 'Use the exponentiation operator (**) instead.',
320
- },
321
- ],
322
-
323
- // disallow use of assignment in return statement
324
- // https://eslint.org/docs/rules/no-return-assign
325
- 'no-return-assign': ['error', 'always'],
326
-
327
- // disallow redundant `return await`
328
- // https://eslint.org/docs/rules/no-return-await
329
- 'no-return-await': 'error',
330
-
331
- // disallow use of `javascript:` urls.
332
- // https://eslint.org/docs/rules/no-script-url
333
- 'no-script-url': 'error',
334
-
335
- // disallow self assignment
336
- // https://eslint.org/docs/rules/no-self-assign
337
- 'no-self-assign': [
338
- 'error',
339
- {
340
- props: true,
341
- },
342
- ],
343
-
344
- // disallow comparisons where both sides are exactly the same
345
- // https://eslint.org/docs/rules/no-self-compare
346
- 'no-self-compare': 'error',
347
-
348
- // disallow use of comma operator
349
- // https://eslint.org/docs/rules/no-sequences
350
- 'no-sequences': 'error',
351
-
352
- // restrict what can be thrown as an exception
353
- // https://eslint.org/docs/rules/no-throw-literal
354
- 'no-throw-literal': 'error',
355
-
356
- // disallow unmodified conditions of loops
357
- // https://eslint.org/docs/rules/no-unmodified-loop-condition
358
- 'no-unmodified-loop-condition': 'off',
359
-
360
- // disallow usage of expressions in statement position
361
- // https://eslint.org/docs/rules/no-unused-expressions
362
- 'no-unused-expressions': [
363
- 'error',
364
- {
365
- allowShortCircuit: false,
366
- allowTernary: false,
367
- allowTaggedTemplates: false,
368
- },
369
- ],
370
-
371
- // disallow unused labels
372
- // https://eslint.org/docs/rules/no-unused-labels
373
- 'no-unused-labels': 'error',
374
-
375
- // disallow unnecessary .call() and .apply()
376
- // https://eslint.org/docs/rules/no-useless-call
377
- 'no-useless-call': 'off',
378
-
379
- // Disallow unnecessary catch clauses
380
- // https://eslint.org/docs/rules/no-useless-catch
381
- 'no-useless-catch': 'error',
382
-
383
- // disallow useless string concatenation
384
- // https://eslint.org/docs/rules/no-useless-concat
385
- 'no-useless-concat': 'error',
386
-
387
- // disallow unnecessary string escaping
388
- // https://eslint.org/docs/rules/no-useless-escape
389
- 'no-useless-escape': 'error',
390
-
391
- // disallow redundant return; keywords
392
- // https://eslint.org/docs/rules/no-useless-return
393
- 'no-useless-return': 'error',
394
-
395
- // disallow use of void operator
396
- // https://eslint.org/docs/rules/no-void
397
- 'no-void': 'error',
398
-
399
- // disallow usage of configurable warning terms in comments: e.g. todo
400
- // https://eslint.org/docs/rules/no-warning-comments
401
- 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
402
-
403
- // disallow use of the with statement
404
- // https://eslint.org/docs/rules/no-with
405
- 'no-with': 'error',
406
-
407
- // require using Error objects as Promise rejection reasons
408
- // https://eslint.org/docs/rules/prefer-promise-reject-errors
409
- 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
410
-
411
- // Suggest using named capture group in regular expression
412
- // https://eslint.org/docs/rules/prefer-named-capture-group
413
- 'prefer-named-capture-group': 'off',
414
-
415
- // https://eslint.org/docs/rules/prefer-regex-literals
416
- 'prefer-regex-literals': [
417
- 'error',
418
- {
419
- disallowRedundantWrapping: true,
420
- },
421
- ],
422
-
423
- // require use of the second argument for parseInt()
424
- // https://eslint.org/docs/rules/radix
425
- radix: 'error',
426
-
427
- // require `await` in `async function` (note: this is a horrible rule that should never be used)
428
- // https://eslint.org/docs/rules/require-await
429
- 'require-await': 'off',
430
-
431
- // Enforce the use of u flag on RegExp
432
- // https://eslint.org/docs/rules/require-unicode-regexp
433
- 'require-unicode-regexp': 'off',
434
-
435
- // requires to declare all vars on top of their containing scope
436
- // https://eslint.org/docs/rules/vars-on-top
437
- 'vars-on-top': 'error',
438
-
439
- // require immediate function invocation to be wrapped in parentheses
440
- // https://eslint.org/docs/rules/wrap-iife.html
441
- 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
442
-
443
- // require or disallow Yoda conditions
444
- // https://eslint.org/docs/rules/yoda
445
- yoda: 'error',
446
- },
447
- };
@@ -1,186 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- // Enforce “for” loop update clause moving the counter in the right direction
4
- // https://eslint.org/docs/rules/for-direction
5
- 'for-direction': 'error',
6
-
7
- // Enforces that a return statement is present in property getters
8
- // https://eslint.org/docs/rules/getter-return
9
- 'getter-return': ['error', { allowImplicit: true }],
10
-
11
- // disallow using an async function as a Promise executor
12
- // https://eslint.org/docs/rules/no-async-promise-executor
13
- 'no-async-promise-executor': 'error',
14
-
15
- // Disallow await inside of loops
16
- // https://eslint.org/docs/rules/no-await-in-loop
17
- 'no-await-in-loop': 'error',
18
-
19
- // Disallow comparisons to negative zero
20
- // https://eslint.org/docs/rules/no-compare-neg-zero
21
- 'no-compare-neg-zero': 'error',
22
-
23
- // disallow assignment in conditional expressions
24
- 'no-cond-assign': ['error', 'always'],
25
-
26
- // disallow use of console
27
- 'no-console': 'warn',
28
-
29
- // disallow use of constant expressions in conditions
30
- 'no-constant-condition': 'warn',
31
-
32
- // disallow control characters in regular expressions
33
- 'no-control-regex': 'error',
34
-
35
- // disallow use of debugger
36
- 'no-debugger': 'error',
37
-
38
- // disallow duplicate arguments in functions
39
- 'no-dupe-args': 'error',
40
-
41
- // Disallow duplicate conditions in if-else-if chains
42
- // https://eslint.org/docs/rules/no-dupe-else-if
43
- 'no-dupe-else-if': 'error',
44
-
45
- // disallow duplicate keys when creating object literals
46
- 'no-dupe-keys': 'error',
47
-
48
- // disallow a duplicate case label.
49
- 'no-duplicate-case': 'error',
50
-
51
- // disallow empty statements
52
- 'no-empty': 'error',
53
-
54
- // disallow the use of empty character classes in regular expressions
55
- 'no-empty-character-class': 'error',
56
-
57
- // disallow assigning to the exception in a catch block
58
- 'no-ex-assign': 'error',
59
-
60
- // disallow double-negation boolean casts in a boolean context
61
- // https://eslint.org/docs/rules/no-extra-boolean-cast
62
- 'no-extra-boolean-cast': 'error',
63
-
64
- // disallow unnecessary parentheses
65
- // https://eslint.org/docs/rules/no-extra-parens
66
- 'no-extra-parens': [
67
- 'off',
68
- 'all',
69
- {
70
- conditionalAssign: true,
71
- nestedBinaryExpressions: false,
72
- returnAssign: false,
73
- ignoreJSX: 'all', // delegate to eslint-plugin-react
74
- enforceForArrowConditionals: false,
75
- },
76
- ],
77
-
78
- // disallow unnecessary semicolons
79
- 'no-extra-semi': 'error',
80
-
81
- // disallow overwriting functions written as function declarations
82
- 'no-func-assign': 'error',
83
-
84
- // https://eslint.org/docs/rules/no-import-assign
85
- 'no-import-assign': 'error',
86
-
87
- // disallow function or variable declarations in nested blocks
88
- 'no-inner-declarations': 'error',
89
-
90
- // disallow invalid regular expression strings in the RegExp constructor
91
- 'no-invalid-regexp': 'error',
92
-
93
- // disallow irregular whitespace outside of strings and comments
94
- 'no-irregular-whitespace': 'error',
95
-
96
- // Disallow Number Literals That Lose Precision
97
- // https://eslint.org/docs/rules/no-loss-of-precision
98
- 'no-loss-of-precision': 'error',
99
-
100
- // Disallow characters which are made with multiple code points in character class syntax
101
- // https://eslint.org/docs/rules/no-misleading-character-class
102
- 'no-misleading-character-class': 'error',
103
-
104
- // disallow the use of object properties of the global object (Math and JSON) as functions
105
- 'no-obj-calls': 'error',
106
-
107
- // Disallow returning values from Promise executor functions
108
- // https://eslint.org/docs/rules/no-promise-executor-return
109
- 'no-promise-executor-return': 'error',
110
-
111
- // disallow use of Object.prototypes builtins directly
112
- // https://eslint.org/docs/rules/no-prototype-builtins
113
- 'no-prototype-builtins': 'error',
114
-
115
- // disallow multiple spaces in a regular expression literal
116
- 'no-regex-spaces': 'error',
117
-
118
- // Disallow returning values from setters
119
- // https://eslint.org/docs/rules/no-setter-return
120
- 'no-setter-return': 'error',
121
-
122
- // disallow sparse arrays
123
- 'no-sparse-arrays': 'error',
124
-
125
- // Disallow template literal placeholder syntax in regular strings
126
- // https://eslint.org/docs/rules/no-template-curly-in-string
127
- 'no-template-curly-in-string': 'error',
128
-
129
- // Avoid code that looks like two expressions but is actually one
130
- // https://eslint.org/docs/rules/no-unexpected-multiline
131
- 'no-unexpected-multiline': 'error',
132
-
133
- // disallow unreachable statements after a return, throw, continue, or break statement
134
- 'no-unreachable': 'error',
135
-
136
- // Disallow loops with a body that allows only one iteration
137
- // https://eslint.org/docs/rules/no-unreachable-loop
138
- 'no-unreachable-loop': [
139
- 'error',
140
- {
141
- ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
142
- },
143
- ],
144
-
145
- // disallow return/throw/break/continue inside finally blocks
146
- // https://eslint.org/docs/rules/no-unsafe-finally
147
- 'no-unsafe-finally': 'error',
148
-
149
- // disallow negating the left operand of relational operators
150
- // https://eslint.org/docs/rules/no-unsafe-negation
151
- 'no-unsafe-negation': 'error',
152
-
153
- // disallow use of optional chaining in contexts where the undefined value is not allowed
154
- // https://eslint.org/docs/rules/no-unsafe-optional-chaining
155
- 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
156
-
157
- // Disallow Unused Private Class Members
158
- // https://eslint.org/docs/rules/no-unused-private-class-members
159
- // TODO: enable once eslint 7 is dropped (which is semver-major)
160
- 'no-unused-private-class-members': 'off',
161
-
162
- // Disallow useless backreferences in regular expressions
163
- // https://eslint.org/docs/rules/no-useless-backreference
164
- 'no-useless-backreference': 'error',
165
-
166
- // disallow negation of the left operand of an in expression
167
- // deprecated in favor of no-unsafe-negation
168
- 'no-negated-in-lhs': 'off',
169
-
170
- // Disallow assignments that can lead to race conditions due to usage of await or yield
171
- // https://eslint.org/docs/rules/require-atomic-updates
172
- // note: not enabled because it is very buggy
173
- 'require-atomic-updates': 'off',
174
-
175
- // disallow comparisons with the value NaN
176
- 'use-isnan': 'error',
177
-
178
- // ensure JSDoc comments are valid
179
- // https://eslint.org/docs/rules/valid-jsdoc
180
- 'valid-jsdoc': 'off',
181
-
182
- // ensure that the results of typeof are compared against a valid string
183
- // https://eslint.org/docs/rules/valid-typeof
184
- 'valid-typeof': ['error', { requireStringLiterals: true }],
185
- },
186
- };