@kazupon/eslint-config 0.16.0 → 0.18.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.
Files changed (60) hide show
  1. package/README.md +8 -1
  2. package/dist/config.d.cts +1 -1
  3. package/dist/config.d.ts +1 -1
  4. package/dist/configs/comments.d.cts +1 -1
  5. package/dist/configs/comments.d.ts +1 -1
  6. package/dist/configs/imports.d.cts +9 -4
  7. package/dist/configs/imports.d.ts +9 -4
  8. package/dist/configs/index.d.cts +17 -16
  9. package/dist/configs/index.d.ts +17 -16
  10. package/dist/configs/javascript.d.cts +1 -1
  11. package/dist/configs/javascript.d.ts +1 -1
  12. package/dist/configs/jsdoc.d.cts +1 -1
  13. package/dist/configs/jsdoc.d.ts +1 -1
  14. package/dist/configs/jsonc.d.cts +1 -1
  15. package/dist/configs/jsonc.d.ts +1 -1
  16. package/dist/configs/markdown.d.cts +28 -0
  17. package/dist/configs/markdown.d.ts +28 -0
  18. package/dist/configs/prettier.d.cts +1 -1
  19. package/dist/configs/prettier.d.ts +1 -1
  20. package/dist/configs/promise.d.cts +1 -1
  21. package/dist/configs/promise.d.ts +1 -1
  22. package/dist/configs/react.d.cts +2 -2
  23. package/dist/configs/react.d.ts +2 -2
  24. package/dist/configs/regexp.d.cts +1 -1
  25. package/dist/configs/regexp.d.ts +1 -1
  26. package/dist/configs/svelte.d.cts +2 -2
  27. package/dist/configs/svelte.d.ts +2 -2
  28. package/dist/configs/toml.d.cts +1 -1
  29. package/dist/configs/toml.d.ts +1 -1
  30. package/dist/configs/typescript.d.cts +1 -1
  31. package/dist/configs/typescript.d.ts +1 -1
  32. package/dist/configs/unicorn.d.cts +1 -1
  33. package/dist/configs/unicorn.d.ts +1 -1
  34. package/dist/configs/vitest.d.cts +1 -1
  35. package/dist/configs/vitest.d.ts +1 -1
  36. package/dist/configs/vue.d.cts +2 -2
  37. package/dist/configs/vue.d.ts +2 -2
  38. package/dist/configs/yml.d.cts +1 -1
  39. package/dist/configs/yml.d.ts +1 -1
  40. package/dist/globs.d.cts +1 -0
  41. package/dist/globs.d.ts +1 -0
  42. package/dist/index.cjs +399 -259
  43. package/dist/index.d.cts +3 -3
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.js +388 -260
  46. package/dist/types/gens/eslint.d.cts +2 -1
  47. package/dist/types/gens/eslint.d.ts +2 -1
  48. package/dist/types/gens/imports.d.cts +478 -0
  49. package/dist/types/gens/imports.d.ts +478 -0
  50. package/dist/types/gens/javascript.d.cts +6 -1
  51. package/dist/types/gens/javascript.d.ts +6 -1
  52. package/dist/types/gens/markdown.d.cts +42 -0
  53. package/dist/types/gens/markdown.d.ts +42 -0
  54. package/dist/types/gens/unicorn.d.cts +153 -138
  55. package/dist/types/gens/unicorn.d.ts +153 -138
  56. package/dist/types/index.d.cts +19 -18
  57. package/dist/types/index.d.ts +19 -18
  58. package/dist/types/overrides.d.cts +1 -1
  59. package/dist/types/overrides.d.ts +1 -1
  60. package/package.json +22 -7
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
+ import { interopDefault } from "@kazupon/jts-utils/module";
2
3
  import { default as globals } from "globals";
3
4
 
4
5
  //#region src/config.ts
@@ -20,17 +21,21 @@ const GLOB_YAML = "**/*.y?(a)ml";
20
21
  const GLOB_TOML = "**/*.toml";
21
22
  const GLOB_VUE = "**/*.vue";
22
23
  const GLOB_SVELTE = "**/*.svelte";
