@w5s/eslint-config 3.40.0 → 5.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.d.ts +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -100
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/config/e18e.ts +14 -6
- package/src/config/es.ts +7 -5
- package/src/config/imports.ts +6 -6
- package/src/config/jsdoc.ts +10 -9
- package/src/config/jsonc.ts +12 -11
- package/src/config/jsx.ts +5 -3
- package/src/config/markdown.ts +11 -10
- package/src/config/next.ts +1 -1
- package/src/config/node.ts +4 -3
- package/src/config/perfectionist.ts +9 -8
- package/src/config/react.ts +4 -3
- package/src/config/stylistic.ts +4 -3
- package/src/config/test.ts +6 -6
- package/src/config/ts.ts +9 -8
- package/src/config/unicorn.ts +7 -7
- package/src/config/unused-imports.ts +4 -3
- package/src/config/yml.ts +6 -5
- package/src/glob.ts +6 -6
- package/src/internal/defaultOptions.ts +19 -0
- package/src/type/PluginOptionsBase.ts +8 -0
- package/src/typegen/jsdoc.d.ts +30 -0
package/dist/index.js
CHANGED
|
@@ -6,28 +6,34 @@ import { eslintIgnores } from "@w5s/eslint-config-ignore";
|
|
|
6
6
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
7
|
import tsPlugin from "@typescript-eslint/eslint-plugin";
|
|
8
8
|
//#region src/glob.ts
|
|
9
|
-
const sourceGlob = Project.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
const sourceGlob = Project.glob({
|
|
10
|
+
fileExtensions: [Project.sourceExtensions()],
|
|
11
|
+
nested: true
|
|
12
|
+
});
|
|
13
|
+
const esSourceGlob = Project.glob({
|
|
14
|
+
fileExtensions: [Project.queryExtensions(["javascript", "javascriptreact"])],
|
|
15
|
+
nested: true
|
|
16
|
+
});
|
|
17
|
+
const jsxSourceGlob = Project.glob({
|
|
18
|
+
fileExtensions: [Project.queryExtensions(["javascriptreact", "typescriptreact"])],
|
|
19
|
+
nested: true
|
|
20
|
+
});
|
|
21
|
+
const jsonSourceGlob = Project.glob({
|
|
22
|
+
fileExtensions: [[
|
|
23
|
+
".json",
|
|
24
|
+
".json5",
|
|
25
|
+
".jsonc"
|
|
26
|
+
]],
|
|
27
|
+
nested: true
|
|
28
|
+
});
|
|
29
|
+
const tsSourceGlob = Project.glob({
|
|
30
|
+
fileExtensions: [Project.queryExtensions(["typescript", "typescriptreact"])],
|
|
31
|
+
nested: true
|
|
32
|
+
});
|
|
33
|
+
const ymlSourceGlob = Project.glob({
|
|
34
|
+
fileExtensions: [Project.queryExtensions(["yaml"])],
|
|
35
|
+
nested: true
|
|
36
|
+
});
|
|
31
37
|
//#endregion
|
|
32
38
|
//#region src/type/StylisticConfig.ts
|
|
33
39
|
const defaultConfig = {
|
|
@@ -61,6 +67,33 @@ const StylisticConfig = {
|
|
|
61
67
|
}
|
|
62
68
|
};
|
|
63
69
|
//#endregion
|
|
70
|
+
//#region src/internal/defaultOptions.ts
|
|
71
|
+
/**
|
|
72
|
+
* Return a new plugin option object with default values
|
|
73
|
+
*
|
|
74
|
+
* @param options
|
|
75
|
+
*/
|
|
76
|
+
function defaultPluginOptions(options) {
|
|
77
|
+
return {
|
|
78
|
+
...options,
|
|
79
|
+
namespace: options.namespace ?? "w5s",
|
|
80
|
+
recommended: options.recommended ?? true,
|
|
81
|
+
stylistic: StylisticConfig.from(options.stylistic ?? true)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/internal/withDefaultFiles.ts
|
|
86
|
+
/**
|
|
87
|
+
* withDefaultFiles
|
|
88
|
+
*
|
|
89
|
+
* @param options The options to process.
|
|
90
|
+
* @param defaultFiles The default files to apply.
|
|
91
|
+
* @returns An array of strings representing the combined files.
|
|
92
|
+
*/
|
|
93
|
+
function withDefaultFiles(options, defaultFiles) {
|
|
94
|
+
return typeof options === "function" ? options(defaultFiles) : [...options == null ? [] : options.flat(), ...defaultFiles];
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
64
97
|
//#region src/config/e18e.ts
|
|
65
98
|
const defaultFiles$11 = [sourceGlob];
|
|
66
99
|
/**
|
|
@@ -69,14 +102,13 @@ const defaultFiles$11 = [sourceGlob];
|
|
|
69
102
|
*/
|
|
70
103
|
async function e18e(options = {}) {
|
|
71
104
|
const [e18ePlugin] = await Promise.all([interopDefault(import("@e18e/eslint-plugin"))]);
|
|
72
|
-
const { files, modernization = true, moduleReplacements = false, performanceImprovements = true, rules = {}, stylistic
|
|
73
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
105
|
+
const { files, modernization = true, moduleReplacements = false, namespace, performanceImprovements = true, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
74
106
|
return [{
|
|
75
|
-
name:
|
|
107
|
+
name: `${namespace}/e18e/setup`,
|
|
76
108
|
plugins: { e18e: e18ePlugin }
|
|
77
109
|
}, {
|
|
78
110
|
files: withDefaultFiles(files, defaultFiles$11),
|
|
79
|
-
name:
|
|
111
|
+
name: `${namespace}/e18e/rules`,
|
|
80
112
|
rules: {
|
|
81
113
|
...modernization ? e18ePlugin.configs.modernization.rules : {},
|
|
82
114
|
...moduleReplacements ? e18ePlugin.configs.moduleReplacements.rules : {},
|
|
@@ -87,7 +119,7 @@ async function e18e(options = {}) {
|
|
|
87
119
|
"e18e/prefer-array-to-sorted": "off",
|
|
88
120
|
"e18e/prefer-array-to-spliced": "off",
|
|
89
121
|
"e18e/prefer-spread-syntax": "off",
|
|
90
|
-
...
|
|
122
|
+
...stylistic.enabled ? {} : {},
|
|
91
123
|
...rules
|
|
92
124
|
}
|
|
93
125
|
}];
|
|
@@ -515,7 +547,7 @@ const esRules = lazy(() => ({
|
|
|
515
547
|
//#region src/config/es.ts
|
|
516
548
|
const defaultFiles$10 = [esSourceGlob];
|
|
517
549
|
async function es(options) {
|
|
518
|
-
const { defaultRestrictedGlobals = restrictedGlobals, defaultRestrictedImportPaths = restrictedImportPaths, defaultRestrictedSyntax = restrictedSyntax, recommended
|
|
550
|
+
const { defaultRestrictedGlobals = restrictedGlobals, defaultRestrictedImportPaths = restrictedImportPaths, defaultRestrictedSyntax = restrictedSyntax, namespace, recommended, restrictedImportPaths: paths, rules = {} } = defaultPluginOptions(options);
|
|
519
551
|
const resolvedGlobals = typeof options.restrictedGlobals === "function" ? options.restrictedGlobals(defaultRestrictedGlobals) : options.restrictedGlobals ?? defaultRestrictedGlobals;
|
|
520
552
|
const resolvedPaths = typeof paths === "function" ? paths(defaultRestrictedImportPaths) : paths ?? defaultRestrictedImportPaths;
|
|
521
553
|
const resolvedSyntax = typeof options.restrictedSyntax === "function" ? options.restrictedSyntax(defaultRestrictedSyntax) : options.restrictedSyntax ?? defaultRestrictedSyntax;
|
|
@@ -542,11 +574,11 @@ async function es(options) {
|
|
|
542
574
|
sourceType: "module"
|
|
543
575
|
},
|
|
544
576
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
545
|
-
name:
|
|
577
|
+
name: `${namespace}/es/setup`
|
|
546
578
|
},
|
|
547
579
|
{
|
|
548
580
|
files: [sourceGlob],
|
|
549
|
-
name:
|
|
581
|
+
name: `${namespace}/source/restricted-rules`,
|
|
550
582
|
rules: {
|
|
551
583
|
"no-restricted-globals": ["error", ...resolvedGlobals],
|
|
552
584
|
"no-restricted-imports": ["error", { paths: resolvedPaths }],
|
|
@@ -555,7 +587,7 @@ async function es(options) {
|
|
|
555
587
|
},
|
|
556
588
|
{
|
|
557
589
|
files: defaultFiles$10,
|
|
558
|
-
name:
|
|
590
|
+
name: `${namespace}/es/rules`,
|
|
559
591
|
rules: {
|
|
560
592
|
...recommended ? es.recommended : {},
|
|
561
593
|
...rules
|
|
@@ -578,17 +610,16 @@ async function ignores(options = {}) {
|
|
|
578
610
|
//#endregion
|
|
579
611
|
//#region src/config/imports.ts
|
|
580
612
|
async function imports(options = {}) {
|
|
581
|
-
const { recommended
|
|
582
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
613
|
+
const { namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
583
614
|
const [importPlugin] = await Promise.all([interopDefault(import("eslint-plugin-import"))]);
|
|
584
615
|
return [{
|
|
585
|
-
name:
|
|
616
|
+
name: `${namespace}/import/setup`,
|
|
586
617
|
plugins: { import: importPlugin }
|
|
587
618
|
}, {
|
|
588
|
-
name:
|
|
619
|
+
name: `${namespace}/import/rules`,
|
|
589
620
|
rules: {
|
|
590
621
|
...recommended ? imports.recommended : {},
|
|
591
|
-
...
|
|
622
|
+
...stylistic.enabled ? imports.stylistic : {},
|
|
592
623
|
...rules
|
|
593
624
|
}
|
|
594
625
|
}];
|
|
@@ -612,10 +643,9 @@ const defaultJsFiles = [esSourceGlob];
|
|
|
612
643
|
const defaultTsFiles = [tsSourceGlob];
|
|
613
644
|
async function jsdoc(options = {}) {
|
|
614
645
|
const [jsdocPlugin] = await Promise.all([interopDefault(import("eslint-plugin-jsdoc"))]);
|
|
615
|
-
const { files, recommended
|
|
616
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
646
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
617
647
|
const recommendedRules = recommended ? jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules : {};
|
|
618
|
-
const stylisticRules =
|
|
648
|
+
const stylisticRules = stylistic.enabled ? {
|
|
619
649
|
...jsdocPlugin.configs["flat/stylistic-typescript-flavor"].rules,
|
|
620
650
|
"jsdoc/check-alignment": "warn",
|
|
621
651
|
"jsdoc/multiline-blocks": "warn",
|
|
@@ -627,12 +657,12 @@ async function jsdoc(options = {}) {
|
|
|
627
657
|
} : {};
|
|
628
658
|
return [
|
|
629
659
|
{
|
|
630
|
-
name:
|
|
660
|
+
name: `${namespace}/jsdoc/setup`,
|
|
631
661
|
plugins: { jsdoc: jsdocPlugin }
|
|
632
662
|
},
|
|
633
663
|
{
|
|
634
664
|
files: withDefaultFiles(files, defaultJsFiles),
|
|
635
|
-
name:
|
|
665
|
+
name: `${namespace}/jsdoc/rules-js`,
|
|
636
666
|
rules: {
|
|
637
667
|
...recommendedRules,
|
|
638
668
|
...recommended ? {
|
|
@@ -652,7 +682,7 @@ async function jsdoc(options = {}) {
|
|
|
652
682
|
},
|
|
653
683
|
{
|
|
654
684
|
files: withDefaultFiles(files, defaultTsFiles),
|
|
655
|
-
name:
|
|
685
|
+
name: `${namespace}/jsdoc/rules-ts`,
|
|
656
686
|
rules: {
|
|
657
687
|
...recommendedRules,
|
|
658
688
|
...recommended ? {
|
|
@@ -678,24 +708,23 @@ async function jsdoc(options = {}) {
|
|
|
678
708
|
const defaultFiles$9 = [jsonSourceGlob];
|
|
679
709
|
async function jsonc(options = {}) {
|
|
680
710
|
const [jsoncPlugin, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
681
|
-
const { files, recommended
|
|
682
|
-
const { enabled: stylisticEnabled, indent } = StylisticConfig.from(stylistic);
|
|
711
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
683
712
|
return [
|
|
684
713
|
{
|
|
685
|
-
name:
|
|
714
|
+
name: `${namespace}/jsonc/setup`,
|
|
686
715
|
plugins: { jsonc: jsoncPlugin }
|
|
687
716
|
},
|
|
688
717
|
{
|
|
689
718
|
files: withDefaultFiles(files, defaultFiles$9),
|
|
690
719
|
languageOptions: { parser: jsoncParser },
|
|
691
|
-
name:
|
|
720
|
+
name: `${namespace}/jsonc/rules`,
|
|
692
721
|
rules: {
|
|
693
722
|
...recommended ? jsoncPlugin.configs["flat/recommended-with-json"][0]?.rules : {},
|
|
694
|
-
...
|
|
723
|
+
...stylistic.enabled ? {
|
|
695
724
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
696
725
|
"jsonc/comma-dangle": ["error", "never"],
|
|
697
726
|
"jsonc/comma-style": ["error", "last"],
|
|
698
|
-
"jsonc/indent": ["error", indent],
|
|
727
|
+
"jsonc/indent": ["error", stylistic.indent],
|
|
699
728
|
"jsonc/key-spacing": ["error", {
|
|
700
729
|
afterColon: true,
|
|
701
730
|
beforeColon: false
|
|
@@ -712,8 +741,8 @@ async function jsonc(options = {}) {
|
|
|
712
741
|
...rules
|
|
713
742
|
}
|
|
714
743
|
},
|
|
715
|
-
|
|
716
|
-
|
|
744
|
+
stylistic.enabled ? sortPackageJson() : {},
|
|
745
|
+
stylistic.enabled ? sortTsconfigJson() : {}
|
|
717
746
|
];
|
|
718
747
|
}
|
|
719
748
|
function sortPackageJson() {
|
|
@@ -915,18 +944,18 @@ function sortTsconfigJson() {
|
|
|
915
944
|
//#region src/config/jsx.ts
|
|
916
945
|
const defaultFiles$8 = [jsxSourceGlob];
|
|
917
946
|
async function jsx(options = {}) {
|
|
918
|
-
const { files, jsxA11y = false, recommended
|
|
947
|
+
const { files, jsxA11y = false, namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
919
948
|
const [jsxA11yPlugin] = await Promise.all([jsxA11y ? interopDefault(import("eslint-plugin-jsx-a11y")) : void 0]);
|
|
920
949
|
return [{
|
|
921
950
|
languageOptions: {
|
|
922
951
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
923
952
|
sourceType: "module"
|
|
924
953
|
},
|
|
925
|
-
name:
|
|
954
|
+
name: `${namespace}/jsx/setup`,
|
|
926
955
|
plugins: { ...jsxA11yPlugin ? { "jsx-a11y": jsxA11yPlugin } : {} }
|
|
927
956
|
}, {
|
|
928
957
|
files: withDefaultFiles(files, defaultFiles$8),
|
|
929
|
-
name:
|
|
958
|
+
name: `${namespace}/jsx/rules`,
|
|
930
959
|
rules: {
|
|
931
960
|
...recommended && jsxA11yPlugin != null ? jsxA11yPlugin.configs.recommended.rules : {},
|
|
932
961
|
...rules
|
|
@@ -956,15 +985,17 @@ const looseRules = lazy(() => {
|
|
|
956
985
|
});
|
|
957
986
|
//#endregion
|
|
958
987
|
//#region src/config/markdown.ts
|
|
959
|
-
const defaultFiles$7 = [Project.
|
|
988
|
+
const defaultFiles$7 = [Project.glob({
|
|
989
|
+
fileExtensions: [Project.queryExtensions(["markdown"])],
|
|
990
|
+
nested: true
|
|
991
|
+
})];
|
|
960
992
|
async function markdown(options = {}) {
|
|
961
993
|
const [markdownPlugin] = await Promise.all([interopDefault(import("@eslint/markdown"))]);
|
|
962
|
-
const { files, language = "markdown/gfm", languageOptions, recommended
|
|
963
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
994
|
+
const { files, language = "markdown/gfm", languageOptions, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
964
995
|
const resolvedFiles = withDefaultFiles(files, defaultFiles$7);
|
|
965
996
|
return [
|
|
966
997
|
{
|
|
967
|
-
name:
|
|
998
|
+
name: `${namespace}/markdown/setup`,
|
|
968
999
|
plugins: { markdown: markdownPlugin }
|
|
969
1000
|
},
|
|
970
1001
|
{
|
|
@@ -974,11 +1005,11 @@ async function markdown(options = {}) {
|
|
|
974
1005
|
frontmatter: "yaml",
|
|
975
1006
|
...languageOptions
|
|
976
1007
|
},
|
|
977
|
-
name:
|
|
1008
|
+
name: `${namespace}/markdown/rules`,
|
|
978
1009
|
processor: mergeProcessors([markdownPlugin.processors.markdown, processorPassThrough]),
|
|
979
1010
|
rules: {
|
|
980
1011
|
...recommended ? markdownPlugin.configs.recommended.at(0)?.rules : {},
|
|
981
|
-
...
|
|
1012
|
+
...stylistic.enabled ? {} : {},
|
|
982
1013
|
...rules
|
|
983
1014
|
}
|
|
984
1015
|
},
|
|
@@ -988,7 +1019,7 @@ async function markdown(options = {}) {
|
|
|
988
1019
|
project: false,
|
|
989
1020
|
projectService: false
|
|
990
1021
|
} },
|
|
991
|
-
name:
|
|
1022
|
+
name: `${namespace}/markdown/embed-code`,
|
|
992
1023
|
rules: {
|
|
993
1024
|
...looseRules(),
|
|
994
1025
|
"no-alert": "off",
|
|
@@ -1019,7 +1050,7 @@ async function markdown(options = {}) {
|
|
|
1019
1050
|
const defaultFiles$6 = [sourceGlob];
|
|
1020
1051
|
async function next(options = {}) {
|
|
1021
1052
|
const [nextPlugin] = await Promise.all([interopDefault(import("@next/eslint-plugin-next"))]);
|
|
1022
|
-
const { files, recommended
|
|
1053
|
+
const { files, recommended, rules = {} } = options;
|
|
1023
1054
|
return [{
|
|
1024
1055
|
name: "w5s/next/setup",
|
|
1025
1056
|
plugins: { next: nextPlugin }
|
|
@@ -1042,12 +1073,12 @@ async function next(options = {}) {
|
|
|
1042
1073
|
//#region src/config/node.ts
|
|
1043
1074
|
async function node(options = {}) {
|
|
1044
1075
|
const [nodePlugin] = await Promise.all([interopDefault(import("eslint-plugin-n"))]);
|
|
1045
|
-
const { recommended, rules = {} } = options;
|
|
1076
|
+
const { namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
1046
1077
|
return [{
|
|
1047
|
-
name:
|
|
1078
|
+
name: `${namespace}/node/setup`,
|
|
1048
1079
|
plugins: { node: nodePlugin }
|
|
1049
1080
|
}, {
|
|
1050
|
-
name:
|
|
1081
|
+
name: `${namespace}/node/rules`,
|
|
1051
1082
|
rules: {
|
|
1052
1083
|
...recommended ? {
|
|
1053
1084
|
"node/no-deprecated-api": "error",
|
|
@@ -1069,17 +1100,16 @@ async function node(options = {}) {
|
|
|
1069
1100
|
const defaultFiles$5 = [sourceGlob];
|
|
1070
1101
|
async function perfectionist(options = {}) {
|
|
1071
1102
|
const [perfectionistPlugin] = await Promise.all([interopDefault(import("eslint-plugin-perfectionist"))]);
|
|
1072
|
-
const { files, recommended
|
|
1073
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1103
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1074
1104
|
return [{
|
|
1075
|
-
name:
|
|
1105
|
+
name: `${namespace}/perfectionist/setup`,
|
|
1076
1106
|
plugins: { perfectionist: perfectionistPlugin }
|
|
1077
1107
|
}, {
|
|
1078
1108
|
files: withDefaultFiles(files, defaultFiles$5),
|
|
1079
|
-
name:
|
|
1109
|
+
name: `${namespace}/perfectionist/rules`,
|
|
1080
1110
|
rules: {
|
|
1081
1111
|
...recommended ? perfectionistPlugin.configs["recommended-natural"].rules : {},
|
|
1082
|
-
...
|
|
1112
|
+
...stylistic.enabled ? {} : {},
|
|
1083
1113
|
...rules
|
|
1084
1114
|
}
|
|
1085
1115
|
}];
|
|
@@ -1089,9 +1119,9 @@ async function perfectionist(options = {}) {
|
|
|
1089
1119
|
const defaultFiles$4 = [sourceGlob];
|
|
1090
1120
|
async function react(options = {}) {
|
|
1091
1121
|
const [reactPlugin] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin"))]);
|
|
1092
|
-
const { files, recommended
|
|
1122
|
+
const { files, namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
1093
1123
|
return [{
|
|
1094
|
-
name:
|
|
1124
|
+
name: `${namespace}/react/setup`,
|
|
1095
1125
|
plugins: { react: reactPlugin }
|
|
1096
1126
|
}, {
|
|
1097
1127
|
files: withDefaultFiles(files, defaultFiles$4),
|
|
@@ -1099,7 +1129,7 @@ async function react(options = {}) {
|
|
|
1099
1129
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
1100
1130
|
sourceType: "module"
|
|
1101
1131
|
},
|
|
1102
|
-
name:
|
|
1132
|
+
name: `${namespace}/react/rules`,
|
|
1103
1133
|
rules: {
|
|
1104
1134
|
...recommended ? ESLintConfig.renameRules(reactPlugin.configs.recommended.rules, { "@eslint-react": "react" }) : {},
|
|
1105
1135
|
...rules
|
|
@@ -1110,7 +1140,7 @@ async function react(options = {}) {
|
|
|
1110
1140
|
//#region src/config/stylistic.ts
|
|
1111
1141
|
async function stylistic(options = {}) {
|
|
1112
1142
|
const [stylisticPlugin] = await Promise.all([interopDefault(import("@stylistic/eslint-plugin"))]);
|
|
1113
|
-
const { rules = {} } = options;
|
|
1143
|
+
const { namespace, rules = {} } = defaultPluginOptions(options);
|
|
1114
1144
|
const { enabled: stylisticEnabled, indent, jsx, quotes, semi } = StylisticConfig.from(options);
|
|
1115
1145
|
const config = stylisticEnabled ? stylisticPlugin.configs.customize({
|
|
1116
1146
|
indent,
|
|
@@ -1120,10 +1150,10 @@ async function stylistic(options = {}) {
|
|
|
1120
1150
|
semi
|
|
1121
1151
|
}) : { rules: {} };
|
|
1122
1152
|
return [{
|
|
1123
|
-
name:
|
|
1153
|
+
name: `${namespace}/style/setup`,
|
|
1124
1154
|
plugins: { style: stylisticPlugin }
|
|
1125
1155
|
}, {
|
|
1126
|
-
name:
|
|
1156
|
+
name: `${namespace}/style/rules`,
|
|
1127
1157
|
rules: {
|
|
1128
1158
|
...stylisticEnabled ? {
|
|
1129
1159
|
...config.rules,
|
|
@@ -1158,14 +1188,13 @@ async function stylistic(options = {}) {
|
|
|
1158
1188
|
const defaultFiles$3 = Project.extensionsToTestGlob(Project.sourceExtensions());
|
|
1159
1189
|
async function test(options = {}) {
|
|
1160
1190
|
const [vitestPlugin] = await Promise.all([interopDefault(import("@vitest/eslint-plugin"))]);
|
|
1161
|
-
const { files, recommended
|
|
1162
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1191
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1163
1192
|
return [{
|
|
1164
|
-
name:
|
|
1193
|
+
name: `${namespace}/test/setup`,
|
|
1165
1194
|
plugins: { test: vitestPlugin }
|
|
1166
1195
|
}, {
|
|
1167
1196
|
files: withDefaultFiles(files, defaultFiles$3),
|
|
1168
|
-
name:
|
|
1197
|
+
name: `${namespace}/test/rules`,
|
|
1169
1198
|
rules: {
|
|
1170
1199
|
...recommended ? {
|
|
1171
1200
|
...ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, { vitest: "test" }),
|
|
@@ -1173,7 +1202,7 @@ async function test(options = {}) {
|
|
|
1173
1202
|
"test/expect-expect": ["error", { assertFunctionNames: ["expect*", "assert*"] }],
|
|
1174
1203
|
"test/valid-title": ESLintConfig.fixme(void 0)
|
|
1175
1204
|
} : {},
|
|
1176
|
-
...
|
|
1205
|
+
...stylistic.enabled ? {} : {},
|
|
1177
1206
|
...rules
|
|
1178
1207
|
}
|
|
1179
1208
|
}];
|
|
@@ -1225,12 +1254,11 @@ const tsRenameMap = { "@typescript-eslint": "ts" };
|
|
|
1225
1254
|
const defaultFiles$2 = [tsSourceGlob];
|
|
1226
1255
|
async function ts(options = {}) {
|
|
1227
1256
|
const [tsPlugin, tsParser] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1228
|
-
const { files, parserOptions = {}, recommended
|
|
1229
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1257
|
+
const { files, namespace, parserOptions = {}, recommended, rules = {}, stylistic, tsconfigPath = "./tsconfig.json", typeChecked = true } = defaultPluginOptions(options);
|
|
1230
1258
|
const tsCustomRules = tsRules();
|
|
1231
1259
|
const resolvedFiles = withDefaultFiles(files, defaultFiles$2);
|
|
1232
1260
|
return [{
|
|
1233
|
-
name:
|
|
1261
|
+
name: `${namespace}/ts/setup`,
|
|
1234
1262
|
plugins: { ts: tsPlugin }
|
|
1235
1263
|
}, {
|
|
1236
1264
|
files: resolvedFiles,
|
|
@@ -1248,13 +1276,13 @@ async function ts(options = {}) {
|
|
|
1248
1276
|
...parserOptions
|
|
1249
1277
|
}
|
|
1250
1278
|
},
|
|
1251
|
-
name:
|
|
1279
|
+
name: `${namespace}/ts/rules`,
|
|
1252
1280
|
rules: {
|
|
1253
1281
|
...recommended ? ESLintConfig.renameRules(tsPlugin.configs["eslint-recommended"].overrides[0].rules, tsRenameMap) : {},
|
|
1254
1282
|
...recommended ? ESLintConfig.renameRules(tsPlugin.configs["strict"].rules, tsRenameMap) : {},
|
|
1255
1283
|
...recommended && typeChecked ? ESLintConfig.renameRules(tsPlugin.configs["recommended-type-checked-only"].rules, tsRenameMap) : {},
|
|
1256
1284
|
...recommended ? tsCustomRules : {},
|
|
1257
|
-
...
|
|
1285
|
+
...stylistic.enabled ? {
|
|
1258
1286
|
...ESLintConfig.renameRules(tsPlugin.configs["stylistic"]?.rules, tsRenameMap),
|
|
1259
1287
|
...typeChecked ? ESLintConfig.renameRules(tsPlugin.configs["stylistic-type-checked-only"].rules, tsRenameMap) : {},
|
|
1260
1288
|
"ts/array-type": ["error", { default: "generic" }],
|
|
@@ -1290,16 +1318,15 @@ async function ts(options = {}) {
|
|
|
1290
1318
|
const defaultFiles$1 = [sourceGlob];
|
|
1291
1319
|
async function unicorn(options = {}) {
|
|
1292
1320
|
const [unicornPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))]);
|
|
1293
|
-
const { files, recommended
|
|
1294
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1321
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1295
1322
|
return [
|
|
1296
1323
|
{
|
|
1297
|
-
name:
|
|
1324
|
+
name: `${namespace}/unicorn/setup`,
|
|
1298
1325
|
plugins: { unicorn: unicornPlugin }
|
|
1299
1326
|
},
|
|
1300
1327
|
{
|
|
1301
1328
|
files: withDefaultFiles(files, defaultFiles$1),
|
|
1302
|
-
name:
|
|
1329
|
+
name: `${namespace}/unicorn/rules`,
|
|
1303
1330
|
rules: {
|
|
1304
1331
|
...recommended && unicornPlugin.configs.unopinionated.rules,
|
|
1305
1332
|
"unicorn/new-for-builtins": "off",
|
|
@@ -1313,13 +1340,13 @@ async function unicorn(options = {}) {
|
|
|
1313
1340
|
"unicorn/prefer-default-parameters": "off",
|
|
1314
1341
|
"unicorn/prefer-set-has": "off",
|
|
1315
1342
|
"unicorn/throw-new-error": "off",
|
|
1316
|
-
...
|
|
1343
|
+
...stylistic.enabled ? {} : {},
|
|
1317
1344
|
...rules
|
|
1318
1345
|
}
|
|
1319
1346
|
},
|
|
1320
1347
|
{
|
|
1321
1348
|
files: ["**/*.config.cjs", "**/*.config.js"],
|
|
1322
|
-
name:
|
|
1349
|
+
name: `${namespace}/unicorn/overrides`,
|
|
1323
1350
|
rules: { "unicorn/prefer-module": "off" }
|
|
1324
1351
|
}
|
|
1325
1352
|
];
|
|
@@ -1328,13 +1355,13 @@ async function unicorn(options = {}) {
|
|
|
1328
1355
|
//#region src/config/unused-imports.ts
|
|
1329
1356
|
async function unusedImports(options = {}) {
|
|
1330
1357
|
const [unusedImportPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports"))]);
|
|
1331
|
-
const { files = [sourceGlob], recommended
|
|
1358
|
+
const { files = [sourceGlob], namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
1332
1359
|
return [{
|
|
1333
|
-
name:
|
|
1360
|
+
name: `${namespace}/unused-imports/setup`,
|
|
1334
1361
|
plugins: { "unused-imports": unusedImportPlugin }
|
|
1335
1362
|
}, {
|
|
1336
1363
|
files,
|
|
1337
|
-
name:
|
|
1364
|
+
name: `${namespace}/unused-imports/rules`,
|
|
1338
1365
|
rules: {
|
|
1339
1366
|
...recommended ? {
|
|
1340
1367
|
"no-unused-vars": "off",
|
|
@@ -1356,15 +1383,15 @@ async function unusedImports(options = {}) {
|
|
|
1356
1383
|
const defaultFiles = [ymlSourceGlob];
|
|
1357
1384
|
async function yml(options = {}) {
|
|
1358
1385
|
const [ymlPlugin] = await Promise.all([interopDefault(import("eslint-plugin-yml"))]);
|
|
1359
|
-
const { files, recommended
|
|
1360
|
-
const { enabled: stylisticEnabled, indent, quotes } =
|
|
1386
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1387
|
+
const { enabled: stylisticEnabled, indent, quotes } = stylistic;
|
|
1361
1388
|
return [{
|
|
1362
|
-
name:
|
|
1389
|
+
name: `${namespace}/yml/setup`,
|
|
1363
1390
|
plugins: { yml: ymlPlugin }
|
|
1364
1391
|
}, {
|
|
1365
1392
|
files: withDefaultFiles(files, defaultFiles),
|
|
1366
1393
|
language: "yml/yaml",
|
|
1367
|
-
name:
|
|
1394
|
+
name: `${namespace}/yml/rules`,
|
|
1368
1395
|
rules: {
|
|
1369
1396
|
...recommended ? ymlPlugin.configs.recommended.reduce((acc, config) => ({
|
|
1370
1397
|
...acc,
|
|
@@ -1416,9 +1443,9 @@ async function defineConfig(options = {}) {
|
|
|
1416
1443
|
//#endregion
|
|
1417
1444
|
//#region src/meta.ts
|
|
1418
1445
|
const meta = Object.freeze({
|
|
1419
|
-
buildNumber:
|
|
1446
|
+
buildNumber: 1790069931,
|
|
1420
1447
|
name: "@w5s/eslint-config",
|
|
1421
|
-
version: "
|
|
1448
|
+
version: "5.0.0"
|
|
1422
1449
|
});
|
|
1423
1450
|
//#endregion
|
|
1424
1451
|
export { StylisticConfig, defineConfig, e18e, es, ignores, imports, jsdoc, jsonc, jsx, markdown, meta, next, node, perfectionist, react, restrictedGlobals, restrictedImportPaths, restrictedSyntax, stylistic, test, ts, unicorn, unusedImports, yml };
|