@kazupon/eslint-config 0.15.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 +24 -22
- package/dist/configs/comments.d.cts +1 -1
- package/dist/configs/comments.d.ts +1 -1
- package/dist/configs/imports.d.cts +21 -0
- package/dist/configs/imports.d.ts +21 -0
- package/dist/configs/index.d.cts +16 -15
- package/dist/configs/index.d.ts +16 -15
- 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 +19 -4
- package/dist/configs/vue.d.ts +19 -4
- package/dist/configs/yml.d.cts +1 -1
- package/dist/configs/yml.d.ts +1 -1
- package/dist/index.cjs +265 -182
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +260 -183
- package/dist/types/gens/eslint.d.cts +2 -1
- package/dist/types/gens/eslint.d.ts +2 -1
- package/dist/types/gens/imports.d.cts +519 -0
- package/dist/types/gens/imports.d.ts +519 -0
- package/dist/types/gens/vue.d.cts +281 -0
- package/dist/types/gens/vue.d.ts +281 -0
- package/dist/types/index.d.cts +18 -17
- package/dist/types/index.d.ts +18 -17
- package/dist/types/overrides.d.cts +1 -1
- package/dist/types/overrides.d.ts +1 -1
- package/package.json +32 -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,6 +48,67 @@ 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/comments.ts
|
|
53
|
+
async function comments(options = {}) {
|
|
54
|
+
const { rules: overrideRules = {} } = options;
|
|
55
|
+
const comments$1 = await loadPlugin("@eslint-community/eslint-plugin-eslint-comments");
|
|
56
|
+
return [{
|
|
57
|
+
name: "@eslint-community/eslint-comments/recommended",
|
|
58
|
+
plugins: { "@eslint-community/eslint-comments": comments$1 },
|
|
59
|
+
rules: { ...comments$1.configs.recommended.rules }
|
|
60
|
+
}, {
|
|
61
|
+
name: "@kazupon/eslint-comments",
|
|
62
|
+
rules: { ...overrideRules }
|
|
63
|
+
}];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/configs/imports.ts
|
|
68
|
+
const IMPORTS_FILES = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX];
|
|
69
|
+
async function imports(options = {}) {
|
|
70
|
+
const { rules: overrideRules = {} } = options;
|
|
71
|
+
const unused = await loadPlugin("eslint-plugin-unused-imports");
|
|
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({
|
|
84
|
+
name: "unused-imports",
|
|
85
|
+
plugins: { "unused-imports": unused },
|
|
86
|
+
files: IMPORTS_FILES,
|
|
87
|
+
rules: {
|
|
88
|
+
"no-unused-vars": "off",
|
|
89
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
90
|
+
"unused-imports/no-unused-imports": "error",
|
|
91
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
92
|
+
args: "all",
|
|
93
|
+
argsIgnorePattern: "^_",
|
|
94
|
+
caughtErrors: "all",
|
|
95
|
+
caughtErrorsIgnorePattern: "^_",
|
|
96
|
+
destructuredArrayIgnorePattern: "^_",
|
|
97
|
+
vars: "all",
|
|
98
|
+
varsIgnorePattern: "^_",
|
|
99
|
+
ignoreRestSiblings: true
|
|
100
|
+
}]
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const overriddenConfig = {
|
|
104
|
+
name: "@kazupon/imports",
|
|
105
|
+
files: IMPORTS_FILES,
|
|
106
|
+
rules: { ...overrideRules }
|
|
107
|
+
};
|
|
108
|
+
configs.push(overriddenConfig);
|
|
109
|
+
return configs;
|
|
110
|
+
}
|
|
111
|
+
|
|
51
112
|
//#endregion
|
|
52
113
|
//#region src/configs/javascript.ts
|
|
53
114
|
async function javascript(options = {}) {
|
|
@@ -80,56 +141,6 @@ async function javascript(options = {}) {
|
|
|
80
141
|
}];
|
|
81
142
|
}
|
|
82
143
|
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/configs/comments.ts
|
|
85
|
-
async function comments(options = {}) {
|
|
86
|
-
const { rules: overrideRules = {} } = options;
|
|
87
|
-
const comments$1 = await loadPlugin("@eslint-community/eslint-plugin-eslint-comments");
|
|
88
|
-
return [{
|
|
89
|
-
name: "@eslint-community/eslint-comments/recommended",
|
|
90
|
-
plugins: { "@eslint-community/eslint-comments": comments$1 },
|
|
91
|
-
rules: { ...comments$1.configs.recommended.rules }
|
|
92
|
-
}, {
|
|
93
|
-
name: "@kazupon/eslint-comments",
|
|
94
|
-
rules: { ...overrideRules }
|
|
95
|
-
}];
|
|
96
|
-
}
|
|
97
|
-
|
|
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
144
|
//#endregion
|
|
134
145
|
//#region src/configs/jsdoc.ts
|
|
135
146
|
async function jsdoc(options = {}) {
|
|
@@ -153,82 +164,6 @@ async function jsdoc(options = {}) {
|
|
|
153
164
|
}];
|
|
154
165
|
}
|
|
155
166
|
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/configs/promise.ts
|
|
158
|
-
async function promise(options = {}) {
|
|
159
|
-
const { rules: overrideRules = {} } = options;
|
|
160
|
-
const promise$1 = await loadPlugin("eslint-plugin-promise");
|
|
161
|
-
return [{
|
|
162
|
-
name: "promise/flat/recommended",
|
|
163
|
-
...promise$1.configs["flat/recommended"]
|
|
164
|
-
}, {
|
|
165
|
-
name: "@kazupon/promise",
|
|
166
|
-
rules: { ...overrideRules }
|
|
167
|
-
}];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/configs/regexp.ts
|
|
172
|
-
async function regexp(options = {}) {
|
|
173
|
-
const { rules: overrideRules = {} } = options;
|
|
174
|
-
const regexp$1 = await loadPlugin("eslint-plugin-regexp");
|
|
175
|
-
return [{
|
|
176
|
-
name: "regexp/flat/recommended",
|
|
177
|
-
...regexp$1.configs["flat/recommended"]
|
|
178
|
-
}, {
|
|
179
|
-
name: "@kazupon/eslint-regexp",
|
|
180
|
-
rules: { ...overrideRules }
|
|
181
|
-
}];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/configs/toml.ts
|
|
186
|
-
async function toml(options = {}) {
|
|
187
|
-
const { rules: overrideRules = {} } = options;
|
|
188
|
-
const toml$1 = await loadPlugin("eslint-plugin-toml");
|
|
189
|
-
const configs = [];
|
|
190
|
-
configs.push(...toml$1.configs["flat/standard"].map((config, index) => {
|
|
191
|
-
return config.name ? config : {
|
|
192
|
-
name: `toml/flat/standard/${index}`,
|
|
193
|
-
...config
|
|
194
|
-
};
|
|
195
|
-
}));
|
|
196
|
-
const overriddenConfig = {
|
|
197
|
-
name: "@kazupon/toml",
|
|
198
|
-
files: [GLOB_TOML],
|
|
199
|
-
rules: { ...overrideRules }
|
|
200
|
-
};
|
|
201
|
-
configs.push(overriddenConfig);
|
|
202
|
-
return configs;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/configs/unicorn.ts
|
|
207
|
-
async function unicorn(options = {}) {
|
|
208
|
-
const { rules: overrideRules = {} } = options;
|
|
209
|
-
const useTypeScript = !options.typescript;
|
|
210
|
-
const unicorn$1 = await loadPlugin("eslint-plugin-unicorn");
|
|
211
|
-
return [{
|
|
212
|
-
files: getGlobSourceFiles(useTypeScript),
|
|
213
|
-
...unicorn$1.configs["flat/recommended"]
|
|
214
|
-
}, {
|
|
215
|
-
name: "@kazupon/unicorn",
|
|
216
|
-
files: getGlobSourceFiles(useTypeScript),
|
|
217
|
-
rules: { ...overrideRules }
|
|
218
|
-
}];
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/configs/prettier.ts
|
|
223
|
-
async function prettier(options = {}) {
|
|
224
|
-
const { rules: overrideRules = {} } = options;
|
|
225
|
-
const prettier$1 = await loadPlugin("eslint-config-prettier");
|
|
226
|
-
return [prettier$1, {
|
|
227
|
-
name: "@kazupon/prettier",
|
|
228
|
-
rules: { ...overrideRules }
|
|
229
|
-
}];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
167
|
//#endregion
|
|
233
168
|
//#region src/configs/jsonc.ts
|
|
234
169
|
async function jsonc(options = {}) {
|
|
@@ -290,61 +225,28 @@ function jsoncSort() {
|
|
|
290
225
|
}
|
|
291
226
|
|
|
292
227
|
//#endregion
|
|
293
|
-
//#region src/configs/
|
|
294
|
-
async function
|
|
228
|
+
//#region src/configs/prettier.ts
|
|
229
|
+
async function prettier(options = {}) {
|
|
295
230
|
const { rules: overrideRules = {} } = options;
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
configs.push(...yml$1.configs["flat/standard"].map((config, index) => {
|
|
300
|
-
return config.name ? config : {
|
|
301
|
-
name: `yml/flat/standard/${index}`,
|
|
302
|
-
...config
|
|
303
|
-
};
|
|
304
|
-
}));
|
|
305
|
-
if (usePrettier) {
|
|
306
|
-
configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
|
|
307
|
-
return config.name ? config : {
|
|
308
|
-
name: `yml/flat/prettier/${index}`,
|
|
309
|
-
...config
|
|
310
|
-
};
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
const overriddenConfig = {
|
|
314
|
-
name: "@kazupon/yml",
|
|
315
|
-
files: [GLOB_YAML],
|
|
231
|
+
const prettier$1 = await loadPlugin("eslint-config-prettier");
|
|
232
|
+
return [prettier$1, {
|
|
233
|
+
name: "@kazupon/prettier",
|
|
316
234
|
rules: { ...overrideRules }
|
|
317
|
-
};
|
|
318
|
-
configs.push(overriddenConfig);
|
|
319
|
-
return configs;
|
|
235
|
+
}];
|
|
320
236
|
}
|
|
321
|
-
const yaml = yml;
|
|
322
237
|
|
|
323
238
|
//#endregion
|
|
324
|
-
//#region src/configs/
|
|
325
|
-
async function
|
|
326
|
-
const { rules: overrideRules = {}
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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",
|
|
333
248
|
rules: { ...overrideRules }
|
|
334
|
-
};
|
|
335
|
-
if (useTypeScript) {
|
|
336
|
-
customConfig.languageOptions = {
|
|
337
|
-
parser: vueParser,
|
|
338
|
-
parserOptions: {
|
|
339
|
-
sourceType: "module",
|
|
340
|
-
parser: await getTypeScriptParser(),
|
|
341
|
-
ecmaFeatures: { jsx: true },
|
|
342
|
-
extraFileExtensions: [".vue"],
|
|
343
|
-
...parserOptions
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
return [...vue$1.configs["flat/recommended"], customConfig];
|
|
249
|
+
}];
|
|
348
250
|
}
|
|
349
251
|
|
|
350
252
|
//#endregion
|
|
@@ -379,6 +281,20 @@ async function react(options = {}) {
|
|
|
379
281
|
return [...configs, customConfig];
|
|
380
282
|
}
|
|
381
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
|
+
|
|
382
298
|
//#endregion
|
|
383
299
|
//#region src/configs/svelte.ts
|
|
384
300
|
async function svelte(options = {}) {
|
|
@@ -406,6 +322,78 @@ async function svelte(options = {}) {
|
|
|
406
322
|
return [...svelte$1.configs["flat/recommended"], customConfig];
|
|
407
323
|
}
|
|
408
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
|
+
|
|
409
397
|
//#endregion
|
|
410
398
|
//#region src/configs/vitest.ts
|
|
411
399
|
async function vitest(options = {}) {
|
|
@@ -438,4 +426,93 @@ async function vitest(options = {}) {
|
|
|
438
426
|
}
|
|
439
427
|
|
|
440
428
|
//#endregion
|
|
441
|
-
|
|
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
|
+
|
|
517
|
+
//#endregion
|
|
518
|
+
export { comments, defineConfig, imports, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommentsRules } from './comments';
|
|
2
|
+
import type { ImportsRules } from './imports';
|
|
2
3
|
import type { JavascriptRules } from './javascript';
|
|
3
4
|
import type { JsdocRules } from './jsdoc';
|
|
4
5
|
import type { JsoncRules } from './jsonc';
|
|
@@ -15,7 +16,7 @@ import type { VueRules } from './vue';
|
|
|
15
16
|
import type { YmlRules } from './yml';
|
|
16
17
|
declare module 'eslint' {
|
|
17
18
|
namespace Linter {
|
|
18
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
19
|
+
interface RulesRecord extends CommentsRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommentsRules } from './comments';
|
|
2
|
+
import type { ImportsRules } from './imports';
|
|
2
3
|
import type { JavascriptRules } from './javascript';
|
|
3
4
|
import type { JsdocRules } from './jsdoc';
|
|
4
5
|
import type { JsoncRules } from './jsonc';
|
|
@@ -15,7 +16,7 @@ import type { VueRules } from './vue';
|
|
|
15
16
|
import type { YmlRules } from './yml';
|
|
16
17
|
declare module 'eslint' {
|
|
17
18
|
namespace Linter {
|
|
18
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
19
|
+
interface RulesRecord extends CommentsRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
}
|