@kazupon/eslint-config 0.18.0 → 0.19.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 (87) hide show
  1. package/dist/index.cjs +97 -216
  2. package/dist/index.d.cts +14216 -3
  3. package/dist/index.d.ts +14216 -3
  4. package/dist/index.js +70 -89
  5. package/package.json +15 -15
  6. package/dist/config.d.cts +0 -9
  7. package/dist/config.d.ts +0 -9
  8. package/dist/configs/comments.d.cts +0 -15
  9. package/dist/configs/comments.d.ts +0 -15
  10. package/dist/configs/imports.d.cts +0 -21
  11. package/dist/configs/imports.d.ts +0 -21
  12. package/dist/configs/index.d.cts +0 -17
  13. package/dist/configs/index.d.ts +0 -17
  14. package/dist/configs/javascript.d.cts +0 -15
  15. package/dist/configs/javascript.d.ts +0 -15
  16. package/dist/configs/jsdoc.d.cts +0 -27
  17. package/dist/configs/jsdoc.d.ts +0 -27
  18. package/dist/configs/jsonc.d.cts +0 -39
  19. package/dist/configs/jsonc.d.ts +0 -39
  20. package/dist/configs/markdown.d.cts +0 -28
  21. package/dist/configs/markdown.d.ts +0 -28
  22. package/dist/configs/prettier.d.cts +0 -15
  23. package/dist/configs/prettier.d.ts +0 -15
  24. package/dist/configs/promise.d.cts +0 -15
  25. package/dist/configs/promise.d.ts +0 -15
  26. package/dist/configs/react.d.cts +0 -26
  27. package/dist/configs/react.d.ts +0 -26
  28. package/dist/configs/regexp.d.cts +0 -15
  29. package/dist/configs/regexp.d.ts +0 -15
  30. package/dist/configs/svelte.d.cts +0 -21
  31. package/dist/configs/svelte.d.ts +0 -21
  32. package/dist/configs/toml.d.cts +0 -15
  33. package/dist/configs/toml.d.ts +0 -15
  34. package/dist/configs/typescript.d.cts +0 -38
  35. package/dist/configs/typescript.d.ts +0 -38
  36. package/dist/configs/unicorn.d.cts +0 -20
  37. package/dist/configs/unicorn.d.ts +0 -20
  38. package/dist/configs/vitest.d.cts +0 -22
  39. package/dist/configs/vitest.d.ts +0 -22
  40. package/dist/configs/vue.d.cts +0 -36
  41. package/dist/configs/vue.d.ts +0 -36
  42. package/dist/configs/yml.d.cts +0 -22
  43. package/dist/configs/yml.d.ts +0 -22
  44. package/dist/globs.d.cts +0 -14
  45. package/dist/globs.d.ts +0 -14
  46. package/dist/types/gens/comments.d.cts +0 -65
  47. package/dist/types/gens/comments.d.ts +0 -65
  48. package/dist/types/gens/eslint.d.cts +0 -23
  49. package/dist/types/gens/eslint.d.ts +0 -23
  50. package/dist/types/gens/imports.d.cts +0 -520
  51. package/dist/types/gens/imports.d.ts +0 -520
  52. package/dist/types/gens/javascript.d.cts +0 -3163
  53. package/dist/types/gens/javascript.d.ts +0 -3163
  54. package/dist/types/gens/jsdoc.d.cts +0 -796
  55. package/dist/types/gens/jsdoc.d.ts +0 -796
  56. package/dist/types/gens/jsonc.d.cts +0 -513
  57. package/dist/types/gens/jsonc.d.ts +0 -513
  58. package/dist/types/gens/markdown.d.cts +0 -42
  59. package/dist/types/gens/markdown.d.ts +0 -42
  60. package/dist/types/gens/prettier.d.cts +0 -2
  61. package/dist/types/gens/prettier.d.ts +0 -2
  62. package/dist/types/gens/promise.d.cts +0 -113
  63. package/dist/types/gens/promise.d.ts +0 -113
  64. package/dist/types/gens/react.d.cts +0 -1053
  65. package/dist/types/gens/react.d.ts +0 -1053
  66. package/dist/types/gens/regexp.d.cts +0 -553
  67. package/dist/types/gens/regexp.d.ts +0 -553
  68. package/dist/types/gens/svelte.d.cts +0 -491
  69. package/dist/types/gens/svelte.d.ts +0 -491
  70. package/dist/types/gens/toml.d.cts +0 -256
  71. package/dist/types/gens/toml.d.ts +0 -256
  72. package/dist/types/gens/typescript.d.cts +0 -1578
  73. package/dist/types/gens/typescript.d.ts +0 -1578
  74. package/dist/types/gens/unicorn.d.cts +0 -925
  75. package/dist/types/gens/unicorn.d.ts +0 -925
  76. package/dist/types/gens/vitest.d.cts +0 -377
  77. package/dist/types/gens/vitest.d.ts +0 -377
  78. package/dist/types/gens/vue.d.cts +0 -2746
  79. package/dist/types/gens/vue.d.ts +0 -2746
  80. package/dist/types/gens/yml.d.cts +0 -375
  81. package/dist/types/gens/yml.d.ts +0 -375
  82. package/dist/types/index.d.cts +0 -19
  83. package/dist/types/index.d.ts +0 -19
  84. package/dist/types/overrides.d.cts +0 -8
  85. package/dist/types/overrides.d.ts +0 -8
  86. package/dist/utils.d.cts +0 -18
  87. package/dist/utils.d.ts +0 -18
