@tb-dev/eslint-config 1.5.15 → 1.6.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/dist/index.mjs DELETED
@@ -1,944 +0,0 @@
1
- import eslintConfigPrettier from 'eslint-config-prettier';
2
- import globals from 'globals';
3
- import process from 'node:process';
4
-
5
- var Glob;
6
- (function (Glob) {
7
- Glob["ALL"] = "**/*.?([cm])[jt]s?(x)";
8
- Glob["JAVASCRIPT"] = "**/*.?([cm])js?(x)";
9
- Glob["TYPESCRIPT"] = "**/*.?([cm])ts?(x)";
10
- Glob["VITEST"] = "**/*.{test,spec}.[jt]s";
11
- Glob["VUE"] = "**/*.vue";
12
- })(Glob || (Glob = {}));
13
- var GlobIgnore;
14
- (function (GlobIgnore) {
15
- GlobIgnore["CACHE"] = "**/cache";
16
- GlobIgnore["DIST"] = "**/dist";
17
- GlobIgnore["LOG"] = "**/log?(s)";
18
- GlobIgnore["NODE_MODULES"] = "**/node_modules";
19
- GlobIgnore["OUT"] = "**/out";
20
- GlobIgnore["TARGET"] = "**/target";
21
- GlobIgnore["TEMP"] = "**/?(.)temp";
22
- })(GlobIgnore || (GlobIgnore = {}));
23
-
24
- /* eslint-disable @typescript-eslint/no-unsafe-return */
25
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
26
- /* eslint-disable @typescript-eslint/no-explicit-any */
27
- async function interopDefault(promise) {
28
- const result = await promise;
29
- return result.default ?? result;
30
- }
31
- function getIgnores() {
32
- return Object.values(GlobIgnore);
33
- }
34
-
35
- /**
36
- * @see https://eslint.org/docs/latest/rules/
37
- */
38
- function javascript(options) {
39
- const { overrides } = options;
40
- const files = [Glob.ALL];
41
- if (options.vue)
42
- files.push(Glob.VUE);
43
- return {
44
- files,
45
- languageOptions: {
46
- ecmaVersion: 'latest',
47
- sourceType: 'module',
48
- globals: {
49
- ...globals.browser,
50
- ...globals.es2021,
51
- ...globals.node,
52
- document: 'readonly',
53
- window: 'readonly'
54
- }
55
- },
56
- rules: {
57
- 'accessor-pairs': ['error', { enforceForClassMembers: true, setWithoutGet: true }],
58
- 'array-callback-return': [
59
- 'error',
60
- {
61
- checkForEach: true,
62
- allowVoid: true
63
- }
64
- ],
65
- 'block-scoped-var': 'error',
66
- 'consistent-this': ['error', 'self'],
67
- 'default-case-last': 'error',
68
- eqeqeq: ['error', 'always'],
69
- 'for-direction': 'error',
70
- 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
71
- 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
72
- 'guard-for-in': 'error',
73
- 'init-declarations': 'off',
74
- 'logical-assignment-operators': ['error', 'always', { enforceForIfStatements: true }],
75
- 'max-params': 'off',
76
- 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
77
- 'no-alert': 'error',
78
- 'no-async-promise-executor': 'error',
79
- 'no-caller': 'error',
80
- 'no-case-declarations': 'error',
81
- 'no-class-assign': 'error',
82
- 'no-compare-neg-zero': 'error',
83
- 'no-cond-assign': ['error', 'always'],
84
- 'no-constant-binary-expression': 'error',
85
- 'no-constant-condition': 'error',
86
- 'no-constructor-return': 'error',
87
- 'no-control-regex': 'error',
88
- 'no-debugger': 'error',
89
- 'no-delete-var': 'error',
90
- 'no-dupe-else-if': 'error',
91
- 'no-duplicate-case': 'error',
92
- 'no-duplicate-imports': ['error', { includeExports: false }],
93
- 'no-else-return': 'error',
94
- 'no-empty': ['error', { allowEmptyCatch: true }],
95
- 'no-empty-character-class': 'error',
96
- 'no-empty-pattern': 'error',
97
- 'no-empty-static-block': 'error',
98
- 'no-eval': 'error',
99
- 'no-ex-assign': 'error',
100
- 'no-extend-native': 'error',
101
- 'no-extra-bind': 'error',
102
- 'no-extra-boolean-cast': 'error',
103
- 'no-fallthrough': ['error', { allowEmptyCase: true }],
104
- 'no-global-assign': 'error',
105
- 'no-implicit-coercion': ['error', { disallowTemplateShorthand: true }],
106
- 'no-import-assign': 'error',
107
- 'no-inner-declarations': ['error', 'both'],
108
- 'no-invalid-regexp': 'error',
109
- 'no-irregular-whitespace': 'error',
110
- 'no-iterator': 'error',
111
- 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
112
- 'no-lone-blocks': 'error',
113
- 'no-lonely-if': 'error',
114
- 'no-misleading-character-class': 'error',
115
- 'no-multi-assign': 'error',
116
- 'no-multi-str': 'error',
117
- 'no-new': 'error',
118
- 'no-new-func': 'error',
119
- 'no-new-native-nonconstructor': 'error',
120
- 'no-new-wrappers': 'error',
121
- 'no-nonoctal-decimal-escape': 'error',
122
- 'no-object-constructor': 'error',
123
- 'no-octal': 'error',
124
- 'no-octal-escape': 'error',
125
- 'no-promise-executor-return': ['error', { allowVoid: true }],
126
- 'no-proto': 'error',
127
- 'no-prototype-builtins': 'error',
128
- 'no-regex-spaces': 'error',
129
- 'no-script-url': 'error',
130
- 'no-self-assign': 'error',
131
- 'no-self-compare': 'error',
132
- 'no-sequences': 'error',
133
- 'no-shadow-restricted-names': 'error',
134
- 'no-sparse-arrays': 'error',
135
- 'no-template-curly-in-string': 'error',
136
- 'no-undef-init': 'error',
137
- 'no-undefined': 'error',
138
- 'no-unexpected-multiline': 'error',
139
- 'no-unmodified-loop-condition': 'error',
140
- 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
141
- 'no-unreachable-loop': 'error',
142
- 'no-unsafe-finally': 'error',
143
- 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
144
- 'no-unused-vars': 'off',
145
- 'no-useless-backreference': 'error',
146
- 'no-useless-call': 'error',
147
- 'no-useless-catch': 'error',
148
- 'no-useless-computed-key': 'error',
149
- 'no-useless-concat': 'error',
150
- 'no-useless-rename': 'error',
151
- 'no-useless-return': 'error',
152
- 'no-var': 'error',
153
- 'no-with': 'error',
154
- 'object-shorthand': ['error', 'always'],
155
- 'operator-assignment': ['error', 'always'],
156
- 'prefer-arrow-callback': 'error',
157
- 'prefer-const': [
158
- 'error',
159
- {
160
- destructuring: 'all',
161
- ignoreReadBeforeAssign: true
162
- }
163
- ],
164
- 'prefer-destructuring': 'off',
165
- 'prefer-exponentiation-operator': 'error',
166
- 'prefer-object-has-own': 'error',
167
- 'prefer-object-spread': 'error',
168
- 'prefer-promise-reject-errors': 'error',
169
- 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
170
- 'prefer-rest-params': 'error',
171
- 'prefer-spread': 'error',
172
- 'prefer-template': 'error',
173
- 'require-atomic-updates': 'error',
174
- 'sort-imports': [
175
- 'error',
176
- {
177
- allowSeparatedGroups: false,
178
- ignoreCase: false,
179
- ignoreDeclarationSort: true,
180
- ignoreMemberSort: false,
181
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
182
- }
183
- ],
184
- 'symbol-description': 'error',
185
- 'use-isnan': 'error',
186
- 'valid-typeof': 'error',
187
- yoda: ['error', 'never'],
188
- ...overrides?.javascript
189
- }
190
- };
191
- }
192
-
193
- /**
194
- * @see https://eslint-plugin-perfectionist.azat.io/rules/
195
- */
196
- async function perfectionist(options) {
197
- const { overrides, perfectionist: enabled = true } = options;
198
- if (!enabled)
199
- return {};
200
- const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
201
- return {
202
- plugins: {
203
- perfectionist: plugin
204
- },
205
- rules: {
206
- 'perfectionist/sort-classes': [
207
- 'error',
208
- {
209
- type: 'natural',
210
- order: 'asc',
211
- groups: [
212
- 'index-signature',
213
- 'property',
214
- 'private-property',
215
- 'constructor',
216
- 'method',
217
- 'private-method',
218
- ['get-method', 'set-method'],
219
- 'static-property',
220
- 'static-method',
221
- 'static-private-method',
222
- 'unknown'
223
- ]
224
- }
225
- ],
226
- 'perfectionist/sort-enums': [
227
- 'error',
228
- {
229
- type: 'natural',
230
- order: 'asc'
231
- }
232
- ],
233
- 'perfectionist/sort-exports': [
234
- 'error',
235
- {
236
- type: 'line-length',
237
- order: 'asc'
238
- }
239
- ],
240
- 'perfectionist/sort-imports': [
241
- 'error',
242
- {
243
- type: 'line-length',
244
- order: 'asc',
245
- 'newlines-between': 'never',
246
- groups: [
247
- ['style', 'side-effect'],
248
- ['builtin', 'builtin-type'],
249
- ['external', 'external-type'],
250
- ['internal', 'internal-type'],
251
- 'unknown'
252
- ]
253
- }
254
- ],
255
- 'perfectionist/sort-interfaces': [
256
- 'error',
257
- {
258
- type: 'natural',
259
- order: 'asc',
260
- 'partition-by-new-line': true
261
- }
262
- ],
263
- 'perfectionist/sort-maps': [
264
- 'error',
265
- {
266
- type: 'natural',
267
- order: 'asc'
268
- }
269
- ],
270
- 'perfectionist/sort-named-exports': [
271
- 'error',
272
- {
273
- type: 'natural',
274
- order: 'asc'
275
- }
276
- ],
277
- 'sort-imports': 'off',
278
- 'perfectionist/sort-named-imports': [
279
- 'error',
280
- {
281
- type: 'natural',
282
- order: 'asc'
283
- }
284
- ],
285
- '@typescript-eslint/adjacent-overload-signatures': 'off',
286
- 'perfectionist/sort-object-types': [
287
- 'error',
288
- {
289
- type: 'natural',
290
- order: 'asc',
291
- 'partition-by-new-line': true
292
- }
293
- ],
294
- ...overrides?.perfectionist
295
- }
296
- };
297
- }
298
-
299
- /**
300
- * @see https://typescript-eslint.io/rules/
301
- */
302
- async function typescript(options) {
303
- const { project, overrides } = options;
304
- const [tsParser, tsPlugin] = await Promise.all([
305
- await interopDefault(import('@typescript-eslint/parser')),
306
- await interopDefault(import('@typescript-eslint/eslint-plugin'))
307
- ]);
308
- const files = [Glob.TYPESCRIPT];
309
- if (options.vue)
310
- files.push(Glob.VUE);
311
- const rules = {
312
- '@typescript-eslint/adjacent-overload-signatures': 'error',
313
- 'no-array-constructor': 'off',
314
- '@typescript-eslint/no-array-constructor': 'error',
315
- '@typescript-eslint/array-type': ['error', { default: 'array' }],
316
- '@typescript-eslint/ban-ts-comment': [
317
- 'error',
318
- {
319
- 'ts-expect-error': 'allow-with-description',
320
- 'ts-ignore': true,
321
- 'ts-nocheck': true,
322
- 'ts-check': false,
323
- minimumDescriptionLength: 3
324
- }
325
- ],
326
- '@typescript-eslint/class-literal-property-style': ['error', 'fields'],
327
- 'class-methods-use-this': 'off',
328
- '@typescript-eslint/class-methods-use-this': [
329
- 'error',
330
- {
331
- ignoreOverrideMethods: true,
332
- ignoreClassesThatImplementAnInterface: 'public-fields'
333
- }
334
- ],
335
- '@typescript-eslint/consistent-generic-constructors': ['error', 'constructor'],
336
- '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
337
- '@typescript-eslint/consistent-type-assertions': [
338
- 'error',
339
- { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }
340
- ],
341
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
342
- 'dot-notation': 'off',
343
- '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
344
- '@typescript-eslint/explicit-function-return-type': 'off',
345
- '@typescript-eslint/explicit-member-accessibility': [
346
- 'error',
347
- {
348
- accessibility: 'explicit',
349
- overrides: {
350
- accessors: 'no-public',
351
- constructors: 'no-public',
352
- methods: 'explicit',
353
- properties: 'explicit',
354
- parameterProperties: 'explicit'
355
- }
356
- }
357
- ],
358
- '@typescript-eslint/explicit-module-boundary-types': 'off',
359
- '@typescript-eslint/method-signature-style': ['error', 'property'],
360
- '@typescript-eslint/no-base-to-string': 'error',
361
- '@typescript-eslint/no-confusing-non-null-assertion': 'error',
362
- '@typescript-eslint/no-confusing-void-expression': [
363
- 'error',
364
- {
365
- ignoreArrowShorthand: true,
366
- ignoreVoidOperator: true
367
- }
368
- ],
369
- '@typescript-eslint/no-duplicate-enum-values': 'error',
370
- '@typescript-eslint/no-duplicate-type-constituents': 'error',
371
- '@typescript-eslint/no-dynamic-delete': 'error',
372
- 'no-empty-function': 'off',
373
- '@typescript-eslint/no-empty-function': 'error',
374
- '@typescript-eslint/no-empty-interface': 'error',
375
- '@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
376
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
377
- '@typescript-eslint/no-extraneous-class': 'error',
378
- '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
379
- '@typescript-eslint/no-for-in-array': 'error',
380
- 'no-implied-eval': 'off',
381
- '@typescript-eslint/no-implied-eval': 'error',
382
- '@typescript-eslint/no-import-type-side-effects': 'error',
383
- '@typescript-eslint/no-inferrable-types': 'error',
384
- '@typescript-eslint/no-invalid-void-type': [
385
- 'error',
386
- {
387
- allowInGenericTypeArguments: true,
388
- allowAsThisParameter: true
389
- }
390
- ],
391
- 'no-loop-func': 'off',
392
- '@typescript-eslint/no-loop-func': 'error',
393
- 'no-loss-of-precision': 'off',
394
- '@typescript-eslint/no-loss-of-precision': 'error',
395
- '@typescript-eslint/no-meaningless-void-operator': 'error',
396
- '@typescript-eslint/no-misused-new': 'error',
397
- '@typescript-eslint/no-misused-promises': [
398
- 'error',
399
- {
400
- checksConditionals: true,
401
- checksSpreads: true,
402
- checksVoidReturn: {
403
- arguments: true,
404
- attributes: true,
405
- properties: true,
406
- returns: true,
407
- variables: true
408
- }
409
- }
410
- ],
411
- '@typescript-eslint/no-mixed-enums': 'error',
412
- '@typescript-eslint/no-namespace': 'error',
413
- '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
414
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
415
- '@typescript-eslint/no-non-null-assertion': 'error',
416
- '@typescript-eslint/no-redundant-type-constituents': 'off',
417
- '@typescript-eslint/no-require-imports': 'error',
418
- 'no-shadow': 'off',
419
- '@typescript-eslint/no-shadow': 'error',
420
- '@typescript-eslint/no-this-alias': 'error',
421
- 'no-throw-literal': 'off',
422
- '@typescript-eslint/no-throw-literal': 'error',
423
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': [
424
- 'error',
425
- {
426
- allowComparingNullableBooleansToTrue: false,
427
- allowComparingNullableBooleansToFalse: true
428
- }
429
- ],
430
- '@typescript-eslint/no-unnecessary-condition': 'error',
431
- '@typescript-eslint/no-unnecessary-qualifier': 'error',
432
- '@typescript-eslint/no-unnecessary-type-arguments': 'error',
433
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
434
- '@typescript-eslint/no-unnecessary-type-constraint': 'error',
435
- '@typescript-eslint/no-unsafe-argument': 'off',
436
- '@typescript-eslint/no-unsafe-assignment': 'off',
437
- '@typescript-eslint/no-unsafe-call': 'error',
438
- '@typescript-eslint/no-unsafe-declaration-merging': 'error',
439
- '@typescript-eslint/no-unsafe-enum-comparison': 'off',
440
- '@typescript-eslint/no-unsafe-member-access': 'error',
441
- '@typescript-eslint/no-unsafe-return': 'off',
442
- '@typescript-eslint/no-unsafe-unary-minus': 'error',
443
- 'no-unused-expressions': 'off',
444
- '@typescript-eslint/no-unused-expressions': [
445
- 'error',
446
- {
447
- allowTaggedTemplates: true
448
- }
449
- ],
450
- 'no-use-before-define': 'off',
451
- '@typescript-eslint/no-use-before-define': [
452
- 'error',
453
- {
454
- functions: false,
455
- enums: true,
456
- typedefs: false
457
- }
458
- ],
459
- 'no-useless-constructor': 'off',
460
- '@typescript-eslint/no-useless-constructor': 'error',
461
- '@typescript-eslint/no-useless-empty-export': 'error',
462
- '@typescript-eslint/non-nullable-type-assertion-style': 'error',
463
- '@typescript-eslint/prefer-as-const': 'error',
464
- '@typescript-eslint/prefer-enum-initializers': 'error',
465
- '@typescript-eslint/prefer-for-of': 'error',
466
- '@typescript-eslint/prefer-function-type': 'error',
467
- '@typescript-eslint/prefer-includes': 'error',
468
- '@typescript-eslint/prefer-literal-enum-member': 'error',
469
- '@typescript-eslint/prefer-nullish-coalescing': [
470
- 'error',
471
- {
472
- ignoreTernaryTests: false,
473
- ignoreConditionalTests: false,
474
- ignoreMixedLogicalExpressions: false,
475
- ignorePrimitives: {
476
- bigint: false,
477
- boolean: false,
478
- number: false,
479
- string: false
480
- }
481
- }
482
- ],
483
- '@typescript-eslint/prefer-optional-chain': 'error',
484
- '@typescript-eslint/prefer-readonly': 'error',
485
- '@typescript-eslint/prefer-readonly-parameter-types': 'off',
486
- '@typescript-eslint/prefer-reduce-type-parameter': 'error',
487
- '@typescript-eslint/prefer-regexp-exec': 'error',
488
- '@typescript-eslint/prefer-return-this-type': 'error',
489
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
490
- '@typescript-eslint/prefer-ts-expect-error': 'error',
491
- '@typescript-eslint/promise-function-async': 'off',
492
- '@typescript-eslint/require-array-sort-compare': 'error',
493
- 'require-await': 'off',
494
- '@typescript-eslint/require-await': 'error',
495
- '@typescript-eslint/restrict-plus-operands': 'error',
496
- '@typescript-eslint/restrict-template-expressions': 'error',
497
- '@typescript-eslint/strict-boolean-expressions': 'off',
498
- '@typescript-eslint/switch-exhaustiveness-check': [
499
- 'error',
500
- {
501
- requireDefaultForNonUnion: true
502
- }
503
- ],
504
- '@typescript-eslint/unbound-method': 'error',
505
- '@typescript-eslint/unified-signatures': [
506
- 'error',
507
- {
508
- ignoreDifferentlyNamedParameters: true
509
- }
510
- ],
511
- ...overrides?.typescript
512
- };
513
- return {
514
- files,
515
- languageOptions: {
516
- ecmaVersion: 'latest',
517
- sourceType: 'module',
518
- parser: tsParser,
519
- parserOptions: {
520
- project,
521
- tsconfigRootDir: process.cwd(),
522
- extraFileExtensions: options.vue ? ['.vue'] : []
523
- }
524
- },
525
- plugins: {
526
- '@typescript-eslint': tsPlugin
527
- },
528
- rules
529
- };
530
- }
531
-
532
- /**
533
- * @see https://github.com/sindresorhus/eslint-plugin-unicorn#rules
534
- */
535
- async function unicorn(options) {
536
- const { overrides, unicorn: enabled = true } = options;
537
- if (!enabled)
538
- return {};
539
- const plugin = await interopDefault(import('eslint-plugin-unicorn'));
540
- return {
541
- plugins: {
542
- unicorn: plugin
543
- },
544
- rules: {
545
- 'unicorn/catch-error-name': [
546
- 'error',
547
- {
548
- name: 'err'
549
- }
550
- ],
551
- 'unicorn/consistent-function-scoping': [
552
- 'error',
553
- {
554
- checkArrowFunctions: true
555
- }
556
- ],
557
- 'unicorn/custom-error-definition': 'error',
558
- 'unicorn/error-message': 'error',
559
- 'unicorn/no-array-for-each': 'error',
560
- 'unicorn/no-array-method-this-argument': 'error',
561
- 'unicorn/no-array-push-push': 'error',
562
- 'unicorn/no-await-expression-member': 'error',
563
- 'unicorn/no-invalid-remove-event-listener': 'error',
564
- 'unicorn/no-thenable': 'error',
565
- 'unicorn/no-typeof-undefined': 'off',
566
- 'unicorn/no-useless-fallback-in-spread': 'error',
567
- 'unicorn/no-useless-length-check': 'error',
568
- 'unicorn/no-useless-promise-resolve-reject': 'error',
569
- 'unicorn/prefer-at': 'error',
570
- 'unicorn/prefer-date-now': 'error',
571
- 'unicorn/prefer-dom-node-append': 'error',
572
- 'unicorn/prefer-dom-node-dataset': 'error',
573
- 'unicorn/prefer-dom-node-remove': 'error',
574
- 'unicorn/prefer-dom-node-text-content': 'error',
575
- 'unicorn/prefer-modern-dom-apis': 'error',
576
- 'unicorn/prefer-node-protocol': 'error',
577
- 'unicorn/prefer-number-properties': 'error',
578
- 'unicorn/prefer-object-from-entries': 'error',
579
- 'unicorn/prefer-prototype-methods': 'error',
580
- 'unicorn/prefer-query-selector': 'error',
581
- 'unicorn/prefer-reflect-apply': 'error',
582
- 'unicorn/prefer-regexp-test': 'error',
583
- 'unicorn/prefer-string-slice': 'error',
584
- 'unicorn/prefer-type-error': 'error',
585
- 'unicorn/relative-url-style': ['error', 'never'],
586
- ...overrides?.unicorn
587
- }
588
- };
589
- }
590
-
591
- async function vitest(options) {
592
- const { overrides, vitest: enabled } = options;
593
- if (!enabled)
594
- return {};
595
- const plugin = await interopDefault(import('eslint-plugin-vitest'));
596
- return {
597
- plugins: {
598
- vitest: plugin
599
- },
600
- files: [Glob.VITEST],
601
- rules: {
602
- 'vitest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
603
- 'vitest/expect-expect': [
604
- 'error',
605
- {
606
- assertFunctionNames: ['expect']
607
- }
608
- ],
609
- 'vitest/max-expects': ['error', { max: 5 }],
610
- 'vitest/max-nested-describe': ['error', { max: 1 }],
611
- 'vitest/no-alias-methods': 'error',
612
- 'vitest/no-commented-out-tests': 'error',
613
- 'vitest/no-conditional-expect': 'error',
614
- 'vitest/no-conditional-in-test': 'error',
615
- 'vitest/no-conditional-tests': 'error',
616
- 'vitest/no-done-callback': 'error',
617
- 'vitest/no-duplicate-hooks': 'error',
618
- 'vitest/no-identical-title': 'error',
619
- 'vitest/no-import-node-test': 'error',
620
- 'vitest/no-standalone-expect': 'error',
621
- 'vitest/no-test-return-statement': 'error',
622
- 'vitest/prefer-comparison-matcher': 'error',
623
- 'vitest/prefer-each': 'error',
624
- 'vitest/prefer-equality-matcher': 'error',
625
- 'vitest/prefer-expect-resolves': 'error',
626
- 'vitest/prefer-hooks-in-order': 'error',
627
- 'vitest/prefer-hooks-on-top': 'error',
628
- 'vitest/prefer-lowercase-title': 'error',
629
- 'vitest/prefer-mock-promise-shorthand': 'error',
630
- 'vitest/prefer-spy-on': 'error',
631
- 'vitest/prefer-to-be-object': 'error',
632
- 'vitest/prefer-to-contain': 'error',
633
- 'vitest/prefer-to-have-length': 'error',
634
- 'vitest/prefer-todo': 'error',
635
- 'vitest/require-top-level-describe': [
636
- 'error',
637
- {
638
- maxNumberOfTopLevelDescribes: 10
639
- }
640
- ],
641
- 'vitest/valid-describe-callback': 'error',
642
- 'vitest/valid-expect': 'error',
643
- ...overrides?.vitest
644
- }
645
- };
646
- }
647
-
648
- /* eslint-disable @typescript-eslint/no-explicit-any */
649
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
650
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
651
- /**
652
- * @see https://eslint.vuejs.org/rules/
653
- */
654
- async function vue(options) {
655
- const { overrides, vue: enabled } = options;
656
- if (!enabled)
657
- return [];
658
- const [vuePlugin, vueParser, tsParser] = await Promise.all([
659
- // @ts-expect-error no types
660
- await interopDefault(import('eslint-plugin-vue')),
661
- await interopDefault(import('vue-eslint-parser')),
662
- await interopDefault(import('@typescript-eslint/parser'))
663
- ]);
664
- const rules = {
665
- ...vuePlugin.configs.base.rules,
666
- 'vue/attribute-hyphenation': ['error', 'always'],
667
- 'vue/attributes-order': 'error',
668
- 'vue/block-lang': [
669
- 'error',
670
- {
671
- script: {
672
- lang: 'ts'
673
- },
674
- style: {
675
- lang: 'scss',
676
- allowNoLang: true
677
- }
678
- }
679
- ],
680
- 'vue/block-order': [
681
- 'error',
682
- {
683
- order: [['script', 'template'], 'style:not([scoped])', 'style[scoped]']
684
- }
685
- ],
686
- 'vue/block-tag-newline': [
687
- 'error',
688
- {
689
- singleline: 'always',
690
- multiline: 'always',
691
- maxEmptyLines: 0
692
- }
693
- ],
694
- 'vue/component-api-style': ['error', ['script-setup']],
695
- 'vue/component-definition-name-casing': ['error', 'PascalCase'],
696
- 'vue/component-name-in-template-casing': ['error', 'PascalCase'],
697
- 'vue/custom-event-name-casing': ['error', 'camelCase'],
698
- 'vue/define-emits-declaration': ['error', 'type-based'],
699
- 'vue/define-macros-order': [
700
- 'error',
701
- {
702
- order: ['defineProps', 'defineEmits']
703
- }
704
- ],
705
- 'vue/define-props-declaration': ['error', 'type-based'],
706
- 'vue/first-attribute-linebreak': 'off',
707
- 'vue/html-button-has-type': [
708
- 'error',
709
- {
710
- button: true,
711
- submit: true,
712
- reset: true
713
- }
714
- ],
715
- 'vue/html-closing-bracket-newline': [
716
- 'error',
717
- {
718
- singleline: 'never',
719
- multiline: 'always'
720
- }
721
- ],
722
- 'vue/html-closing-bracket-spacing': [
723
- 'error',
724
- {
725
- startTag: 'never',
726
- endTag: 'never',
727
- selfClosingTag: 'always'
728
- }
729
- ],
730
- 'vue/html-self-closing': [
731
- 'error',
732
- {
733
- html: {
734
- void: 'never',
735
- normal: 'always',
736
- component: 'always'
737
- },
738
- svg: 'always',
739
- math: 'always'
740
- }
741
- ],
742
- 'vue/match-component-file-name': [
743
- 'off',
744
- {
745
- extensions: ['tsx', 'vue'],
746
- shouldMatchCase: false
747
- }
748
- ],
749
- 'vue/match-component-import-name': 'error',
750
- 'vue/multi-word-component-names': 'off',
751
- 'vue/mustache-interpolation-spacing': ['error', 'always'],
752
- 'vue/no-arrow-functions-in-watch': 'off',
753
- 'vue/no-async-in-computed-properties': 'error',
754
- 'vue/no-boolean-default': ['error', 'no-default'],
755
- 'vue/no-computed-properties-in-data': 'error',
756
- 'vue/no-dupe-keys': 'error',
757
- 'vue/no-dupe-v-else-if': 'error',
758
- 'vue/no-duplicate-attributes': [
759
- 'error',
760
- {
761
- allowCoexistClass: true,
762
- allowCoexistStyle: true
763
- }
764
- ],
765
- 'vue/no-export-in-script-setup': 'error',
766
- 'vue/no-expose-after-await': 'error',
767
- 'vue/no-lifecycle-after-await': 'error',
768
- 'vue/no-lone-template': 'error',
769
- 'vue/no-multi-spaces': 'error',
770
- 'vue/no-multiple-objects-in-class': 'error',
771
- 'vue/no-mutating-props': 'error',
772
- 'vue/no-parsing-error': 'error',
773
- 'vue/no-ref-as-operand': 'error',
774
- 'vue/no-ref-object-reactivity-loss': 'error',
775
- 'vue/no-reserved-component-names': 'error',
776
- 'vue/no-reserved-keys': 'error',
777
- 'vue/no-reserved-props': 'error',
778
- 'vue/no-required-prop-with-default': [
779
- 'error',
780
- {
781
- autofix: true
782
- }
783
- ],
784
- 'vue/no-root-v-if': 'error',
785
- 'vue/no-setup-props-reactivity-loss': 'error',
786
- 'vue/no-shared-component-data': 'error',
787
- 'vue/no-side-effects-in-computed-properties': 'error',
788
- 'vue/no-spaces-around-equal-signs-in-attribute': 'error',
789
- 'vue/no-static-inline-styles': [
790
- 'error',
791
- {
792
- allowBinding: false
793
- }
794
- ],
795
- 'vue/no-template-key': 'error',
796
- 'vue/no-template-shadow': 'error',
797
- 'vue/no-template-target-blank': 'error',
798
- 'vue/no-textarea-mustache': 'error',
799
- 'vue/no-unused-components': 'error',
800
- 'vue/no-unused-emit-declarations': 'error',
801
- 'vue/no-unused-properties': 'error',
802
- 'vue/no-unused-refs': 'error',
803
- 'vue/no-unused-vars': [
804
- 'error',
805
- {
806
- ignorePattern: '^_'
807
- }
808
- ],
809
- 'vue/no-use-computed-property-like-method': 'error',
810
- 'vue/no-use-v-else-with-v-for': 'error',
811
- 'vue/no-use-v-if-with-v-for': 'error',
812
- 'vue/no-useless-mustaches': [
813
- 'error',
814
- {
815
- ignoreIncludesComment: false,
816
- ignoreStringEscape: false
817
- }
818
- ],
819
- 'vue/no-useless-template-attributes': 'error',
820
- 'vue/no-useless-v-bind': 'error',
821
- 'vue/no-v-for-template-key-on-child': 'error',
822
- 'vue/no-v-text-v-html-on-component': 'error',
823
- 'vue/no-v-html': 'off',
824
- 'vue/no-watch-after-await': 'error',
825
- 'vue/order-in-components': 'error',
826
- 'vue/padding-line-between-blocks': ['error', 'always'],
827
- 'vue/prefer-define-options': 'error',
828
- 'vue/prefer-import-from-vue': 'error',
829
- 'vue/prefer-separate-static-class': 'error',
830
- 'vue/prefer-true-attribute-shorthand': 'error',
831
- 'vue/prop-name-casing': ['error', 'camelCase'],
832
- 'vue/require-component-is': 'error',
833
- 'vue/require-default-prop': 'off',
834
- 'vue/require-explicit-emits': [
835
- 'error',
836
- {
837
- allowProps: false
838
- }
839
- ],
840
- 'vue/require-macro-variable-name': [
841
- 'error',
842
- {
843
- defineProps: 'props',
844
- defineEmits: 'emit',
845
- defineSlots: 'slots',
846
- useSlots: 'slots',
847
- useAttrs: 'attrs'
848
- }
849
- ],
850
- 'vue/require-prop-types': 'error',
851
- 'vue/require-render-return': 'error',
852
- 'vue/require-slots-as-functions': 'error',
853
- 'vue/require-toggle-inside-transition': 'error',
854
- 'vue/require-typed-ref': 'error',
855
- 'vue/require-v-for-key': 'error',
856
- 'vue/require-valid-default-prop': 'error',
857
- 'vue/return-in-computed-property': 'error',
858
- 'vue/return-in-emits-validator': 'error',
859
- 'vue/this-in-template': ['error', 'never'],
860
- 'vue/use-v-on-exact': 'error',
861
- 'vue/v-bind-style': ['error', 'shorthand'],
862
- 'vue/v-for-delimiter-style': ['error', 'of'],
863
- 'vue/v-on-handler-style': 'off',
864
- 'vue/v-on-style': ['error', 'shorthand'],
865
- 'vue/v-slot-style': [
866
- 'error',
867
- {
868
- atComponent: 'shorthand',
869
- default: 'shorthand',
870
- named: 'shorthand'
871
- }
872
- ],
873
- 'vue/v-on-event-hyphenation': ['error', 'always'],
874
- 'vue/valid-attribute-name': 'error',
875
- 'vue/valid-define-emits': 'error',
876
- 'vue/valid-define-options': 'error',
877
- 'vue/valid-define-props': 'error',
878
- 'vue/valid-next-tick': 'error',
879
- 'vue/valid-template-root': 'error',
880
- 'vue/valid-v-bind': 'error',
881
- 'vue/valid-v-cloak': 'error',
882
- 'vue/valid-v-else-if': 'error',
883
- 'vue/valid-v-else': 'error',
884
- 'vue/valid-v-for': 'error',
885
- 'vue/valid-v-html': 'error',
886
- 'vue/valid-v-if': 'error',
887
- 'vue/valid-v-memo': 'error',
888
- 'vue/valid-v-model': 'error',
889
- 'vue/valid-v-on': 'error',
890
- 'vue/valid-v-once': 'error',
891
- 'vue/valid-v-pre': 'error',
892
- 'vue/valid-v-show': 'error',
893
- 'vue/valid-v-slot': 'error',
894
- 'vue/valid-v-text': 'error',
895
- ...overrides?.vue
896
- };
897
- return [
898
- {
899
- plugins: {
900
- vue: vuePlugin
901
- }
902
- },
903
- {
904
- files: [Glob.VUE],
905
- languageOptions: {
906
- parser: vueParser,
907
- parserOptions: {
908
- parser: tsParser,
909
- project: options.project,
910
- tsconfigRootDir: process.cwd(),
911
- extraFileExtensions: ['.vue'],
912
- sourceType: 'module',
913
- ecmaVersion: 'latest'
914
- }
915
- }
916
- },
917
- {
918
- // @ts-expect-error no types
919
- processor: vuePlugin.processors['.vue'],
920
- rules
921
- }
922
- ];
923
- }
924
-
925
- /* eslint-disable @typescript-eslint/no-explicit-any */
926
- /* eslint-disable @typescript-eslint/no-unsafe-return */
927
- async function config(options) {
928
- const { prettier = true } = options;
929
- const objs = await Promise.all([
930
- javascript(options),
931
- typescript(options),
932
- ...(await vue(options)),
933
- perfectionist(options),
934
- unicorn(options),
935
- vitest(options),
936
- prettier ? eslintConfigPrettier : {},
937
- {
938
- ignores: [...getIgnores(), ...(options.ignores ?? [])]
939
- }
940
- ]);
941
- return objs;
942
- }
943
-
944
- export { config as default };