@croct/eslint-plugin 0.7.1 → 0.8.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,265 +1,912 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.javascript = void 0;
4
- exports.javascript = {
5
- extends: [
6
- 'plugin:jest/recommended',
7
- 'airbnb-base',
8
- 'plugin:eslint-comments/recommended',
9
- ],
10
- plugins: [
11
- 'jest',
12
- 'import',
13
- 'no-smart-quotes',
14
- 'import-newlines',
15
- 'newline-destructuring',
16
- '@croct',
6
+ exports.baseRules = void 0;
7
+ exports.createJavaScriptConfig = createJavaScriptConfig;
8
+ const globals_1 = __importDefault(require("globals"));
9
+ const eslint_plugin_jest_1 = __importDefault(require("eslint-plugin-jest"));
10
+ const eslint_plugin_import_x_1 = require("eslint-plugin-import-x");
11
+ // @ts-expect-error - no types available
12
+ const eslint_plugin_eslint_comments_1 = __importDefault(require("@eslint-community/eslint-plugin-eslint-comments"));
13
+ // @ts-expect-error - no types available
14
+ const eslint_plugin_import_newlines_1 = __importDefault(require("eslint-plugin-import-newlines"));
15
+ // @ts-expect-error - no types available
16
+ const eslint_plugin_newline_destructuring_1 = __importDefault(require("eslint-plugin-newline-destructuring"));
17
+ // @ts-expect-error - no types available
18
+ const eslint_plugin_1 = __importDefault(require("@stylistic/eslint-plugin"));
19
+ const baseRules = {
20
+ // Custom rules
21
+ '@croct/argument-spacing': 'error',
22
+ '@croct/complex-expression-spacing': 'error',
23
+ '@croct/newline-per-chained-call': 'error',
24
+ '@croct/min-chained-call-depth': 'error',
25
+ '@croct/parameter-destructuring': 'error',
26
+ // ESLint comments rules
27
+ '@eslint-community/eslint-comments/disable-enable-pair': [
28
+ 'error',
29
+ {
30
+ allowWholeFile: true,
31
+ },
17
32
  ],
18
- rules: {
19
- '@croct/argument-spacing': 'error',
20
- '@croct/complex-expression-spacing': 'error',
21
- '@croct/newline-per-chained-call': 'error',
22
- '@croct/min-chained-call-depth': 'error',
23
- '@croct/parameter-destructuring': 'error',
24
- 'eslint-comments/disable-enable-pair': [
25
- 'error',
26
- {
27
- allowWholeFile: true,
28
- },
29
- ],
30
- 'eslint-comments/require-description': 'error',
31
- 'eslint-comments/no-unused-disable': 'error',
32
- 'newline-per-chained-call': 'off',
33
- 'no-plusplus': 'off',
34
- 'array-bracket-newline': [
35
- 'error',
36
- 'consistent',
37
- ],
38
- 'multiline-ternary': [
39
- 'error',
40
- 'always-multiline',
41
- ],
42
- 'no-undef-init': 'error',
43
- 'jest/consistent-test-it': [
44
- 'error',
45
- {
46
- fn: 'it',
47
- },
48
- ],
49
- 'jest/no-large-snapshots': 'off',
50
- 'jest/prefer-expect-resolves': 'error',
51
- 'jest/prefer-lowercase-title': [
52
- 'error',
53
- {
54
- ignore: ['describe'],
55
- },
56
- ],
57
- 'jest/prefer-spy-on': 'error',
58
- 'jest/require-top-level-describe': 'error',
59
- 'jest/prefer-to-contain': 'error',
60
- 'jest/prefer-hooks-on-top': 'error',
61
- 'jest/prefer-equality-matcher': 'error',
62
- 'jest/no-test-return-statement': 'error',
63
- 'function-call-argument-newline': [
64
- 'error',
65
- 'consistent',
66
- ],
67
- 'no-underscore-dangle': 'off',
68
- 'import/no-default-export': 'error',
69
- 'array-element-newline': [
70
- 'error',
71
- 'consistent',
72
- ],
73
- 'import-newlines/enforce': [
74
- 'error',
75
- {
76
- items: 6,
77
- 'max-len': 120,
78
- },
79
- ],
80
- 'no-smart-quotes/no-smart-quotes': 'error',
81
- 'no-shadow': 'error',
82
- 'import/prefer-default-export': 'off',
83
- 'import/no-extraneous-dependencies': 'off',
84
- 'no-use-before-define': [
85
- 'error',
86
- {
87
- functions: false,
33
+ '@eslint-community/eslint-comments/require-description': 'error',
34
+ '@eslint-community/eslint-comments/no-unused-disable': 'error',
35
+ // Best practices (from airbnb-base)
36
+ 'accessor-pairs': 'off',
37
+ 'array-callback-return': ['error', { allowImplicit: true }],
38
+ 'block-scoped-var': 'error',
39
+ complexity: ['off', 20],
40
+ 'class-methods-use-this': 'off',
41
+ 'consistent-return': 'off',
42
+ curly: ['error', 'multi-line'],
43
+ 'default-case': 'off',
44
+ 'default-case-last': 'error',
45
+ 'default-param-last': 'error',
46
+ 'dot-notation': ['error', { allowKeywords: true }],
47
+ '@stylistic/dot-location': ['error', 'property'],
48
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
49
+ 'grouped-accessor-pairs': 'error',
50
+ 'guard-for-in': 'error',
51
+ 'max-classes-per-file': 'off',
52
+ 'no-alert': 'warn',
53
+ 'no-caller': 'error',
54
+ 'no-case-declarations': 'error',
55
+ 'no-constructor-return': 'error',
56
+ 'no-div-regex': 'off',
57
+ 'no-else-return': ['error', { allowElseIf: false }],
58
+ 'no-empty-function': ['error', {
59
+ allow: [
60
+ 'arrowFunctions',
61
+ 'functions',
62
+ 'methods',
63
+ ],
64
+ }],
65
+ 'no-empty-pattern': 'error',
66
+ 'no-eq-null': 'off',
67
+ 'no-eval': 'error',
68
+ 'no-extend-native': 'error',
69
+ 'no-extra-bind': 'error',
70
+ 'no-extra-label': 'error',
71
+ 'no-fallthrough': 'error',
72
+ '@stylistic/no-floating-decimal': 'error',
73
+ 'no-global-assign': ['error', { exceptions: [] }],
74
+ 'no-native-reassign': 'off',
75
+ 'no-implicit-coercion': ['off', {
76
+ boolean: false,
77
+ number: true,
78
+ string: true,
79
+ allow: [],
80
+ }],
81
+ 'no-implicit-globals': 'off',
82
+ 'no-implied-eval': 'error',
83
+ 'no-invalid-this': 'off',
84
+ 'no-iterator': 'error',
85
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
86
+ 'no-lone-blocks': 'error',
87
+ 'no-loop-func': 'error',
88
+ 'no-magic-numbers': ['off', {
89
+ ignore: [],
90
+ ignoreArrayIndexes: true,
91
+ enforceConst: true,
92
+ detectObjects: false,
93
+ }],
94
+ '@stylistic/no-multi-spaces': ['error', {
95
+ ignoreEOLComments: false,
96
+ }],
97
+ 'no-multi-str': 'error',
98
+ 'no-new': 'error',
99
+ 'no-new-func': 'error',
100
+ 'no-new-wrappers': 'error',
101
+ 'no-nonoctal-decimal-escape': 'error',
102
+ 'no-octal': 'error',
103
+ 'no-octal-escape': 'error',
104
+ 'no-param-reassign': ['error', {
105
+ props: true,
106
+ ignorePropertyModificationsFor: [
107
+ 'acc',
108
+ 'accumulator',
109
+ 'e',
110
+ 'ctx',
111
+ 'context',
112
+ 'req',
113
+ 'request',
114
+ 'res',
115
+ 'response',
116
+ '$scope',
117
+ 'staticContext',
118
+ ],
119
+ }],
120
+ 'no-proto': 'error',
121
+ 'no-redeclare': 'error',
122
+ 'no-restricted-properties': ['error', {
123
+ object: 'arguments',
124
+ property: 'callee',
125
+ message: 'arguments.callee is deprecated',
126
+ }, {
127
+ object: 'global',
128
+ property: 'isFinite',
129
+ message: 'Please use Number.isFinite instead',
130
+ }, {
131
+ object: 'self',
132
+ property: 'isFinite',
133
+ message: 'Please use Number.isFinite instead',
134
+ }, {
135
+ object: 'window',
136
+ property: 'isFinite',
137
+ message: 'Please use Number.isFinite instead',
138
+ }, {
139
+ object: 'global',
140
+ property: 'isNaN',
141
+ message: 'Please use Number.isNaN instead',
142
+ }, {
143
+ object: 'self',
144
+ property: 'isNaN',
145
+ message: 'Please use Number.isNaN instead',
146
+ }, {
147
+ object: 'window',
148
+ property: 'isNaN',
149
+ message: 'Please use Number.isNaN instead',
150
+ }, {
151
+ property: '__defineGetter__',
152
+ message: 'Please use Object.defineProperty instead.',
153
+ }, {
154
+ property: '__defineSetter__',
155
+ message: 'Please use Object.defineProperty instead.',
156
+ }, {
157
+ object: 'Math',
158
+ property: 'pow',
159
+ message: 'Use the exponentiation operator (**) instead.',
160
+ }],
161
+ 'no-return-assign': ['error', 'always'],
162
+ 'no-return-await': 'error',
163
+ 'no-script-url': 'error',
164
+ 'no-self-assign': ['error', {
165
+ props: true,
166
+ }],
167
+ 'no-self-compare': 'error',
168
+ 'no-sequences': 'error',
169
+ 'no-throw-literal': 'error',
170
+ 'no-unmodified-loop-condition': 'off',
171
+ 'no-unused-expressions': 'error',
172
+ 'no-unused-labels': 'error',
173
+ 'no-useless-call': 'off',
174
+ 'no-useless-catch': 'error',
175
+ 'no-useless-concat': 'error',
176
+ 'no-useless-escape': 'error',
177
+ 'no-useless-return': 'error',
178
+ 'no-void': 'error',
179
+ 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
180
+ 'no-with': 'error',
181
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
182
+ 'prefer-named-capture-group': 'off',
183
+ 'prefer-regex-literals': ['error', {
184
+ disallowRedundantWrapping: true,
185
+ }],
186
+ radix: 'error',
187
+ 'require-await': 'error',
188
+ 'require-unicode-regexp': 'off',
189
+ 'vars-on-top': 'error',
190
+ '@stylistic/wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
191
+ yoda: 'error',
192
+ // Errors (from airbnb-base)
193
+ 'for-direction': 'error',
194
+ 'getter-return': ['error', { allowImplicit: true }],
195
+ 'no-async-promise-executor': 'error',
196
+ 'no-await-in-loop': 'off',
197
+ 'no-compare-neg-zero': 'error',
198
+ 'no-cond-assign': ['error', 'always'],
199
+ 'no-console': 'warn',
200
+ 'no-constant-condition': 'warn',
201
+ 'no-control-regex': 'error',
202
+ 'no-debugger': 'error',
203
+ 'no-dupe-args': 'error',
204
+ 'no-dupe-else-if': 'error',
205
+ 'no-dupe-keys': 'error',
206
+ 'no-duplicate-case': 'error',
207
+ 'no-empty': 'error',
208
+ 'no-empty-character-class': 'error',
209
+ 'no-ex-assign': 'error',
210
+ 'no-extra-boolean-cast': 'error',
211
+ '@stylistic/no-extra-parens': ['off', 'all', {
212
+ conditionalAssign: true,
213
+ nestedBinaryExpressions: false,
214
+ returnAssign: false,
215
+ ignoreJSX: 'all',
216
+ enforceForArrowConditionals: false,
217
+ }],
218
+ '@stylistic/no-extra-semi': 'error',
219
+ 'no-func-assign': 'error',
220
+ 'no-import-assign': 'error',
221
+ 'no-inner-declarations': 'error',
222
+ 'no-invalid-regexp': 'error',
223
+ 'no-irregular-whitespace': 'error',
224
+ 'no-loss-of-precision': 'error',
225
+ 'no-misleading-character-class': 'error',
226
+ 'no-obj-calls': 'error',
227
+ 'no-promise-executor-return': 'error',
228
+ 'no-prototype-builtins': 'error',
229
+ 'no-regex-spaces': 'error',
230
+ 'no-setter-return': 'error',
231
+ 'no-sparse-arrays': 'error',
232
+ 'no-template-curly-in-string': 'error',
233
+ 'no-unexpected-multiline': 'error',
234
+ 'no-unreachable': 'error',
235
+ 'no-unreachable-loop': ['error', {
236
+ ignore: [],
237
+ }],
238
+ 'no-unsafe-finally': 'error',
239
+ 'no-unsafe-negation': 'error',
240
+ 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
241
+ 'no-unused-private-class-members': 'off',
242
+ 'no-useless-backreference': 'error',
243
+ 'no-negated-in-lhs': 'off',
244
+ 'require-atomic-updates': 'off',
245
+ 'use-isnan': 'error',
246
+ 'valid-jsdoc': 'off',
247
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
248
+ // Style (from airbnb-base, with customizations)
249
+ '@stylistic/array-bracket-newline': ['error', 'consistent'],
250
+ '@stylistic/array-element-newline': ['error', 'consistent'],
251
+ '@stylistic/array-bracket-spacing': ['error', 'never'],
252
+ '@stylistic/block-spacing': ['error', 'always'],
253
+ '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
254
+ camelcase: ['error', { properties: 'never', ignoreDestructuring: false }],
255
+ 'capitalized-comments': ['off', 'never', {
256
+ line: {
257
+ ignorePattern: '.*',
258
+ ignoreInlineComments: true,
259
+ ignoreConsecutiveComments: true,
88
260
  },
89
- ],
90
- 'arrow-parens': [
91
- 'error',
92
- 'as-needed',
93
- ],
94
- 'class-methods-use-this': 'off',
95
- 'consistent-return': 'off',
96
- 'default-case': 'off',
97
- 'import/extensions': [
98
- 'error',
99
- 'never',
100
- {
101
- d: 'always',
102
- json: 'always',
261
+ block: {
262
+ ignorePattern: '.*',
263
+ ignoreInlineComments: true,
264
+ ignoreConsecutiveComments: true,
103
265
  },
104
- ],
105
- 'import/no-unresolved': 'off',
106
- indent: [
107
- 'error',
108
- 4,
109
- {
110
- SwitchCase: 1,
266
+ }],
267
+ '@stylistic/comma-dangle': ['error', {
268
+ arrays: 'always-multiline',
269
+ objects: 'always-multiline',
270
+ imports: 'always-multiline',
271
+ exports: 'always-multiline',
272
+ functions: 'always-multiline',
273
+ }],
274
+ '@stylistic/comma-spacing': ['error', { before: false, after: true }],
275
+ '@stylistic/comma-style': ['error', 'last', {
276
+ exceptions: {
277
+ ArrayExpression: false,
278
+ ArrayPattern: false,
279
+ ArrowFunctionExpression: false,
280
+ CallExpression: false,
281
+ FunctionDeclaration: false,
282
+ FunctionExpression: false,
283
+ ImportDeclaration: false,
284
+ ObjectExpression: false,
285
+ ObjectPattern: false,
286
+ VariableDeclaration: false,
287
+ NewExpression: false,
111
288
  },
112
- ],
113
- 'linebreak-style': [
114
- 'error',
115
- 'unix',
116
- ],
117
- 'max-classes-per-file': 'off',
118
- 'max-len': [
119
- 'error',
120
- {
121
- code: 120,
122
- ignoreStrings: false,
123
- ignoreComments: false,
124
- ignoreTemplateLiterals: false,
125
- ignoreTrailingComments: false,
126
- ignoreUrls: false,
289
+ }],
290
+ '@stylistic/computed-property-spacing': ['error', 'never'],
291
+ 'consistent-this': 'off',
292
+ '@stylistic/eol-last': ['error', 'always'],
293
+ '@stylistic/function-call-argument-newline': ['error', 'consistent'],
294
+ 'func-call-spacing': ['error', 'never'],
295
+ 'func-name-matching': ['off', 'always', {
296
+ includeCommonJSModuleExports: false,
297
+ considerPropertyDescriptor: true,
298
+ }],
299
+ 'func-names': 'warn',
300
+ 'func-style': ['off', 'expression'],
301
+ '@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
302
+ 'id-denylist': 'off',
303
+ 'id-length': 'off',
304
+ 'id-match': 'off',
305
+ '@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
306
+ '@stylistic/indent': [
307
+ 'error',
308
+ 4,
309
+ {
310
+ SwitchCase: 1,
311
+ VariableDeclarator: 1,
312
+ outerIIFEBody: 1,
313
+ FunctionDeclaration: {
314
+ parameters: 1,
315
+ body: 1,
127
316
  },
128
- ],
129
- 'no-await-in-loop': 'off',
130
- 'no-bitwise': 'off',
131
- 'no-continue': 'off',
132
- 'no-multiple-empty-lines': [
133
- 'error',
134
- {
135
- max: 1,
136
- maxEOF: 0,
137
- maxBOF: 0,
317
+ FunctionExpression: {
318
+ parameters: 1,
319
+ body: 1,
138
320
  },
139
- ],
140
- 'no-unused-expressions': 'error',
141
- 'no-unused-vars': [
142
- 'error',
143
- {
144
- args: 'after-used',
145
- ignoreRestSiblings: true,
321
+ CallExpression: {
322
+ arguments: 1,
146
323
  },
147
- ],
148
- 'no-restricted-syntax': [
149
- 'error',
150
- 'ForInStatement',
151
- 'LabeledStatement',
152
- 'WithStatement',
153
- ],
154
- 'object-curly-newline': [
155
- 'error',
156
- {
157
- multiline: true,
158
- consistent: true,
324
+ ArrayExpression: 1,
325
+ ObjectExpression: 1,
326
+ ImportDeclaration: 1,
327
+ flatTernaryExpressions: false,
328
+ ignoredNodes: [
329
+ 'JSXElement',
330
+ 'JSXElement > *',
331
+ 'JSXAttribute',
332
+ 'JSXIdentifier',
333
+ 'JSXNamespacedName',
334
+ 'JSXMemberExpression',
335
+ 'JSXSpreadAttribute',
336
+ 'JSXExpressionContainer',
337
+ 'JSXOpeningElement',
338
+ 'JSXClosingElement',
339
+ 'JSXFragment',
340
+ 'JSXOpeningFragment',
341
+ 'JSXClosingFragment',
342
+ 'JSXText',
343
+ 'JSXEmptyExpression',
344
+ 'JSXSpreadChild',
345
+ ],
346
+ ignoreComments: false,
347
+ },
348
+ ],
349
+ 'jsx-quotes': ['error', 'prefer-double'],
350
+ '@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
351
+ '@stylistic/keyword-spacing': ['error', {
352
+ before: true,
353
+ after: true,
354
+ overrides: {
355
+ return: { after: true },
356
+ throw: { after: true },
357
+ case: { after: true },
159
358
  },
160
- ],
161
- 'object-curly-spacing': [
162
- 'error',
163
- 'never',
164
- ],
165
- 'require-await': 'error',
166
- 'object-shorthand': [
167
- 'error',
168
- 'never',
169
- ],
170
- 'padding-line-between-statements': [
171
- 'error',
172
- {
173
- blankLine: 'always',
174
- prev: '*',
175
- next: [
176
- 'try',
177
- ],
359
+ }],
360
+ 'line-comment-position': ['off', {
361
+ position: 'above',
362
+ ignorePattern: '',
363
+ applyDefaultPatterns: true,
364
+ }],
365
+ '@stylistic/linebreak-style': ['error', 'unix'],
366
+ '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
367
+ '@stylistic/lines-around-comment': 'off',
368
+ 'lines-around-directive': ['error', {
369
+ before: 'always',
370
+ after: 'always',
371
+ }],
372
+ 'max-depth': ['off', 4],
373
+ 'max-len': [
374
+ 'error',
375
+ {
376
+ code: 120,
377
+ ignoreStrings: false,
378
+ ignoreComments: false,
379
+ ignoreTemplateLiterals: false,
380
+ ignoreTrailingComments: false,
381
+ ignoreUrls: false,
382
+ },
383
+ ],
384
+ 'max-lines': ['off', {
385
+ max: 300,
386
+ skipBlankLines: true,
387
+ skipComments: true,
388
+ }],
389
+ 'max-lines-per-function': ['off', {
390
+ max: 50,
391
+ skipBlankLines: true,
392
+ skipComments: true,
393
+ IIFEs: true,
394
+ }],
395
+ 'max-nested-callbacks': 'off',
396
+ 'max-params': ['off', 3],
397
+ 'max-statements': ['off', 10],
398
+ 'max-statements-per-line': ['off', { max: 1 }],
399
+ '@stylistic/multiline-comment-style': ['off', 'starred-block'],
400
+ '@stylistic/multiline-ternary': ['error', 'always-multiline'],
401
+ 'new-cap': ['error', {
402
+ newIsCap: true,
403
+ newIsCapExceptions: [],
404
+ capIsNew: false,
405
+ capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
406
+ }],
407
+ '@stylistic/new-parens': 'error',
408
+ 'newline-after-var': 'off',
409
+ 'newline-before-return': 'off',
410
+ '@stylistic/newline-per-chained-call': 'off',
411
+ 'no-array-constructor': 'error',
412
+ 'no-bitwise': 'off',
413
+ 'no-continue': 'off',
414
+ 'no-inline-comments': 'off',
415
+ 'no-lonely-if': 'error',
416
+ 'no-mixed-operators': ['error', {
417
+ groups: [
418
+ ['%', '**'],
419
+ ['%', '+'],
420
+ ['%', '-'],
421
+ ['%', '*'],
422
+ ['%', '/'],
423
+ ['/', '*'],
424
+ ['&', '|', '<<', '>>', '>>>'],
425
+ ['==', '!=', '===', '!=='],
426
+ ['&&', '||'],
427
+ ],
428
+ allowSamePrecedence: false,
429
+ }],
430
+ 'no-mixed-spaces-and-tabs': 'error',
431
+ 'no-multi-assign': ['error'],
432
+ '@stylistic/no-multiple-empty-lines': [
433
+ 'error',
434
+ {
435
+ max: 1,
436
+ maxEOF: 0,
437
+ maxBOF: 0,
438
+ },
439
+ ],
440
+ 'no-negated-condition': 'off',
441
+ 'no-nested-ternary': 'error',
442
+ 'no-new-object': 'error',
443
+ 'no-plusplus': 'off',
444
+ 'no-restricted-syntax': [
445
+ 'error',
446
+ 'ForInStatement',
447
+ 'LabeledStatement',
448
+ 'WithStatement',
449
+ ],
450
+ 'no-spaced-func': 'error',
451
+ 'no-tabs': 'error',
452
+ 'no-ternary': 'off',
453
+ '@stylistic/no-trailing-spaces': ['error', {
454
+ skipBlankLines: false,
455
+ ignoreComments: false,
456
+ }],
457
+ 'no-underscore-dangle': 'off',
458
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
459
+ '@stylistic/no-whitespace-before-property': 'error',
460
+ '@stylistic/nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
461
+ '@stylistic/object-curly-spacing': ['error', 'never'],
462
+ '@stylistic/object-curly-newline': [
463
+ 'error',
464
+ {
465
+ multiline: true,
466
+ consistent: true,
467
+ },
468
+ ],
469
+ '@stylistic/object-property-newline': ['error', {
470
+ allowAllPropertiesOnSameLine: true,
471
+ }],
472
+ 'one-var': ['error', 'never'],
473
+ '@stylistic/one-var-declaration-per-line': ['error', 'always'],
474
+ 'operator-assignment': ['error', 'always'],
475
+ '@stylistic/operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
476
+ '@stylistic/padded-blocks': ['error', {
477
+ blocks: 'never',
478
+ classes: 'never',
479
+ switches: 'never',
480
+ }, {
481
+ allowSingleLineBlocks: true,
482
+ }],
483
+ '@stylistic/padding-line-between-statements': [
484
+ 'error',
485
+ {
486
+ blankLine: 'always',
487
+ prev: '*',
488
+ next: [
489
+ 'try',
490
+ ],
491
+ },
492
+ {
493
+ blankLine: 'always',
494
+ prev: [
495
+ 'break',
496
+ 'return',
497
+ ],
498
+ next: [
499
+ 'case',
500
+ 'default',
501
+ ],
502
+ },
503
+ {
504
+ blankLine: 'always',
505
+ prev: [
506
+ 'const',
507
+ 'let',
508
+ 'var',
509
+ ],
510
+ next: '*',
511
+ },
512
+ {
513
+ blankLine: 'any',
514
+ prev: [
515
+ 'const',
516
+ 'let',
517
+ 'var',
518
+ ],
519
+ next: [
520
+ 'const',
521
+ 'let',
522
+ 'var',
523
+ ],
524
+ },
525
+ {
526
+ blankLine: 'always',
527
+ prev: '*',
528
+ next: [
529
+ 'break',
530
+ 'continue',
531
+ 'return',
532
+ 'if',
533
+ 'function',
534
+ 'block',
535
+ 'block-like',
536
+ ],
537
+ },
538
+ {
539
+ blankLine: 'any',
540
+ prev: [
541
+ 'case',
542
+ ],
543
+ next: [
544
+ 'case',
545
+ ],
546
+ },
547
+ ],
548
+ 'prefer-exponentiation-operator': 'error',
549
+ 'prefer-object-spread': 'error',
550
+ '@stylistic/quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
551
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
552
+ 'require-jsdoc': 'off',
553
+ '@stylistic/semi': ['error', 'always'],
554
+ '@stylistic/semi-spacing': ['error', { before: false, after: true }],
555
+ '@stylistic/semi-style': ['error', 'last'],
556
+ 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
557
+ 'sort-vars': 'off',
558
+ '@stylistic/space-before-blocks': 'error',
559
+ '@stylistic/space-before-function-paren': ['error', {
560
+ anonymous: 'always',
561
+ named: 'never',
562
+ asyncArrow: 'always',
563
+ }],
564
+ '@stylistic/space-in-parens': ['error', 'never'],
565
+ '@stylistic/space-infix-ops': 'error',
566
+ '@stylistic/space-unary-ops': ['error', {
567
+ words: true,
568
+ nonwords: false,
569
+ overrides: {},
570
+ }],
571
+ '@stylistic/spaced-comment': ['error', 'always', {
572
+ line: {
573
+ exceptions: ['-', '+'],
574
+ markers: ['=', '!', '/'],
178
575
  },
179
- {
180
- blankLine: 'always',
181
- prev: [
182
- 'break',
183
- 'return',
184
- ],
185
- next: [
186
- 'case',
187
- 'default',
188
- ],
576
+ block: {
577
+ exceptions: ['-', '+'],
578
+ markers: ['=', '!', ':', '::'],
579
+ balanced: true,
189
580
  },
190
- {
191
- blankLine: 'always',
192
- prev: [
193
- 'const',
194
- 'let',
195
- 'var',
196
- ],
197
- next: '*',
581
+ }],
582
+ '@stylistic/switch-colon-spacing': ['error', { after: true, before: false }],
583
+ '@stylistic/template-tag-spacing': ['error', 'never'],
584
+ 'unicode-bom': ['error', 'never'],
585
+ '@stylistic/wrap-regex': 'off',
586
+ // ES6 (from airbnb-base)
587
+ 'arrow-body-style': ['error', 'as-needed', {
588
+ requireReturnForObjectLiteral: false,
589
+ }],
590
+ '@stylistic/arrow-parens': ['error', 'as-needed'],
591
+ '@stylistic/arrow-spacing': ['error', { before: true, after: true }],
592
+ 'constructor-super': 'error',
593
+ '@stylistic/generator-star-spacing': ['error', { before: false, after: true }],
594
+ 'no-class-assign': 'error',
595
+ '@stylistic/no-confusing-arrow': ['error', {
596
+ allowParens: true,
597
+ }],
598
+ 'no-const-assign': 'error',
599
+ 'no-dupe-class-members': 'error',
600
+ 'no-duplicate-imports': 'off',
601
+ 'no-new-symbol': 'error',
602
+ 'no-restricted-exports': ['error', {
603
+ restrictedNamedExports: [
604
+ 'default',
605
+ 'then',
606
+ ],
607
+ }],
608
+ 'no-restricted-imports': ['off', {
609
+ paths: [],
610
+ patterns: [],
611
+ }],
612
+ 'no-this-before-super': 'error',
613
+ 'no-useless-computed-key': 'error',
614
+ 'no-useless-constructor': 'error',
615
+ 'no-useless-rename': ['error', {
616
+ ignoreDestructuring: false,
617
+ ignoreImport: false,
618
+ ignoreExport: false,
619
+ }],
620
+ 'no-var': 'error',
621
+ 'object-shorthand': ['error', 'never'],
622
+ 'prefer-arrow-callback': ['error', {
623
+ allowNamedFunctions: false,
624
+ allowUnboundThis: true,
625
+ }],
626
+ 'prefer-const': ['error', {
627
+ destructuring: 'any',
628
+ ignoreReadBeforeAssign: true,
629
+ }],
630
+ 'prefer-destructuring': ['error', {
631
+ VariableDeclarator: {
632
+ array: false,
633
+ object: true,
198
634
  },
199
- {
200
- blankLine: 'any',
201
- prev: [
202
- 'const',
203
- 'let',
204
- 'var',
205
- ],
206
- next: [
207
- 'const',
208
- 'let',
209
- 'var',
210
- ],
635
+ AssignmentExpression: {
636
+ array: true,
637
+ object: false,
211
638
  },
212
- {
213
- blankLine: 'always',
214
- prev: '*',
215
- next: [
216
- 'break',
217
- 'continue',
218
- 'return',
219
- 'if',
220
- 'function',
221
- 'block',
222
- 'block-like',
223
- ],
639
+ }, {
640
+ enforceForRenamedProperties: false,
641
+ }],
642
+ 'prefer-numeric-literals': 'error',
643
+ 'prefer-reflect': 'off',
644
+ 'prefer-rest-params': 'error',
645
+ 'prefer-spread': 'error',
646
+ 'prefer-template': 'error',
647
+ 'require-yield': 'error',
648
+ '@stylistic/rest-spread-spacing': ['error', 'never'],
649
+ 'sort-imports': ['off', {
650
+ ignoreCase: false,
651
+ ignoreDeclarationSort: false,
652
+ ignoreMemberSort: false,
653
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
654
+ }],
655
+ 'symbol-description': 'error',
656
+ '@stylistic/template-curly-spacing': 'error',
657
+ '@stylistic/yield-star-spacing': ['error', 'after'],
658
+ // Variables (from airbnb-base)
659
+ 'init-declarations': 'off',
660
+ 'no-catch-shadow': 'off',
661
+ 'no-delete-var': 'error',
662
+ 'no-label-var': 'error',
663
+ 'no-restricted-globals': [
664
+ 'error',
665
+ {
666
+ name: 'isFinite',
667
+ message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
668
+ },
669
+ {
670
+ name: 'isNaN',
671
+ message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
672
+ },
673
+ 'addEventListener',
674
+ 'blur',
675
+ 'close',
676
+ 'closed',
677
+ 'confirm',
678
+ 'defaultStatus',
679
+ 'defaultstatus',
680
+ 'event',
681
+ 'external',
682
+ 'find',
683
+ 'focus',
684
+ 'frameElement',
685
+ 'frames',
686
+ 'history',
687
+ 'innerHeight',
688
+ 'innerWidth',
689
+ 'length',
690
+ 'location',
691
+ 'locationbar',
692
+ 'menubar',
693
+ 'moveBy',
694
+ 'moveTo',
695
+ 'name',
696
+ 'onblur',
697
+ 'onerror',
698
+ 'onfocus',
699
+ 'onload',
700
+ 'onresize',
701
+ 'onunload',
702
+ 'open',
703
+ 'opener',
704
+ 'opera',
705
+ 'outerHeight',
706
+ 'outerWidth',
707
+ 'pageXOffset',
708
+ 'pageYOffset',
709
+ 'parent',
710
+ 'print',
711
+ 'removeEventListener',
712
+ 'resizeBy',
713
+ 'resizeTo',
714
+ 'screen',
715
+ 'screenLeft',
716
+ 'screenTop',
717
+ 'screenX',
718
+ 'screenY',
719
+ 'scroll',
720
+ 'scrollbars',
721
+ 'scrollBy',
722
+ 'scrollTo',
723
+ 'scrollX',
724
+ 'scrollY',
725
+ 'self',
726
+ 'status',
727
+ 'statusbar',
728
+ 'stop',
729
+ 'toolbar',
730
+ 'top',
731
+ ],
732
+ 'no-shadow': 'error',
733
+ 'no-shadow-restricted-names': 'error',
734
+ 'no-undef': 'error',
735
+ 'no-undef-init': 'error',
736
+ 'no-undefined': 'off',
737
+ 'no-unused-vars': [
738
+ 'error',
739
+ {
740
+ args: 'after-used',
741
+ ignoreRestSiblings: true,
742
+ },
743
+ ],
744
+ 'no-use-before-define': [
745
+ 'error',
746
+ {
747
+ functions: false,
748
+ },
749
+ ],
750
+ // Strict (from airbnb-base)
751
+ strict: ['error', 'never'],
752
+ // Node (from airbnb-base)
753
+ 'callback-return': 'off',
754
+ 'global-require': 'error',
755
+ 'handle-callback-err': 'off',
756
+ 'no-buffer-constructor': 'error',
757
+ 'no-mixed-requires': ['off', false],
758
+ 'no-new-require': 'error',
759
+ 'no-path-concat': 'error',
760
+ 'no-process-env': 'off',
761
+ 'no-process-exit': 'off',
762
+ 'no-restricted-modules': 'off',
763
+ 'no-sync': 'off',
764
+ // Import rules (from airbnb-base)
765
+ 'import-x/no-unresolved': 'off',
766
+ 'import-x/named': 'error',
767
+ 'import-x/default': 'off',
768
+ 'import-x/namespace': 'off',
769
+ 'import-x/export': 'error',
770
+ 'import-x/no-named-as-default': 'error',
771
+ 'import-x/no-named-as-default-member': 'error',
772
+ 'import-x/no-deprecated': 'off',
773
+ 'import-x/no-extraneous-dependencies': 'off',
774
+ 'import-x/no-mutable-exports': 'error',
775
+ 'import-x/no-commonjs': 'off',
776
+ 'import-x/no-amd': 'error',
777
+ 'import-x/no-nodejs-modules': 'off',
778
+ 'import-x/first': 'error',
779
+ 'import-x/imports-first': 'off',
780
+ 'import-x/no-duplicates': 'error',
781
+ 'import-x/no-namespace': 'off',
782
+ 'import-x/extensions': [
783
+ 'error',
784
+ 'never',
785
+ {
786
+ d: 'always',
787
+ json: 'always',
788
+ },
789
+ ],
790
+ 'import-x/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
791
+ 'import-x/newline-after-import': 'error',
792
+ 'import-x/prefer-default-export': 'off',
793
+ 'import-x/no-restricted-paths': 'off',
794
+ 'import-x/max-dependencies': ['off', { max: 10 }],
795
+ 'import-x/no-absolute-path': 'error',
796
+ 'import-x/no-dynamic-require': 'error',
797
+ 'import-x/no-internal-modules': ['off', {
798
+ allow: [],
799
+ }],
800
+ 'import-x/unambiguous': 'off',
801
+ 'import-x/no-webpack-loader-syntax': 'error',
802
+ 'import-x/no-unassigned-import': 'off',
803
+ 'import-x/no-named-default': 'error',
804
+ 'import-x/no-anonymous-default-export': ['off', {
805
+ allowArray: false,
806
+ allowArrowFunction: false,
807
+ allowAnonymousClass: false,
808
+ allowAnonymousFunction: false,
809
+ allowLiteral: false,
810
+ allowObject: false,
811
+ }],
812
+ 'import-x/exports-last': 'off',
813
+ 'import-x/group-exports': 'off',
814
+ 'import-x/no-default-export': 'error',
815
+ 'import-x/no-named-export': 'off',
816
+ 'import-x/no-self-import': 'error',
817
+ 'import-x/no-cycle': ['error', { maxDepth: Infinity }],
818
+ 'import-x/no-useless-path-segments': ['error', { commonjs: true }],
819
+ 'import-x/dynamic-import-chunkname': ['off', {
820
+ importFunctions: [],
821
+ webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
822
+ }],
823
+ 'import-x/no-relative-parent-imports': 'off',
824
+ 'import-x/no-unused-modules': ['off', {
825
+ ignoreExports: [],
826
+ missingExports: true,
827
+ unusedExports: true,
828
+ }],
829
+ 'import-x/no-import-module-exports': ['error', {
830
+ exceptions: [],
831
+ }],
832
+ 'import-x/no-relative-packages': 'error',
833
+ // Custom plugin rules
834
+ 'import-newlines/enforce': [
835
+ 'error',
836
+ {
837
+ items: 6,
838
+ 'max-len': 120,
839
+ },
840
+ ],
841
+ 'newline-destructuring/newline': [
842
+ 'error',
843
+ {
844
+ maxLength: 100,
845
+ itemsWithRest: Infinity,
846
+ items: Infinity,
847
+ },
848
+ ],
849
+ // Jest rules
850
+ 'jest/consistent-test-it': [
851
+ 'error',
852
+ {
853
+ fn: 'it',
854
+ },
855
+ ],
856
+ 'jest/no-large-snapshots': 'off',
857
+ 'jest/prefer-expect-resolves': 'error',
858
+ 'jest/prefer-lowercase-title': [
859
+ 'error',
860
+ {
861
+ ignore: ['describe'],
862
+ },
863
+ ],
864
+ 'jest/prefer-spy-on': 'error',
865
+ 'jest/require-top-level-describe': 'error',
866
+ 'jest/prefer-to-contain': 'error',
867
+ 'jest/prefer-hooks-on-top': 'error',
868
+ 'jest/prefer-equality-matcher': 'error',
869
+ 'jest/no-test-return-statement': 'error',
870
+ };
871
+ exports.baseRules = baseRules;
872
+ // Factory function to create JavaScript config with the plugin reference
873
+ function createJavaScriptConfig(plugin) {
874
+ return [
875
+ eslint_plugin_jest_1.default.configs['flat/recommended'],
876
+ {
877
+ name: '@croct/javascript',
878
+ plugins: {
879
+ '@stylistic': eslint_plugin_1.default,
880
+ '@eslint-community/eslint-comments': eslint_plugin_eslint_comments_1.default,
881
+ 'import-newlines': eslint_plugin_import_newlines_1.default,
882
+ // import-x exports types using ESLint v8 for compatibility reasons,
883
+ // but it is compatible with ESLint v9 as well.
884
+ 'import-x': eslint_plugin_import_x_1.importX,
885
+ 'newline-destructuring': eslint_plugin_newline_destructuring_1.default,
886
+ '@croct': plugin,
224
887
  },
225
- {
226
- blankLine: 'any',
227
- prev: [
228
- 'case',
229
- ],
230
- next: [
231
- 'case',
232
- ],
888
+ languageOptions: {
889
+ ecmaVersion: 2018,
890
+ sourceType: 'module',
891
+ globals: {
892
+ ...globals_1.default.es2017,
893
+ ...globals_1.default.node,
894
+ },
233
895
  },
234
- ],
235
- 'no-useless-escape': 'error',
236
- 'newline-destructuring/newline': [
237
- 'error',
238
- {
239
- maxLength: 100,
240
- itemsWithRest: Infinity,
241
- items: Infinity,
896
+ rules: {
897
+ ...eslint_plugin_eslint_comments_1.default.configs.recommended.rules,
898
+ ...baseRules,
242
899
  },
243
- ],
244
- 'jsx-quotes': [
245
- 'error',
246
- 'prefer-double',
247
- ],
248
- },
249
- overrides: [
900
+ },
250
901
  {
902
+ name: '@croct/javascript/tests',
251
903
  files: [
252
904
  'src/**/*.test.js',
253
905
  'test/**/*.js',
254
906
  ],
255
- extends: ['plugin:jest/recommended'],
256
- plugins: ['jest'],
257
907
  rules: {
258
908
  'no-new-object': 'off',
259
909
  },
260
- env: {
261
- jest: true,
262
- },
263
910
  },
264
- ],
265
- };
911
+ ];
912
+ }