@tb-dev/eslint-config 4.3.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 +96 -29
- package/dist/index.d.ts +19 -12
- package/dist/index.js +94 -29
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
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
|
|
|
6
8
|
var Glob = /* @__PURE__ */ ((Glob2) => {
|
|
7
9
|
Glob2["All"] = "**/*.?([cm])[jt]s?(x)";
|
|
8
10
|
Glob2["Javascript"] = "**/*.?([cm])js?(x)";
|
|
11
|
+
Glob2["Json"] = "**/*.json?([c5])";
|
|
9
12
|
Glob2["Typescript"] = "**/*.?([cm])ts?(x)";
|
|
10
13
|
Glob2["Vitest"] = "**/*.{test,spec}.[jt]s";
|
|
11
14
|
Glob2["Vue"] = "**/*.vue";
|
|
@@ -36,6 +39,7 @@ function getIgnores() {
|
|
|
36
39
|
const stylisticRules = {
|
|
37
40
|
"stylistic/array-bracket-newline": ["error", "consistent"],
|
|
38
41
|
"stylistic/array-bracket-spacing": ["error", "never"],
|
|
42
|
+
"stylistic/array-element-newline": ["error", "consistent"],
|
|
39
43
|
"stylistic/arrow-parens": ["error", "always"],
|
|
40
44
|
"stylistic/arrow-spacing": "error",
|
|
41
45
|
"stylistic/block-spacing": "error",
|
|
@@ -142,14 +146,13 @@ const stylisticRules = {
|
|
|
142
146
|
"stylistic/yield-star-spacing": ["error", "after"]
|
|
143
147
|
};
|
|
144
148
|
async function stylistic(options) {
|
|
145
|
-
|
|
146
|
-
if (!enabled) return {};
|
|
149
|
+
if (!options.features?.stylistic) return {};
|
|
147
150
|
const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
|
|
148
151
|
const files = [Glob.All];
|
|
149
|
-
if (options.vue) files.push(Glob.Vue);
|
|
152
|
+
if (options.features.vue) files.push(Glob.Vue);
|
|
150
153
|
const rules = {
|
|
151
154
|
...stylisticRules,
|
|
152
|
-
...overrides?.stylistic
|
|
155
|
+
...options.overrides?.stylistic
|
|
153
156
|
};
|
|
154
157
|
return {
|
|
155
158
|
files,
|
|
@@ -159,8 +162,7 @@ async function stylistic(options) {
|
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
async function vue(options) {
|
|
162
|
-
|
|
163
|
-
if (!enabled) return [];
|
|
165
|
+
if (!options.features?.vue) return [];
|
|
164
166
|
const [vuePlugin, vueParser, tsParser] = await Promise.all([
|
|
165
167
|
// @ts-expect-error no types
|
|
166
168
|
interopDefault(import('eslint-plugin-vue')),
|
|
@@ -321,9 +323,9 @@ async function vue(options) {
|
|
|
321
323
|
"vue/valid-v-show": "error",
|
|
322
324
|
"vue/valid-v-slot": "error",
|
|
323
325
|
"vue/valid-v-text": "error",
|
|
324
|
-
...overrides?.vue
|
|
326
|
+
...options.overrides?.vue
|
|
325
327
|
};
|
|
326
|
-
if (options.stylistic) {
|
|
328
|
+
if (options.features.stylistic) {
|
|
327
329
|
Object.assign(rules, {
|
|
328
330
|
"vue/first-attribute-linebreak": ["error", {
|
|
329
331
|
singleline: "beside",
|
|
@@ -360,7 +362,7 @@ async function vue(options) {
|
|
|
360
362
|
math: "always"
|
|
361
363
|
}],
|
|
362
364
|
"vue/max-attributes-per-line": ["error", {
|
|
363
|
-
singleline:
|
|
365
|
+
singleline: Number.MAX_SAFE_INTEGER,
|
|
364
366
|
multiline: 1
|
|
365
367
|
}],
|
|
366
368
|
"vue/multiline-html-element-content-newline": ["error", {
|
|
@@ -381,6 +383,7 @@ async function vue(options) {
|
|
|
381
383
|
const vueStylistic = [
|
|
382
384
|
"vue/array-bracket-newline",
|
|
383
385
|
"vue/array-bracket-spacing",
|
|
386
|
+
"vue/array-element-newline",
|
|
384
387
|
"vue/key-spacing",
|
|
385
388
|
"vue/keyword-spacing",
|
|
386
389
|
"vue/max-len",
|
|
@@ -404,9 +407,7 @@ async function vue(options) {
|
|
|
404
407
|
}, {}));
|
|
405
408
|
}
|
|
406
409
|
return [
|
|
407
|
-
{
|
|
408
|
-
plugins: { vue: vuePlugin }
|
|
409
|
-
},
|
|
410
|
+
{ plugins: { vue: vuePlugin } },
|
|
410
411
|
{
|
|
411
412
|
files: [Glob.Vue],
|
|
412
413
|
languageOptions: {
|
|
@@ -429,9 +430,60 @@ async function vue(options) {
|
|
|
429
430
|
];
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
async function jsonc(options) {
|
|
434
|
+
if (!options.features?.jsonc) return [];
|
|
435
|
+
const [jsoncPlugin, jsoncParser] = await Promise.all([
|
|
436
|
+
interopDefault(import('eslint-plugin-jsonc')),
|
|
437
|
+
interopDefault(import('jsonc-eslint-parser'))
|
|
438
|
+
]);
|
|
439
|
+
const rules = {
|
|
440
|
+
"jsonc/no-bigint-literals": "error",
|
|
441
|
+
"jsonc/no-binary-expression": "error",
|
|
442
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
443
|
+
"jsonc/no-infinity": "error",
|
|
444
|
+
"jsonc/no-nan": "error",
|
|
445
|
+
"jsonc/no-number-props": "error",
|
|
446
|
+
"jsonc/no-undefined-value": "error",
|
|
447
|
+
"jsonc/valid-json-number": "error",
|
|
448
|
+
...options.overrides?.jsonc
|
|
449
|
+
};
|
|
450
|
+
if (options.features.stylistic) {
|
|
451
|
+
Object.assign(rules, {
|
|
452
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
453
|
+
"jsonc/quotes": ["error", "double", { avoidEscape: false }],
|
|
454
|
+
"jsonc/space-unary-ops": "error"
|
|
455
|
+
});
|
|
456
|
+
const jsoncStylistic = [
|
|
457
|
+
"jsonc/array-bracket-newline",
|
|
458
|
+
"jsonc/array-bracket-spacing",
|
|
459
|
+
"jsonc/array-element-newline",
|
|
460
|
+
"jsonc/comma-style",
|
|
461
|
+
"jsonc/indent",
|
|
462
|
+
"jsonc/key-spacing",
|
|
463
|
+
"jsonc/object-curly-newline",
|
|
464
|
+
"jsonc/object-curly-spacing",
|
|
465
|
+
"jsonc/object-property-newline"
|
|
466
|
+
];
|
|
467
|
+
Object.assign(rules, jsoncStylistic.reduce((acc, rule) => {
|
|
468
|
+
const name = rule.replace("jsonc/", "stylistic/");
|
|
469
|
+
if (Object.hasOwn(stylisticRules, name)) {
|
|
470
|
+
acc[rule] = stylisticRules[name];
|
|
471
|
+
}
|
|
472
|
+
return acc;
|
|
473
|
+
}, {}));
|
|
474
|
+
}
|
|
475
|
+
return [
|
|
476
|
+
{ plugins: { jsonc: jsoncPlugin } },
|
|
477
|
+
{
|
|
478
|
+
files: [Glob.Json],
|
|
479
|
+
languageOptions: { parser: jsoncParser }
|
|
480
|
+
},
|
|
481
|
+
{ rules }
|
|
482
|
+
];
|
|
483
|
+
}
|
|
484
|
+
|
|
432
485
|
async function vitest(options) {
|
|
433
|
-
|
|
434
|
-
if (!enabled) return {};
|
|
486
|
+
if (!options.features?.vitest) return {};
|
|
435
487
|
const plugin = await interopDefault(import('eslint-plugin-vitest'));
|
|
436
488
|
return {
|
|
437
489
|
plugins: { vitest: plugin },
|
|
@@ -468,13 +520,13 @@ async function vitest(options) {
|
|
|
468
520
|
"vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
|
|
469
521
|
"vitest/valid-describe-callback": "error",
|
|
470
522
|
"vitest/valid-expect": "error",
|
|
471
|
-
...overrides?.vitest
|
|
523
|
+
...options.overrides?.vitest
|
|
472
524
|
}
|
|
473
525
|
};
|
|
474
526
|
}
|
|
475
527
|
|
|
476
528
|
async function unicorn(options) {
|
|
477
|
-
const {
|
|
529
|
+
const { unicorn: enabled = true } = options.features ?? {};
|
|
478
530
|
if (!enabled) return {};
|
|
479
531
|
const plugin = await interopDefault(import('eslint-plugin-unicorn'));
|
|
480
532
|
return {
|
|
@@ -519,15 +571,29 @@ async function unicorn(options) {
|
|
|
519
571
|
"unicorn/prefer-structured-clone": "error",
|
|
520
572
|
"unicorn/prefer-type-error": "error",
|
|
521
573
|
"unicorn/relative-url-style": ["error", "never"],
|
|
522
|
-
...overrides?.unicorn
|
|
574
|
+
...options.overrides?.unicorn
|
|
523
575
|
}
|
|
524
576
|
};
|
|
525
577
|
}
|
|
526
578
|
|
|
579
|
+
async function tailwind(options) {
|
|
580
|
+
if (!options.features?.tailwind) return {};
|
|
581
|
+
const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
|
|
582
|
+
const rules = {
|
|
583
|
+
"tailwindcss/classnames-order": "error",
|
|
584
|
+
"tailwindcss/enforces-shorthand": "error",
|
|
585
|
+
"tailwindcss/no-contradicting-classname": "error",
|
|
586
|
+
...options.overrides?.tailwind
|
|
587
|
+
};
|
|
588
|
+
return {
|
|
589
|
+
plugins: { tailwindcss: plugin },
|
|
590
|
+
rules
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
|
|
527
594
|
function javascript(options) {
|
|
528
|
-
const { overrides } = options;
|
|
529
595
|
const files = [Glob.All];
|
|
530
|
-
if (options.vue) files.push(Glob.Vue);
|
|
596
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
531
597
|
return {
|
|
532
598
|
files,
|
|
533
599
|
languageOptions: {
|
|
@@ -663,19 +729,18 @@ function javascript(options) {
|
|
|
663
729
|
"use-isnan": "error",
|
|
664
730
|
"valid-typeof": "error",
|
|
665
731
|
yoda: ["error", "never"],
|
|
666
|
-
...overrides?.javascript
|
|
732
|
+
...options.overrides?.javascript
|
|
667
733
|
}
|
|
668
734
|
};
|
|
669
735
|
}
|
|
670
736
|
|
|
671
737
|
async function typescript(options) {
|
|
672
|
-
const { project, overrides } = options;
|
|
673
738
|
const [tsParser, tsPlugin] = await Promise.all([
|
|
674
739
|
interopDefault(import('@typescript-eslint/parser')),
|
|
675
740
|
interopDefault(import('@typescript-eslint/eslint-plugin'))
|
|
676
741
|
]);
|
|
677
742
|
const files = [Glob.Typescript];
|
|
678
|
-
if (options.vue) files.push(Glob.Vue);
|
|
743
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
679
744
|
const rules = {
|
|
680
745
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
681
746
|
"no-array-constructor": "off",
|
|
@@ -876,7 +941,7 @@ async function typescript(options) {
|
|
|
876
941
|
"@typescript-eslint/unbound-method": "error",
|
|
877
942
|
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
878
943
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
879
|
-
...overrides?.typescript
|
|
944
|
+
...options.overrides?.typescript
|
|
880
945
|
};
|
|
881
946
|
return {
|
|
882
947
|
files,
|
|
@@ -885,9 +950,9 @@ async function typescript(options) {
|
|
|
885
950
|
sourceType: "module",
|
|
886
951
|
parser: tsParser,
|
|
887
952
|
parserOptions: {
|
|
888
|
-
project,
|
|
953
|
+
project: options.project,
|
|
889
954
|
tsconfigRootDir: process.cwd(),
|
|
890
|
-
extraFileExtensions: options.vue ? [".vue"] : []
|
|
955
|
+
extraFileExtensions: options.features?.vue ? [".vue"] : []
|
|
891
956
|
}
|
|
892
957
|
},
|
|
893
958
|
plugins: { "@typescript-eslint": tsPlugin },
|
|
@@ -896,7 +961,7 @@ async function typescript(options) {
|
|
|
896
961
|
}
|
|
897
962
|
|
|
898
963
|
async function perfectionist(options) {
|
|
899
|
-
const {
|
|
964
|
+
const { perfectionist: enabled = true } = options.features ?? {};
|
|
900
965
|
if (!enabled) return {};
|
|
901
966
|
const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
|
|
902
967
|
return {
|
|
@@ -957,7 +1022,7 @@ async function perfectionist(options) {
|
|
|
957
1022
|
order: "asc",
|
|
958
1023
|
ignoreCase: true
|
|
959
1024
|
}],
|
|
960
|
-
...overrides?.perfectionist
|
|
1025
|
+
...options.overrides?.perfectionist
|
|
961
1026
|
}
|
|
962
1027
|
};
|
|
963
1028
|
}
|
|
@@ -970,13 +1035,15 @@ async function defineConfig(options) {
|
|
|
970
1035
|
javascript(options),
|
|
971
1036
|
typescript(options),
|
|
972
1037
|
...await vue(options),
|
|
1038
|
+
...await jsonc(options),
|
|
1039
|
+
stylistic(options),
|
|
973
1040
|
perfectionist(options),
|
|
974
1041
|
unicorn(options),
|
|
975
|
-
stylistic(options),
|
|
976
1042
|
vitest(options),
|
|
1043
|
+
tailwind(options),
|
|
977
1044
|
ignores
|
|
978
1045
|
]);
|
|
979
1046
|
return objects;
|
|
980
1047
|
}
|
|
981
1048
|
|
|
982
|
-
|
|
1049
|
+
exports.defineConfig = defineConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,23 +15,31 @@ declare interface ConfigObject {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare interface ConfigOptions {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
};
|
|
28
34
|
/** `tsconfig.json` files for TypeScript. */
|
|
29
35
|
project: string[];
|
|
30
36
|
ignores?: Ignores['ignores'];
|
|
31
37
|
overrides?: {
|
|
32
38
|
javascript?: Rules;
|
|
39
|
+
jsonc?: Rules;
|
|
33
40
|
perfectionist?: Rules;
|
|
34
41
|
stylistic?: Rules;
|
|
42
|
+
tailwind?: Rules;
|
|
35
43
|
typescript?: Rules;
|
|
36
44
|
unicorn?: Rules;
|
|
37
45
|
vitest?: Rules;
|
|
@@ -41,8 +49,7 @@ declare interface ConfigOptions {
|
|
|
41
49
|
knownSafePromises?: KnownSafePromise[];
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
|
|
45
|
-
export default defineConfig;
|
|
52
|
+
export declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
|
|
46
53
|
|
|
47
54
|
declare interface Ignores {
|
|
48
55
|
ignores: string[];
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import globals from 'globals';
|
|
|
4
4
|
var Glob = /* @__PURE__ */ ((Glob2) => {
|
|
5
5
|
Glob2["All"] = "**/*.?([cm])[jt]s?(x)";
|
|
6
6
|
Glob2["Javascript"] = "**/*.?([cm])js?(x)";
|
|
7
|
+
Glob2["Json"] = "**/*.json?([c5])";
|
|
7
8
|
Glob2["Typescript"] = "**/*.?([cm])ts?(x)";
|
|
8
9
|
Glob2["Vitest"] = "**/*.{test,spec}.[jt]s";
|
|
9
10
|
Glob2["Vue"] = "**/*.vue";
|
|
@@ -34,6 +35,7 @@ function getIgnores() {
|
|
|
34
35
|
const stylisticRules = {
|
|
35
36
|
"stylistic/array-bracket-newline": ["error", "consistent"],
|
|
36
37
|
"stylistic/array-bracket-spacing": ["error", "never"],
|
|
38
|
+
"stylistic/array-element-newline": ["error", "consistent"],
|
|
37
39
|
"stylistic/arrow-parens": ["error", "always"],
|
|
38
40
|
"stylistic/arrow-spacing": "error",
|
|
39
41
|
"stylistic/block-spacing": "error",
|
|
@@ -140,14 +142,13 @@ const stylisticRules = {
|
|
|
140
142
|
"stylistic/yield-star-spacing": ["error", "after"]
|
|
141
143
|
};
|
|
142
144
|
async function stylistic(options) {
|
|
143
|
-
|
|
144
|
-
if (!enabled) return {};
|
|
145
|
+
if (!options.features?.stylistic) return {};
|
|
145
146
|
const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
|
|
146
147
|
const files = [Glob.All];
|
|
147
|
-
if (options.vue) files.push(Glob.Vue);
|
|
148
|
+
if (options.features.vue) files.push(Glob.Vue);
|
|
148
149
|
const rules = {
|
|
149
150
|
...stylisticRules,
|
|
150
|
-
...overrides?.stylistic
|
|
151
|
+
...options.overrides?.stylistic
|
|
151
152
|
};
|
|
152
153
|
return {
|
|
153
154
|
files,
|
|
@@ -157,8 +158,7 @@ async function stylistic(options) {
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
async function vue(options) {
|
|
160
|
-
|
|
161
|
-
if (!enabled) return [];
|
|
161
|
+
if (!options.features?.vue) return [];
|
|
162
162
|
const [vuePlugin, vueParser, tsParser] = await Promise.all([
|
|
163
163
|
// @ts-expect-error no types
|
|
164
164
|
interopDefault(import('eslint-plugin-vue')),
|
|
@@ -319,9 +319,9 @@ async function vue(options) {
|
|
|
319
319
|
"vue/valid-v-show": "error",
|
|
320
320
|
"vue/valid-v-slot": "error",
|
|
321
321
|
"vue/valid-v-text": "error",
|
|
322
|
-
...overrides?.vue
|
|
322
|
+
...options.overrides?.vue
|
|
323
323
|
};
|
|
324
|
-
if (options.stylistic) {
|
|
324
|
+
if (options.features.stylistic) {
|
|
325
325
|
Object.assign(rules, {
|
|
326
326
|
"vue/first-attribute-linebreak": ["error", {
|
|
327
327
|
singleline: "beside",
|
|
@@ -358,7 +358,7 @@ async function vue(options) {
|
|
|
358
358
|
math: "always"
|
|
359
359
|
}],
|
|
360
360
|
"vue/max-attributes-per-line": ["error", {
|
|
361
|
-
singleline:
|
|
361
|
+
singleline: Number.MAX_SAFE_INTEGER,
|
|
362
362
|
multiline: 1
|
|
363
363
|
}],
|
|
364
364
|
"vue/multiline-html-element-content-newline": ["error", {
|
|
@@ -379,6 +379,7 @@ async function vue(options) {
|
|
|
379
379
|
const vueStylistic = [
|
|
380
380
|
"vue/array-bracket-newline",
|
|
381
381
|
"vue/array-bracket-spacing",
|
|
382
|
+
"vue/array-element-newline",
|
|
382
383
|
"vue/key-spacing",
|
|
383
384
|
"vue/keyword-spacing",
|
|
384
385
|
"vue/max-len",
|
|
@@ -402,9 +403,7 @@ async function vue(options) {
|
|
|
402
403
|
}, {}));
|
|
403
404
|
}
|
|
404
405
|
return [
|
|
405
|
-
{
|
|
406
|
-
plugins: { vue: vuePlugin }
|
|
407
|
-
},
|
|
406
|
+
{ plugins: { vue: vuePlugin } },
|
|
408
407
|
{
|
|
409
408
|
files: [Glob.Vue],
|
|
410
409
|
languageOptions: {
|
|
@@ -427,9 +426,60 @@ async function vue(options) {
|
|
|
427
426
|
];
|
|
428
427
|
}
|
|
429
428
|
|
|
429
|
+
async function jsonc(options) {
|
|
430
|
+
if (!options.features?.jsonc) return [];
|
|
431
|
+
const [jsoncPlugin, jsoncParser] = await Promise.all([
|
|
432
|
+
interopDefault(import('eslint-plugin-jsonc')),
|
|
433
|
+
interopDefault(import('jsonc-eslint-parser'))
|
|
434
|
+
]);
|
|
435
|
+
const rules = {
|
|
436
|
+
"jsonc/no-bigint-literals": "error",
|
|
437
|
+
"jsonc/no-binary-expression": "error",
|
|
438
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
439
|
+
"jsonc/no-infinity": "error",
|
|
440
|
+
"jsonc/no-nan": "error",
|
|
441
|
+
"jsonc/no-number-props": "error",
|
|
442
|
+
"jsonc/no-undefined-value": "error",
|
|
443
|
+
"jsonc/valid-json-number": "error",
|
|
444
|
+
...options.overrides?.jsonc
|
|
445
|
+
};
|
|
446
|
+
if (options.features.stylistic) {
|
|
447
|
+
Object.assign(rules, {
|
|
448
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
449
|
+
"jsonc/quotes": ["error", "double", { avoidEscape: false }],
|
|
450
|
+
"jsonc/space-unary-ops": "error"
|
|
451
|
+
});
|
|
452
|
+
const jsoncStylistic = [
|
|
453
|
+
"jsonc/array-bracket-newline",
|
|
454
|
+
"jsonc/array-bracket-spacing",
|
|
455
|
+
"jsonc/array-element-newline",
|
|
456
|
+
"jsonc/comma-style",
|
|
457
|
+
"jsonc/indent",
|
|
458
|
+
"jsonc/key-spacing",
|
|
459
|
+
"jsonc/object-curly-newline",
|
|
460
|
+
"jsonc/object-curly-spacing",
|
|
461
|
+
"jsonc/object-property-newline"
|
|
462
|
+
];
|
|
463
|
+
Object.assign(rules, jsoncStylistic.reduce((acc, rule) => {
|
|
464
|
+
const name = rule.replace("jsonc/", "stylistic/");
|
|
465
|
+
if (Object.hasOwn(stylisticRules, name)) {
|
|
466
|
+
acc[rule] = stylisticRules[name];
|
|
467
|
+
}
|
|
468
|
+
return acc;
|
|
469
|
+
}, {}));
|
|
470
|
+
}
|
|
471
|
+
return [
|
|
472
|
+
{ plugins: { jsonc: jsoncPlugin } },
|
|
473
|
+
{
|
|
474
|
+
files: [Glob.Json],
|
|
475
|
+
languageOptions: { parser: jsoncParser }
|
|
476
|
+
},
|
|
477
|
+
{ rules }
|
|
478
|
+
];
|
|
479
|
+
}
|
|
480
|
+
|
|
430
481
|
async function vitest(options) {
|
|
431
|
-
|
|
432
|
-
if (!enabled) return {};
|
|
482
|
+
if (!options.features?.vitest) return {};
|
|
433
483
|
const plugin = await interopDefault(import('eslint-plugin-vitest'));
|
|
434
484
|
return {
|
|
435
485
|
plugins: { vitest: plugin },
|
|
@@ -466,13 +516,13 @@ async function vitest(options) {
|
|
|
466
516
|
"vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
|
|
467
517
|
"vitest/valid-describe-callback": "error",
|
|
468
518
|
"vitest/valid-expect": "error",
|
|
469
|
-
...overrides?.vitest
|
|
519
|
+
...options.overrides?.vitest
|
|
470
520
|
}
|
|
471
521
|
};
|
|
472
522
|
}
|
|
473
523
|
|
|
474
524
|
async function unicorn(options) {
|
|
475
|
-
const {
|
|
525
|
+
const { unicorn: enabled = true } = options.features ?? {};
|
|
476
526
|
if (!enabled) return {};
|
|
477
527
|
const plugin = await interopDefault(import('eslint-plugin-unicorn'));
|
|
478
528
|
return {
|
|
@@ -517,15 +567,29 @@ async function unicorn(options) {
|
|
|
517
567
|
"unicorn/prefer-structured-clone": "error",
|
|
518
568
|
"unicorn/prefer-type-error": "error",
|
|
519
569
|
"unicorn/relative-url-style": ["error", "never"],
|
|
520
|
-
...overrides?.unicorn
|
|
570
|
+
...options.overrides?.unicorn
|
|
521
571
|
}
|
|
522
572
|
};
|
|
523
573
|
}
|
|
524
574
|
|
|
575
|
+
async function tailwind(options) {
|
|
576
|
+
if (!options.features?.tailwind) return {};
|
|
577
|
+
const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
|
|
578
|
+
const rules = {
|
|
579
|
+
"tailwindcss/classnames-order": "error",
|
|
580
|
+
"tailwindcss/enforces-shorthand": "error",
|
|
581
|
+
"tailwindcss/no-contradicting-classname": "error",
|
|
582
|
+
...options.overrides?.tailwind
|
|
583
|
+
};
|
|
584
|
+
return {
|
|
585
|
+
plugins: { tailwindcss: plugin },
|
|
586
|
+
rules
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
525
590
|
function javascript(options) {
|
|
526
|
-
const { overrides } = options;
|
|
527
591
|
const files = [Glob.All];
|
|
528
|
-
if (options.vue) files.push(Glob.Vue);
|
|
592
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
529
593
|
return {
|
|
530
594
|
files,
|
|
531
595
|
languageOptions: {
|
|
@@ -661,19 +725,18 @@ function javascript(options) {
|
|
|
661
725
|
"use-isnan": "error",
|
|
662
726
|
"valid-typeof": "error",
|
|
663
727
|
yoda: ["error", "never"],
|
|
664
|
-
...overrides?.javascript
|
|
728
|
+
...options.overrides?.javascript
|
|
665
729
|
}
|
|
666
730
|
};
|
|
667
731
|
}
|
|
668
732
|
|
|
669
733
|
async function typescript(options) {
|
|
670
|
-
const { project, overrides } = options;
|
|
671
734
|
const [tsParser, tsPlugin] = await Promise.all([
|
|
672
735
|
interopDefault(import('@typescript-eslint/parser')),
|
|
673
736
|
interopDefault(import('@typescript-eslint/eslint-plugin'))
|
|
674
737
|
]);
|
|
675
738
|
const files = [Glob.Typescript];
|
|
676
|
-
if (options.vue) files.push(Glob.Vue);
|
|
739
|
+
if (options.features?.vue) files.push(Glob.Vue);
|
|
677
740
|
const rules = {
|
|
678
741
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
679
742
|
"no-array-constructor": "off",
|
|
@@ -874,7 +937,7 @@ async function typescript(options) {
|
|
|
874
937
|
"@typescript-eslint/unbound-method": "error",
|
|
875
938
|
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
876
939
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
877
|
-
...overrides?.typescript
|
|
940
|
+
...options.overrides?.typescript
|
|
878
941
|
};
|
|
879
942
|
return {
|
|
880
943
|
files,
|
|
@@ -883,9 +946,9 @@ async function typescript(options) {
|
|
|
883
946
|
sourceType: "module",
|
|
884
947
|
parser: tsParser,
|
|
885
948
|
parserOptions: {
|
|
886
|
-
project,
|
|
949
|
+
project: options.project,
|
|
887
950
|
tsconfigRootDir: process.cwd(),
|
|
888
|
-
extraFileExtensions: options.vue ? [".vue"] : []
|
|
951
|
+
extraFileExtensions: options.features?.vue ? [".vue"] : []
|
|
889
952
|
}
|
|
890
953
|
},
|
|
891
954
|
plugins: { "@typescript-eslint": tsPlugin },
|
|
@@ -894,7 +957,7 @@ async function typescript(options) {
|
|
|
894
957
|
}
|
|
895
958
|
|
|
896
959
|
async function perfectionist(options) {
|
|
897
|
-
const {
|
|
960
|
+
const { perfectionist: enabled = true } = options.features ?? {};
|
|
898
961
|
if (!enabled) return {};
|
|
899
962
|
const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
|
|
900
963
|
return {
|
|
@@ -955,7 +1018,7 @@ async function perfectionist(options) {
|
|
|
955
1018
|
order: "asc",
|
|
956
1019
|
ignoreCase: true
|
|
957
1020
|
}],
|
|
958
|
-
...overrides?.perfectionist
|
|
1021
|
+
...options.overrides?.perfectionist
|
|
959
1022
|
}
|
|
960
1023
|
};
|
|
961
1024
|
}
|
|
@@ -968,13 +1031,15 @@ async function defineConfig(options) {
|
|
|
968
1031
|
javascript(options),
|
|
969
1032
|
typescript(options),
|
|
970
1033
|
...await vue(options),
|
|
1034
|
+
...await jsonc(options),
|
|
1035
|
+
stylistic(options),
|
|
971
1036
|
perfectionist(options),
|
|
972
1037
|
unicorn(options),
|
|
973
|
-
stylistic(options),
|
|
974
1038
|
vitest(options),
|
|
1039
|
+
tailwind(options),
|
|
975
1040
|
ignores
|
|
976
1041
|
]);
|
|
977
1042
|
return objects;
|
|
978
1043
|
}
|
|
979
1044
|
|
|
980
|
-
export { defineConfig
|
|
1045
|
+
export { defineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/eslint-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "ESLint config",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"@stylistic/eslint-plugin": "^2.3.0",
|
|
28
28
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
29
29
|
"@typescript-eslint/parser": "^7.17.0",
|
|
30
|
+
"eslint-plugin-jsonc": "^2.16.0",
|
|
30
31
|
"eslint-plugin-perfectionist": "^3.0.0",
|
|
32
|
+
"eslint-plugin-tailwindcss": "^3.17.4",
|
|
31
33
|
"eslint-plugin-unicorn": "^54.0.0",
|
|
32
34
|
"eslint-plugin-vitest": "^0.5.4",
|
|
33
35
|
"eslint-plugin-vue": "^9.27.0",
|