@kazupon/eslint-config 0.36.0 → 0.37.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/README.md +23 -23
- package/dist/index.d.ts +895 -1027
- package/dist/index.js +31 -46
- package/package.json +52 -47
package/dist/index.js
CHANGED
|
@@ -12,18 +12,17 @@ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
|
12
12
|
* @returns {FlatConfigComposer} eslint flat configuration composer
|
|
13
13
|
*/
|
|
14
14
|
function defineConfig(...configs) {
|
|
15
|
-
const baseConfigs = [];
|
|
16
15
|
/**
|
|
17
16
|
* built-in configurations
|
|
18
17
|
* baseConfigs.push(javascript().then(c => c))
|
|
19
18
|
*/
|
|
20
|
-
return new FlatConfigComposer().append(...
|
|
19
|
+
return new FlatConfigComposer().append(...[], ...configs);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
//#endregion
|
|
24
23
|
//#region src/globs.ts
|
|
25
24
|
/**
|
|
26
|
-
* @author kazuya kawaguchi (a.k.a.
|
|
25
|
+
* @author kazuya kawaguchi (a.k.a. `@kazupon`)
|
|
27
26
|
* @license MIT
|
|
28
27
|
*/
|
|
29
28
|
const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -66,11 +65,10 @@ const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_
|
|
|
66
65
|
* @returns {Promise<T>} loaded plugin
|
|
67
66
|
*/
|
|
68
67
|
async function loadPlugin(name) {
|
|
69
|
-
|
|
68
|
+
return interopDefault(await import(name).catch((error) => {
|
|
70
69
|
console.error(error);
|
|
71
70
|
throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
|
|
72
|
-
});
|
|
73
|
-
return interopDefault(mod);
|
|
71
|
+
}));
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* get TypeScript parser
|
|
@@ -80,8 +78,7 @@ async function loadPlugin(name) {
|
|
|
80
78
|
* @returns {Promise<typeof import('typescript-eslint')['parser']>} TypeScript parser
|
|
81
79
|
*/
|
|
82
80
|
async function getTypeScriptParser() {
|
|
83
|
-
|
|
84
|
-
return ts.parser;
|
|
81
|
+
return (await loadPlugin("typescript-eslint")).parser;
|
|
85
82
|
}
|
|
86
83
|
/**
|
|
87
84
|
* get glob source files
|
|
@@ -146,7 +143,7 @@ async function comments(options = {}) {
|
|
|
146
143
|
async function css(options = {}) {
|
|
147
144
|
const { rules: overrideRules = {} } = options;
|
|
148
145
|
const tolerant = !!options.tolerant;
|
|
149
|
-
const customSyntax =
|
|
146
|
+
const customSyntax = options.customSyntax;
|
|
150
147
|
const css$1 = await loadPlugin("@eslint/css");
|
|
151
148
|
const core = {
|
|
152
149
|
name: "@eslint/css/recommended",
|
|
@@ -157,9 +154,9 @@ async function css(options = {}) {
|
|
|
157
154
|
if (tolerant) core.languageOptions = { tolerant };
|
|
158
155
|
if (customSyntax) {
|
|
159
156
|
core.languageOptions = core.languageOptions || {};
|
|
160
|
-
if (typeof customSyntax === "string" && customSyntax === "
|
|
161
|
-
const
|
|
162
|
-
core.languageOptions.customSyntax =
|
|
157
|
+
if (typeof customSyntax === "string" && (customSyntax === "tailwind3" || customSyntax === "tailwind4")) {
|
|
158
|
+
const tailwindCssTree = await loadPlugin("tailwind-csstree");
|
|
159
|
+
core.languageOptions.customSyntax = tailwindCssTree[customSyntax];
|
|
163
160
|
} else if (isObject(customSyntax)) core.languageOptions.customSyntax = customSyntax;
|
|
164
161
|
}
|
|
165
162
|
return [core, {
|
|
@@ -252,7 +249,7 @@ async function html(options = {}) {
|
|
|
252
249
|
* @returns {{ [syntax: string]: string } | undefined} resolved template engine syntax, or undefined if no syntax is provided
|
|
253
250
|
*/
|
|
254
251
|
function resolveTemplateEngineSyntax(syntax, parser) {
|
|
255
|
-
if (!syntax) return
|
|
252
|
+
if (!syntax) return;
|
|
256
253
|
switch (syntax) {
|
|
257
254
|
case "erb": return parser.TEMPLATE_ENGINE_SYNTAX.ERB;
|
|
258
255
|
case "handlebar": return parser.TEMPLATE_ENGINE_SYNTAX.HANDLEBAR;
|
|
@@ -340,12 +337,18 @@ async function imports(options = {}) {
|
|
|
340
337
|
*/
|
|
341
338
|
async function javascript(options = {}) {
|
|
342
339
|
const { rules: overrideRules = {} } = options;
|
|
343
|
-
|
|
344
|
-
|
|
340
|
+
return [(
|
|
341
|
+
/**
|
|
342
|
+
* {
|
|
343
|
+
* name: 'eslint/defaults/rules',
|
|
344
|
+
* ...(js.configs.recommended as Linter.Config)
|
|
345
|
+
* },
|
|
346
|
+
*/
|
|
347
|
+
{
|
|
345
348
|
name: "@kazupon/javascript/markdown-block",
|
|
346
349
|
files: ["**/*.md/*.{js,cjs,mjs}"],
|
|
347
|
-
...js.configs.recommended
|
|
348
|
-
}, {
|
|
350
|
+
...(await loadPlugin("@eslint/js")).configs.recommended
|
|
351
|
+
}), {
|
|
349
352
|
name: "@kazupon/javascript/overrides",
|
|
350
353
|
languageOptions: {
|
|
351
354
|
ecmaVersion: 2022,
|
|
@@ -585,7 +588,7 @@ function jsoncSort() {
|
|
|
585
588
|
* @returns {Promise<Linter.Config[]>} eslint flat configurations with `@eslint/markdown` and overrides
|
|
586
589
|
*/
|
|
587
590
|
async function markdown(options = {}) {
|
|
588
|
-
const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [], preferences = true
|
|
591
|
+
const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [], preferences = true } = options;
|
|
589
592
|
const language = options.language || "gfm";
|
|
590
593
|
/**
|
|
591
594
|
* TODO: remove this option
|
|
@@ -612,21 +615,7 @@ async function markdown(options = {}) {
|
|
|
612
615
|
];
|
|
613
616
|
if (preferences) {
|
|
614
617
|
const preferencesPlugin = await loadPlugin("eslint-plugin-markdown-preferences");
|
|
615
|
-
configs.push({
|
|
616
|
-
...preferencesPlugin.configs.recommended,
|
|
617
|
-
rules: {
|
|
618
|
-
...preferencesPlugin.configs.recommended.rules,
|
|
619
|
-
"markdown-preferences/no-trailing-spaces": "error",
|
|
620
|
-
"markdown-preferences/prefer-linked-words": ["error", {
|
|
621
|
-
words: linkedWords,
|
|
622
|
-
ignores: linkedWordsIgnores
|
|
623
|
-
}],
|
|
624
|
-
"markdown-preferences/prefer-inline-code-words": ["error", {
|
|
625
|
-
words: inlineCodeWords,
|
|
626
|
-
ignores: inlineCodeWordsIgnores
|
|
627
|
-
}]
|
|
628
|
-
}
|
|
629
|
-
});
|
|
618
|
+
configs.push({ ...preferencesPlugin.configs.recommended });
|
|
630
619
|
}
|
|
631
620
|
const custom = {
|
|
632
621
|
name: "@kazupon/markdown",
|
|
@@ -655,10 +644,9 @@ const md = markdown;
|
|
|
655
644
|
*/
|
|
656
645
|
async function prettier(options = {}) {
|
|
657
646
|
const { rules: overrideRules = {} } = options;
|
|
658
|
-
const prettier$1 = await loadPlugin("eslint-config-prettier");
|
|
659
647
|
return [{
|
|
660
648
|
name: "config-prettier",
|
|
661
|
-
...prettier
|
|
649
|
+
...await loadPlugin("eslint-config-prettier")
|
|
662
650
|
}, {
|
|
663
651
|
name: "@kazupon/prettier",
|
|
664
652
|
rules: { ...overrideRules }
|
|
@@ -675,10 +663,9 @@ async function prettier(options = {}) {
|
|
|
675
663
|
*/
|
|
676
664
|
async function promise(options = {}) {
|
|
677
665
|
const { rules: overrideRules = {} } = options;
|
|
678
|
-
const promise$1 = await loadPlugin("eslint-plugin-promise");
|
|
679
666
|
return [{
|
|
680
667
|
name: "promise/flat/recommended",
|
|
681
|
-
...promise
|
|
668
|
+
...(await loadPlugin("eslint-plugin-promise")).configs["flat/recommended"]
|
|
682
669
|
}, {
|
|
683
670
|
name: "@kazupon/promise",
|
|
684
671
|
rules: { ...overrideRules }
|
|
@@ -714,7 +701,7 @@ async function react(options = {}) {
|
|
|
714
701
|
...react$1.configs.flat.recommended
|
|
715
702
|
}, {
|
|
716
703
|
files: getGlobSourceFiles(useTypeScript),
|
|
717
|
-
...reactHooks.configs["recommended-latest"]
|
|
704
|
+
...reactHooks.configs.flat["recommended-latest"]
|
|
718
705
|
}];
|
|
719
706
|
if (enableRefresh) configs.push({
|
|
720
707
|
name: "react-refresh/flat",
|
|
@@ -878,13 +865,12 @@ async function typescript(options = {}) {
|
|
|
878
865
|
...extraFileExtensions.map((ext) => `**/*.${ext}`)
|
|
879
866
|
];
|
|
880
867
|
const files = [...options.files ?? [], ...baseFiles];
|
|
881
|
-
const extendedPreset = ts.configs.recommendedTypeChecked.map((config) => {
|
|
882
|
-
const mapped = { ...config };
|
|
883
|
-
if (config.files) mapped.files = [...config.files, `${GLOB_MARKDOWN}/**/${GLOB_TS}`];
|
|
884
|
-
return mapped;
|
|
885
|
-
});
|
|
886
868
|
return [
|
|
887
|
-
...
|
|
869
|
+
...ts.configs.recommendedTypeChecked.map((config) => {
|
|
870
|
+
const mapped = { ...config };
|
|
871
|
+
if (config.files) mapped.files = [...config.files, `${GLOB_MARKDOWN}/**/${GLOB_TS}`];
|
|
872
|
+
return mapped;
|
|
873
|
+
}),
|
|
888
874
|
{
|
|
889
875
|
files: [
|
|
890
876
|
GLOB_JS,
|
|
@@ -1019,8 +1005,7 @@ async function vue(options = {}) {
|
|
|
1019
1005
|
configs.push(composableBase, composable.configs["flat/recommended"][1]);
|
|
1020
1006
|
}
|
|
1021
1007
|
if (options.scopedCss) {
|
|
1022
|
-
const
|
|
1023
|
-
const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
|
|
1008
|
+
const scopedCssMapped = (await loadPlugin("eslint-plugin-vue-scoped-css")).configs["flat/recommended"].map((config, index) => {
|
|
1024
1009
|
const mapped = {
|
|
1025
1010
|
...config,
|
|
1026
1011
|
ignores: [GLOB_MARKDOWN]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kazupon/eslint-config",
|
|
3
3
|
"description": "ESLint config for @kazupon",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.37.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "kawakazu80@gmail.com",
|
|
7
7
|
"name": "kazuya kawaguchi"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
53
|
-
"@eslint/js": "^9.
|
|
53
|
+
"@eslint/js": "^9.37.0",
|
|
54
54
|
"@kazupon/eslint-plugin": "^0.6.2",
|
|
55
55
|
"@kazupon/jts-utils": "^0.7.1",
|
|
56
56
|
"@stylistic/eslint-plugin": "^4.4.1",
|
|
@@ -59,35 +59,36 @@
|
|
|
59
59
|
"globals": "^16.4.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@eslint/css": ">=0.
|
|
63
|
-
"@eslint/markdown": ">=7.
|
|
64
|
-
"@html-eslint/eslint-plugin": ">=0.
|
|
62
|
+
"@eslint/css": ">=0.13.0",
|
|
63
|
+
"@eslint/markdown": ">=7.4.0",
|
|
64
|
+
"@html-eslint/eslint-plugin": ">=0.47.0",
|
|
65
65
|
"@intlify/eslint-plugin-vue-i18n": ">=4.0.0",
|
|
66
|
-
"@vitest/eslint-plugin": ">=1.
|
|
66
|
+
"@vitest/eslint-plugin": ">=1.3.0",
|
|
67
67
|
"eslint": ">=8.56.0 || >=9.0.0",
|
|
68
|
-
"eslint-config-prettier": ">=
|
|
69
|
-
"eslint-import-resolver-typescript": ">=
|
|
68
|
+
"eslint-config-prettier": ">=10.1.0",
|
|
69
|
+
"eslint-import-resolver-typescript": ">=4.4.0",
|
|
70
70
|
"eslint-plugin-barrel-files": ">=3.0.1",
|
|
71
|
-
"eslint-plugin-import": ">=2.
|
|
72
|
-
"eslint-plugin-jsdoc": "
|
|
73
|
-
"eslint-plugin-jsonc": ">=2.
|
|
74
|
-
"eslint-plugin-markdown-preferences": ">=0.
|
|
71
|
+
"eslint-plugin-import": ">=2.32.0",
|
|
72
|
+
"eslint-plugin-jsdoc": ">61.1.0",
|
|
73
|
+
"eslint-plugin-jsonc": ">=2.21.0",
|
|
74
|
+
"eslint-plugin-markdown-preferences": ">=0.36.2",
|
|
75
75
|
"eslint-plugin-module-interop": ">=0.3.0",
|
|
76
|
-
"eslint-plugin-promise": ">=
|
|
77
|
-
"eslint-plugin-react": ">=7.
|
|
78
|
-
"eslint-plugin-react-hooks": ">=
|
|
79
|
-
"eslint-plugin-react-refresh": ">=0.4.
|
|
80
|
-
"eslint-plugin-regexp": ">=2.
|
|
81
|
-
"eslint-plugin-svelte": ">=
|
|
82
|
-
"eslint-plugin-toml": ">=0.
|
|
83
|
-
"eslint-plugin-unicorn": ">=
|
|
84
|
-
"eslint-plugin-unused-imports": ">=4.
|
|
85
|
-
"eslint-plugin-vue": ">=
|
|
76
|
+
"eslint-plugin-promise": ">=7.2.0",
|
|
77
|
+
"eslint-plugin-react": ">=7.37.0",
|
|
78
|
+
"eslint-plugin-react-hooks": ">=7.0.0",
|
|
79
|
+
"eslint-plugin-react-refresh": ">=0.4.0",
|
|
80
|
+
"eslint-plugin-regexp": ">=2.10.0",
|
|
81
|
+
"eslint-plugin-svelte": ">=3.12.0",
|
|
82
|
+
"eslint-plugin-toml": ">=0.12.0",
|
|
83
|
+
"eslint-plugin-unicorn": ">=61.0.0",
|
|
84
|
+
"eslint-plugin-unused-imports": ">=4.2.0",
|
|
85
|
+
"eslint-plugin-vue": ">=10.5.0",
|
|
86
86
|
"eslint-plugin-vue-composable": ">=1.0.0",
|
|
87
|
-
"eslint-plugin-vue-scoped-css": ">=2.
|
|
87
|
+
"eslint-plugin-vue-scoped-css": ">=2.12.0",
|
|
88
88
|
"eslint-plugin-vuejs-accessibility": ">=2.4.0",
|
|
89
|
-
"eslint-plugin-yml": ">=1.
|
|
89
|
+
"eslint-plugin-yml": ">=1.19.0",
|
|
90
90
|
"svelte": ">=4.0.0",
|
|
91
|
+
"tailwind-csstree": ">=0.1.4",
|
|
91
92
|
"typescript-eslint": ">=7.0.0"
|
|
92
93
|
},
|
|
93
94
|
"peerDependenciesMeta": {
|
|
@@ -175,54 +176,58 @@
|
|
|
175
176
|
"svelte": {
|
|
176
177
|
"optional": true
|
|
177
178
|
},
|
|
179
|
+
"tailwind-csstree": {
|
|
180
|
+
"optional": true
|
|
181
|
+
},
|
|
178
182
|
"typescript-eslint": {
|
|
179
183
|
"optional": true
|
|
180
184
|
}
|
|
181
185
|
},
|
|
182
186
|
"devDependencies": {
|
|
183
187
|
"@eslint/compat": "^1.4.0",
|
|
184
|
-
"@eslint/css": "^0.
|
|
185
|
-
"@eslint/markdown": "^7.
|
|
186
|
-
"@html-eslint/eslint-plugin": "^0.
|
|
188
|
+
"@eslint/css": "^0.13.0",
|
|
189
|
+
"@eslint/markdown": "^7.4.0",
|
|
190
|
+
"@html-eslint/eslint-plugin": "^0.47.0",
|
|
187
191
|
"@intlify/eslint-plugin-vue-i18n": "^4.1.0",
|
|
188
192
|
"@kazupon/prettier-config": "^0.1.1",
|
|
189
193
|
"@types/eslint": "^9.6.1",
|
|
190
|
-
"@types/node": "^22.18.
|
|
191
|
-
"@vitest/eslint-plugin": "^1.3.
|
|
192
|
-
"bumpp": "^10.
|
|
193
|
-
"eslint": "^9.
|
|
194
|
+
"@types/node": "^22.18.9",
|
|
195
|
+
"@vitest/eslint-plugin": "^1.3.16",
|
|
196
|
+
"bumpp": "^10.3.1",
|
|
197
|
+
"eslint": "^9.37.0",
|
|
194
198
|
"eslint-config-prettier": "^10.1.8",
|
|
195
199
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
196
200
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
197
201
|
"eslint-plugin-import": "^2.32.0",
|
|
198
|
-
"eslint-plugin-jsdoc": "^
|
|
199
|
-
"eslint-plugin-jsonc": "^2.
|
|
200
|
-
"eslint-plugin-markdown-preferences": "^0.
|
|
202
|
+
"eslint-plugin-jsdoc": "^61.1.4",
|
|
203
|
+
"eslint-plugin-jsonc": "^2.21.0",
|
|
204
|
+
"eslint-plugin-markdown-preferences": "^0.36.2",
|
|
201
205
|
"eslint-plugin-module-interop": "^0.3.1",
|
|
202
206
|
"eslint-plugin-promise": "^7.2.1",
|
|
203
207
|
"eslint-plugin-react": "^7.37.5",
|
|
204
|
-
"eslint-plugin-react-hooks": "^
|
|
205
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
208
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
209
|
+
"eslint-plugin-react-refresh": "^0.4.23",
|
|
206
210
|
"eslint-plugin-regexp": "^2.10.0",
|
|
207
|
-
"eslint-plugin-svelte": "^
|
|
211
|
+
"eslint-plugin-svelte": "^3.12.0",
|
|
208
212
|
"eslint-plugin-toml": "^0.12.0",
|
|
209
|
-
"eslint-plugin-unicorn": "^61.0.
|
|
213
|
+
"eslint-plugin-unicorn": "^61.0.2",
|
|
210
214
|
"eslint-plugin-unused-imports": "^4.2.0",
|
|
211
215
|
"eslint-plugin-vue": "^10.5.0",
|
|
212
216
|
"eslint-plugin-vue-composable": "^1.0.0",
|
|
213
217
|
"eslint-plugin-vue-scoped-css": "^2.12.0",
|
|
214
218
|
"eslint-plugin-vuejs-accessibility": "^2.4.1",
|
|
215
|
-
"eslint-plugin-yml": "^1.
|
|
219
|
+
"eslint-plugin-yml": "^1.19.0",
|
|
216
220
|
"eslint-typegen": "^2.3.0",
|
|
217
221
|
"gh-changelogen": "^0.2.8",
|
|
218
|
-
"jiti": "^2.6.
|
|
219
|
-
"knip": "^5.64.
|
|
220
|
-
"lint-staged": "^16.2.
|
|
222
|
+
"jiti": "^2.6.1",
|
|
223
|
+
"knip": "^5.64.3",
|
|
224
|
+
"lint-staged": "^16.2.4",
|
|
221
225
|
"prettier": "^3.6.2",
|
|
222
|
-
"svelte": "^5.39.
|
|
223
|
-
"
|
|
224
|
-
"
|
|
225
|
-
"typescript
|
|
226
|
+
"svelte": "^5.39.11",
|
|
227
|
+
"tailwind-csstree": "^0.1.4",
|
|
228
|
+
"tsdown": "^0.15.6",
|
|
229
|
+
"typescript": "^5.9.3",
|
|
230
|
+
"typescript-eslint": "^8.46.0",
|
|
226
231
|
"vitest": "^3.2.4"
|
|
227
232
|
},
|
|
228
233
|
"prettier": "@kazupon/prettier-config",
|
|
@@ -253,7 +258,7 @@
|
|
|
253
258
|
"lint:knip": "knip",
|
|
254
259
|
"lint:prettier": "prettier . --check --experimental-cli",
|
|
255
260
|
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
256
|
-
"test": "vitest run
|
|
261
|
+
"test": "vitest run",
|
|
257
262
|
"typecheck": "tsc -p .",
|
|
258
263
|
"typegen": "pnpx jiti scripts/typegen.ts"
|
|
259
264
|
}
|