@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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [21.2.1](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v21.2.0...v21.2.1) (2025-08-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove unused eslint9 package.json ([cda17cd](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/cda17cd59058bc5a9563e5c98a2aa0a92a476a8f))
7
+
8
+ # [21.2.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v21.1.0...v21.2.0) (2025-07-10)
9
+
10
+
11
+ ### Features
12
+
13
+ * **jest:** Adds jest/prefer-to-have-length rule ([fcc6d27](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/fcc6d27fa8d210af327089e23fc1a0051d7da8ca))
14
+
1
15
  # [21.1.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v21.0.0...v21.1.0) (2025-06-20)
2
16
 
3
17
 
package/README.md CHANGED
@@ -25,6 +25,19 @@ upstream later.
25
25
 
26
26
  The TS portion of this plugin has been migrated to eslint v9 and can be used as `const gitlabPlugin = require('@gitlab/eslint-plugin/eslint9');`. You still add the `@gitlab/eslint-plugin` as a dependency.
27
27
 
28
+ Add these overrides to your project's package.json:
29
+
30
+ ```json
31
+ "overrides": {
32
+ "@gitlab/eslint-plugin": {
33
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
34
+ "@typescript-eslint/parser": "^8.38.0"
35
+ }
36
+ }
37
+ ```
38
+
39
+ (replace the versions with what your main project uses)
40
+
28
41
  ## Contribution guidelines
29
42
 
30
43
  Please refer to
@@ -5,14 +5,14 @@ const promisePlugin = require('eslint-plugin-promise');
5
5
  const importPlugin = require('eslint-plugin-import');
6
6
 
7
7
  // Import all the base configurations
8
- const bestPracticesConfig = require('./base/best-practices');
9
- const errorsConfig = require('./base/errors');
10
- const nodeConfig = require('./base/node');
11
- const styleConfig = require('./base/style');
12
- const variablesConfig = require('./base/variables');
13
- const es6Config = require('./base/es6');
14
- const importsConfig = require('./base/imports');
15
- const strictConfig = require('./base/strict');
8
+ const bestPracticesConfig = require('../../lib/configs/base/best-practices');
9
+ const errorsConfig = require('../../lib/configs/base/errors');
10
+ const nodeConfig = require('../../lib/configs/base/node');
11
+ const styleConfig = require('../../lib/configs/base/style');
12
+ const variablesConfig = require('../../lib/configs/base/variables');
13
+ const es6Config = require('../../lib/configs/base/es6');
14
+ const importsConfig = require('../../lib/configs/base/imports');
15
+ const strictConfig = require('../../lib/configs/base/strict');
16
16
 
17
17
  /*
18
18
  This plugin contains rules related to GitLab JavaScript style guide
@@ -16,5 +16,6 @@ module.exports = {
16
16
  toBeTruthy: 'Prefer a stronger matcher like `toBe(true)`',
17
17
  },
18
18
  ],
19
+ 'jest/prefer-to-have-length': 'error',
19
20
  },
20
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/eslint-plugin",
3
- "version": "21.1.0",
3
+ "version": "21.2.1",
4
4
  "description": "GitLab package for our custom eslint rules",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -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
- };