@kazupon/eslint-config 0.16.0 → 0.17.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/README.md +1 -1
- package/dist/configs/comments.d.cts +1 -1
- package/dist/configs/comments.d.ts +1 -1
- package/dist/configs/imports.d.cts +9 -4
- package/dist/configs/imports.d.ts +9 -4
- package/dist/configs/index.d.cts +16 -16
- package/dist/configs/index.d.ts +16 -16
- package/dist/configs/javascript.d.cts +1 -1
- package/dist/configs/javascript.d.ts +1 -1
- package/dist/configs/jsdoc.d.cts +1 -1
- package/dist/configs/jsdoc.d.ts +1 -1
- package/dist/configs/jsonc.d.cts +1 -1
- package/dist/configs/jsonc.d.ts +1 -1
- package/dist/configs/prettier.d.cts +1 -1
- package/dist/configs/prettier.d.ts +1 -1
- package/dist/configs/promise.d.cts +1 -1
- package/dist/configs/promise.d.ts +1 -1
- package/dist/configs/react.d.cts +2 -2
- package/dist/configs/react.d.ts +2 -2
- package/dist/configs/regexp.d.cts +1 -1
- package/dist/configs/regexp.d.ts +1 -1
- package/dist/configs/svelte.d.cts +2 -2
- package/dist/configs/svelte.d.ts +2 -2
- package/dist/configs/toml.d.cts +1 -1
- package/dist/configs/toml.d.ts +1 -1
- package/dist/configs/typescript.d.cts +1 -1
- package/dist/configs/typescript.d.ts +1 -1
- package/dist/configs/unicorn.d.cts +1 -1
- package/dist/configs/unicorn.d.ts +1 -1
- package/dist/configs/vitest.d.cts +1 -1
- package/dist/configs/vitest.d.ts +1 -1
- package/dist/configs/vue.d.cts +2 -2
- package/dist/configs/vue.d.ts +2 -2
- package/dist/configs/yml.d.cts +1 -1
- package/dist/configs/yml.d.ts +1 -1
- package/dist/index.cjs +253 -242
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +253 -242
- package/dist/types/gens/imports.d.cts +477 -0
- package/dist/types/gens/imports.d.ts +477 -0
- package/dist/types/index.d.cts +18 -18
- package/dist/types/index.d.ts +18 -18
- package/dist/types/overrides.d.cts +1 -1
- package/dist/types/overrides.d.ts +1 -1
- package/package.json +12 -2
package/dist/index.js
CHANGED
|
@@ -7,6 +7,13 @@ function defineConfig(...configs) {
|
|
|
7
7
|
return new FlatConfigComposer().append(...baseConfigs, ...configs);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
|
|
12
|
+
async function interopDefault(mod) {
|
|
13
|
+
const resolved = await mod;
|
|
14
|
+
return resolved.default || resolved;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
//#endregion
|
|
11
18
|
//#region src/globs.ts
|
|
12
19
|
const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -24,13 +31,6 @@ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
|
24
31
|
const GLOB_TESTS = [`**/test/**/*.${GLOB_SRC_EXT}`, `**/tests/**/*.${GLOB_SRC_EXT}`, `**/spec/**/*.${GLOB_SRC_EXT}`, `**/specs/**/*.${GLOB_SRC_EXT}`, `**/e2e/**/*.${GLOB_SRC_EXT}`, `**/__tests__/**/*.${GLOB_SRC_EXT}`, `**/__test__/**/*.${GLOB_SRC_EXT}`, `**/*.spec.${GLOB_SRC_EXT}`, `**/*.test.${GLOB_SRC_EXT}`];
|
|
25
32
|
const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
|
|
26
33
|
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
|
|
29
|
-
async function interopDefault(mod) {
|
|
30
|
-
const resolved = await mod;
|
|
31
|
-
return resolved.default || resolved;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/utils.ts
|
|
36
36
|
async function loadPlugin(name) {
|
|
@@ -48,38 +48,6 @@ function getGlobSourceFiles(useTypeScript = false) {
|
|
|
48
48
|
return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/configs/javascript.ts
|
|
53
|
-
async function javascript(options = {}) {
|
|
54
|
-
const { rules: overrideRules = {} } = options;
|
|
55
|
-
const js = await loadPlugin("@eslint/js");
|
|
56
|
-
return [{
|
|
57
|
-
name: "eslint/defaults/rules",
|
|
58
|
-
...js.configs.recommended
|
|
59
|
-
}, {
|
|
60
|
-
name: "@kazupon/javascript/@eslint/js",
|
|
61
|
-
languageOptions: {
|
|
62
|
-
ecmaVersion: 2022,
|
|
63
|
-
globals: {
|
|
64
|
-
...globals.browser,
|
|
65
|
-
...globals.node,
|
|
66
|
-
...globals.es2022,
|
|
67
|
-
document: "readonly",
|
|
68
|
-
navigator: "readonly",
|
|
69
|
-
window: "readonly"
|
|
70
|
-
},
|
|
71
|
-
parserOptions: {
|
|
72
|
-
ecmaFeatures: { jsx: true },
|
|
73
|
-
ecmaVersion: 2022,
|
|
74
|
-
sourceType: "module"
|
|
75
|
-
},
|
|
76
|
-
sourceType: "module"
|
|
77
|
-
},
|
|
78
|
-
linterOptions: { reportUnusedDisableDirectives: true },
|
|
79
|
-
rules: { ...overrideRules }
|
|
80
|
-
}];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
51
|
//#endregion
|
|
84
52
|
//#region src/configs/comments.ts
|
|
85
53
|
async function comments(options = {}) {
|
|
@@ -95,71 +63,24 @@ async function comments(options = {}) {
|
|
|
95
63
|
}];
|
|
96
64
|
}
|
|
97
65
|
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/configs/typescript.ts
|
|
100
|
-
async function typescript(options = {}) {
|
|
101
|
-
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = { project: true } } = options;
|
|
102
|
-
const ts = await loadPlugin("typescript-eslint");
|
|
103
|
-
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
|
|
104
|
-
return [...ts.configs.recommendedTypeChecked, {
|
|
105
|
-
files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_YAML, GLOB_TOML],
|
|
106
|
-
...ts.configs.disableTypeChecked
|
|
107
|
-
}, {
|
|
108
|
-
name: "@kazupon/typescipt/typescript-eslint",
|
|
109
|
-
files,
|
|
110
|
-
languageOptions: {
|
|
111
|
-
parser: ts.parser,
|
|
112
|
-
parserOptions: {
|
|
113
|
-
extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
|
|
114
|
-
sourceType: "module",
|
|
115
|
-
...parserOptions
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
rules: {
|
|
119
|
-
"@typescript-eslint/no-unused-vars": ["error", {
|
|
120
|
-
args: "all",
|
|
121
|
-
argsIgnorePattern: "^_",
|
|
122
|
-
caughtErrors: "all",
|
|
123
|
-
caughtErrorsIgnorePattern: "^_",
|
|
124
|
-
destructuredArrayIgnorePattern: "^_",
|
|
125
|
-
varsIgnorePattern: "^_",
|
|
126
|
-
ignoreRestSiblings: true
|
|
127
|
-
}],
|
|
128
|
-
...overrideRules
|
|
129
|
-
}
|
|
130
|
-
}];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/configs/jsdoc.ts
|
|
135
|
-
async function jsdoc(options = {}) {
|
|
136
|
-
const { rules: overrideRules = {}, typescript: typescript$1, error = false } = options;
|
|
137
|
-
const jsdoc$1 = await loadPlugin("eslint-plugin-jsdoc");
|
|
138
|
-
function resolvePreset() {
|
|
139
|
-
let preset = "recommended";
|
|
140
|
-
if (typescript$1 === "syntax") {
|
|
141
|
-
preset = `${preset}-typescript`;
|
|
142
|
-
} else if (typescript$1 === "flavor") {
|
|
143
|
-
preset = `${preset}-typescript-flavor`;
|
|
144
|
-
}
|
|
145
|
-
if (error) {
|
|
146
|
-
preset = `${preset}-error`;
|
|
147
|
-
}
|
|
148
|
-
return preset;
|
|
149
|
-
}
|
|
150
|
-
return [jsdoc$1.configs[`flat/${resolvePreset()}`], {
|
|
151
|
-
name: "@kazupon/jsdoc",
|
|
152
|
-
rules: { ...overrideRules }
|
|
153
|
-
}];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
66
|
//#endregion
|
|
157
67
|
//#region src/configs/imports.ts
|
|
158
68
|
const IMPORTS_FILES = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX];
|
|
159
69
|
async function imports(options = {}) {
|
|
160
70
|
const { rules: overrideRules = {} } = options;
|
|
161
71
|
const unused = await loadPlugin("eslint-plugin-unused-imports");
|
|
162
|
-
const
|
|
72
|
+
const importX = await loadPlugin("eslint-plugin-import-x");
|
|
73
|
+
const configs = [importX.flatConfigs.recommended];
|
|
74
|
+
if (options.typescript) {
|
|
75
|
+
try {
|
|
76
|
+
await loadPlugin("eslint-import-resolver-typescript");
|
|
77
|
+
importX.flatConfigs.typescript.settings["import-x/resolver"]["typescript"] = true;
|
|
78
|
+
configs.push(importX.flatConfigs.typescript);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new Error(`Not found eslint-import-resolver-typescript: ${error.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
configs.push({
|
|
163
84
|
name: "unused-imports",
|
|
164
85
|
plugins: { "unused-imports": unused },
|
|
165
86
|
files: IMPORTS_FILES,
|
|
@@ -178,7 +99,7 @@ async function imports(options = {}) {
|
|
|
178
99
|
ignoreRestSiblings: true
|
|
179
100
|
}]
|
|
180
101
|
}
|
|
181
|
-
}
|
|
102
|
+
});
|
|
182
103
|
const overriddenConfig = {
|
|
183
104
|
name: "@kazupon/imports",
|
|
184
105
|
files: IMPORTS_FILES,
|
|
@@ -189,77 +110,56 @@ async function imports(options = {}) {
|
|
|
189
110
|
}
|
|
190
111
|
|
|
191
112
|
//#endregion
|
|
192
|
-
//#region src/configs/
|
|
193
|
-
async function
|
|
194
|
-
const { rules: overrideRules = {} } = options;
|
|
195
|
-
const promise$1 = await loadPlugin("eslint-plugin-promise");
|
|
196
|
-
return [{
|
|
197
|
-
name: "promise/flat/recommended",
|
|
198
|
-
...promise$1.configs["flat/recommended"]
|
|
199
|
-
}, {
|
|
200
|
-
name: "@kazupon/promise",
|
|
201
|
-
rules: { ...overrideRules }
|
|
202
|
-
}];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/configs/regexp.ts
|
|
207
|
-
async function regexp(options = {}) {
|
|
208
|
-
const { rules: overrideRules = {} } = options;
|
|
209
|
-
const regexp$1 = await loadPlugin("eslint-plugin-regexp");
|
|
210
|
-
return [{
|
|
211
|
-
name: "regexp/flat/recommended",
|
|
212
|
-
...regexp$1.configs["flat/recommended"]
|
|
213
|
-
}, {
|
|
214
|
-
name: "@kazupon/eslint-regexp",
|
|
215
|
-
rules: { ...overrideRules }
|
|
216
|
-
}];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/configs/toml.ts
|
|
221
|
-
async function toml(options = {}) {
|
|
222
|
-
const { rules: overrideRules = {} } = options;
|
|
223
|
-
const toml$1 = await loadPlugin("eslint-plugin-toml");
|
|
224
|
-
const configs = [];
|
|
225
|
-
configs.push(...toml$1.configs["flat/standard"].map((config, index) => {
|
|
226
|
-
return config.name ? config : {
|
|
227
|
-
name: `toml/flat/standard/${index}`,
|
|
228
|
-
...config
|
|
229
|
-
};
|
|
230
|
-
}));
|
|
231
|
-
const overriddenConfig = {
|
|
232
|
-
name: "@kazupon/toml",
|
|
233
|
-
files: [GLOB_TOML],
|
|
234
|
-
rules: { ...overrideRules }
|
|
235
|
-
};
|
|
236
|
-
configs.push(overriddenConfig);
|
|
237
|
-
return configs;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/configs/unicorn.ts
|
|
242
|
-
async function unicorn(options = {}) {
|
|
113
|
+
//#region src/configs/javascript.ts
|
|
114
|
+
async function javascript(options = {}) {
|
|
243
115
|
const { rules: overrideRules = {} } = options;
|
|
244
|
-
const
|
|
245
|
-
const unicorn$1 = await loadPlugin("eslint-plugin-unicorn");
|
|
116
|
+
const js = await loadPlugin("@eslint/js");
|
|
246
117
|
return [{
|
|
247
|
-
|
|
248
|
-
...
|
|
118
|
+
name: "eslint/defaults/rules",
|
|
119
|
+
...js.configs.recommended
|
|
249
120
|
}, {
|
|
250
|
-
name: "@kazupon/
|
|
251
|
-
|
|
121
|
+
name: "@kazupon/javascript/@eslint/js",
|
|
122
|
+
languageOptions: {
|
|
123
|
+
ecmaVersion: 2022,
|
|
124
|
+
globals: {
|
|
125
|
+
...globals.browser,
|
|
126
|
+
...globals.node,
|
|
127
|
+
...globals.es2022,
|
|
128
|
+
document: "readonly",
|
|
129
|
+
navigator: "readonly",
|
|
130
|
+
window: "readonly"
|
|
131
|
+
},
|
|
132
|
+
parserOptions: {
|
|
133
|
+
ecmaFeatures: { jsx: true },
|
|
134
|
+
ecmaVersion: 2022,
|
|
135
|
+
sourceType: "module"
|
|
136
|
+
},
|
|
137
|
+
sourceType: "module"
|
|
138
|
+
},
|
|
139
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
252
140
|
rules: { ...overrideRules }
|
|
253
141
|
}];
|
|
254
142
|
}
|
|
255
143
|
|
|
256
144
|
//#endregion
|
|
257
|
-
//#region src/configs/
|
|
258
|
-
async function
|
|
259
|
-
const { rules: overrideRules = {} } = options;
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
145
|
+
//#region src/configs/jsdoc.ts
|
|
146
|
+
async function jsdoc(options = {}) {
|
|
147
|
+
const { rules: overrideRules = {}, typescript: typescript$1, error = false } = options;
|
|
148
|
+
const jsdoc$1 = await loadPlugin("eslint-plugin-jsdoc");
|
|
149
|
+
function resolvePreset() {
|
|
150
|
+
let preset = "recommended";
|
|
151
|
+
if (typescript$1 === "syntax") {
|
|
152
|
+
preset = `${preset}-typescript`;
|
|
153
|
+
} else if (typescript$1 === "flavor") {
|
|
154
|
+
preset = `${preset}-typescript-flavor`;
|
|
155
|
+
}
|
|
156
|
+
if (error) {
|
|
157
|
+
preset = `${preset}-error`;
|
|
158
|
+
}
|
|
159
|
+
return preset;
|
|
160
|
+
}
|
|
161
|
+
return [jsdoc$1.configs[`flat/${resolvePreset()}`], {
|
|
162
|
+
name: "@kazupon/jsdoc",
|
|
263
163
|
rules: { ...overrideRules }
|
|
264
164
|
}];
|
|
265
165
|
}
|
|
@@ -325,92 +225,28 @@ function jsoncSort() {
|
|
|
325
225
|
}
|
|
326
226
|
|
|
327
227
|
//#endregion
|
|
328
|
-
//#region src/configs/
|
|
329
|
-
async function
|
|
228
|
+
//#region src/configs/prettier.ts
|
|
229
|
+
async function prettier(options = {}) {
|
|
330
230
|
const { rules: overrideRules = {} } = options;
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
configs.push(...yml$1.configs["flat/standard"].map((config, index) => {
|
|
335
|
-
return config.name ? config : {
|
|
336
|
-
name: `yml/flat/standard/${index}`,
|
|
337
|
-
...config
|
|
338
|
-
};
|
|
339
|
-
}));
|
|
340
|
-
if (usePrettier) {
|
|
341
|
-
configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
|
|
342
|
-
return config.name ? config : {
|
|
343
|
-
name: `yml/flat/prettier/${index}`,
|
|
344
|
-
...config
|
|
345
|
-
};
|
|
346
|
-
}));
|
|
347
|
-
}
|
|
348
|
-
const overriddenConfig = {
|
|
349
|
-
name: "@kazupon/yml",
|
|
350
|
-
files: [GLOB_YAML],
|
|
231
|
+
const prettier$1 = await loadPlugin("eslint-config-prettier");
|
|
232
|
+
return [prettier$1, {
|
|
233
|
+
name: "@kazupon/prettier",
|
|
351
234
|
rules: { ...overrideRules }
|
|
352
|
-
};
|
|
353
|
-
configs.push(overriddenConfig);
|
|
354
|
-
return configs;
|
|
235
|
+
}];
|
|
355
236
|
}
|
|
356
|
-
const yaml = yml;
|
|
357
237
|
|
|
358
238
|
//#endregion
|
|
359
|
-
//#region src/configs/
|
|
360
|
-
async function
|
|
361
|
-
const { rules: overrideRules = {}
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const composableBase = { ...composable.configs["flat/recommended"][0] };
|
|
369
|
-
delete composableBase.languageOptions;
|
|
370
|
-
configs.push(composableBase, composable.configs["flat/recommended"][1]);
|
|
371
|
-
}
|
|
372
|
-
if (options.scopedCss) {
|
|
373
|
-
const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
|
|
374
|
-
const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
|
|
375
|
-
return config.name ? config : {
|
|
376
|
-
name: `vue/scoped-css/recommended/${index}`,
|
|
377
|
-
...config
|
|
378
|
-
};
|
|
379
|
-
});
|
|
380
|
-
configs.push(scopedCssMapped[0], scopedCssMapped[2]);
|
|
381
|
-
}
|
|
382
|
-
if (options.a11y) {
|
|
383
|
-
const a11y = await loadPlugin("eslint-plugin-vuejs-accessibility");
|
|
384
|
-
const a11yBase = { ...a11y.configs["flat/recommended"][0] };
|
|
385
|
-
delete a11yBase.languageOptions;
|
|
386
|
-
configs.push(a11yBase);
|
|
387
|
-
const a11yRules = {
|
|
388
|
-
...a11y.configs["flat/recommended"][1],
|
|
389
|
-
name: "vuejs-accessibility:rules"
|
|
390
|
-
};
|
|
391
|
-
delete a11yRules.languageOptions;
|
|
392
|
-
delete a11yRules.plugins;
|
|
393
|
-
configs.push(a11yRules);
|
|
394
|
-
}
|
|
395
|
-
const customConfig = {
|
|
396
|
-
name: "@kazupon/vue",
|
|
397
|
-
files: [GLOB_VUE],
|
|
239
|
+
//#region src/configs/promise.ts
|
|
240
|
+
async function promise(options = {}) {
|
|
241
|
+
const { rules: overrideRules = {} } = options;
|
|
242
|
+
const promise$1 = await loadPlugin("eslint-plugin-promise");
|
|
243
|
+
return [{
|
|
244
|
+
name: "promise/flat/recommended",
|
|
245
|
+
...promise$1.configs["flat/recommended"]
|
|
246
|
+
}, {
|
|
247
|
+
name: "@kazupon/promise",
|
|
398
248
|
rules: { ...overrideRules }
|
|
399
|
-
};
|
|
400
|
-
if (options.typescript) {
|
|
401
|
-
customConfig.languageOptions = {
|
|
402
|
-
parser: vueParser,
|
|
403
|
-
parserOptions: {
|
|
404
|
-
sourceType: "module",
|
|
405
|
-
parser: await getTypeScriptParser(),
|
|
406
|
-
ecmaFeatures: { jsx: true },
|
|
407
|
-
extraFileExtensions: [".vue"],
|
|
408
|
-
...parserOptions
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
configs.push(customConfig);
|
|
413
|
-
return configs;
|
|
249
|
+
}];
|
|
414
250
|
}
|
|
415
251
|
|
|
416
252
|
//#endregion
|
|
@@ -445,6 +281,20 @@ async function react(options = {}) {
|
|
|
445
281
|
return [...configs, customConfig];
|
|
446
282
|
}
|
|
447
283
|
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/configs/regexp.ts
|
|
286
|
+
async function regexp(options = {}) {
|
|
287
|
+
const { rules: overrideRules = {} } = options;
|
|
288
|
+
const regexp$1 = await loadPlugin("eslint-plugin-regexp");
|
|
289
|
+
return [{
|
|
290
|
+
name: "regexp/flat/recommended",
|
|
291
|
+
...regexp$1.configs["flat/recommended"]
|
|
292
|
+
}, {
|
|
293
|
+
name: "@kazupon/eslint-regexp",
|
|
294
|
+
rules: { ...overrideRules }
|
|
295
|
+
}];
|
|
296
|
+
}
|
|
297
|
+
|
|
448
298
|
//#endregion
|
|
449
299
|
//#region src/configs/svelte.ts
|
|
450
300
|
async function svelte(options = {}) {
|
|
@@ -472,6 +322,78 @@ async function svelte(options = {}) {
|
|
|
472
322
|
return [...svelte$1.configs["flat/recommended"], customConfig];
|
|
473
323
|
}
|
|
474
324
|
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/configs/toml.ts
|
|
327
|
+
async function toml(options = {}) {
|
|
328
|
+
const { rules: overrideRules = {} } = options;
|
|
329
|
+
const toml$1 = await loadPlugin("eslint-plugin-toml");
|
|
330
|
+
const configs = [];
|
|
331
|
+
configs.push(...toml$1.configs["flat/standard"].map((config, index) => {
|
|
332
|
+
return config.name ? config : {
|
|
333
|
+
name: `toml/flat/standard/${index}`,
|
|
334
|
+
...config
|
|
335
|
+
};
|
|
336
|
+
}));
|
|
337
|
+
const overriddenConfig = {
|
|
338
|
+
name: "@kazupon/toml",
|
|
339
|
+
files: [GLOB_TOML],
|
|
340
|
+
rules: { ...overrideRules }
|
|
341
|
+
};
|
|
342
|
+
configs.push(overriddenConfig);
|
|
343
|
+
return configs;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/configs/typescript.ts
|
|
348
|
+
async function typescript(options = {}) {
|
|
349
|
+
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = { project: true } } = options;
|
|
350
|
+
const ts = await loadPlugin("typescript-eslint");
|
|
351
|
+
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
|
|
352
|
+
return [...ts.configs.recommendedTypeChecked, {
|
|
353
|
+
files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_YAML, GLOB_TOML],
|
|
354
|
+
...ts.configs.disableTypeChecked
|
|
355
|
+
}, {
|
|
356
|
+
name: "@kazupon/typescipt/typescript-eslint",
|
|
357
|
+
files,
|
|
358
|
+
languageOptions: {
|
|
359
|
+
parser: ts.parser,
|
|
360
|
+
parserOptions: {
|
|
361
|
+
extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
|
|
362
|
+
sourceType: "module",
|
|
363
|
+
...parserOptions
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
rules: {
|
|
367
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
368
|
+
args: "all",
|
|
369
|
+
argsIgnorePattern: "^_",
|
|
370
|
+
caughtErrors: "all",
|
|
371
|
+
caughtErrorsIgnorePattern: "^_",
|
|
372
|
+
destructuredArrayIgnorePattern: "^_",
|
|
373
|
+
varsIgnorePattern: "^_",
|
|
374
|
+
ignoreRestSiblings: true
|
|
375
|
+
}],
|
|
376
|
+
...overrideRules
|
|
377
|
+
}
|
|
378
|
+
}];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/configs/unicorn.ts
|
|
383
|
+
async function unicorn(options = {}) {
|
|
384
|
+
const { rules: overrideRules = {} } = options;
|
|
385
|
+
const useTypeScript = !options.typescript;
|
|
386
|
+
const unicorn$1 = await loadPlugin("eslint-plugin-unicorn");
|
|
387
|
+
return [{
|
|
388
|
+
files: getGlobSourceFiles(useTypeScript),
|
|
389
|
+
...unicorn$1.configs["flat/recommended"]
|
|
390
|
+
}, {
|
|
391
|
+
name: "@kazupon/unicorn",
|
|
392
|
+
files: getGlobSourceFiles(useTypeScript),
|
|
393
|
+
rules: { ...overrideRules }
|
|
394
|
+
}];
|
|
395
|
+
}
|
|
396
|
+
|
|
475
397
|
//#endregion
|
|
476
398
|
//#region src/configs/vitest.ts
|
|
477
399
|
async function vitest(options = {}) {
|
|
@@ -503,5 +425,94 @@ async function vitest(options = {}) {
|
|
|
503
425
|
return configs;
|
|
504
426
|
}
|
|
505
427
|
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/configs/vue.ts
|
|
430
|
+
async function vue(options = {}) {
|
|
431
|
+
const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
|
|
432
|
+
const vue$1 = await loadPlugin("eslint-plugin-vue");
|
|
433
|
+
const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
434
|
+
const configs = [];
|
|
435
|
+
configs.push(...vue$1.configs["flat/recommended"]);
|
|
436
|
+
if (options.composable) {
|
|
437
|
+
const composable = await loadPlugin("eslint-plugin-vue-composable");
|
|
438
|
+
const composableBase = { ...composable.configs["flat/recommended"][0] };
|
|
439
|
+
delete composableBase.languageOptions;
|
|
440
|
+
configs.push(composableBase, composable.configs["flat/recommended"][1]);
|
|
441
|
+
}
|
|
442
|
+
if (options.scopedCss) {
|
|
443
|
+
const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
|
|
444
|
+
const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
|
|
445
|
+
return config.name ? config : {
|
|
446
|
+
name: `vue/scoped-css/recommended/${index}`,
|
|
447
|
+
...config
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
configs.push(scopedCssMapped[0], scopedCssMapped[2]);
|
|
451
|
+
}
|
|
452
|
+
if (options.a11y) {
|
|
453
|
+
const a11y = await loadPlugin("eslint-plugin-vuejs-accessibility");
|
|
454
|
+
const a11yBase = { ...a11y.configs["flat/recommended"][0] };
|
|
455
|
+
delete a11yBase.languageOptions;
|
|
456
|
+
configs.push(a11yBase);
|
|
457
|
+
const a11yRules = {
|
|
458
|
+
...a11y.configs["flat/recommended"][1],
|
|
459
|
+
name: "vuejs-accessibility:rules"
|
|
460
|
+
};
|
|
461
|
+
delete a11yRules.languageOptions;
|
|
462
|
+
delete a11yRules.plugins;
|
|
463
|
+
configs.push(a11yRules);
|
|
464
|
+
}
|
|
465
|
+
const customConfig = {
|
|
466
|
+
name: "@kazupon/vue",
|
|
467
|
+
files: [GLOB_VUE],
|
|
468
|
+
rules: { ...overrideRules }
|
|
469
|
+
};
|
|
470
|
+
if (options.typescript) {
|
|
471
|
+
customConfig.languageOptions = {
|
|
472
|
+
parser: vueParser,
|
|
473
|
+
parserOptions: {
|
|
474
|
+
sourceType: "module",
|
|
475
|
+
parser: await getTypeScriptParser(),
|
|
476
|
+
ecmaFeatures: { jsx: true },
|
|
477
|
+
extraFileExtensions: [".vue"],
|
|
478
|
+
...parserOptions
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
configs.push(customConfig);
|
|
483
|
+
return configs;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/configs/yml.ts
|
|
488
|
+
async function yml(options = {}) {
|
|
489
|
+
const { rules: overrideRules = {} } = options;
|
|
490
|
+
const usePrettier = !!options.prettier;
|
|
491
|
+
const yml$1 = await loadPlugin("eslint-plugin-yml");
|
|
492
|
+
const configs = [];
|
|
493
|
+
configs.push(...yml$1.configs["flat/standard"].map((config, index) => {
|
|
494
|
+
return config.name ? config : {
|
|
495
|
+
name: `yml/flat/standard/${index}`,
|
|
496
|
+
...config
|
|
497
|
+
};
|
|
498
|
+
}));
|
|
499
|
+
if (usePrettier) {
|
|
500
|
+
configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
|
|
501
|
+
return config.name ? config : {
|
|
502
|
+
name: `yml/flat/prettier/${index}`,
|
|
503
|
+
...config
|
|
504
|
+
};
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
const overriddenConfig = {
|
|
508
|
+
name: "@kazupon/yml",
|
|
509
|
+
files: [GLOB_YAML],
|
|
510
|
+
rules: { ...overrideRules }
|
|
511
|
+
};
|
|
512
|
+
configs.push(overriddenConfig);
|
|
513
|
+
return configs;
|
|
514
|
+
}
|
|
515
|
+
const yaml = yml;
|
|
516
|
+
|
|
506
517
|
//#endregion
|
|
507
518
|
export { comments, defineConfig, imports, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
|