package/dist/index.cjs CHANGED
@@ -22,14 +22,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  }) : target, mod));
23
23
 
24
24
  //#endregion
25
- const { FlatConfigComposer } = __toESM(require("eslint-flat-config-utils"));
26
- const { interopDefault } = __toESM(require("@kazupon/jts-utils/module"));
27
- const { default: globals } = __toESM(require("globals"));
25
+ const eslint_flat_config_utils = __toESM(require("eslint-flat-config-utils"));
26
+ const __kazupon_jts_utils_module = __toESM(require("@kazupon/jts-utils/module"));
27
+ const globals = __toESM(require("globals"));
28
28
 
29
29
  //#region src/config.ts
30
30
  function defineConfig(...configs) {
31
31
  const baseConfigs = [];
32
- return new FlatConfigComposer().append(...baseConfigs, ...configs);
32
+ return new eslint_flat_config_utils.FlatConfigComposer().append(...baseConfigs, ...configs);
33
33
  }
34
34
 
35
35
  //#endregion
@@ -67,7 +67,7 @@ async function loadPlugin(name) {
67
67
  console.error(error);
68
68
  throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
69
69
  });
70
- return interopDefault(mod);
70
+ return (0, __kazupon_jts_utils_module.interopDefault)(mod);
71
71
  }
