@tb-dev/eslint-config 6.7.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,1087 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const process = require('node:process');
6
- const globals = require('globals');
7
-
8
- var Glob = /* @__PURE__ */ ((Glob2) => {
9
- Glob2["All"] = "**/*.?([cm])[jt]s?(x)";
10
- Glob2["Html"] = "**/*.html";
11
- Glob2["Javascript"] = "**/*.?([cm])js?(x)";
12
- Glob2["Svelte"] = "**/*.svelte";
13
- Glob2["Typescript"] = "**/*.?([cm])ts?(x)";
14
- Glob2["Vue"] = "**/*.vue";
15
- return Glob2;
16
- })(Glob || {});
17
- var GlobIgnore = /* @__PURE__ */ ((GlobIgnore2) => {
18
- GlobIgnore2["Autogenerated"] = "**/autogenerated";
19
- GlobIgnore2["Cache"] = "**/cache";
20
- GlobIgnore2["Dist"] = "**/dist";
21
- GlobIgnore2["Log"] = "**/log?(s)";
22
- GlobIgnore2["NodeModules"] = "**/node_modules";
23
- GlobIgnore2["Out"] = "**/out";
24
- GlobIgnore2["SvelteKit"] = "**/.svelte-kit";
25
- GlobIgnore2["Target"] = "**/target";
26
- GlobIgnore2["Temp"] = "**/?(.)temp";
27
- return GlobIgnore2;
28
- })(GlobIgnore || {});
29
-
30
- async function interopDefault(promise) {
31
- const result = await promise;
32
- return result.default ?? result;
33
- }
34
- function isEnabled(config, feature) {
35
- if (Array.isArray(config)) {
36
- return config.includes(feature);
37
- } else if (typeof config === "boolean") {
38
- return config;
39
- }
40
- switch (feature) {
41
- case "perfectionist":
42
- return config?.perfectionist ?? true;
43
- case "react":
44
- return config?.react ?? false;
45
- case "reactCompiler":
46
- return config?.reactCompiler ?? config?.react ?? false;
47
- case "reactHooks":
48
- return config?.reactHooks ?? config?.react ?? false;
49
- case "svelte":
50
- return config?.svelte ?? false;
51
- case "tailwind":
52
- return config?.tailwind ?? false;
53
- case "unicorn":
54
- return config?.unicorn ?? true;
55
- case "vue":
56
- return config?.vue ?? false;
57
- default:
58
- return false;
59
- }
60
- }
61
- function getIgnores() {
62
- return Object.values(GlobIgnore);
63
- }
64
-
65
- async function vue(options) {
66
- if (!isEnabled(options.features, "vue")) return [];
67
- const [vuePlugin, vueParser, tsParser] = await Promise.all([
68
- interopDefault(import('eslint-plugin-vue')),
69
- interopDefault(import('vue-eslint-parser')),
70
- interopDefault(import('@typescript-eslint/parser'))
71
- ]);
72
- const rules = {
73
- ...vuePlugin.configs.base.rules,
74
- "vue/attribute-hyphenation": ["error", "always"],
75
- "vue/attributes-order": "error",
76
- "vue/block-lang": [
77
- "error",
78
- {
79
- script: { lang: "ts" },
80
- style: {
81
- lang: "scss",
82
- allowNoLang: true
83
- }
84
- }
85
- ],
86
- "vue/block-order": [
87
- "error",
88
- { order: [["script", "template"], "style:not([scoped])", "style[scoped]"] }
89
- ],
90
- "vue/block-tag-newline": [
91
- "error",
92
- {
93
- singleline: "always",
94
- multiline: "always",
95
- maxEmptyLines: 0
96
- }
97
- ],
98
- "vue/component-api-style": ["error", ["script-setup"]],
99
- "vue/component-definition-name-casing": ["error", "PascalCase"],
100
- "vue/component-name-in-template-casing": [
101
- "error",
102
- "PascalCase",
103
- {
104
- registeredComponentsOnly: false
105
- }
106
- ],
107
- "vue/custom-event-name-casing": ["error", "kebab-case"],
108
- "vue/define-emits-declaration": ["error", "type-based"],
109
- "vue/define-macros-order": [
110
- "error",
111
- {
112
- order: ["defineOptions", "defineProps", "defineModel", "defineEmits", "defineSlots"],
113
- defineExposeLast: true
114
- }
115
- ],
116
- "vue/define-props-declaration": ["error", "type-based"],
117
- "vue/enforce-style-attribute": ["error", { allow: ["scoped"] }],
118
- "vue/html-button-has-type": [
119
- "error",
120
- {
121
- button: true,
122
- submit: true,
123
- reset: true
124
- }
125
- ],
126
- "vue/match-component-file-name": [
127
- "off",
128
- {
129
- extensions: ["tsx", "vue"],
130
- shouldMatchCase: false
131
- }
132
- ],
133
- "vue/match-component-import-name": "error",
134
- "vue/multi-word-component-names": "off",
135
- "vue/no-arrow-functions-in-watch": "off",
136
- "vue/no-async-in-computed-properties": "error",
137
- "vue/no-boolean-default": ["error", "no-default"],
138
- "vue/no-computed-properties-in-data": "error",
139
- "vue/no-deprecated-delete-set": "error",
140
- "vue/no-dupe-keys": "error",
141
- "vue/no-dupe-v-else-if": "error",
142
- "vue/no-duplicate-attributes": [
143
- "error",
144
- {
145
- allowCoexistClass: true,
146
- allowCoexistStyle: true
147
- }
148
- ],
149
- "vue/no-export-in-script-setup": "error",
150
- "vue/no-expose-after-await": "error",
151
- "vue/no-import-compiler-macros": "error",
152
- "vue/no-lifecycle-after-await": "error",
153
- "vue/no-lone-template": "error",
154
- "vue/no-multiple-objects-in-class": "error",
155
- "vue/no-mutating-props": "error",
156
- "vue/no-parsing-error": "error",
157
- "vue/no-ref-as-operand": "error",
158
- "vue/no-ref-object-reactivity-loss": "error",
159
- "vue/no-reserved-component-names": [
160
- "error",
161
- {
162
- disallowVueBuiltInComponents: true,
163
- disallowVue3BuiltInComponents: true,
164
- htmlElementCaseSensitive: true
165
- }
166
- ],
167
- "vue/no-reserved-keys": "error",
168
- "vue/no-reserved-props": "error",
169
- "vue/no-required-prop-with-default": ["error", { autofix: true }],
170
- "vue/no-root-v-if": "error",
171
- "vue/no-setup-props-reactivity-loss": "error",
172
- "vue/no-shared-component-data": "error",
173
- "vue/no-side-effects-in-computed-properties": "error",
174
- "vue/no-static-inline-styles": ["error", { allowBinding: false }],
175
- "vue/no-template-key": "error",
176
- "vue/no-template-shadow": "error",
177
- "vue/no-template-target-blank": "error",
178
- "vue/no-textarea-mustache": "error",
179
- "vue/no-unused-components": "error",
180
- "vue/no-unused-emit-declarations": "error",
181
- "vue/no-unused-properties": "error",
182
- "vue/no-unused-refs": "error",
183
- "vue/no-unused-vars": ["error", { ignorePattern: "^_" }],
184
- "vue/no-use-computed-property-like-method": "error",
185
- "vue/no-use-v-else-with-v-for": "error",
186
- "vue/no-use-v-if-with-v-for": "error",
187
- "vue/no-useless-mustaches": [
188
- "error",
189
- {
190
- ignoreIncludesComment: false,
191
- ignoreStringEscape: false
192
- }
193
- ],
194
- "vue/no-useless-template-attributes": "error",
195
- "vue/no-useless-v-bind": "error",
196
- "vue/no-v-for-template-key-on-child": "error",
197
- "vue/no-v-text-v-html-on-component": "error",
198
- "vue/no-v-html": "off",
199
- "vue/no-watch-after-await": "error",
200
- "vue/order-in-components": "error",
201
- "vue/padding-line-between-blocks": ["error", "always"],
202
- "vue/prefer-define-options": "error",
203
- "vue/prefer-import-from-vue": "error",
204
- "vue/prefer-separate-static-class": "error",
205
- "vue/prefer-true-attribute-shorthand": "error",
206
- "vue/prop-name-casing": ["error", "camelCase"],
207
- "vue/require-component-is": "error",
208
- "vue/require-default-prop": "off",
209
- "vue/require-explicit-emits": ["error", { allowProps: false }],
210
- "vue/require-explicit-slots": "error",
211
- "vue/require-macro-variable-name": [
212
- "error",
213
- {
214
- defineProps: "props",
215
- defineEmits: "emit",
216
- defineSlots: "slots",
217
- useSlots: "slots",
218
- useAttrs: "attrs"
219
- }
220
- ],
221
- "vue/require-prop-types": "error",
222
- "vue/require-render-return": "error",
223
- "vue/require-slots-as-functions": "error",
224
- "vue/require-toggle-inside-transition": "error",
225
- "vue/require-typed-ref": "error",
226
- "vue/require-v-for-key": "error",
227
- "vue/require-valid-default-prop": "error",
228
- "vue/return-in-computed-property": "error",
229
- "vue/return-in-emits-validator": "error",
230
- "vue/this-in-template": ["error", "never"],
231
- "vue/use-v-on-exact": "error",
232
- "vue/v-bind-style": [
233
- "error",
234
- "shorthand",
235
- {
236
- sameNameShorthand: "always"
237
- }
238
- ],
239
- "vue/v-for-delimiter-style": ["error", "of"],
240
- "vue/v-on-handler-style": "off",
241
- "vue/v-on-style": ["error", "shorthand"],
242
- "vue/v-slot-style": [
243
- "error",
244
- {
245
- atComponent: "shorthand",
246
- default: "shorthand",
247
- named: "shorthand"
248
- }
249
- ],
250
- "vue/v-on-event-hyphenation": ["error", "always"],
251
- "vue/valid-attribute-name": "error",
252
- "vue/valid-define-emits": "error",
253
- "vue/valid-define-options": "error",
254
- "vue/valid-define-props": "error",
255
- "vue/valid-next-tick": "error",
256
- "vue/valid-template-root": "error",
257
- "vue/valid-v-bind": "error",
258
- "vue/valid-v-cloak": "error",
259
- "vue/valid-v-else-if": "error",
260
- "vue/valid-v-else": "error",
261
- "vue/valid-v-for": "error",
262
- "vue/valid-v-html": "error",
263
- "vue/valid-v-if": "error",
264
- "vue/valid-v-memo": "error",
265
- "vue/valid-v-model": "error",
266
- "vue/valid-v-on": "error",
267
- "vue/valid-v-once": "error",
268
- "vue/valid-v-pre": "error",
269
- "vue/valid-v-show": "error",
270
- "vue/valid-v-slot": "error",
271
- "vue/valid-v-text": "error",
272
- ...options.overrides?.vue
273
- };
274
- return [
275
- { plugins: { vue: vuePlugin } },
276
- {
277
- files: [Glob.Vue],
278
- languageOptions: {
279
- parser: vueParser,
280
- parserOptions: {
281
- parser: tsParser,
282
- project: options.project,
283
- tsconfigRootDir: process.cwd(),
284
- extraFileExtensions: [".vue"],
285
- sourceType: "module",
286
- ecmaVersion: "latest"
287
- }
288
- }
289
- },
290
- {
291
- // @ts-expect-error no types
292
- processor: vuePlugin.processors[".vue"],
293
- rules
294
- }
295
- ];
296
- }
297
-
298
- async function react(options) {
299
- if (!isEnabled(options.features, "react")) return [];
300
- const plugin = await interopDefault(import('eslint-plugin-react'));
301
- return [
302
- {
303
- plugins: { react: plugin },
304
- rules: {
305
- "react/button-has-type": "error",
306
- "react/function-component-definition": "off",
307
- "react/hook-use-state": ["error", { allowDestructuredState: true }],
308
- "react/jsx-boolean-value": ["error", "never", { assumeUndefinedIsFalse: true }],
309
- "react/jsx-key": [
310
- "error",
311
- {
312
- checkFragmentShorthand: true,
313
- checkKeyMustBeforeSpread: false,
314
- warnOnDuplicates: true
315
- }
316
- ],
317
- "react/jsx-no-script-url": "error",
318
- "react/jsx-no-useless-fragment": "error",
319
- "react/jsx-pascal-case": [
320
- "error",
321
- {
322
- allowAllCaps: false,
323
- allowNamespace: true,
324
- allowLeadingUnderscore: false
325
- }
326
- ],
327
- "react/jsx-props-no-spread-multi": "error",
328
- "react/no-access-state-in-setstate": "error",
329
- "react/no-array-index-key": "error",
330
- "react/no-danger": "error",
331
- "react/no-deprecated": "error",
332
- "react/no-direct-mutation-state": "error",
333
- "react/no-find-dom-node": "error",
334
- "react/no-is-mounted": "error",
335
- "react/no-render-return-value": "error",
336
- "react/no-unsafe": "error",
337
- ...options.overrides?.react
338
- }
339
- },
340
- {
341
- settings: {
342
- react: {
343
- version: options.reactVersion ?? "19.0"
344
- }
345
- }
346
- }
347
- ];
348
- }
349
-
350
- async function svelte(options) {
351
- if (!isEnabled(options.features, "svelte")) return [];
352
- const [sveltePlugin, svelteParser, tsParser] = await Promise.all([
353
- interopDefault(import('eslint-plugin-svelte')),
354
- interopDefault(import('svelte-eslint-parser')),
355
- interopDefault(import('@typescript-eslint/parser'))
356
- ]);
357
- const rules = {
358
- "svelte/block-lang": ["error", { script: "ts" }],
359
- "svelte/button-has-type": "error",
360
- "svelte/infinite-reactive-loop": "error",
361
- "svelte/no-at-debug-tags": "off",
362
- "svelte/no-at-html-tags": "error",
363
- "svelte/no-dom-manipulating": "error",
364
- "svelte/no-dupe-else-if-blocks": "error",
365
- "svelte/no-dupe-on-directives": "error",
366
- "svelte/no-dupe-style-properties": "error",
367
- "svelte/no-dupe-use-directives": "error",
368
- "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
369
- "svelte/no-ignored-unsubscribe": "error",
370
- "svelte/no-immutable-reactive-statements": "error",
371
- "svelte/no-inline-styles": "error",
372
- "svelte/no-inspect": "off",
373
- "svelte/no-not-function-handler": "error",
374
- "svelte/no-object-in-text-mustaches": "error",
375
- "svelte/no-reactive-functions": "error",
376
- "svelte/no-reactive-reassign": "error",
377
- "svelte/no-shorthand-style-property-overrides": "error",
378
- "svelte/no-store-async": "error",
379
- "svelte/no-target-blank": "error",
380
- "svelte/no-unknown-style-directive-property": "error",
381
- "svelte/no-unnecessary-state-wrap": "error",
382
- "svelte/no-unused-props": "error",
383
- "svelte/no-unused-svelte-ignore": "error",
384
- "svelte/no-useless-mustaches": "error",
385
- "svelte/require-each-key": "error",
386
- "svelte/require-store-reactive-access": "error",
387
- "svelte/require-stores-init": "error",
388
- "svelte/valid-each-key": "error",
389
- ...options.overrides?.svelte
390
- };
391
- return [
392
- {
393
- plugins: { svelte: sveltePlugin },
394
- rules
395
- },
396
- {
397
- files: [Glob.Svelte],
398
- languageOptions: {
399
- parser: svelteParser,
400
- parserOptions: {
401
- parser: tsParser,
402
- project: options.project,
403
- extraFileExtensions: [".svelte"]
404
- }
405
- }
406
- }
407
- ];
408
- }
409
-
410
- async function unicorn(options) {
411
- if (!isEnabled(options.features, "unicorn")) return {};
412
- const plugin = await interopDefault(import('eslint-plugin-unicorn'));
413
- return {
414
- plugins: { unicorn: plugin },
415
- rules: {
416
- "unicorn/catch-error-name": ["error", { name: "err" }],
417
- "unicorn/consistent-date-clone": "error",
418
- "unicorn/consistent-empty-array-spread": "error",
419
- "unicorn/consistent-existence-index-check": "error",
420
- "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
421
- "unicorn/custom-error-definition": "error",
422
- "unicorn/error-message": "error",
423
- "unicorn/no-array-for-each": "off",
424
- "unicorn/no-array-method-this-argument": "error",
425
- "unicorn/no-array-push-push": "error",
426
- "unicorn/no-await-expression-member": "error",
427
- "unicorn/no-await-in-promise-methods": "error",
428
- "unicorn/no-invalid-fetch-options": "error",
429
- "unicorn/no-invalid-remove-event-listener": "error",
430
- "unicorn/no-length-as-slice-end": "error",
431
- "unicorn/no-magic-array-flat-depth": "error",
432
- "unicorn/no-negation-in-equality-check": "error",
433
- "unicorn/no-single-promise-in-promise-methods": "error",
434
- "unicorn/no-thenable": "error",
435
- "unicorn/no-typeof-undefined": "off",
436
- "unicorn/no-useless-fallback-in-spread": "error",
437
- "unicorn/no-useless-length-check": "error",
438
- "unicorn/no-useless-promise-resolve-reject": "error",
439
- "unicorn/prefer-at": "error",
440
- "unicorn/prefer-date-now": "error",
441
- "unicorn/prefer-dom-node-append": "error",
442
- "unicorn/prefer-dom-node-dataset": "error",
443
- "unicorn/prefer-dom-node-remove": "error",
444
- "unicorn/prefer-dom-node-text-content": "error",
445
- "unicorn/prefer-global-this": "off",
446
- "unicorn/prefer-math-min-max": "error",
447
- "unicorn/prefer-modern-dom-apis": "error",
448
- "unicorn/prefer-node-protocol": "error",
449
- "unicorn/prefer-number-properties": "error",
450
- "unicorn/prefer-object-from-entries": "error",
451
- "unicorn/prefer-prototype-methods": "error",
452
- "unicorn/prefer-query-selector": "error",
453
- "unicorn/prefer-reflect-apply": "error",
454
- "unicorn/prefer-regexp-test": "error",
455
- "unicorn/prefer-string-raw": "error",
456
- "unicorn/prefer-string-slice": "error",
457
- "unicorn/prefer-structured-clone": "error",
458
- "unicorn/prefer-type-error": "error",
459
- "unicorn/relative-url-style": ["error", "never"],
460
- ...options.overrides?.unicorn
461
- }
462
- };
463
- }
464
-
465
- async function tailwind(options) {
466
- if (!isEnabled(options.features, "tailwind")) return {};
467
- const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
468
- const callees = ["classnames", "clsx", "cn", "ctl", "cva", "tv"];
469
- const rules = {
470
- "tailwindcss/enforces-shorthand": ["error", { callees }],
471
- "tailwindcss/no-contradicting-classname": ["error", { callees }],
472
- ...options.overrides?.tailwind
473
- };
474
- return {
475
- plugins: { tailwindcss: plugin },
476
- rules
477
- };
478
- }
479
-
480
- function javascript(options) {
481
- const files = [Glob.All];
482
- if (isEnabled(options.features, "vue")) {
483
- files.push(Glob.Vue);
484
- }
485
- if (isEnabled(options.features, "svelte")) {
486
- files.push(Glob.Svelte);
487
- }
488
- return {
489
- files,
490
- languageOptions: {
491
- ecmaVersion: "latest",
492
- sourceType: "module",
493
- parserOptions: {
494
- ecmaFeatures: {
495
- jsx: isEnabled(options.features, "react")
496
- }
497
- },
498
- globals: {
499
- ...globals.browser,
500
- ...globals.es2021,
501
- ...globals.node,
502
- document: "readonly",
503
- window: "readonly"
504
- }
505
- },
506
- rules: {
507
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
508
- "array-callback-return": [
509
- "error",
510
- {
511
- checkForEach: false,
512
- allowVoid: true
513
- }
514
- ],
515
- "block-scoped-var": "error",
516
- "consistent-this": ["error", "self"],
517
- "default-case-last": "error",
518
- eqeqeq: ["error", "always"],
519
- "for-direction": "error",
520
- "func-style": ["error", "declaration", { allowArrowFunctions: true }],
521
- "grouped-accessor-pairs": ["error", "getBeforeSet"],
522
- "guard-for-in": "error",
523
- "init-declarations": "off",
524
- "logical-assignment-operators": ["error", "always", { enforceForIfStatements: true }],
525
- "max-params": "off",
526
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
527
- "no-alert": "error",
528
- "no-async-promise-executor": "error",
529
- "no-caller": "error",
530
- "no-case-declarations": "error",
531
- "no-class-assign": "error",
532
- "no-compare-neg-zero": "error",
533
- "no-cond-assign": ["error", "always"],
534
- "no-constant-binary-expression": "error",
535
- "no-constant-condition": "error",
536
- "no-constructor-return": "error",
537
- "no-control-regex": "error",
538
- "no-debugger": "error",
539
- "no-delete-var": "error",
540
- "no-dupe-else-if": "error",
541
- "no-duplicate-case": "error",
542
- "no-duplicate-imports": ["error", { includeExports: false }],
543
- "no-else-return": "error",
544
- "no-empty": ["error", { allowEmptyCatch: true }],
545
- "no-empty-character-class": "error",
546
- "no-empty-pattern": "error",
547
- "no-empty-static-block": "error",
548
- "no-eval": "error",
549
- "no-ex-assign": "error",
550
- "no-extend-native": "error",
551
- "no-extra-bind": "error",
552
- "no-extra-boolean-cast": "error",
553
- "no-fallthrough": ["error", { allowEmptyCase: true }],
554
- "no-global-assign": "error",
555
- "no-implicit-coercion": ["error", { disallowTemplateShorthand: true }],
556
- "no-import-assign": "error",
557
- "no-inner-declarations": ["error", "both"],
558
- "no-invalid-regexp": "error",
559
- "no-irregular-whitespace": "error",
560
- "no-iterator": "error",
561
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
562
- "no-lone-blocks": "error",
563
- "no-lonely-if": "error",
564
- "no-loss-of-precision": "error",
565
- "no-misleading-character-class": "error",
566
- "no-multi-assign": "error",
567
- "no-multi-str": "error",
568
- "no-new": "error",
569
- "no-new-func": "error",
570
- "no-new-native-nonconstructor": "error",
571
- "no-new-wrappers": "error",
572
- "no-nonoctal-decimal-escape": "error",
573
- "no-object-constructor": "error",
574
- "no-octal": "error",
575
- "no-octal-escape": "error",
576
- "no-promise-executor-return": ["error", { allowVoid: true }],
577
- "no-proto": "error",
578
- "no-prototype-builtins": "error",
579
- "no-regex-spaces": "error",
580
- "no-script-url": "error",
581
- "no-self-assign": "error",
582
- "no-self-compare": "error",
583
- "no-sequences": "error",
584
- "no-shadow-restricted-names": "error",
585
- "no-sparse-arrays": "error",
586
- "no-template-curly-in-string": "error",
587
- "no-undef-init": "error",
588
- "no-undefined": "error",
589
- "no-unexpected-multiline": "error",
590
- "no-unmodified-loop-condition": "error",
591
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
592
- "no-unreachable-loop": "error",
593
- "no-unsafe-finally": "error",
594
- "no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
595
- "no-unused-vars": "off",
596
- "no-useless-backreference": "error",
597
- "no-useless-call": "error",
598
- "no-useless-catch": "error",
599
- "no-useless-computed-key": "error",
600
- "no-useless-concat": "error",
601
- "no-useless-rename": "error",
602
- "no-useless-return": "error",
603
- "no-var": "error",
604
- "no-with": "error",
605
- "object-shorthand": ["error", "always"],
606
- "operator-assignment": ["error", "always"],
607
- "prefer-arrow-callback": "error",
608
- "prefer-const": [
609
- "error",
610
- {
611
- destructuring: "all",
612
- ignoreReadBeforeAssign: true
613
- }
614
- ],
615
- "prefer-destructuring": "off",
616
- "prefer-exponentiation-operator": "error",
617
- "prefer-object-has-own": "error",
618
- "prefer-object-spread": "error",
619
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
620
- "prefer-rest-params": "error",
621
- "prefer-spread": "error",
622
- "prefer-template": "error",
623
- "require-atomic-updates": ["error", { allowProperties: true }],
624
- "sort-imports": [
625
- "error",
626
- {
627
- allowSeparatedGroups: false,
628
- ignoreCase: false,
629
- ignoreDeclarationSort: true,
630
- ignoreMemberSort: false,
631
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
632
- }
633
- ],
634
- "symbol-description": "off",
635
- "use-isnan": "error",
636
- "valid-typeof": "error",
637
- yoda: ["error", "never"],
638
- ...options.overrides?.javascript
639
- }
640
- };
641
- }
642
-
643
- async function typescript(options) {
644
- const [tsParser, tsPlugin] = await Promise.all([
645
- interopDefault(import('@typescript-eslint/parser')),
646
- interopDefault(import('@typescript-eslint/eslint-plugin'))
647
- ]);
648
- const files = [Glob.Typescript];
649
- if (isEnabled(options.features, "vue")) {
650
- files.push(Glob.Vue);
651
- }
652
- if (isEnabled(options.features, "svelte")) {
653
- files.push(Glob.Svelte);
654
- }
655
- const extraFileExtensions = [];
656
- if (isEnabled(options.features, "vue")) {
657
- extraFileExtensions.push(".vue");
658
- }
659
- if (isEnabled(options.features, "svelte")) {
660
- extraFileExtensions.push(".svelte");
661
- }
662
- const rules = {
663
- "@typescript-eslint/adjacent-overload-signatures": "error",
664
- "no-array-constructor": "off",
665
- "@typescript-eslint/no-array-constructor": "error",
666
- "@typescript-eslint/array-type": ["error", { default: "array" }],
667
- "@typescript-eslint/ban-ts-comment": [
668
- "error",
669
- {
670
- "ts-expect-error": "allow-with-description",
671
- "ts-ignore": true,
672
- "ts-nocheck": true,
673
- "ts-check": false,
674
- minimumDescriptionLength: 3
675
- }
676
- ],
677
- "@typescript-eslint/class-literal-property-style": ["error", "fields"],
678
- "class-methods-use-this": "off",
679
- "@typescript-eslint/class-methods-use-this": [
680
- "error",
681
- {
682
- ignoreOverrideMethods: true,
683
- ignoreClassesThatImplementAnInterface: "public-fields"
684
- }
685
- ],
686
- "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
687
- "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
688
- "@typescript-eslint/consistent-type-assertions": [
689
- "error",
690
- {
691
- assertionStyle: "as",
692
- objectLiteralTypeAssertions: "allow-as-parameter"
693
- }
694
- ],
695
- "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
696
- "dot-notation": "off",
697
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
698
- "@typescript-eslint/explicit-function-return-type": "off",
699
- "@typescript-eslint/explicit-member-accessibility": [
700
- "error",
701
- {
702
- accessibility: "explicit",
703
- overrides: {
704
- accessors: "no-public",
705
- constructors: "no-public",
706
- methods: "explicit",
707
- properties: "explicit",
708
- parameterProperties: "explicit"
709
- }
710
- }
711
- ],
712
- "@typescript-eslint/explicit-module-boundary-types": "off",
713
- "@typescript-eslint/method-signature-style": ["error", "property"],
714
- camelcase: "off",
715
- "@typescript-eslint/naming-convention": [
716
- "error",
717
- {
718
- selector: ["classProperty", "variable"],
719
- format: ["strictCamelCase", "UPPER_CASE"],
720
- leadingUnderscore: "allow"
721
- },
722
- {
723
- selector: ["classicAccessor", "classMethod", "parameter", "parameterProperty"],
724
- format: ["strictCamelCase"],
725
- leadingUnderscore: "allow"
726
- },
727
- {
728
- selector: ["function"],
729
- format: ["strictCamelCase", "StrictPascalCase"]
730
- },
731
- {
732
- selector: ["class", "enum", "enumMember", "interface", "typeAlias", "typeParameter"],
733
- format: ["StrictPascalCase"]
734
- }
735
- ],
736
- "@typescript-eslint/no-array-delete": "error",
737
- "@typescript-eslint/no-base-to-string": "error",
738
- "@typescript-eslint/no-confusing-non-null-assertion": "error",
739
- "@typescript-eslint/no-confusing-void-expression": [
740
- "error",
741
- {
742
- ignoreArrowShorthand: true,
743
- ignoreVoidOperator: true
744
- }
745
- ],
746
- "@typescript-eslint/no-duplicate-enum-values": "error",
747
- "@typescript-eslint/no-duplicate-type-constituents": "error",
748
- "@typescript-eslint/no-dynamic-delete": "error",
749
- "@typescript-eslint/no-empty-object-type": [
750
- "error",
751
- {
752
- allowInterfaces: "never",
753
- allowObjectTypes: "never"
754
- }
755
- ],
756
- "@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
757
- "@typescript-eslint/no-extra-non-null-assertion": "error",
758
- "@typescript-eslint/no-extraneous-class": "error",
759
- "@typescript-eslint/no-floating-promises": [
760
- "error",
761
- {
762
- allowForKnownSafeCalls: options.knownSafeCalls ?? [],
763
- allowForKnownSafePromises: options.knownSafePromises ?? [],
764
- checkThenables: false,
765
- ignoreIIFE: true,
766
- ignoreVoid: true
767
- }
768
- ],
769
- "@typescript-eslint/no-for-in-array": "error",
770
- "no-implied-eval": "off",
771
- "@typescript-eslint/no-implied-eval": "error",
772
- "@typescript-eslint/no-import-type-side-effects": "error",
773
- "@typescript-eslint/no-inferrable-types": "error",
774
- "@typescript-eslint/no-invalid-void-type": [
775
- "error",
776
- {
777
- allowInGenericTypeArguments: true,
778
- allowAsThisParameter: true
779
- }
780
- ],
781
- "no-loop-func": "off",
782
- "@typescript-eslint/no-loop-func": "error",
783
- "@typescript-eslint/no-meaningless-void-operator": "error",
784
- "@typescript-eslint/no-misused-new": "error",
785
- "@typescript-eslint/no-misused-promises": [
786
- "error",
787
- {
788
- checksConditionals: true,
789
- checksSpreads: true,
790
- checksVoidReturn: {
791
- arguments: true,
792
- attributes: true,
793
- properties: true,
794
- returns: true,
795
- variables: true
796
- }
797
- }
798
- ],
799
- "@typescript-eslint/no-misused-spread": "error",
800
- "@typescript-eslint/no-mixed-enums": "error",
801
- "@typescript-eslint/no-namespace": "error",
802
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
803
- "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
804
- "@typescript-eslint/no-non-null-assertion": "error",
805
- "@typescript-eslint/no-redundant-type-constituents": "off",
806
- "@typescript-eslint/no-require-imports": "error",
807
- "no-shadow": "off",
808
- "@typescript-eslint/no-shadow": "error",
809
- "@typescript-eslint/no-this-alias": "error",
810
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": [
811
- "error",
812
- {
813
- allowComparingNullableBooleansToTrue: false,
814
- allowComparingNullableBooleansToFalse: true
815
- }
816
- ],
817
- "@typescript-eslint/no-unnecessary-condition": "error",
818
- "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
819
- "@typescript-eslint/no-unnecessary-qualifier": "error",
820
- "@typescript-eslint/no-unnecessary-type-arguments": "error",
821
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
822
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
823
- "@typescript-eslint/no-unnecessary-type-parameters": "error",
824
- "@typescript-eslint/no-unsafe-argument": "off",
825
- "@typescript-eslint/no-unsafe-assignment": "off",
826
- "@typescript-eslint/no-unsafe-call": "error",
827
- "@typescript-eslint/no-unsafe-declaration-merging": "error",
828
- "@typescript-eslint/no-unsafe-function-type": "error",
829
- "@typescript-eslint/no-unsafe-enum-comparison": "off",
830
- "@typescript-eslint/no-unsafe-member-access": "error",
831
- "@typescript-eslint/no-unsafe-return": "off",
832
- "@typescript-eslint/no-unsafe-unary-minus": "error",
833
- "no-unused-expressions": "off",
834
- "@typescript-eslint/no-unused-expressions": ["error", { allowTaggedTemplates: true }],
835
- "no-use-before-define": "off",
836
- "@typescript-eslint/no-use-before-define": [
837
- "error",
838
- {
839
- functions: false,
840
- enums: true,
841
- typedefs: false
842
- }
843
- ],
844
- "no-useless-constructor": "off",
845
- "@typescript-eslint/no-useless-constructor": "error",
846
- "@typescript-eslint/no-useless-empty-export": "error",
847
- "@typescript-eslint/no-wrapper-object-types": "error",
848
- "@typescript-eslint/non-nullable-type-assertion-style": "error",
849
- "no-throw-literal": "off",
850
- "@typescript-eslint/only-throw-error": [
851
- "error",
852
- {
853
- allowThrowingAny: false,
854
- allowThrowingUnknown: false
855
- }
856
- ],
857
- "@typescript-eslint/prefer-as-const": "error",
858
- "@typescript-eslint/prefer-enum-initializers": "error",
859
- "@typescript-eslint/prefer-find": "error",
860
- "@typescript-eslint/prefer-for-of": "error",
861
- "@typescript-eslint/prefer-function-type": "off",
862
- "@typescript-eslint/prefer-includes": "error",
863
- "@typescript-eslint/prefer-literal-enum-member": "error",
864
- "@typescript-eslint/prefer-nullish-coalescing": [
865
- "error",
866
- {
867
- ignoreTernaryTests: false,
868
- ignoreConditionalTests: false,
869
- ignoreMixedLogicalExpressions: false,
870
- ignorePrimitives: {
871
- bigint: false,
872
- boolean: false,
873
- number: false,
874
- string: false
875
- }
876
- }
877
- ],
878
- "@typescript-eslint/prefer-optional-chain": "error",
879
- "prefer-promise-reject-errors": "off",
880
- "@typescript-eslint/prefer-promise-reject-errors": [
881
- "error",
882
- {
883
- allowThrowingAny: false,
884
- allowThrowingUnknown: false
885
- }
886
- ],
887
- "@typescript-eslint/prefer-readonly": "error",
888
- "@typescript-eslint/prefer-readonly-parameter-types": "off",
889
- "@typescript-eslint/prefer-reduce-type-parameter": "error",
890
- "@typescript-eslint/prefer-regexp-exec": "error",
891
- "@typescript-eslint/prefer-return-this-type": "error",
892
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
893
- "@typescript-eslint/promise-function-async": "off",
894
- "@typescript-eslint/require-array-sort-compare": "error",
895
- "require-await": "off",
896
- "@typescript-eslint/require-await": "error",
897
- "@typescript-eslint/restrict-plus-operands": "error",
898
- "@typescript-eslint/restrict-template-expressions": "error",
899
- "no-return-await": "off",
900
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
901
- "@typescript-eslint/strict-boolean-expressions": "off",
902
- "@typescript-eslint/switch-exhaustiveness-check": [
903
- "error",
904
- {
905
- considerDefaultExhaustiveForUnions: true,
906
- requireDefaultForNonUnion: true
907
- }
908
- ],
909
- "@typescript-eslint/unbound-method": "error",
910
- "@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
911
- "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
912
- ...options.overrides?.typescript
913
- };
914
- return [
915
- {
916
- files,
917
- languageOptions: {
918
- ecmaVersion: "latest",
919
- sourceType: "module",
920
- parser: tsParser,
921
- parserOptions: {
922
- project: options.project,
923
- tsconfigRootDir: process.cwd(),
924
- extraFileExtensions,
925
- ecmaFeatures: {
926
- jsx: isEnabled(options.features, "react")
927
- }
928
- }
929
- },
930
- plugins: { "@typescript-eslint": tsPlugin },
931
- rules
932
- },
933
- {
934
- files: options.moduleBoundaryTypesFiles ?? ["*.ts", "*.tsx"],
935
- rules: {
936
- "@typescript-eslint/explicit-module-boundary-types": "error"
937
- }
938
- }
939
- ];
940
- }
941
-
942
- async function reactHooks(options) {
943
- if (!isEnabled(options.features, "reactHooks")) return {};
944
- const plugin = await interopDefault(import('eslint-plugin-react-hooks'));
945
- return {
946
- plugins: { "react-hooks": plugin },
947
- rules: {
948
- "react-hooks/rules-of-hooks": "error",
949
- "react-hooks/exhaustive-deps": "error",
950
- ...options.overrides?.reactHooks
951
- }
952
- };
953
- }
954
-
955
- async function perfectionist(options) {
956
- if (!isEnabled(options.features, "perfectionist")) return {};
957
- const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
958
- return {
959
- plugins: { perfectionist: plugin },
960
- rules: {
961
- "perfectionist/sort-array-includes": [
962
- "error",
963
- {
964
- type: "natural",
965
- order: "asc",
966
- ignoreCase: true,
967
- groupKind: "literals-first"
968
- }
969
- ],
970
- "perfectionist/sort-enums": [
971
- "error",
972
- {
973
- type: "natural",
974
- order: "asc"
975
- }
976
- ],
977
- "perfectionist/sort-exports": [
978
- "error",
979
- {
980
- type: "line-length",
981
- order: "asc",
982
- ignoreCase: true
983
- }
984
- ],
985
- "perfectionist/sort-imports": [
986
- "error",
987
- {
988
- type: "line-length",
989
- order: "asc",
990
- ignoreCase: true,
991
- newlinesBetween: "never",
992
- groups: [["side-effect-style", "side-effect"], "unknown"]
993
- }
994
- ],
995
- "perfectionist/sort-interfaces": [
996
- "error",
997
- {
998
- type: "natural",
999
- order: "asc",
1000
- ignoreCase: true,
1001
- partitionByNewLine: true
1002
- }
1003
- ],
1004
- "perfectionist/sort-intersection-types": [
1005
- "error",
1006
- {
1007
- type: "natural",
1008
- order: "asc"
1009
- }
1010
- ],
1011
- "perfectionist/sort-maps": [
1012
- "error",
1013
- {
1014
- type: "natural",
1015
- order: "asc"
1016
- }
1017
- ],
1018
- "perfectionist/sort-named-exports": [
1019
- "error",
1020
- {
1021
- type: "natural",
1022
- order: "asc"
1023
- }
1024
- ],
1025
- "sort-imports": "off",
1026
- "perfectionist/sort-named-imports": [
1027
- "error",
1028
- {
1029
- type: "natural",
1030
- order: "asc"
1031
- }
1032
- ],
1033
- "@typescript-eslint/adjacent-overload-signatures": "off",
1034
- "perfectionist/sort-object-types": [
1035
- "error",
1036
- {
1037
- type: "natural",
1038
- order: "asc",
1039
- partitionByNewLine: true
1040
- }
1041
- ],
1042
- "perfectionist/sort-switch-case": [
1043
- "error",
1044
- {
1045
- type: "natural",
1046
- order: "asc",
1047
- ignoreCase: true
1048
- }
1049
- ],
1050
- ...options.overrides?.perfectionist
1051
- }
1052
- };
1053
- }
1054
-
1055
- async function reactCompiler(options) {
1056
- if (!isEnabled(options.features, "reactCompiler")) return {};
1057
- const plugin = await interopDefault(import('eslint-plugin-react-compiler'));
1058
- return {
1059
- plugins: { "react-compiler": plugin },
1060
- rules: {
1061
- "react-compiler/react-compiler": "error",
1062
- ...options.overrides?.reactCompiler
1063
- }
1064
- };
1065
- }
1066
-
1067
- async function defineConfig(options) {
1068
- const ignores = {
1069
- ignores: [...getIgnores(), ...options.ignores ?? []]
1070
- };
1071
- const objects = await Promise.all([
1072
- javascript(options),
1073
- ...await typescript(options),
1074
- ...await vue(options),
1075
- ...await svelte(options),
1076
- ...await react(options),
1077
- reactHooks(options),
1078
- reactCompiler(options),
1079
- perfectionist(options),
1080
- unicorn(options),
1081
- tailwind(options),
1082
- ignores
1083
- ]);
1084
- return objects;
1085
- }
1086
-
1087
- exports.defineConfig = defineConfig;