24
+ const GLOB_MARKDOWN = "**/*.md";
23
25
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
24
- 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}`];
26
+ const GLOB_TESTS = [
27
+ `**/test/**/*.${GLOB_SRC_EXT}`,
28
+ `**/tests/**/*.${GLOB_SRC_EXT}`,
29
+ `**/spec/**/*.${GLOB_SRC_EXT}`,
30
+ `**/specs/**/*.${GLOB_SRC_EXT}`,
31
+ `**/e2e/**/*.${GLOB_SRC_EXT}`,
32
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
33
+ `**/__test__/**/*.${GLOB_SRC_EXT}`,
34
+ `**/*.spec.${GLOB_SRC_EXT}`,
35
+ `**/*.test.${GLOB_SRC_EXT}`
36
+ ];
25
37
  const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
26
38
 
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
39
  //#endregion
35
40
  //#region src/utils.ts
36
41
  async function loadPlugin(name) {
@@ -45,7 +50,77 @@ async function getTypeScriptParser() {
45
50
  return ts.parser;
46
51
  }
47
52
  function getGlobSourceFiles(useTypeScript = false) {
48
- return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
53
+ return [
54
+ GLOB_JS,
55
+ GLOB_JSX,
56
+ ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []
57
+ ];
58
+ }
59
+
60
+ //#endregion
61
+ //#region src/configs/comments.ts
62
+ async function comments(options = {}) {
63
+ const { rules: overrideRules = {} } = options;
64
+ const comments$1 = await loadPlugin("@eslint-community/eslint-plugin-eslint-comments");
65
+ return [{
66
+ name: "@eslint-community/eslint-comments/recommended",
67
+ plugins: { "@eslint-community/eslint-comments": comments$1 },
68
+ rules: { ...comments$1.configs.recommended.rules }
69
+ }, {
70
+ name: "@kazupon/eslint-comments",
71
+ rules: { ...overrideRules }
72
+ }];
73
+ }
74
+
75
+ //#endregion
76
+ //#region src/configs/imports.ts
77
+ const IMPORTS_FILES = [
78
+ GLOB_JS,
79
+ GLOB_JSX,
80
+ GLOB_TS,
81
+ GLOB_TSX
82
+ ];
83
+ async function imports(options = {}) {
84
+ const { rules: overrideRules = {} } = options;
85
+ const unused = await loadPlugin("eslint-plugin-unused-imports");
86
+ const imports$1 = await loadPlugin("eslint-plugin-import");
87
+ const configs = [imports$1.flatConfigs.recommended];
88
+ if (options.typescript) {
89
+ try {
90
+ await loadPlugin("eslint-import-resolver-typescript");
91
+ imports$1.flatConfigs.typescript.settings["import/resolver"]["typescript"] = true;
92
+ configs.push(imports$1.flatConfigs.typescript);
93
+ } catch (error) {
94
+ throw new Error(`Not found eslint-import-resolver-typescript: ${error.message}`);
95
+ }
96
+ }
97
+ configs.push({
98
+ name: "unused-imports",
99
+ plugins: { "unused-imports": unused },
100
+ files: IMPORTS_FILES,
101
+ rules: {
102
+ "no-unused-vars": "off",
103
+ "@typescript-eslint/no-unused-vars": "off",
104
+ "unused-imports/no-unused-imports": "error",
105
+ "unused-imports/no-unused-vars": ["error", {
106
+ args: "all",
107
+ argsIgnorePattern: "^_",
108
+ caughtErrors: "all",
109
+ caughtErrorsIgnorePattern: "^_",
110
+ destructuredArrayIgnorePattern: "^_",
111
+ vars: "all",
112
+ varsIgnorePattern: "^_",
113
+ ignoreRestSiblings: true
114
+ }]
115
+ }
116
+ });
117
+ const overriddenConfig = {
118
+ name: "@kazupon/imports",
119
+ files: IMPORTS_FILES,
120
+ rules: { ...overrideRules }
121
+ };
122
+ configs.push(overriddenConfig);
123
+ return configs;
49
124
  }
50
125
 
51
126
  //#endregion
@@ -80,56 +155,6 @@ async function javascript(options = {}) {
80
155
  }];
81
156
  }
82
157
 
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
158
  //#endregion
134
159
  //#region src/configs/jsdoc.ts
135
160
  async function jsdoc(options = {}) {
@@ -154,39 +179,158 @@ async function jsdoc(options = {}) {
154
179
  }
155
180
 
156
181
  //#endregion
157
- //#region src/configs/imports.ts
158
- const IMPORTS_FILES = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX];
159
- async function imports(options = {}) {
182
+ //#region src/configs/jsonc.ts
183
+ async function jsonc(options = {}) {
160
184
  const { rules: overrideRules = {} } = options;
161
- const unused = await loadPlugin("eslint-plugin-unused-imports");
162
- const configs = [{
163
- name: "unused-imports",
164
- plugins: { "unused-imports": unused },
165
- files: IMPORTS_FILES,
166
- rules: {
167
- "no-unused-vars": "off",
168
- "@typescript-eslint/no-unused-vars": "off",
169
- "unused-imports/no-unused-imports": "error",
170
- "unused-imports/no-unused-vars": ["error", {
171
- args: "all",
172
- argsIgnorePattern: "^_",
173
- caughtErrors: "all",
174
- caughtErrorsIgnorePattern: "^_",
175
- destructuredArrayIgnorePattern: "^_",
176
- vars: "all",
177
- varsIgnorePattern: "^_",
178
- ignoreRestSiblings: true
179
- }]
185
+ const kinds = [
186
+ options.json ? "json" : "",
187
+ options.jsonc ? "jsonc" : "",
188
+ options.json5 ? "json5" : ""
189
+ ];
190
+ const usePrettier = !!options.prettier;
191
+ const jsonc$1 = await loadPlugin("eslint-plugin-jsonc");
192
+ const configs = [];
193
+ for (const kind of kinds) {
194
+ if (kind) {
195
+ configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
196
+ return config.name ? config : {
197
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
198
+ ...config
199
+ };
200
+ }));
180
201
  }
181
- }];
202
+ }
203
+ if (usePrettier) {
204
+ configs.push(...jsonc$1.configs["flat/prettier"].map((config, index) => {
205
+ return config.name ? config : {
206
+ name: `jsonc/flat/prettier/${index}`,
207
+ ...config
208
+ };
209
+ }));
210
+ }
182
211
  const overriddenConfig = {
183
- name: "@kazupon/imports",
184
- files: IMPORTS_FILES,
212
+ name: "@kazupon/jsonc",
213
+ files: [
214
+ GLOB_JSON,
215
+ GLOB_JSON5,
216
+ GLOB_JSONC
217
+ ],
185
218
  rules: { ...overrideRules }
186
219
  };
187
- configs.push(overriddenConfig);
220
+ configs.push(...jsoncSort(), overriddenConfig);
188
221
  return configs;
189
222
  }
223
+ /**
224
+ * jsonc sort configurations
225
+ * @returns {Linter.Config[]} jsonc sort configurations
226
+ */
227
+ function jsoncSort() {
228
+ return [{
229
+ name: "@kazupon/jsonc/sort/package.json",
230
+ files: ["**/package.json"],
231
+ rules: {
232
+ "jsonc/sort-array-values": ["error", {
233
+ order: { type: "asc" },
234
+ pathPattern: "^files$"
235
+ }],
236
+ "jsonc/sort-keys": [
237
+ "error",
238
+ {
239
+ order: [
240
+ "name",
241
+ "description",
242
+ "private",
243
+ "version",
244
+ "author",
245
+ "contributors",
246
+ "license",
247
+ "funding",
248
+ "bugs",
249
+ "repository",
250
+ "keywords",
251
+ "homepage",
252
+ "publishConfig",
253
+ "packageManager",
254
+ "engines",
255
+ "os",
256
+ "cpu",
257
+ "type",
258
+ "sideEffects",
259
+ "bin",
260
+ "files",
261
+ "main",
262
+ "module",
263
+ "browser",
264
+ "unpkg",
265
+ "jsdelivr",
266
+ "directories",
267
+ "exports",
268
+ "types",
269
+ "typesVersions",
270
+ "scripts",
271
+ "dependencies",
272
+ "peerDependencies",
273
+ "peerDependenciesMeta",
274
+ "optionalDependencies",
275
+ "devDependencies",
276
+ "pnpm",
277
+ "overrides",
278
+ "resolutions",
279
+ "workspaces",
280
+ "prettier",
281
+ "buildOptions",
282
+ "lint-staged"
283
+ ],
284
+ pathPattern: "^$"
285
+ },
286
+ {
287
+ order: { type: "asc" },
288
+ pathPattern: "^scripts$"
289
+ },
290
+ {
291
+ order: { type: "asc" },
292
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
293
+ },
294
+ {
295
+ order: { type: "asc" },
296
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
297
+ }
298
+ ]
299
+ }
300
+ }];
301
+ }
302
+
303
+ //#endregion
304
+ //#region src/configs/markdown.ts
305
+ async function markdown(options = {}) {
306
+ const { rules: overrideRules = {} } = options;
307
+ const language = options.language || "gfm";
308
+ const fencedCodeBlocks = typeof options.fencedCodeBlocks === "boolean" ? options.fencedCodeBlocks : true;
309
+ const markdown$1 = await loadPlugin("@eslint/markdown");
310
+ const recommended = markdown$1.configs["recommended"][0];
311
+ recommended.language = `markdown/${language}`;
312
+ return [
313
+ recommended,
314
+ ...fencedCodeBlocks ? markdown$1.configs["processor"] : [],
315
+ {
316
+ name: "@kazupon/markdown",
317
+ files: [GLOB_MARKDOWN],
318
+ rules: { ...overrideRules }
319
+ }
320
+ ];
321
+ }
322
+ const md = markdown;
323
+
324
+ //#endregion
325
+ //#region src/configs/prettier.ts
326
+ async function prettier(options = {}) {
327
+ const { rules: overrideRules = {} } = options;
328
+ const prettier$1 = await loadPlugin("eslint-config-prettier");
329
+ return [prettier$1, {
330
+ name: "@kazupon/prettier",
331
+ rules: { ...overrideRules }
332
+ }];
333
+ }
190
334
 
191
335
  //#endregion
192
336
  //#region src/configs/promise.ts
@@ -202,6 +346,42 @@ async function promise(options = {}) {
202
346
  }];
203
347
  }
204
348
 
349
+ //#endregion
350
+ //#region src/configs/react.ts
351
+ async function react(options = {}) {
352
+ const { rules: overrideRules = {}, settings = {} } = options;
353
+ const useTypeScript = !options.typescript;
354
+ const enableRefresh = !!options.refresh;
355
+ const [react$1, reactHooks, reactRefresh] = await Promise.all([
356
+ loadPlugin("eslint-plugin-react"),
357
+ loadPlugin("eslint-plugin-react-hooks"),
358
+ enableRefresh ? loadPlugin("eslint-plugin-react-refresh") : null
359
+ ]);
360
+ const customConfig = {
361
+ name: "@kazupon/react",
362
+ files: getGlobSourceFiles(useTypeScript),
363
+ rules: { ...overrideRules }
364
+ };
365
+ const configs = [{
366
+ name: "react/flat/recommended",
367
+ files: getGlobSourceFiles(useTypeScript),
368
+ settings,
369
+ ...react$1.configs.flat.recommended
370
+ }, {
371
+ name: "react-hooks/flat",
372
+ files: getGlobSourceFiles(useTypeScript),
373
+ plugins: { "react-hooks": reactHooks }
374
+ }];
375
+ if (enableRefresh) {
376
+ configs.push({
377
+ name: "react-refresh/flat",
378
+ files: getGlobSourceFiles(useTypeScript),
379
+ plugins: { "react-refresh": reactRefresh }
380
+ });
381
+ }
382
+ return [...configs, customConfig];
383
+ }
384
+
205
385
  //#endregion
206
386
  //#region src/configs/regexp.ts
207
387
  async function regexp(options = {}) {
@@ -216,6 +396,33 @@ async function regexp(options = {}) {
216
396
  }];
217
397
  }
218
398
 
399
+ //#endregion
400
+ //#region src/configs/svelte.ts
401
+ async function svelte(options = {}) {
402
+ const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
403
+ const useTypeScript = !!options.typescript;
404
+ const svelte$1 = await loadPlugin("eslint-plugin-svelte");
405
+ const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]["parser"];
406
+ const customConfig = {
407
+ name: "@kazupon/svelte",
408
+ files: [GLOB_SVELTE],
409
+ rules: { ...overrideRules }
410
+ };
411
+ if (useTypeScript) {
412
+ customConfig.languageOptions = {
413
+ parser: svelteParser,
414
+ parserOptions: {
415
+ sourceType: "module",
416
+ parser: await getTypeScriptParser(),
417
+ ecmaFeatures: { jsx: true },
418
+ extraFileExtensions: [".svelte"],
419
+ ...parserOptions
420
+ }
421
+ };
422
+ }
423
+ return [...svelte$1.configs["flat/recommended"], customConfig];
424
+ }
425
+
219
426
  //#endregion
220
427
  //#region src/configs/toml.ts
221
428
  async function toml(options = {}) {
@@ -237,6 +444,57 @@ async function toml(options = {}) {
237
444
  return configs;
238
445
  }
239
446
 
447
+ //#endregion
448
+ //#region src/configs/typescript.ts
449
+ async function typescript(options = {}) {
450
+ const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = { project: true } } = options;
451
+ const ts = await loadPlugin("typescript-eslint");
452
+ const files = options.files ?? [
453
+ GLOB_TS,
454
+ GLOB_TSX,
455
+ ...extraFileExtensions.map((ext) => `**/*${ext}`)
456
+ ];
457
+ return [
458
+ ...ts.configs.recommendedTypeChecked,
459
+ {
460
+ files: [
461
+ GLOB_JS,
462
+ GLOB_JSX,
463
+ GLOB_JSON,
464
+ GLOB_JSON5,
465
+ GLOB_JSONC,
466
+ GLOB_YAML,
467
+ GLOB_TOML
468
+ ],
469
+ ...ts.configs.disableTypeChecked
470
+ },
471
+ {
472
+ name: "@kazupon/typescipt/typescript-eslint",
473
+ files,
474
+ languageOptions: {
475
+ parser: ts.parser,
476
+ parserOptions: {
477
+ extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
478
+ sourceType: "module",
479
+ ...parserOptions
480
+ }
481
+ },
482
+ rules: {
483
+ "@typescript-eslint/no-unused-vars": ["error", {
484
+ args: "all",
485
+ argsIgnorePattern: "^_",
486
+ caughtErrors: "all",
487
+ caughtErrorsIgnorePattern: "^_",
488
+ destructuredArrayIgnorePattern: "^_",
489
+ varsIgnorePattern: "^_",
490
+ ignoreRestSiblings: true
491
+ }],
492
+ ...overrideRules
493
+ }
494
+ }
495
+ ];
496
+ }
497
+
240
498
  //#endregion
241
499
  //#region src/configs/unicorn.ts
242
500
  async function unicorn(options = {}) {
@@ -254,106 +512,35 @@ async function unicorn(options = {}) {
254
512
  }
255
513
 
256
514
  //#endregion
257
- //#region src/configs/prettier.ts
258
- async function prettier(options = {}) {
259
- const { rules: overrideRules = {} } = options;
260
- const prettier$1 = await loadPlugin("eslint-config-prettier");
261
- return [prettier$1, {
262
- name: "@kazupon/prettier",
263
- rules: { ...overrideRules }
264
- }];
265
- }
266
-
267
- //#endregion
268
- //#region src/configs/jsonc.ts
269
- async function jsonc(options = {}) {
270
- const { rules: overrideRules = {} } = options;
271
- const kinds = [options.json ? "json" : "", options.jsonc ? "jsonc" : "", options.json5 ? "json5" : ""];
272
- const usePrettier = !!options.prettier;
273
- const jsonc$1 = await loadPlugin("eslint-plugin-jsonc");
515
+ //#region src/configs/vitest.ts
516
+ async function vitest(options = {}) {
517
+ const { rules: overrideRules = {}, files: overrideFiles = [] } = options;
518
+ const typeTesting = !!options.typeTesting;
519
+ const vitest$1 = await loadPlugin("@vitest/eslint-plugin");
274
520
  const configs = [];
275
- for (const kind of kinds) {
276
- if (kind) {
277
- configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
278
- return config.name ? config : {
279
- name: `jsonc/flat/recommended-with-${kind}/${index}`,
280
- ...config
281
- };
282
- }));
283
- }
521
+ const base = {
522
+ files: GLOB_TESTS,
523
+ ...vitest$1.configs["recommended"]
524
+ };
525
+ if (base.name == undefined) {
526
+ base.name = "@vitest/eslint-plugin";
284
527
  }
285
- if (usePrettier) {
286
- configs.push(...jsonc$1.configs["flat/prettier"].map((config, index) => {
287
- return config.name ? config : {
288
- name: `jsonc/flat/prettier/${index}`,
289
- ...config
290
- };
291
- }));
528
+ if (typeTesting) {
529
+ base.files = [...base.files, ...GLOB_TESTS_TYPE];
530
+ base.settings = { vitest: { typecheck: true } };
531
+ base.languageOptions = { globals: { ...vitest$1.environments.env.globals } };
292
532
  }
293
- const overriddenConfig = {
294
- name: "@kazupon/jsonc",
295
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
533
+ configs.push(base);
534
+ const custom = {
535
+ name: "@kazupon/vitest",
296
536
  rules: { ...overrideRules }
297
537
  };
298
- configs.push(...jsoncSort(), overriddenConfig);
299
- return configs;
300
- }
301
- function jsoncSort() {
302
- return [{
303
- name: "@kazupon/jsonc/sort/package.json",
304
- files: ["**/package.json"],
305
- rules: {
306
- "jsonc/sort-array-values": ["error", {
307
- order: { type: "asc" },
308
- pathPattern: "^files$"
309
- }],
310
- "jsonc/sort-keys": ["error", {
311
- order: ["name", "description", "private", "version", "author", "contributors", "license", "funding", "bugs", "repository", "keywords", "homepage", "publishConfig", "packageManager", "engines", "os", "cpu", "type", "sideEffects", "bin", "files", "main", "module", "browser", "unpkg", "jsdelivr", "directories", "exports", "types", "typesVersions", "scripts", "dependencies", "peerDependencies", "peerDependenciesMeta", "optionalDependencies", "devDependencies", "pnpm", "overrides", "resolutions", "workspaces", "prettier", "buildOptions", "lint-staged"],
312
- pathPattern: "^$"
313
- }, {
314
- order: { type: "asc" },
315
- pathPattern: "^scripts$"
316
- }, {
317
- order: { type: "asc" },
318
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
319
- }, {
320
- order: { type: "asc" },
321
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
322
- }]
323
- }
324
- }];
325
- }
326
-
327
- //#endregion
328
- //#region src/configs/yml.ts
329
- async function yml(options = {}) {
330
- const { rules: overrideRules = {} } = options;
331
- const usePrettier = !!options.prettier;
332
- const yml$1 = await loadPlugin("eslint-plugin-yml");
333
- const configs = [];
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
- }));
538
+ if (overrideFiles.length > 0) {
539
+ custom.files = overrideFiles;
347
540
  }
