@mikey-pro/eslint-config 8.0.14 → 8.0.16
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/index.js +2 -0
- package/overrides.js +14 -4
- package/package.json +1 -1
- package/rules.js +48 -110
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import importSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
|
14
14
|
import perfectionistPlugin from 'eslint-plugin-perfectionist';
|
|
15
15
|
import noSecretsPlugin from 'eslint-plugin-no-secrets';
|
|
16
16
|
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests';
|
|
17
|
+
// Remove jest plugin import since it's now in overrides.js
|
|
17
18
|
|
|
18
19
|
import { baseOverrides } from './overrides.js';
|
|
19
20
|
import { baseRules } from './rules.js';
|
|
@@ -81,6 +82,7 @@ const config = [
|
|
|
81
82
|
perfectionist: perfectionistPlugin,
|
|
82
83
|
'no-secrets': noSecretsPlugin,
|
|
83
84
|
'no-only-tests': noOnlyTestsPlugin,
|
|
85
|
+
// Remove jest plugin from here since it's in overrides
|
|
84
86
|
},
|
|
85
87
|
rules: {
|
|
86
88
|
...baseRules,
|
package/overrides.js
CHANGED
|
@@ -4,6 +4,7 @@ import typescriptParser from '@typescript-eslint/parser';
|
|
|
4
4
|
import typeScriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
5
|
import importPlugin from 'eslint-plugin-import';
|
|
6
6
|
import markdownPlugin from 'eslint-plugin-markdownlint';
|
|
7
|
+
import jestPlugin from 'eslint-plugin-jest';
|
|
7
8
|
|
|
8
9
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
|
|
@@ -357,13 +358,17 @@ const json5 = {
|
|
|
357
358
|
};
|
|
358
359
|
|
|
359
360
|
const jestJs = {
|
|
360
|
-
files: ['*.test.js'],
|
|
361
|
-
plugins:
|
|
361
|
+
files: ['*.test.js', '**/__tests__/**/*.js'],
|
|
362
|
+
plugins: {
|
|
363
|
+
jest: jestPlugin,
|
|
364
|
+
},
|
|
362
365
|
extends: ['plugin:jest/all'],
|
|
363
366
|
env: {
|
|
364
367
|
jest: true,
|
|
365
368
|
},
|
|
366
369
|
rules: {
|
|
370
|
+
'jest/prefer-spy-on': 'warn',
|
|
371
|
+
'jest/require-top-level-describe': 'error',
|
|
367
372
|
'unicorn/no-array-callback-reference': 'off',
|
|
368
373
|
'jest/unbound-method': 'off',
|
|
369
374
|
'unicorn/prevent-abbreviations': [
|
|
@@ -376,14 +381,19 @@ const jestJs = {
|
|
|
376
381
|
};
|
|
377
382
|
|
|
378
383
|
const jestTs = {
|
|
379
|
-
files: ['*.test.ts'],
|
|
384
|
+
files: ['*.test.ts', '**/__tests__/**/*.ts'],
|
|
380
385
|
parser: '@typescript-eslint/parser',
|
|
381
|
-
plugins:
|
|
386
|
+
plugins: {
|
|
387
|
+
'@typescript-eslint': typeScriptPlugin,
|
|
388
|
+
jest: jestPlugin,
|
|
389
|
+
},
|
|
382
390
|
extends: ['plugin:jest/all'],
|
|
383
391
|
env: {
|
|
384
392
|
jest: true,
|
|
385
393
|
},
|
|
386
394
|
rules: {
|
|
395
|
+
'jest/prefer-spy-on': 'warn',
|
|
396
|
+
'jest/require-top-level-describe': 'error',
|
|
387
397
|
'unicorn/no-array-callback-reference': 'off',
|
|
388
398
|
'jest/unbound-method': 'off',
|
|
389
399
|
'unicorn/prevent-abbreviations': [
|
package/package.json
CHANGED
package/rules.js
CHANGED
|
@@ -73,6 +73,14 @@ export const baseRules = {
|
|
|
73
73
|
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
74
74
|
selector: 'WithStatement',
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
selector: "CallExpression[callee.property.name='reduce'][arguments.length<2]",
|
|
78
|
+
message: 'Provide initialValue to reduce'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
selector: "CallExpression[callee.property.name='forEach']",
|
|
82
|
+
message: 'Use for...of instead'
|
|
83
|
+
}
|
|
76
84
|
],
|
|
77
85
|
'no-shadow': 'off',
|
|
78
86
|
'no-shadow-restricted-names': 'warn',
|
|
@@ -122,7 +130,7 @@ export const baseRules = {
|
|
|
122
130
|
],
|
|
123
131
|
radix: 'warn',
|
|
124
132
|
'filenames/match-regex': 'off',
|
|
125
|
-
'require-atomic-updates': 'error',
|
|
133
|
+
'require-atomic-updates': ['error', { allowProperties: false }],
|
|
126
134
|
'sort-imports': 'off',
|
|
127
135
|
'rest-spread-spacing': 'off',
|
|
128
136
|
semi: 'off',
|
|
@@ -176,7 +184,7 @@ export const baseRules = {
|
|
|
176
184
|
|
|
177
185
|
// Error handling
|
|
178
186
|
'no-await-in-loop': 'warn',
|
|
179
|
-
'no-promise-executor-return': 'error',
|
|
187
|
+
'no-promise-executor-return': ['error', { allowVoid: true }],
|
|
180
188
|
'no-unsafe-optional-chaining': 'error',
|
|
181
189
|
|
|
182
190
|
// Modern practices
|
|
@@ -193,12 +201,14 @@ export const baseRules = {
|
|
|
193
201
|
'promise/prefer-await-to-callbacks': 'warn',
|
|
194
202
|
|
|
195
203
|
// Security
|
|
196
|
-
'security/detect-non-literal-fs-filename': '
|
|
204
|
+
'security/detect-non-literal-fs-filename': 'error',
|
|
197
205
|
'security/detect-unsafe-regex': 'error',
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
'
|
|
201
|
-
'
|
|
206
|
+
'security/detect-buffer-noassert': 'error',
|
|
207
|
+
'security/detect-child-process': 'warn',
|
|
208
|
+
'security/detect-disable-mustache-escape': 'error',
|
|
209
|
+
'security/detect-possible-timing-attacks': 'error',
|
|
210
|
+
'security/detect-non-literal-regexp': 'error',
|
|
211
|
+
'security/detect-non-literal-require': 'error',
|
|
202
212
|
|
|
203
213
|
// Code Quality
|
|
204
214
|
'sonarjs/cognitive-complexity': ['error', 15],
|
|
@@ -206,18 +216,15 @@ export const baseRules = {
|
|
|
206
216
|
'sonarjs/no-redundant-boolean': 'error',
|
|
207
217
|
'sonarjs/prefer-immediate-return': 'error',
|
|
208
218
|
|
|
209
|
-
// RegExp
|
|
210
|
-
'regexp/no-missing-g-flag': 'error',
|
|
211
|
-
'regexp/no-useless-flag': 'error',
|
|
212
|
-
'regexp/prefer-quantifier': 'error',
|
|
213
|
-
|
|
214
219
|
// Enhanced TypeScript
|
|
215
220
|
'etc/no-commented-out-code': 'warn',
|
|
216
221
|
'etc/no-implicit-any-catch': 'error',
|
|
217
222
|
'etc/prefer-interface': 'error',
|
|
218
223
|
|
|
219
224
|
// Enhanced Import Rules
|
|
220
|
-
'import/no-relative-parent-imports': '
|
|
225
|
+
'import/no-relative-parent-imports': ['error', {
|
|
226
|
+
ignore: ['@/components', '@/utils', '@/types']
|
|
227
|
+
}],
|
|
221
228
|
'import/no-extraneous-dependencies': ['error', {
|
|
222
229
|
devDependencies: ['**/*.test.{js,ts}', '**/*.spec.{js,ts}', '**/test/**']
|
|
223
230
|
}],
|
|
@@ -226,11 +233,6 @@ export const baseRules = {
|
|
|
226
233
|
'promise/no-nesting': 'warn',
|
|
227
234
|
'promise/prefer-await-to-then': 'warn',
|
|
228
235
|
|
|
229
|
-
// Security Enhancements
|
|
230
|
-
'security/detect-buffer-noassert': 'error',
|
|
231
|
-
'security/detect-child-process': 'warn',
|
|
232
|
-
'security/detect-disable-mustache-escape': 'error',
|
|
233
|
-
|
|
234
236
|
// Code Organization
|
|
235
237
|
'typescript-sort-keys/interface': 'warn',
|
|
236
238
|
'typescript-sort-keys/string-enum': 'warn',
|
|
@@ -242,14 +244,17 @@ export const baseRules = {
|
|
|
242
244
|
'sonarjs/no-duplicated-branches': 'error',
|
|
243
245
|
'sonarjs/max-switch-cases': ['warn', 10],
|
|
244
246
|
|
|
245
|
-
//
|
|
246
|
-
'
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// Better Type Safety
|
|
247
|
+
// Import Safety
|
|
248
|
+
'import/no-cycle': ['error', {
|
|
249
|
+
maxDepth: 1,
|
|
250
|
+
ignoreExternal: true
|
|
251
|
+
}],
|
|
251
252
|
'import/no-relative-packages': 'error',
|
|
252
253
|
'import/no-self-import': 'error',
|
|
254
|
+
'import/no-namespace': 'error',
|
|
255
|
+
'import/no-empty-named-blocks': 'error',
|
|
256
|
+
'import/no-duplicates': ['error', { 'prefer-inline': true }],
|
|
257
|
+
'import/no-import-module-exports': 'error',
|
|
253
258
|
|
|
254
259
|
// Architecture Boundaries
|
|
255
260
|
'boundaries/element-types': [
|
|
@@ -270,87 +275,6 @@ export const baseRules = {
|
|
|
270
275
|
'radar/cognitive-complexity': ['error', 15],
|
|
271
276
|
|
|
272
277
|
// Enhanced Security
|
|
273
|
-
'security/detect-non-literal-fs-filename': ['error', { allowInlineConfig: false }],
|
|
274
|
-
'security/detect-unsafe-regex': ['error', { allowDollarMatchAll: false }],
|
|
275
|
-
'security/detect-buffer-noassert': 'error',
|
|
276
|
-
|
|
277
|
-
// Better Type Safety
|
|
278
|
-
'import/no-cycle': ['error', { maxDepth: 1 }],
|
|
279
|
-
'import/no-relative-packages': 'error',
|
|
280
|
-
'unicorn/prefer-module': 'error',
|
|
281
|
-
|
|
282
|
-
// Code Style
|
|
283
|
-
'perfectionist/sort-named-imports': [
|
|
284
|
-
'warn',
|
|
285
|
-
{
|
|
286
|
-
type: 'natural',
|
|
287
|
-
order: 'asc',
|
|
288
|
-
'ignore-case': true
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
|
|
292
|
-
// Enhanced Security
|
|
293
|
-
'security/detect-possible-timing-attacks': ['error', {
|
|
294
|
-
threshold: 8,
|
|
295
|
-
catchAliases: true
|
|
296
|
-
}],
|
|
297
|
-
'security/detect-non-literal-regexp': ['error', {
|
|
298
|
-
report: 'error',
|
|
299
|
-
warnOnDynamicRegexp: true
|
|
300
|
-
}],
|
|
301
|
-
'security/detect-unsafe-regex': ['error', {
|
|
302
|
-
maxLength: 50
|
|
303
|
-
}],
|
|
304
|
-
|
|
305
|
-
// Import Safety
|
|
306
|
-
'import/no-import-module-exports': 'error',
|
|
307
|
-
'import/no-relative-parent-imports': ['error', {
|
|
308
|
-
ignore: ['@/components', '@/utils', '@/types']
|
|
309
|
-
}],
|
|
310
|
-
|
|
311
|
-
// Better Code Organization
|
|
312
|
-
'perfectionist/sort-objects': ['error', {
|
|
313
|
-
type: 'natural',
|
|
314
|
-
order: 'asc',
|
|
315
|
-
'spread-last': true
|
|
316
|
-
}],
|
|
317
|
-
'perfectionist/sort-named-imports': ['error', {
|
|
318
|
-
type: 'natural',
|
|
319
|
-
order: 'asc',
|
|
320
|
-
'ignore-case': true
|
|
321
|
-
}],
|
|
322
|
-
|
|
323
|
-
// Advanced Performance
|
|
324
|
-
'no-restricted-syntax': [
|
|
325
|
-
'error',
|
|
326
|
-
{
|
|
327
|
-
selector: "CallExpression[callee.property.name='reduce'][arguments.length<2]",
|
|
328
|
-
message: 'Provide initialValue to reduce'
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
selector: "CallExpression[callee.property.name='forEach']",
|
|
332
|
-
message: 'Use for...of instead'
|
|
333
|
-
}
|
|
334
|
-
],
|
|
335
|
-
'require-atomic-updates': ['error', { allowProperties: false }],
|
|
336
|
-
'no-constant-binary-expression': 'error',
|
|
337
|
-
|
|
338
|
-
// Better Error Handling
|
|
339
|
-
'no-implicit-coercion': ['error', { boolean: false, number: true, string: true }],
|
|
340
|
-
'unicorn/prefer-type-error': 'error',
|
|
341
|
-
'unicorn/no-useless-undefined': ['error', { checkArguments: true }],
|
|
342
|
-
|
|
343
|
-
// Enhanced Import Safety
|
|
344
|
-
'import/no-cycle': ['error', { maxDepth: 1, ignoreExternal: true }],
|
|
345
|
-
'import/no-relative-packages': 'error',
|
|
346
|
-
'import/no-self-import': 'error',
|
|
347
|
-
|
|
348
|
-
// Type Safety
|
|
349
|
-
'unicorn/prefer-at': 'error',
|
|
350
|
-
'unicorn/prefer-string-replace-all': 'error',
|
|
351
|
-
'unicorn/require-post-message-target-origin': 'error',
|
|
352
|
-
|
|
353
|
-
// Security
|
|
354
278
|
'n/no-unsupported-features/es-syntax': ['error', {
|
|
355
279
|
version: '>=18.0.0',
|
|
356
280
|
ignores: ['modules', 'dynamicImport']
|
|
@@ -369,11 +293,25 @@ export const baseRules = {
|
|
|
369
293
|
|
|
370
294
|
// Better Error Handling
|
|
371
295
|
'max-classes-per-file': ['error', 1],
|
|
372
|
-
'no-promise-executor-return': ['error', { allowVoid: true }],
|
|
373
296
|
'unicorn/catch-error-name': ['error', { name: 'error' }],
|
|
297
|
+
'unicorn/no-useless-undefined': ['error', { checkArguments: true }],
|
|
298
|
+
'unicorn/prefer-type-error': 'error',
|
|
374
299
|
|
|
375
|
-
//
|
|
376
|
-
'
|
|
377
|
-
|
|
378
|
-
|
|
300
|
+
// Code Style
|
|
301
|
+
'perfectionist/sort-named-imports': ['error', {
|
|
302
|
+
type: 'natural',
|
|
303
|
+
order: 'asc',
|
|
304
|
+
'ignore-case': true
|
|
305
|
+
}],
|
|
306
|
+
'perfectionist/sort-objects': ['error', {
|
|
307
|
+
type: 'natural',
|
|
308
|
+
order: 'asc',
|
|
309
|
+
'spread-last': true
|
|
310
|
+
}],
|
|
311
|
+
|
|
312
|
+
// Advanced Performance
|
|
313
|
+
'no-implicit-coercion': ['error', { boolean: false, number: true, string: true }],
|
|
314
|
+
'unicorn/prefer-at': 'error',
|
|
315
|
+
'unicorn/prefer-string-replace-all': 'error',
|
|
316
|
+
'unicorn/require-post-message-target-origin': 'error'
|
|
379
317
|
};
|