72
72
  async function getTypeScriptParser() {
73
73
  const ts = await loadPlugin("typescript-eslint");
@@ -106,17 +106,18 @@ const IMPORTS_FILES = [
106
106
  ];
107
107
  async function imports(options = {}) {
108
108
  const { rules: overrideRules = {} } = options;
109
- const unused = await loadPlugin("eslint-plugin-unused-imports");
109
+ const unused = await loadPlugin(
110
+ // eslint-disable-line @typescript-eslint/no-unsafe-assignment
111
+ "eslint-plugin-unused-imports"
112
+ );
110
113
  const imports$1 = await loadPlugin("eslint-plugin-import");
111
114
  const configs = [imports$1.flatConfigs.recommended];
112
- if (options.typescript) {
113
- try {
114
- await loadPlugin("eslint-import-resolver-typescript");
115
- imports$1.flatConfigs.typescript.settings["import/resolver"]["typescript"] = true;
116
- configs.push(imports$1.flatConfigs.typescript);
117
- } catch (error) {
118
- throw new Error(`Not found eslint-import-resolver-typescript: ${error.message}`);
119
- }
115
+ if (options.typescript) try {
116
+ await loadPlugin("eslint-import-resolver-typescript");
117
+ imports$1.flatConfigs.typescript.settings["import/resolver"]["typescript"] = true;
118
+ configs.push(imports$1.flatConfigs.typescript);
119
+ } catch (error) {
120
+ throw new Error(`Not found eslint-import-resolver-typescript: ${error.message}`);
120
121
  }
121
122
  configs.push({
122
123
  name: "unused-imports",
@@ -160,9 +161,9 @@ async function javascript(options = {}) {
160
161
  languageOptions: {
161
162
  ecmaVersion: 2022,
162
163
  globals: {
163
- ...globals.browser,
164
- ...globals.node,
165
- ...globals.es2022,
164
+ ...globals.default.browser,
165
+ ...globals.default.node,
166
+ ...globals.default.es2022,
166
167
  document: "readonly",
167
168
  navigator: "readonly",
168
169
  window: "readonly"
@@ -186,14 +187,9 @@ async function jsdoc(options = {}) {
186
187
  const jsdoc$1 = await loadPlugin("eslint-plugin-jsdoc");
187
188
  function resolvePreset() {
188
189
  let preset = "recommended";
189
- if (typescript$1 === "syntax") {
190
- preset = `${preset}-typescript`;
191
- } else if (typescript$1 === "flavor") {
192
- preset = `${preset}-typescript-flavor`;
193
- }
194
- if (error) {
195
- preset = `${preset}-error`;
196
- }
190
+ if (typescript$1 === "syntax") preset = `${preset}-typescript`;
191
+ else if (typescript$1 === "flavor") preset = `${preset}-typescript-flavor`;
192
+ if (error) preset = `${preset}-error`;
197
193
  return preset;
198
194
  }
199
195
  return [jsdoc$1.configs[`flat/${resolvePreset()}`], {
@@ -214,24 +210,18 @@ async function jsonc(options = {}) {
214
210
  const usePrettier = !!options.prettier;
215
211
  const jsonc$1 = await loadPlugin("eslint-plugin-jsonc");
216
212
  const configs = [];
217
- for (const kind of kinds) {
218
- if (kind) {
219
- configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
220
- return config.name ? config : {
221
- name: `jsonc/flat/recommended-with-${kind}/${index}`,
222
- ...config
223
- };
224
- }));
225
- }
226
- }
227
- if (usePrettier) {
228
- configs.push(...jsonc$1.configs["flat/prettier"].map((config, index) => {
229
- return config.name ? config : {
230
- name: `jsonc/flat/prettier/${index}`,
231
- ...config
232
- };
233
- }));
234
- }
213
+ for (const kind of kinds) if (kind) configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
214
+ return config.name ? config : {
215
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
216
+ ...config
217
+ };
218
+ }));
219
+ if (usePrettier) configs.push(...jsonc$1.configs["flat/prettier"].map((config, index) => {
220
+ return config.name ? config : {
221
+ name: `jsonc/flat/prettier/${index}`,
222
+ ...config
223
+ };
224
+ }));
235
225
  const overriddenConfig = {
236
226
  name: "@kazupon/jsonc",
237
227
  files: [
@@ -396,13 +386,11 @@ async function react(options = {}) {
396
386
  files: getGlobSourceFiles(useTypeScript),
397
387
  plugins: { "react-hooks": reactHooks }
398
388
  }];
399
- if (enableRefresh) {
400
- configs.push({
401
- name: "react-refresh/flat",
402
- files: getGlobSourceFiles(useTypeScript),
403
- plugins: { "react-refresh": reactRefresh }
404
- });
405
- }
389
+ if (enableRefresh) configs.push({
390
+ name: "react-refresh/flat",
391
+ files: getGlobSourceFiles(useTypeScript),
392
+ plugins: { "react-refresh": reactRefresh }
393
+ });
406
394
  return [...configs, customConfig];
407
395
  }
408
396
 
@@ -426,24 +414,22 @@ async function svelte(options = {}) {
426
414
  const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
427
415
  const useTypeScript = !!options.typescript;
428
416
  const svelte$1 = await loadPlugin("eslint-plugin-svelte");
429
- const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]["parser"];
417
+ const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]?.parser;
430
418
  const customConfig = {
431
419
  name: "@kazupon/svelte",
432
420
  files: [GLOB_SVELTE],
433
421
  rules: { ...overrideRules }
434
422
  };
435
- if (useTypeScript) {
436
- customConfig.languageOptions = {
437
- parser: svelteParser,
438
- parserOptions: {
439
- sourceType: "module",
440
- parser: await getTypeScriptParser(),
441
- ecmaFeatures: { jsx: true },
442
- extraFileExtensions: [".svelte"],
443
- ...parserOptions
444
- }
445
- };
446
- }
423
+ if (useTypeScript) customConfig.languageOptions = {
424
+ parser: svelteParser,
425
+ parserOptions: {
426
+ sourceType: "module",
427
+ parser: await getTypeScriptParser(),
428
+ ecmaFeatures: { jsx: true },
429
+ extraFileExtensions: [".svelte"],
430
+ ...parserOptions
431
+ }
432
+ };
447
433
  return [...svelte$1.configs["flat/recommended"], customConfig];
448
434
  }
449
435
 
@@ -546,9 +532,7 @@ async function vitest(options = {}) {
546
532
  files: GLOB_TESTS,
547
533
  ...vitest$1.configs["recommended"]
548
534
  };
549
- if (base.name == undefined) {
550
- base.name = "@vitest/eslint-plugin";
551
- }
535
+ if (base.name == undefined) base.name = "@vitest/eslint-plugin";
552
536
  if (typeTesting) {
553
537
  base.files = [...base.files, ...GLOB_TESTS_TYPE];
554
538
  base.settings = { vitest: { typecheck: true } };
@@ -559,9 +543,7 @@ async function vitest(options = {}) {
559
543
  name: "@kazupon/vitest",
560
544
  rules: { ...overrideRules }
561
545
  };
562
- if (overrideFiles.length > 0) {
563
- custom.files = overrideFiles;
564
- }
546
+ if (overrideFiles.length > 0) custom.files = overrideFiles;
565
547
  configs.push(custom);
566
548
  return configs;
567
549
  }
@@ -571,7 +553,7 @@ async function vitest(options = {}) {
571
553
  async function vue(options = {}) {
572
554
  const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
573
555
  const vue$1 = await loadPlugin("eslint-plugin-vue");
574
- const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
556
+ const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]?.parser;
575
557
  const configs = [];
576
558
  configs.push(...vue$1.configs["flat/recommended"]);
577
559
  if (options.composable) {
@@ -582,12 +564,15 @@ async function vue(options = {}) {
582
564
  }
583
565
  if (options.scopedCss) {
584
566
  const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
585
- const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
586
- return config.name ? config : {
587
- name: `vue/scoped-css/recommended/${index}`,
588
- ...config
589
- };
590
- });
567
+ const scopedCssMapped = scopedCss.configs["flat/recommended"].map(
568
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
569
+ (config, index) => {
570
+ return config.name ? config : {
571
+ name: `vue/scoped-css/recommended/${index}`,
572
+ ...config
573
+ };
574
+ }
575
+ );
591
576
  configs.push(scopedCssMapped[0], scopedCssMapped[2]);
592
577
  }
593
578
  if (options.a11y) {
@@ -608,18 +593,16 @@ async function vue(options = {}) {
608
593
  files: [GLOB_VUE],
609
594
  rules: { ...overrideRules }
610
595
  };
611
- if (options.typescript) {
612
- customConfig.languageOptions = {
613
- parser: vueParser,
614
- parserOptions: {
615
- sourceType: "module",
616
- parser: await getTypeScriptParser(),
617
- ecmaFeatures: { jsx: true },
618
- extraFileExtensions: [".vue"],
619
- ...parserOptions
620
- }
621
- };
622
- }
596
+ if (options.typescript) customConfig.languageOptions = {
597
+ parser: vueParser,
598
+ parserOptions: {
599
+ sourceType: "module",
600
+ parser: await getTypeScriptParser(),
601
+ ecmaFeatures: { jsx: true },
602
+ extraFileExtensions: [".vue"],
603
+ ...parserOptions
604
+ }
605
+ };
623
606
  configs.push(customConfig);
624
607
  return configs;
625
608
  }
@@ -637,14 +620,12 @@ async function yml(options = {}) {
637
620
  ...config
638
621
  };
639
622
  }));
640
- if (usePrettier) {
641
- configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
642
- return config.name ? config : {
643
- name: `yml/flat/prettier/${index}`,
644
- ...config
645
- };
646
- }));
647
- }
623
+ if (usePrettier) configs.push(...yml$1.configs["flat/prettier"].map((config, index) => {
624
+ return config.name ? config : {
625
+ name: `yml/flat/prettier/${index}`,
626
+ ...config
627
+ };
628
+ }));
648
629
  const overriddenConfig = {
649
630
  name: "@kazupon/yml",
650
631
  files: [GLOB_YAML],
@@ -656,123 +637,23 @@ async function yml(options = {}) {
656
637
  const yaml = yml;
657
638
 
658
639
  //#endregion
659
- Object.defineProperty(exports, 'comments', {
660
- enumerable: true,
661
- get: function () {
662
- return comments;
663
- }
664
- });
665
- Object.defineProperty(exports, 'defineConfig', {
666
- enumerable: true,
667
- get: function () {
668
- return defineConfig;
669
- }
670
- });
671
- Object.defineProperty(exports, 'imports', {
672
- enumerable: true,
673
- get: function () {
674
- return imports;
675
- }
676
- });
677
- Object.defineProperty(exports, 'javascript', {
678
- enumerable: true,
679
- get: function () {
680
- return javascript;
681
- }
682
- });
683
- Object.defineProperty(exports, 'jsdoc', {
684
- enumerable: true,
685
- get: function () {
686
- return jsdoc;
687
- }
688
- });
689
- Object.defineProperty(exports, 'jsonc', {
690
- enumerable: true,
691
- get: function () {
692
- return jsonc;
693
- }
694
- });
695
- Object.defineProperty(exports, 'markdown', {
696
- enumerable: true,
697
- get: function () {
698
- return markdown;
699
- }
700
- });
701
- Object.defineProperty(exports, 'md', {
702
- enumerable: true,
703
- get: function () {
704
- return md;
705
- }
706
- });
707
- Object.defineProperty(exports, 'prettier', {
708
- enumerable: true,
709
- get: function () {
710
- return prettier;
711
- }
712
- });
713
- Object.defineProperty(exports, 'promise', {
714
- enumerable: true,
715
- get: function () {
716
- return promise;
717
- }
718
- });
719
- Object.defineProperty(exports, 'react', {
720
- enumerable: true,
721
- get: function () {
722
- return react;
723
- }
724
- });
725
- Object.defineProperty(exports, 'regexp', {
726
- enumerable: true,
727
- get: function () {
728
- return regexp;
729
- }
730
- });
731
- Object.defineProperty(exports, 'svelte', {
732
- enumerable: true,
733
- get: function () {
734
- return svelte;
735
- }
736
- });
737
- Object.defineProperty(exports, 'toml', {
738
- enumerable: true,
739
- get: function () {
740
- return toml;
741
- }
742
- });
743
- Object.defineProperty(exports, 'typescript', {
744
- enumerable: true,
745
- get: function () {
746
- return typescript;
747
- }
748
- });
749
- Object.defineProperty(exports, 'unicorn', {
750
- enumerable: true,
751
- get: function () {
752
- return unicorn;
753
- }
754
- });
755
- Object.defineProperty(exports, 'vitest', {
756
- enumerable: true,
757
- get: function () {
758
- return vitest;
759
- }
760
- });
761
- Object.defineProperty(exports, 'vue', {
762
- enumerable: true,
763
- get: function () {
764
- return vue;
765
- }
766
- });
767
- Object.defineProperty(exports, 'yaml', {
768
- enumerable: true,
769
- get: function () {
770
- return yaml;
771
- }
772
- });
773
- Object.defineProperty(exports, 'yml', {
774
- enumerable: true,
775
- get: function () {
776
- return yml;
777
- }
778
- });
640
+ exports.comments = comments
641
+ exports.defineConfig = defineConfig
642
+ exports.imports = imports
643
+ exports.javascript = javascript
644
+ exports.jsdoc = jsdoc
645
+ exports.jsonc = jsonc
646
+ exports.markdown = markdown
647
+ exports.md = md
648
+ exports.prettier = prettier
649
+ exports.promise = promise
650
+ exports.react = react
651
+ exports.regexp = regexp
652
+ exports.svelte = svelte
653
+ exports.toml = toml
654
+ exports.typescript = typescript
655
+ exports.unicorn = unicorn
656
+ exports.vitest = vitest
657
+ exports.vue = vue
658
+ exports.yaml = yaml
659
+ exports.yml = yml