348
- const overriddenConfig = {
349
- name: "@kazupon/yml",
350
- files: [GLOB_YAML],
351
- rules: { ...overrideRules }
352
- };
353
- configs.push(overriddenConfig);
541
+ configs.push(custom);
354
542
  return configs;
355
543
  }
356
- const yaml = yml;
357
544
 
358
545
  //#endregion
359
546
  //#region src/configs/vue.ts
@@ -414,94 +601,35 @@ async function vue(options = {}) {
414
601
  }
415
602
 
416
603
  //#endregion
417
- //#region src/configs/react.ts
418
- async function react(options = {}) {
419
- const { rules: overrideRules = {}, settings = {} } = options;
420
- const useTypeScript = !options.typescript;
421
- const enableRefresh = !!options.refresh;
422
- const [react$1, reactHooks, reactRefresh] = await Promise.all([loadPlugin("eslint-plugin-react"), loadPlugin("eslint-plugin-react-hooks"), enableRefresh ? loadPlugin("eslint-plugin-react-refresh") : null]);
423
- const customConfig = {
424
- name: "@kazupon/react",
425
- files: getGlobSourceFiles(useTypeScript),
426
- rules: { ...overrideRules }
427
- };
428
- const configs = [{
429
- name: "react/flat/recommended",
430
- files: getGlobSourceFiles(useTypeScript),
431
- settings,
432
- ...react$1.configs.flat.recommended
433
- }, {
434
- name: "react-hooks/flat",
435
- files: getGlobSourceFiles(useTypeScript),
436
- plugins: { "react-hooks": reactHooks }
437
- }];
438
- if (enableRefresh) {
439
- configs.push({
440
- name: "react-refresh/flat",
441
- files: getGlobSourceFiles(useTypeScript),
442
- plugins: { "react-refresh": reactRefresh }
443
- });
444
- }
445
- return [...configs, customConfig];
446
- }
447
-
448
- //#endregion
449
- //#region src/configs/svelte.ts
450
- async function svelte(options = {}) {
451
- const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
452
- const useTypeScript = !!options.typescript;
453
- const svelte$1 = await loadPlugin("eslint-plugin-svelte");
454
- const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]["parser"];
455
- const customConfig = {
456
- name: "@kazupon/svelte",
457
- files: [GLOB_SVELTE],
458
- rules: { ...overrideRules }
459
- };
460
- if (useTypeScript) {
461
- customConfig.languageOptions = {
462
- parser: svelteParser,
463
- parserOptions: {
464
- sourceType: "module",
465
- parser: await getTypeScriptParser(),
466
- ecmaFeatures: { jsx: true },
467
- extraFileExtensions: [".svelte"],
468
- ...parserOptions
469
- }
470
- };
471
- }
472
- return [...svelte$1.configs["flat/recommended"], customConfig];
473
- }
474
-
475
- //#endregion
476
- //#region src/configs/vitest.ts
477
- async function vitest(options = {}) {
478
- const { rules: overrideRules = {}, files: overrideFiles = [] } = options;
479
- const typeTesting = !!options.typeTesting;
480
- const vitest$1 = await loadPlugin("@vitest/eslint-plugin");
604
+ //#region src/configs/yml.ts
605
+ async function yml(options = {}) {
606
+ const { rules: overrideRules = {} } = options;
607
+ const usePrettier = !!options.prettier;
608
+ const yml$1 = await loadPlugin("eslint-plugin-yml");
481
609
  const configs = [];
482
- const base = {
483
- files: GLOB_TESTS,
484
- ...vitest$1.configs["recommended"]
485
- };
486
- if (base.name == undefined) {
487
- base.name = "@vitest/eslint-plugin";
488
- }
489
- if (typeTesting) {
490
- base.files = [...base.files, ...GLOB_TESTS_TYPE];
491
- base.settings = { vitest: { typecheck: true } };
492
- base.languageOptions = { globals: { ...vitest$1.environments.env.globals } };
610
+ configs.push(...yml$1.configs["flat/standard"].map((config, index) => {
611
+ return config.name ? config : {
612
+ name: `yml/flat/standard/${index}`,
613
+ ...config
614
+ };
615
+ }));
616
+ if (usePrettier) {
617
+ configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
618
+ return config.name ? config : {
619
+ name: `yml/flat/prettier/${index}`,
620
+ ...config
621
+ };
622
+ }));
493
623
  }
494
- configs.push(base);
495
- const custom = {
496
- name: "@kazupon/vitest",
624
+ const overriddenConfig = {
625
+ name: "@kazupon/yml",
626
+ files: [GLOB_YAML],
497
627
  rules: { ...overrideRules }
498
628
  };
499
- if (overrideFiles.length > 0) {
500
- custom.files = overrideFiles;
501
- }
502
- configs.push(custom);
629
+ configs.push(overriddenConfig);
503
630
  return configs;
504
631
  }
632
+ const yaml = yml;
505
633
 
506
634
  //#endregion
507
- export { comments, defineConfig, imports, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
635
+ export { comments, defineConfig, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };