@w5s/eslint-config 3.36.0 → 4.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 +59 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +121 -95
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- 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 -12
- package/src/config/jsx.ts +5 -3
- package/src/config/markdown.ts +11 -10
- package/src/config/next.ts +1 -1
- package/src/config/perfectionist.ts +9 -8
- package/src/config/react.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 +2 -1
- package/src/config/yml.ts +6 -5
- package/src/defineConfig.ts +21 -4
- 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 +32 -0
- package/src/typegen/next.d.ts +5 -0
- package/src/typegen/react.d.ts +2 -2
- package/src/typegen/ts.d.ts +9 -1
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 =
|
|
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() {
|
|
@@ -776,7 +805,6 @@ function sortPackageJson() {
|
|
|
776
805
|
"simple-git-hooks",
|
|
777
806
|
"pre-commit",
|
|
778
807
|
"commitlint",
|
|
779
|
-
"lint-staged",
|
|
780
808
|
"config",
|
|
781
809
|
"nodemonConfig",
|
|
782
810
|
"browserify",
|
|
@@ -916,18 +944,18 @@ function sortTsconfigJson() {
|
|
|
916
944
|
//#region src/config/jsx.ts
|
|
917
945
|
const defaultFiles$8 = [jsxSourceGlob];
|
|
918
946
|
async function jsx(options = {}) {
|
|
919
|
-
const { files, jsxA11y = false, recommended
|
|
947
|
+
const { files, jsxA11y = false, namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
920
948
|
const [jsxA11yPlugin] = await Promise.all([jsxA11y ? interopDefault(import("eslint-plugin-jsx-a11y")) : void 0]);
|
|
921
949
|
return [{
|
|
922
950
|
languageOptions: {
|
|
923
951
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
924
952
|
sourceType: "module"
|
|
925
953
|
},
|
|
926
|
-
name:
|
|
954
|
+
name: `${namespace}/jsx/setup`,
|
|
927
955
|
plugins: { ...jsxA11yPlugin ? { "jsx-a11y": jsxA11yPlugin } : {} }
|
|
928
956
|
}, {
|
|
929
957
|
files: withDefaultFiles(files, defaultFiles$8),
|
|
930
|
-
name:
|
|
958
|
+
name: `${namespace}/jsx/rules`,
|
|
931
959
|
rules: {
|
|
932
960
|
...recommended && jsxA11yPlugin != null ? jsxA11yPlugin.configs.recommended.rules : {},
|
|
933
961
|
...rules
|
|
@@ -957,15 +985,17 @@ const looseRules = lazy(() => {
|
|
|
957
985
|
});
|
|
958
986
|
//#endregion
|
|
959
987
|
//#region src/config/markdown.ts
|
|
960
|
-
const defaultFiles$7 = [
|
|
988
|
+
const defaultFiles$7 = [Project.glob({
|
|
989
|
+
fileExtensions: [Project.queryExtensions(["markdown"])],
|
|
990
|
+
nested: true
|
|
991
|
+
})];
|
|
961
992
|
async function markdown(options = {}) {
|
|
962
993
|
const [markdownPlugin] = await Promise.all([interopDefault(import("@eslint/markdown"))]);
|
|
963
|
-
const { files, language = "markdown/gfm", languageOptions, recommended
|
|
964
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
994
|
+
const { files, language = "markdown/gfm", languageOptions, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
965
995
|
const resolvedFiles = withDefaultFiles(files, defaultFiles$7);
|
|
966
996
|
return [
|
|
967
997
|
{
|
|
968
|
-
name:
|
|
998
|
+
name: `${namespace}/markdown/setup`,
|
|
969
999
|
plugins: { markdown: markdownPlugin }
|
|
970
1000
|
},
|
|
971
1001
|
{
|
|
@@ -975,11 +1005,11 @@ async function markdown(options = {}) {
|
|
|
975
1005
|
frontmatter: "yaml",
|
|
976
1006
|
...languageOptions
|
|
977
1007
|
},
|
|
978
|
-
name:
|
|
1008
|
+
name: `${namespace}/markdown/rules`,
|
|
979
1009
|
processor: mergeProcessors([markdownPlugin.processors.markdown, processorPassThrough]),
|
|
980
1010
|
rules: {
|
|
981
1011
|
...recommended ? markdownPlugin.configs.recommended.at(0)?.rules : {},
|
|
982
|
-
...
|
|
1012
|
+
...stylistic.enabled ? {} : {},
|
|
983
1013
|
...rules
|
|
984
1014
|
}
|
|
985
1015
|
},
|
|
@@ -989,7 +1019,7 @@ async function markdown(options = {}) {
|
|
|
989
1019
|
project: false,
|
|
990
1020
|
projectService: false
|
|
991
1021
|
} },
|
|
992
|
-
name:
|
|
1022
|
+
name: `${namespace}/markdown/embed-code`,
|
|
993
1023
|
rules: {
|
|
994
1024
|
...looseRules(),
|
|
995
1025
|
"no-alert": "off",
|
|
@@ -1020,7 +1050,7 @@ async function markdown(options = {}) {
|
|
|
1020
1050
|
const defaultFiles$6 = [sourceGlob];
|
|
1021
1051
|
async function next(options = {}) {
|
|
1022
1052
|
const [nextPlugin] = await Promise.all([interopDefault(import("@next/eslint-plugin-next"))]);
|
|
1023
|
-
const { files, recommended
|
|
1053
|
+
const { files, recommended, rules = {} } = options;
|
|
1024
1054
|
return [{
|
|
1025
1055
|
name: "w5s/next/setup",
|
|
1026
1056
|
plugins: { next: nextPlugin }
|
|
@@ -1070,17 +1100,16 @@ async function node(options = {}) {
|
|
|
1070
1100
|
const defaultFiles$5 = [sourceGlob];
|
|
1071
1101
|
async function perfectionist(options = {}) {
|
|
1072
1102
|
const [perfectionistPlugin] = await Promise.all([interopDefault(import("eslint-plugin-perfectionist"))]);
|
|
1073
|
-
const { files, recommended
|
|
1074
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1103
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1075
1104
|
return [{
|
|
1076
|
-
name:
|
|
1105
|
+
name: `${namespace}/perfectionist/setup`,
|
|
1077
1106
|
plugins: { perfectionist: perfectionistPlugin }
|
|
1078
1107
|
}, {
|
|
1079
1108
|
files: withDefaultFiles(files, defaultFiles$5),
|
|
1080
|
-
name:
|
|
1109
|
+
name: `${namespace}/perfectionist/rules`,
|
|
1081
1110
|
rules: {
|
|
1082
1111
|
...recommended ? perfectionistPlugin.configs["recommended-natural"].rules : {},
|
|
1083
|
-
...
|
|
1112
|
+
...stylistic.enabled ? {} : {},
|
|
1084
1113
|
...rules
|
|
1085
1114
|
}
|
|
1086
1115
|
}];
|
|
@@ -1090,9 +1119,9 @@ async function perfectionist(options = {}) {
|
|
|
1090
1119
|
const defaultFiles$4 = [sourceGlob];
|
|
1091
1120
|
async function react(options = {}) {
|
|
1092
1121
|
const [reactPlugin] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin"))]);
|
|
1093
|
-
const { files, recommended
|
|
1122
|
+
const { files, namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
1094
1123
|
return [{
|
|
1095
|
-
name:
|
|
1124
|
+
name: `${namespace}/react/setup`,
|
|
1096
1125
|
plugins: { react: reactPlugin }
|
|
1097
1126
|
}, {
|
|
1098
1127
|
files: withDefaultFiles(files, defaultFiles$4),
|
|
@@ -1100,7 +1129,7 @@ async function react(options = {}) {
|
|
|
1100
1129
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
1101
1130
|
sourceType: "module"
|
|
1102
1131
|
},
|
|
1103
|
-
name:
|
|
1132
|
+
name: `${namespace}/react/rules`,
|
|
1104
1133
|
rules: {
|
|
1105
1134
|
...recommended ? ESLintConfig.renameRules(reactPlugin.configs.recommended.rules, { "@eslint-react": "react" }) : {},
|
|
1106
1135
|
...rules
|
|
@@ -1159,14 +1188,13 @@ async function stylistic(options = {}) {
|
|
|
1159
1188
|
const defaultFiles$3 = Project.extensionsToTestGlob(Project.sourceExtensions());
|
|
1160
1189
|
async function test(options = {}) {
|
|
1161
1190
|
const [vitestPlugin] = await Promise.all([interopDefault(import("@vitest/eslint-plugin"))]);
|
|
1162
|
-
const { files, recommended
|
|
1163
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1191
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1164
1192
|
return [{
|
|
1165
|
-
name:
|
|
1193
|
+
name: `${namespace}/test/setup`,
|
|
1166
1194
|
plugins: { test: vitestPlugin }
|
|
1167
1195
|
}, {
|
|
1168
1196
|
files: withDefaultFiles(files, defaultFiles$3),
|
|
1169
|
-
name:
|
|
1197
|
+
name: `${namespace}/test/rules`,
|
|
1170
1198
|
rules: {
|
|
1171
1199
|
...recommended ? {
|
|
1172
1200
|
...ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, { vitest: "test" }),
|
|
@@ -1174,7 +1202,7 @@ async function test(options = {}) {
|
|
|
1174
1202
|
"test/expect-expect": ["error", { assertFunctionNames: ["expect*", "assert*"] }],
|
|
1175
1203
|
"test/valid-title": ESLintConfig.fixme(void 0)
|
|
1176
1204
|
} : {},
|
|
1177
|
-
...
|
|
1205
|
+
...stylistic.enabled ? {} : {},
|
|
1178
1206
|
...rules
|
|
1179
1207
|
}
|
|
1180
1208
|
}];
|
|
@@ -1226,12 +1254,11 @@ const tsRenameMap = { "@typescript-eslint": "ts" };
|
|
|
1226
1254
|
const defaultFiles$2 = [tsSourceGlob];
|
|
1227
1255
|
async function ts(options = {}) {
|
|
1228
1256
|
const [tsPlugin, tsParser] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1229
|
-
const { files, parserOptions = {}, recommended
|
|
1230
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1257
|
+
const { files, namespace, parserOptions = {}, recommended, rules = {}, stylistic, tsconfigPath = "./tsconfig.json", typeChecked = true } = defaultPluginOptions(options);
|
|
1231
1258
|
const tsCustomRules = tsRules();
|
|
1232
1259
|
const resolvedFiles = withDefaultFiles(files, defaultFiles$2);
|
|
1233
1260
|
return [{
|
|
1234
|
-
name:
|
|
1261
|
+
name: `${namespace}/ts/setup`,
|
|
1235
1262
|
plugins: { ts: tsPlugin }
|
|
1236
1263
|
}, {
|
|
1237
1264
|
files: resolvedFiles,
|
|
@@ -1249,13 +1276,13 @@ async function ts(options = {}) {
|
|
|
1249
1276
|
...parserOptions
|
|
1250
1277
|
}
|
|
1251
1278
|
},
|
|
1252
|
-
name:
|
|
1279
|
+
name: `${namespace}/ts/rules`,
|
|
1253
1280
|
rules: {
|
|
1254
1281
|
...recommended ? ESLintConfig.renameRules(tsPlugin.configs["eslint-recommended"].overrides[0].rules, tsRenameMap) : {},
|
|
1255
1282
|
...recommended ? ESLintConfig.renameRules(tsPlugin.configs["strict"].rules, tsRenameMap) : {},
|
|
1256
1283
|
...recommended && typeChecked ? ESLintConfig.renameRules(tsPlugin.configs["recommended-type-checked-only"].rules, tsRenameMap) : {},
|
|
1257
1284
|
...recommended ? tsCustomRules : {},
|
|
1258
|
-
...
|
|
1285
|
+
...stylistic.enabled ? {
|
|
1259
1286
|
...ESLintConfig.renameRules(tsPlugin.configs["stylistic"]?.rules, tsRenameMap),
|
|
1260
1287
|
...typeChecked ? ESLintConfig.renameRules(tsPlugin.configs["stylistic-type-checked-only"].rules, tsRenameMap) : {},
|
|
1261
1288
|
"ts/array-type": ["error", { default: "generic" }],
|
|
@@ -1291,16 +1318,15 @@ async function ts(options = {}) {
|
|
|
1291
1318
|
const defaultFiles$1 = [sourceGlob];
|
|
1292
1319
|
async function unicorn(options = {}) {
|
|
1293
1320
|
const [unicornPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))]);
|
|
1294
|
-
const { files, recommended
|
|
1295
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1321
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1296
1322
|
return [
|
|
1297
1323
|
{
|
|
1298
|
-
name:
|
|
1324
|
+
name: `${namespace}/unicorn/setup`,
|
|
1299
1325
|
plugins: { unicorn: unicornPlugin }
|
|
1300
1326
|
},
|
|
1301
1327
|
{
|
|
1302
1328
|
files: withDefaultFiles(files, defaultFiles$1),
|
|
1303
|
-
name:
|
|
1329
|
+
name: `${namespace}/unicorn/rules`,
|
|
1304
1330
|
rules: {
|
|
1305
1331
|
...recommended && unicornPlugin.configs.unopinionated.rules,
|
|
1306
1332
|
"unicorn/new-for-builtins": "off",
|
|
@@ -1314,13 +1340,13 @@ async function unicorn(options = {}) {
|
|
|
1314
1340
|
"unicorn/prefer-default-parameters": "off",
|
|
1315
1341
|
"unicorn/prefer-set-has": "off",
|
|
1316
1342
|
"unicorn/throw-new-error": "off",
|
|
1317
|
-
...
|
|
1343
|
+
...stylistic.enabled ? {} : {},
|
|
1318
1344
|
...rules
|
|
1319
1345
|
}
|
|
1320
1346
|
},
|
|
1321
1347
|
{
|
|
1322
1348
|
files: ["**/*.config.cjs", "**/*.config.js"],
|
|
1323
|
-
name:
|
|
1349
|
+
name: `${namespace}/unicorn/overrides`,
|
|
1324
1350
|
rules: { "unicorn/prefer-module": "off" }
|
|
1325
1351
|
}
|
|
1326
1352
|
];
|
|
@@ -1329,7 +1355,7 @@ async function unicorn(options = {}) {
|
|
|
1329
1355
|
//#region src/config/unused-imports.ts
|
|
1330
1356
|
async function unusedImports(options = {}) {
|
|
1331
1357
|
const [unusedImportPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports"))]);
|
|
1332
|
-
const { files = [sourceGlob], recommended
|
|
1358
|
+
const { files = [sourceGlob], recommended, rules = {} } = defaultPluginOptions(options);
|
|
1333
1359
|
return [{
|
|
1334
1360
|
name: "w5s/unused-imports/setup",
|
|
1335
1361
|
plugins: { "unused-imports": unusedImportPlugin }
|
|
@@ -1357,15 +1383,15 @@ async function unusedImports(options = {}) {
|
|
|
1357
1383
|
const defaultFiles = [ymlSourceGlob];
|
|
1358
1384
|
async function yml(options = {}) {
|
|
1359
1385
|
const [ymlPlugin] = await Promise.all([interopDefault(import("eslint-plugin-yml"))]);
|
|
1360
|
-
const { files, recommended
|
|
1361
|
-
const { enabled: stylisticEnabled, indent, quotes } =
|
|
1386
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
1387
|
+
const { enabled: stylisticEnabled, indent, quotes } = stylistic;
|
|
1362
1388
|
return [{
|
|
1363
|
-
name:
|
|
1389
|
+
name: `${namespace}/yml/setup`,
|
|
1364
1390
|
plugins: { yml: ymlPlugin }
|
|
1365
1391
|
}, {
|
|
1366
1392
|
files: withDefaultFiles(files, defaultFiles),
|
|
1367
1393
|
language: "yml/yaml",
|
|
1368
|
-
name:
|
|
1394
|
+
name: `${namespace}/yml/rules`,
|
|
1369
1395
|
rules: {
|
|
1370
1396
|
...recommended ? ymlPlugin.configs.recommended.reduce((acc, config) => ({
|
|
1371
1397
|
...acc,
|
|
@@ -1398,7 +1424,7 @@ async function yml(options = {}) {
|
|
|
1398
1424
|
//#endregion
|
|
1399
1425
|
//#region src/defineConfig.ts
|
|
1400
1426
|
async function defineConfig(options = {}) {
|
|
1401
|
-
const { plugins = {}, rules } = options;
|
|
1427
|
+
const { overrides = [], plugins = {}, rules, todo = [] } = options;
|
|
1402
1428
|
const stylisticOptions = typeof plugins.stylistic === "boolean" ? { enabled: plugins.stylistic } : {
|
|
1403
1429
|
enabled: true,
|
|
1404
1430
|
...plugins.stylistic
|
|
@@ -1412,14 +1438,14 @@ async function defineConfig(options = {}) {
|
|
|
1412
1438
|
...optionsOrBoolean
|
|
1413
1439
|
});
|
|
1414
1440
|
const includeEnabled = (factory, input) => input.enabled ? [factory(input)] : [];
|
|
1415
|
-
return ESLintConfig.concat(...includeEnabled(ignores, toOption(options)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(jsx, toOption(plugins.jsx)), ...includeEnabled(unusedImports, toOption(plugins["unused-imports"])), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(next, toOption(plugins.next, false)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(test, toOption(plugins.test)), ...includeEnabled(stylistic, stylisticOptions), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(
|
|
1441
|
+
return ESLintConfig.concat(...includeEnabled(ignores, toOption(options)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(jsx, toOption(plugins.jsx)), ...includeEnabled(unusedImports, toOption(plugins["unused-imports"])), ...includeEnabled(jsdoc, toOption(plugins.jsdoc)), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(next, toOption(plugins.next, false)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(test, toOption(plugins.test)), ...includeEnabled(stylistic, stylisticOptions), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(markdown, toOption(plugins.markdown)), ...includeEnabled(yml, toOption(plugins.yml)), ...rules ? [{ rules }] : [], ...todo, ...overrides);
|
|
1416
1442
|
}
|
|
1417
1443
|
//#endregion
|
|
1418
1444
|
//#region src/meta.ts
|
|
1419
1445
|
const meta = Object.freeze({
|
|
1420
|
-
buildNumber:
|
|
1446
|
+
buildNumber: 1790065426,
|
|
1421
1447
|
name: "@w5s/eslint-config",
|
|
1422
|
-
version: "
|
|
1448
|
+
version: "4.0.0"
|
|
1423
1449
|
});
|
|
1424
1450
|
//#endregion
|
|
1425
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 };
|