@tb-dev/eslint-config 4.4.0 → 4.4.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.cjs +26 -31
- package/dist/index.d.ts +17 -16
- package/dist/index.js +24 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
3
5
|
const process = require('node:process');
|
|
4
6
|
const globals = require('globals');
|
|
5
7
|
|
|
@@ -144,14 +146,13 @@ const stylisticRules = {
|
|
|
144
146
|
"stylistic/yield-star-spacing": ["error", "after"]
|
|
145
147
|
};
|
|
146
148
|
async function stylistic(options) {
|
|
147
|
-
|
|
148
|
-
if (!enabled) return {};
|
|
149
|
+
if (!options.features?.stylistic) return {};
|
|
149
150
|
const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
|
|
150
151
|
const files = [Glob.All];
|
|
151
|
-
if (options.vue) files.push(Glob.Vue);
|
|
152
|
+
if (options.features.vue) files.push(Glob.Vue);
|
|
152
153
|
const rules = {
|
|
153
154
|
...stylisticRules,
|
|
154
|
-
...overrides?.stylistic
|
|
155
|
+
...options.overrides?.stylistic
|
|
155
156
|
};
|
|
156
157
|
return {
|
|
157
158
|
files,
|
|
@@ -161,8 +162,7 @@ async function stylistic(options) {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
async function vue(options) {
|
|
164
|
-
|
|
165
|
-
if (!enabled) return [];
|
|
165
|
+
if (!options.features?.vue) return [];
|
|
166
166
|
const [vuePlugin, vueParser, tsParser] = await Promise.all([
|
|
167
167
|
// @ts-expect-error no types
|
|
168
168
|
interopDefault(import('eslint-plugin-vue')),
|
|
@@ -323,9 +323,9 @@ async function vue(options) {
|
|
|
323
323
|
"vue/valid-v-show": "error",
|
|
324
324
|
"vue/valid-v-slot": "error",
|
|
325
325
|
"vue/valid-v-text": "error",
|
|
326
|
-
...overrides?.vue
|
|
326
|
+
...options.overrides?.vue
|
|
327
327
|
};
|
|
328
|
-
if (options.stylistic) {
|
|
328
|
+
if (options.features.stylistic) {
|
|
329
329
|
Object.assign(rules, {
|
|
330
330
|
"vue/first-attribute-linebreak": ["error", {
|
|
331
331
|
singleline: "beside",
|
|
@@ -431,8 +431,7 @@ async function vue(options) {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
async function jsonc(options) {
|
|
434
|
-
|
|
435
|
-
if (!enabled) return [];
|
|
434
|
+
if (!options.features?.jsonc) return [];
|
|
436
435
|
const [jsoncPlugin, jsoncParser] = await Promise.all([
|
|
437
436
|
interopDefault(import('eslint-plugin-jsonc')),
|
|
438
437
|
interopDefault(import('jsonc-eslint-parser'))
|
|
@@ -446,9 +445,9 @@ async function jsonc(options) {
|
|
|
446
445
|
"jsonc/no-number-props": "error",
|
|
447
446
|
"jsonc/no-undefined-value": "error",
|
|
448
447
|
"jsonc/valid-json-number": "error",
|
|
449
|
-
...overrides?.jsonc
|
|
448
|
+
...options.overrides?.jsonc
|
|
450
449
|
};
|
|
451
|
-
if (options.stylistic) {
|
|
450
|
+
if (options.features.stylistic) {
|
|
452
451
|
Object.assign(rules, {
|
|
453
452
|
"jsonc/comma-dangle": ["error", "never"],
|
|
454
453
|
"jsonc/quotes": ["error", "double", { avoidEscape: false }],
|
|
@@ -484,8 +483,7 @@ async function jsonc(options) {
|
|
|
484
483
|
}
|
|
485
484
|
|
|
486
485
|
async function vitest(options) {
|
|
487
|
-
|
|
488
|
-
if (!enabled) return {};
|
|
486
|
+
if (!options.features?.vitest) return {};
|
|
489
487
|
const plugin = await interopDefault(import('eslint-plugin-vitest'));
|
|
490
488
|
return {
|
|
491
489
|
plugins: { vitest: plugin },
|
|
@@ -522,13 +520,13 @@ async function vitest(options) {
|
|
|
522
520
|
"vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
|
|
523
521
|
"vitest/valid-describe-callback": "error",
|
|
524
522
|
"vitest/valid-expect": "error",
|
|
525
|
-
...overrides?.vitest
|
|
523
|
+
...options.overrides?.vitest
|
|
526
524
|
}
|
|
527
525
|
};
|
|
528
526
|
}
|
|
529
527
|
|
|
530
528
|
async function unicorn(options) {
|
|
531
|
-
const {
|
|
529
|
+
const { unicorn: enabled = true } = options.features ?? {};
|
|
532
530
|
if (!enabled) return {};
|
|
533
531
|
const plugin = await interopDefault(import('eslint-plugin-unicorn'));
|
|
534
532
|
return {
|
|
@@ -573,20 +571,19 @@ async function unicorn(options) {
|
|
|
573
571
|
"unicorn/prefer-structured-clone": "error",
|
|
574
572
|
"unicorn/prefer-type-error": "error",
|
|
575
573
|
"unicorn/relative-url-style": ["error", "never"],
|
|
576
|
-
...overrides?.unicorn
|
|
574
|
+
...options.overrides?.unicorn
|
|
577
575
|
}
|
|
578
576
|
};
|
|
579
577
|
}
|
|
580
578
|
|
|
581
579
|
async function tailwind(options) {
|
|
582
|
-
|
|
583
|
-
if (!enabled) return {};
|
|
580
|
+
if (!options.features?.tailwind) return {};
|
|
584
581
|
const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
|
|
585
582
|
const rules = {
|
|
586
583
|
"tailwindcss/classnames-order": "error",
|
|
587
584
|
"tailwindcss/enforces-shorthand": "error",
|
|
588
585
|
"tailwindcss/no-contradicting-classname": "error",
|
|
589
|
-
...overrides?.tailwind
|
|
586
|
+
...options.overrides?.tailwind
|
|
590
587
|
};
|
|
591
588
|
return {
|
|
592
589
|
plugins: { tailwindcss: plugin },
|
|
@@ -595,9 +592,8 @@ async function tailwind(options) {
|
|
|
595
592
|
}
|
|
596
593
|
|
|
597
594
|
function javascript(options) {
|
|
598
|
-
const { overrides } = options;
|
|
599
595
|
const files = [Glob.All];
|
|
600
|
-
if (options.vue) files.push(Glob.Vue);
|
|
596
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
601
597
|
return {
|
|
602
598
|
files,
|
|
603
599
|
languageOptions: {
|
|
@@ -733,19 +729,18 @@ function javascript(options) {
|
|
|
733
729
|
"use-isnan": "error",
|
|
734
730
|
"valid-typeof": "error",
|
|
735
731
|
yoda: ["error", "never"],
|
|
736
|
-
...overrides?.javascript
|
|
732
|
+
...options.overrides?.javascript
|
|
737
733
|
}
|
|
738
734
|
};
|
|
739
735
|
}
|
|
740
736
|
|
|
741
737
|
async function typescript(options) {
|
|
742
|
-
const { project, overrides } = options;
|
|
743
738
|
const [tsParser, tsPlugin] = await Promise.all([
|
|
744
739
|
interopDefault(import('@typescript-eslint/parser')),
|
|
745
740
|
interopDefault(import('@typescript-eslint/eslint-plugin'))
|
|
746
741
|
]);
|
|
747
742
|
const files = [Glob.Typescript];
|
|
748
|
-
if (options.vue) files.push(Glob.Vue);
|
|
743
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
749
744
|
const rules = {
|
|
750
745
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
751
746
|
"no-array-constructor": "off",
|
|
@@ -946,7 +941,7 @@ async function typescript(options) {
|
|
|
946
941
|
"@typescript-eslint/unbound-method": "error",
|
|
947
942
|
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
948
943
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
949
|
-
...overrides?.typescript
|
|
944
|
+
...options.overrides?.typescript
|
|
950
945
|
};
|
|
951
946
|
return {
|
|
952
947
|
files,
|
|
@@ -955,9 +950,9 @@ async function typescript(options) {
|
|
|
955
950
|
sourceType: "module",
|
|
956
951
|
parser: tsParser,
|
|
957
952
|
parserOptions: {
|
|
958
|
-
project,
|
|
953
|
+
project: options.project,
|
|
959
954
|
tsconfigRootDir: process.cwd(),
|
|
960
|
-
extraFileExtensions: options.vue ? [".vue"] : []
|
|
955
|
+
extraFileExtensions: options.features?.vue ? [".vue"] : []
|
|
961
956
|
}
|
|
962
957
|
},
|
|
963
958
|
plugins: { "@typescript-eslint": tsPlugin },
|
|
@@ -966,7 +961,7 @@ async function typescript(options) {
|
|
|
966
961
|
}
|
|
967
962
|
|
|
968
963
|
async function perfectionist(options) {
|
|
969
|
-
const {
|
|
964
|
+
const { perfectionist: enabled = true } = options.features ?? {};
|
|
970
965
|
if (!enabled) return {};
|
|
971
966
|
const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
|
|
972
967
|
return {
|
|
@@ -1027,7 +1022,7 @@ async function perfectionist(options) {
|
|
|
1027
1022
|
order: "asc",
|
|
1028
1023
|
ignoreCase: true
|
|
1029
1024
|
}],
|
|
1030
|
-
...overrides?.perfectionist
|
|
1025
|
+
...options.overrides?.perfectionist
|
|
1031
1026
|
}
|
|
1032
1027
|
};
|
|
1033
1028
|
}
|
|
@@ -1051,4 +1046,4 @@ async function defineConfig(options) {
|
|
|
1051
1046
|
return objects;
|
|
1052
1047
|
}
|
|
1053
1048
|
|
|
1054
|
-
|
|
1049
|
+
exports.defineConfig = defineConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,20 +15,22 @@ declare interface ConfigObject {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare interface ConfigOptions {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
features?: {
|
|
19
|
+
/** @default false */
|
|
20
|
+
jsonc?: boolean;
|
|
21
|
+
/** @default true */
|
|
22
|
+
perfectionist?: boolean;
|
|
23
|
+
/** @default false */
|
|
24
|
+
stylistic?: boolean;
|
|
25
|
+
/** @default false */
|
|
26
|
+
tailwind?: boolean;
|
|
27
|
+
/** @default true */
|
|
28
|
+
unicorn?: boolean;
|
|
29
|
+
/** @default false */
|
|
30
|
+
vitest?: boolean;
|
|
31
|
+
/** @default false */
|
|
32
|
+
vue?: boolean;
|
|
33
|
+
};
|
|
32
34
|
/** `tsconfig.json` files for TypeScript. */
|
|
33
35
|
project: string[];
|
|
34
36
|
ignores?: Ignores['ignores'];
|
|
@@ -47,8 +49,7 @@ declare interface ConfigOptions {
|
|
|
47
49
|
knownSafePromises?: KnownSafePromise[];
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
|
|
51
|
-
export default defineConfig;
|
|
52
|
+
export declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
|
|
52
53
|
|
|
53
54
|
declare interface Ignores {
|
|
54
55
|
ignores: string[];
|
package/dist/index.js
CHANGED
|
@@ -142,14 +142,13 @@ const stylisticRules = {
|
|
|
142
142
|
"stylistic/yield-star-spacing": ["error", "after"]
|
|
143
143
|
};
|
|
144
144
|
async function stylistic(options) {
|
|
145
|
-
|
|
146
|
-
if (!enabled) return {};
|
|
145
|
+
if (!options.features?.stylistic) return {};
|
|
147
146
|
const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
|
|
148
147
|
const files = [Glob.All];
|
|
149
|
-
if (options.vue) files.push(Glob.Vue);
|
|
148
|
+
if (options.features.vue) files.push(Glob.Vue);
|
|
150
149
|
const rules = {
|
|
151
150
|
...stylisticRules,
|
|
152
|
-
...overrides?.stylistic
|
|
151
|
+
...options.overrides?.stylistic
|
|
153
152
|
};
|
|
154
153
|
return {
|
|
155
154
|
files,
|
|
@@ -159,8 +158,7 @@ async function stylistic(options) {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
async function vue(options) {
|
|
162
|
-
|
|
163
|
-
if (!enabled) return [];
|
|
161
|
+
if (!options.features?.vue) return [];
|
|
164
162
|
const [vuePlugin, vueParser, tsParser] = await Promise.all([
|
|
165
163
|
// @ts-expect-error no types
|
|
166
164
|
interopDefault(import('eslint-plugin-vue')),
|
|
@@ -321,9 +319,9 @@ async function vue(options) {
|
|
|
321
319
|
"vue/valid-v-show": "error",
|
|
322
320
|
"vue/valid-v-slot": "error",
|
|
323
321
|
"vue/valid-v-text": "error",
|
|
324
|
-
...overrides?.vue
|
|
322
|
+
...options.overrides?.vue
|
|
325
323
|
};
|
|
326
|
-
if (options.stylistic) {
|
|
324
|
+
if (options.features.stylistic) {
|
|
327
325
|
Object.assign(rules, {
|
|
328
326
|
"vue/first-attribute-linebreak": ["error", {
|
|
329
327
|
singleline: "beside",
|
|
@@ -429,8 +427,7 @@ async function vue(options) {
|
|
|
429
427
|
}
|
|
430
428
|
|
|
431
429
|
async function jsonc(options) {
|
|
432
|
-
|
|
433
|
-
if (!enabled) return [];
|
|
430
|
+
if (!options.features?.jsonc) return [];
|
|
434
431
|
const [jsoncPlugin, jsoncParser] = await Promise.all([
|
|
435
432
|
interopDefault(import('eslint-plugin-jsonc')),
|
|
436
433
|
interopDefault(import('jsonc-eslint-parser'))
|
|
@@ -444,9 +441,9 @@ async function jsonc(options) {
|
|
|
444
441
|
"jsonc/no-number-props": "error",
|
|
445
442
|
"jsonc/no-undefined-value": "error",
|
|
446
443
|
"jsonc/valid-json-number": "error",
|
|
447
|
-
...overrides?.jsonc
|
|
444
|
+
...options.overrides?.jsonc
|
|
448
445
|
};
|
|
449
|
-
if (options.stylistic) {
|
|
446
|
+
if (options.features.stylistic) {
|
|
450
447
|
Object.assign(rules, {
|
|
451
448
|
"jsonc/comma-dangle": ["error", "never"],
|
|
452
449
|
"jsonc/quotes": ["error", "double", { avoidEscape: false }],
|
|
@@ -482,8 +479,7 @@ async function jsonc(options) {
|
|
|
482
479
|
}
|
|
483
480
|
|
|
484
481
|
async function vitest(options) {
|
|
485
|
-
|
|
486
|
-
if (!enabled) return {};
|
|
482
|
+
if (!options.features?.vitest) return {};
|
|
487
483
|
const plugin = await interopDefault(import('eslint-plugin-vitest'));
|
|
488
484
|
return {
|
|
489
485
|
plugins: { vitest: plugin },
|
|
@@ -520,13 +516,13 @@ async function vitest(options) {
|
|
|
520
516
|
"vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
|
|
521
517
|
"vitest/valid-describe-callback": "error",
|
|
522
518
|
"vitest/valid-expect": "error",
|
|
523
|
-
...overrides?.vitest
|
|
519
|
+
...options.overrides?.vitest
|
|
524
520
|
}
|
|
525
521
|
};
|
|
526
522
|
}
|
|
527
523
|
|
|
528
524
|
async function unicorn(options) {
|
|
529
|
-
const {
|
|
525
|
+
const { unicorn: enabled = true } = options.features ?? {};
|
|
530
526
|
if (!enabled) return {};
|
|
531
527
|
const plugin = await interopDefault(import('eslint-plugin-unicorn'));
|
|
532
528
|
return {
|
|
@@ -571,20 +567,19 @@ async function unicorn(options) {
|
|
|
571
567
|
"unicorn/prefer-structured-clone": "error",
|
|
572
568
|
"unicorn/prefer-type-error": "error",
|
|
573
569
|
"unicorn/relative-url-style": ["error", "never"],
|
|
574
|
-
...overrides?.unicorn
|
|
570
|
+
...options.overrides?.unicorn
|
|
575
571
|
}
|
|
576
572
|
};
|
|
577
573
|
}
|
|
578
574
|
|
|
579
575
|
async function tailwind(options) {
|
|
580
|
-
|
|
581
|
-
if (!enabled) return {};
|
|
576
|
+
if (!options.features?.tailwind) return {};
|
|
582
577
|
const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
|
|
583
578
|
const rules = {
|
|
584
579
|
"tailwindcss/classnames-order": "error",
|
|
585
580
|
"tailwindcss/enforces-shorthand": "error",
|
|
586
581
|
"tailwindcss/no-contradicting-classname": "error",
|
|
587
|
-
...overrides?.tailwind
|
|
582
|
+
...options.overrides?.tailwind
|
|
588
583
|
};
|
|
589
584
|
return {
|
|
590
585
|
plugins: { tailwindcss: plugin },
|
|
@@ -593,9 +588,8 @@ async function tailwind(options) {
|
|
|
593
588
|
}
|
|
594
589
|
|
|
595
590
|
function javascript(options) {
|
|
596
|
-
const { overrides } = options;
|
|
597
591
|
const files = [Glob.All];
|
|
598
|
-
if (options.vue) files.push(Glob.Vue);
|
|
592
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
599
593
|
return {
|
|
600
594
|
files,
|
|
601
595
|
languageOptions: {
|
|
@@ -731,19 +725,18 @@ function javascript(options) {
|
|
|
731
725
|
"use-isnan": "error",
|
|
732
726
|
"valid-typeof": "error",
|
|
733
727
|
yoda: ["error", "never"],
|
|
734
|
-
...overrides?.javascript
|
|
728
|
+
...options.overrides?.javascript
|
|
735
729
|
}
|
|
736
730
|
};
|
|
737
731
|
}
|
|
738
732
|
|
|
739
733
|
async function typescript(options) {
|
|
740
|
-
const { project, overrides } = options;
|
|
741
734
|
const [tsParser, tsPlugin] = await Promise.all([
|
|
742
735
|
interopDefault(import('@typescript-eslint/parser')),
|
|
743
736
|
interopDefault(import('@typescript-eslint/eslint-plugin'))
|
|
744
737
|
]);
|
|
745
738
|
const files = [Glob.Typescript];
|
|
746
|
-
if (options.vue) files.push(Glob.Vue);
|
|
739
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
747
740
|
const rules = {
|
|
748
741
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
749
742
|
"no-array-constructor": "off",
|
|
@@ -944,7 +937,7 @@ async function typescript(options) {
|
|
|
944
937
|
"@typescript-eslint/unbound-method": "error",
|
|
945
938
|
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
946
939
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
947
|
-
...overrides?.typescript
|
|
940
|
+
...options.overrides?.typescript
|
|
948
941
|
};
|
|
949
942
|
return {
|
|
950
943
|
files,
|
|
@@ -953,9 +946,9 @@ async function typescript(options) {
|
|
|
953
946
|
sourceType: "module",
|
|
954
947
|
parser: tsParser,
|
|
955
948
|
parserOptions: {
|
|
956
|
-
project,
|
|
949
|
+
project: options.project,
|
|
957
950
|
tsconfigRootDir: process.cwd(),
|
|
958
|
-
extraFileExtensions: options.vue ? [".vue"] : []
|
|
951
|
+
extraFileExtensions: options.features?.vue ? [".vue"] : []
|
|
959
952
|
}
|
|
960
953
|
},
|
|
961
954
|
plugins: { "@typescript-eslint": tsPlugin },
|
|
@@ -964,7 +957,7 @@ async function typescript(options) {
|
|
|
964
957
|
}
|
|
965
958
|
|
|
966
959
|
async function perfectionist(options) {
|
|
967
|
-
const {
|
|
960
|
+
const { perfectionist: enabled = true } = options.features ?? {};
|
|
968
961
|
if (!enabled) return {};
|
|
969
962
|
const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
|
|
970
963
|
return {
|
|
@@ -1025,7 +1018,7 @@ async function perfectionist(options) {
|
|
|
1025
1018
|
order: "asc",
|
|
1026
1019
|
ignoreCase: true
|
|
1027
1020
|
}],
|
|
1028
|
-
...overrides?.perfectionist
|
|
1021
|
+
...options.overrides?.perfectionist
|
|
1029
1022
|
}
|
|
1030
1023
|
};
|
|
1031
1024
|
}
|
|
@@ -1049,4 +1042,4 @@ async function defineConfig(options) {
|
|
|
1049
1042
|
return objects;
|
|
1050
1043
|
}
|
|
1051
1044
|
|
|
1052
|
-
export { defineConfig
|
|
1045
|
+
export { defineConfig };
|