@kazupon/eslint-config 0.35.0 → 0.37.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 (4) hide show
  1. package/README.md +25 -22
  2. package/dist/index.d.ts +1431 -1169
  3. package/dist/index.js +60 -47
  4. package/package.json +69 -59
package/dist/index.js CHANGED
@@ -12,18 +12,17 @@ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
12
12
  * @returns {FlatConfigComposer} eslint flat configuration composer
13
13
  */
14
14
  function defineConfig(...configs) {
15
- const baseConfigs = [];
16
15
  /**
17
16
  * built-in configurations
18
17
  * baseConfigs.push(javascript().then(c => c))
19
18
  */
20
- return new FlatConfigComposer().append(...baseConfigs, ...configs);
19
+ return new FlatConfigComposer().append(...[], ...configs);
21
20
  }
22
21
 
23
22
  //#endregion
24
23
  //#region src/globs.ts
25
24
  /**
26
- * @author kazuya kawaguchi (a.k.a. @kazupon)
25
+ * @author kazuya kawaguchi (a.k.a. `@kazupon`)
27
26
  * @license MIT
28
27
  */
29
28
  const GLOB_JS = "**/*.?([cm])js";
@@ -66,11 +65,10 @@ const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_
66
65
  * @returns {Promise<T>} loaded plugin
67
66
  */
68
67
  async function loadPlugin(name) {
69
- const mod = await import(name).catch((error) => {
68
+ return interopDefault(await import(name).catch((error) => {
70
69
  console.error(error);
71
70
  throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
72
- });
73
- return interopDefault(mod);
71
+ }));
74
72
  }
75
73
  /**
76
74
  * get TypeScript parser
@@ -80,8 +78,7 @@ async function loadPlugin(name) {
80
78
  * @returns {Promise<typeof import('typescript-eslint')['parser']>} TypeScript parser
81
79
  */
82
80
  async function getTypeScriptParser() {
83
- const ts = await loadPlugin("typescript-eslint");
84
- return ts.parser;
81
+ return (await loadPlugin("typescript-eslint")).parser;
85
82
  }
86
83
  /**
87
84
  * get glob source files
@@ -146,7 +143,7 @@ async function comments(options = {}) {
146
143
  async function css(options = {}) {
147
144
  const { rules: overrideRules = {} } = options;
148
145
  const tolerant = !!options.tolerant;
149
- const customSyntax = !!options.customSyntax;
146
+ const customSyntax = options.customSyntax;
150
147
  const css$1 = await loadPlugin("@eslint/css");
151
148
  const core = {
152
149
  name: "@eslint/css/recommended",
@@ -157,9 +154,9 @@ async function css(options = {}) {
157
154
  if (tolerant) core.languageOptions = { tolerant };
158
155
  if (customSyntax) {
159
156
  core.languageOptions = core.languageOptions || {};
160
- if (typeof customSyntax === "string" && customSyntax === "tailwind") {
161
- const { tailwindSyntax } = await loadPlugin("@eslint/css/syntax");
162
- core.languageOptions.customSyntax = tailwindSyntax;
157
+ if (typeof customSyntax === "string" && (customSyntax === "tailwind3" || customSyntax === "tailwind4")) {
158
+ const tailwindCssTree = await loadPlugin("tailwind-csstree");
159
+ core.languageOptions.customSyntax = tailwindCssTree[customSyntax];
163
160
  } else if (isObject(customSyntax)) core.languageOptions.customSyntax = customSyntax;
164
161
  }
165
162
  return [core, {
@@ -169,6 +166,34 @@ async function css(options = {}) {
169
166
  }];
170
167
  }
171
168
 
169
+ //#endregion
170
+ //#region src/configs/deps.ts
171
+ /**
172
+ * `eslint-plugin-barrel-files` and overrides configuration options
173
+ *
174
+ * @param {DepsOptions & OverridesOptions} options - deps configuration options
175
+ * @returns {Promise<Linter.Config[]>} eslint flat configurations with `eslint-plugin-barrel-files` and overrides
176
+ */
177
+ async function deps(options = {}) {
178
+ const { rules: overrideRules = {}, barrel = false } = options;
179
+ const configs = [];
180
+ if (barrel) {
181
+ const barrelPlugin = await loadPlugin("eslint-plugin-barrel-files");
182
+ const barrelConfig = {
183
+ name: "barrel-files/recommended",
184
+ files: [GLOB_SRC],
185
+ ...barrelPlugin.configs["recommended"]
186
+ };
187
+ configs.push(barrelConfig);
188
+ if (Object.keys(overrideRules).length > 0) configs.push({
189
+ name: "@kazupon/barrel-files",
190
+ files: [GLOB_SRC],
191
+ rules: overrideRules
192
+ });
193
+ }
194
+ return configs;
195
+ }
196
+
172
197
  //#endregion
173
198
  //#region src/configs/html.ts
174
199
  /**
@@ -224,7 +249,7 @@ async function html(options = {}) {
224
249
  * @returns {{ [syntax: string]: string } | undefined} resolved template engine syntax, or undefined if no syntax is provided
225
250
  */
226
251
  function resolveTemplateEngineSyntax(syntax, parser) {
227
- if (!syntax) return void 0;
252
+ if (!syntax) return;
228
253
  switch (syntax) {
229
254
  case "erb": return parser.TEMPLATE_ENGINE_SYNTAX.ERB;
230
255
  case "handlebar": return parser.TEMPLATE_ENGINE_SYNTAX.HANDLEBAR;
@@ -312,12 +337,18 @@ async function imports(options = {}) {
312
337
  */
313
338
  async function javascript(options = {}) {
314
339
  const { rules: overrideRules = {} } = options;
315
- const js = await loadPlugin("@eslint/js");
316
- return [{
340
+ return [(
341
+ /**
342
+ * {
343
+ * name: 'eslint/defaults/rules',
344
+ * ...(js.configs.recommended as Linter.Config)
345
+ * },
346
+ */
347
+ {
317
348
  name: "@kazupon/javascript/markdown-block",
318
349
  files: ["**/*.md/*.{js,cjs,mjs}"],
319
- ...js.configs.recommended
320
- }, {
350
+ ...(await loadPlugin("@eslint/js")).configs.recommended
351
+ }), {
321
352
  name: "@kazupon/javascript/overrides",
322
353
  languageOptions: {
323
354
  ecmaVersion: 2022,
@@ -557,7 +588,7 @@ function jsoncSort() {
557
588
  * @returns {Promise<Linter.Config[]>} eslint flat configurations with `@eslint/markdown` and overrides
558
589
  */
559
590
  async function markdown(options = {}) {
560
- const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [], preferences = true, inlineCodeWords = [], inlineCodeWordsIgnores = [], linkedWords = [], linkedWordsIgnores = [] } = options;
591
+ const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [], preferences = true } = options;
561
592
  const language = options.language || "gfm";
562
593
  /**
563
594
  * TODO: remove this option
@@ -584,21 +615,7 @@ async function markdown(options = {}) {
584
615
  ];
585
616
  if (preferences) {
586
617
  const preferencesPlugin = await loadPlugin("eslint-plugin-markdown-preferences");
587
- configs.push({
588
- ...preferencesPlugin.configs.recommended,
589
- rules: {
590
- ...preferencesPlugin.configs.recommended.rules,
591
- "markdown-preferences/no-trailing-spaces": "error",
592
- "markdown-preferences/prefer-linked-words": ["error", {
593
- words: linkedWords,
594
- ignores: linkedWordsIgnores
595
- }],
596
- "markdown-preferences/prefer-inline-code-words": ["error", {
597
- words: inlineCodeWords,
598
- ignores: inlineCodeWordsIgnores
599
- }]
600
- }
601
- });
618
+ configs.push({ ...preferencesPlugin.configs.recommended });
602
619
  }
603
620
  const custom = {
604
621
  name: "@kazupon/markdown",
@@ -627,10 +644,9 @@ const md = markdown;
627
644
  */
628
645
  async function prettier(options = {}) {
629
646
  const { rules: overrideRules = {} } = options;
630
- const prettier$1 = await loadPlugin("eslint-config-prettier");
631
647
  return [{
632
648
  name: "config-prettier",
633
- ...prettier$1
649
+ ...await loadPlugin("eslint-config-prettier")
634
650
  }, {
635
651
  name: "@kazupon/prettier",
636
652
  rules: { ...overrideRules }
@@ -647,10 +663,9 @@ async function prettier(options = {}) {
647
663
  */
648
664
  async function promise(options = {}) {
649
665
  const { rules: overrideRules = {} } = options;
650
- const promise$1 = await loadPlugin("eslint-plugin-promise");
651
666
  return [{
652
667
  name: "promise/flat/recommended",
653
- ...promise$1.configs["flat/recommended"]
668
+ ...(await loadPlugin("eslint-plugin-promise")).configs["flat/recommended"]
654
669
  }, {
655
670
  name: "@kazupon/promise",
656
671
  rules: { ...overrideRules }
@@ -686,7 +701,7 @@ async function react(options = {}) {
686
701
  ...react$1.configs.flat.recommended
687
702
  }, {
688
703
  files: getGlobSourceFiles(useTypeScript),
689
- ...reactHooks.configs["recommended-latest"]
704
+ ...reactHooks.configs.flat["recommended-latest"]
690
705
  }];
691
706
  if (enableRefresh) configs.push({
692
707
  name: "react-refresh/flat",
@@ -850,13 +865,12 @@ async function typescript(options = {}) {
850
865
  ...extraFileExtensions.map((ext) => `**/*.${ext}`)
851
866
  ];
852
867
  const files = [...options.files ?? [], ...baseFiles];
853
- const extendedPreset = ts.configs.recommendedTypeChecked.map((config) => {
854
- const mapped = { ...config };
855
- if (config.files) mapped.files = [...config.files, `${GLOB_MARKDOWN}/**/${GLOB_TS}`];
856
- return mapped;
857
- });
858
868
  return [
859
- ...extendedPreset,
869
+ ...ts.configs.recommendedTypeChecked.map((config) => {
870
+ const mapped = { ...config };
871
+ if (config.files) mapped.files = [...config.files, `${GLOB_MARKDOWN}/**/${GLOB_TS}`];
872
+ return mapped;
873
+ }),
860
874
  {
861
875
  files: [
862
876
  GLOB_JS,
@@ -991,8 +1005,7 @@ async function vue(options = {}) {
991
1005
  configs.push(composableBase, composable.configs["flat/recommended"][1]);
992
1006
  }
993
1007
  if (options.scopedCss) {
994
- const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
995
- const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
1008
+ const scopedCssMapped = (await loadPlugin("eslint-plugin-vue-scoped-css")).configs["flat/recommended"].map((config, index) => {
996
1009
  const mapped = {
997
1010
  ...config,
998
1011
  ignores: [GLOB_MARKDOWN]
@@ -1080,4 +1093,4 @@ async function yml(options = {}) {
1080
1093
  const yaml = yml;
1081
1094
 
1082
1095
  //#endregion
1083
- export { comments, css, defineConfig, html, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, stylistic, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
1096
+ export { comments, css, defineConfig, deps, html, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, stylistic, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
3
  "description": "ESLint config for @kazupon",
4
- "version": "0.35.0",
4
+ "version": "0.37.0",
5
5
  "author": {
6
6
  "email": "kawakazu80@gmail.com",
7
7
  "name": "kazuya kawaguchi"
@@ -50,43 +50,45 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
53
- "@eslint/js": "^9.32.0",
54
- "@kazupon/eslint-plugin": "^0.6.1",
55
- "@kazupon/jts-utils": "^0.6.0",
53
+ "@eslint/js": "^9.37.0",
54
+ "@kazupon/eslint-plugin": "^0.6.2",
55
+ "@kazupon/jts-utils": "^0.7.1",
56
56
  "@stylistic/eslint-plugin": "^4.4.1",
57
- "eslint-flat-config-utils": "^2.1.0",
57
+ "eslint-flat-config-utils": "^2.1.4",
58
58
  "eslint-merge-processors": "^2.0.0",
59
- "globals": "^16.3.0"
59
+ "globals": "^16.4.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@eslint/css": ">=0.5.0",
63
- "@eslint/markdown": ">=7.0.0",
64
- "@html-eslint/eslint-plugin": ">=0.41.0",
62
+ "@eslint/css": ">=0.13.0",
63
+ "@eslint/markdown": ">=7.4.0",
64
+ "@html-eslint/eslint-plugin": ">=0.47.0",
65
65
  "@intlify/eslint-plugin-vue-i18n": ">=4.0.0",
66
- "@vitest/eslint-plugin": ">=1.0.0",
66
+ "@vitest/eslint-plugin": ">=1.3.0",
67
67
  "eslint": ">=8.56.0 || >=9.0.0",
68
- "eslint-config-prettier": ">=9.1.0",
69
- "eslint-import-resolver-typescript": ">=3.6.0",
70
- "eslint-plugin-import": ">=2.31.0",
71
- "eslint-plugin-jsdoc": ">=51.0.0",
72
- "eslint-plugin-jsonc": ">=2.16.0",
73
- "eslint-plugin-markdown-preferences": ">=0.5.0",
68
+ "eslint-config-prettier": ">=10.1.0",
69
+ "eslint-import-resolver-typescript": ">=4.4.0",
70
+ "eslint-plugin-barrel-files": ">=3.0.1",
71
+ "eslint-plugin-import": ">=2.32.0",
72
+ "eslint-plugin-jsdoc": ">61.1.0",
73
+ "eslint-plugin-jsonc": ">=2.21.0",
74
+ "eslint-plugin-markdown-preferences": ">=0.36.2",
74
75
  "eslint-plugin-module-interop": ">=0.3.0",
75
- "eslint-plugin-promise": ">=6.4.0",
76
- "eslint-plugin-react": ">=7.35.0",
77
- "eslint-plugin-react-hooks": ">=5.2.0",
78
- "eslint-plugin-react-refresh": ">=0.4.19",
79
- "eslint-plugin-regexp": ">=2.6.0",
80
- "eslint-plugin-svelte": ">=2.43.0",
81
- "eslint-plugin-toml": ">=0.11.0",
82
- "eslint-plugin-unicorn": ">=57.0.0",
83
- "eslint-plugin-unused-imports": ">=4.1.0",
84
- "eslint-plugin-vue": ">=9.24.0",
76
+ "eslint-plugin-promise": ">=7.2.0",
77
+ "eslint-plugin-react": ">=7.37.0",
78
+ "eslint-plugin-react-hooks": ">=7.0.0",
79
+ "eslint-plugin-react-refresh": ">=0.4.0",
80
+ "eslint-plugin-regexp": ">=2.10.0",
81
+ "eslint-plugin-svelte": ">=3.12.0",
82
+ "eslint-plugin-toml": ">=0.12.0",
83
+ "eslint-plugin-unicorn": ">=61.0.0",
84
+ "eslint-plugin-unused-imports": ">=4.2.0",
85
+ "eslint-plugin-vue": ">=10.5.0",
85
86
  "eslint-plugin-vue-composable": ">=1.0.0",
86
- "eslint-plugin-vue-scoped-css": ">=2.8.0",
87
+ "eslint-plugin-vue-scoped-css": ">=2.12.0",
87
88
  "eslint-plugin-vuejs-accessibility": ">=2.4.0",
88
- "eslint-plugin-yml": ">=1.14.0",
89
+ "eslint-plugin-yml": ">=1.19.0",
89
90
  "svelte": ">=4.0.0",
91
+ "tailwind-csstree": ">=0.1.4",
90
92
  "typescript-eslint": ">=7.0.0"
91
93
  },
92
94
  "peerDependenciesMeta": {
@@ -111,6 +113,9 @@
111
113
  "eslint-import-resolver-typescript": {
112
114
  "optional": true
113
115
  },
116
+ "eslint-plugin-barrel-files": {
117
+ "optional": true
118
+ },
114
119
  "eslint-plugin-import": {
115
120
  "optional": true
116
121
  },
@@ -171,53 +176,58 @@
171
176
  "svelte": {
172
177
  "optional": true
173
178
  },
179
+ "tailwind-csstree": {
180
+ "optional": true
181
+ },
174
182
  "typescript-eslint": {
175
183
  "optional": true
176
184
  }
177
185
  },
178
186
  "devDependencies": {
179
- "@eslint/compat": "^1.3.1",
180
- "@eslint/css": "^0.9.0",
181
- "@eslint/markdown": "^7.1.0",
182
- "@html-eslint/eslint-plugin": "^0.44.0",
183
- "@intlify/eslint-plugin-vue-i18n": "^4.0.1",
187
+ "@eslint/compat": "^1.4.0",
188
+ "@eslint/css": "^0.13.0",
189
+ "@eslint/markdown": "^7.4.0",
190
+ "@html-eslint/eslint-plugin": "^0.47.0",
191
+ "@intlify/eslint-plugin-vue-i18n": "^4.1.0",
184
192
  "@kazupon/prettier-config": "^0.1.1",
185
193
  "@types/eslint": "^9.6.1",
186
- "@types/node": "^22.16.5",
187
- "@vitest/eslint-plugin": "^1.3.4",
188
- "bumpp": "^10.2.1",
189
- "eslint": "^9.32.0",
194
+ "@types/node": "^22.18.9",
195
+ "@vitest/eslint-plugin": "^1.3.16",
196
+ "bumpp": "^10.3.1",
197
+ "eslint": "^9.37.0",
190
198
  "eslint-config-prettier": "^10.1.8",
191
199
  "eslint-import-resolver-typescript": "^4.4.4",
200
+ "eslint-plugin-barrel-files": "^3.0.1",
192
201
  "eslint-plugin-import": "^2.32.0",
193
- "eslint-plugin-jsdoc": "^52.0.0",
194
- "eslint-plugin-jsonc": "^2.20.1",
195
- "eslint-plugin-markdown-preferences": "^0.5.0",
202
+ "eslint-plugin-jsdoc": "^61.1.4",
203
+ "eslint-plugin-jsonc": "^2.21.0",
204
+ "eslint-plugin-markdown-preferences": "^0.36.2",
196
205
  "eslint-plugin-module-interop": "^0.3.1",
197
206
  "eslint-plugin-promise": "^7.2.1",
198
207
  "eslint-plugin-react": "^7.37.5",
199
- "eslint-plugin-react-hooks": "^5.2.0",
200
- "eslint-plugin-react-refresh": "^0.4.20",
201
- "eslint-plugin-regexp": "^2.9.0",
202
- "eslint-plugin-svelte": "^2.46.1",
208
+ "eslint-plugin-react-hooks": "^7.0.0",
209
+ "eslint-plugin-react-refresh": "^0.4.23",
210
+ "eslint-plugin-regexp": "^2.10.0",
211
+ "eslint-plugin-svelte": "^3.12.0",
203
212
  "eslint-plugin-toml": "^0.12.0",
204
- "eslint-plugin-unicorn": "^59.0.1",
205
- "eslint-plugin-unused-imports": "^4.1.4",
206
- "eslint-plugin-vue": "^10.3.0",
213
+ "eslint-plugin-unicorn": "^61.0.2",
214
+ "eslint-plugin-unused-imports": "^4.2.0",
215
+ "eslint-plugin-vue": "^10.5.0",
207
216
  "eslint-plugin-vue-composable": "^1.0.0",
208
- "eslint-plugin-vue-scoped-css": "^2.11.0",
217
+ "eslint-plugin-vue-scoped-css": "^2.12.0",
209
218
  "eslint-plugin-vuejs-accessibility": "^2.4.1",
210
- "eslint-plugin-yml": "^1.18.0",
219
+ "eslint-plugin-yml": "^1.19.0",
211
220
  "eslint-typegen": "^2.3.0",
212
221
  "gh-changelogen": "^0.2.8",
213
- "jiti": "^2.5.1",
214
- "knip": "^5.62.0",
215
- "lint-staged": "^16.1.2",
222
+ "jiti": "^2.6.1",
223
+ "knip": "^5.64.3",
224
+ "lint-staged": "^16.2.4",
216
225
  "prettier": "^3.6.2",
217
- "svelte": "^5.37.1",
218
- "tsdown": "^0.13.0",
219
- "typescript": "^5.8.3",
220
- "typescript-eslint": "^8.38.0",
226
+ "svelte": "^5.39.11",
227
+ "tailwind-csstree": "^0.1.4",
228
+ "tsdown": "^0.15.6",
229
+ "typescript": "^5.9.3",
230
+ "typescript-eslint": "^8.46.0",
221
231
  "vitest": "^3.2.4"
222
232
  },
223
233
  "prettier": "@kazupon/prettier-config",
@@ -239,16 +249,16 @@
239
249
  "build:inspector": "pnpm build && pnpx @eslint/config-inspector build",
240
250
  "changelog": "gh-changelogen --repo=kazupon/eslint-config",
241
251
  "dev": "pnpx @eslint/config-inspector --config eslint.config.ts",
242
- "fix": "pnpm run --parallel --color \"/^fix:/\"",
252
+ "fix": "pnpm run --color \"/^fix:/\"",
243
253
  "fix:eslint": "eslint . --fix",
244
254
  "fix:knip": "knip --fix --no-exit-code",
245
255
  "fix:prettier": "prettier . --write --experimental-cli",
246
- "lint": "pnpm run --parallel --color \"/^lint:/\"",
256
+ "lint": "pnpm run --color \"/^lint:/\"",
247
257
  "lint:eslint": "eslint .",
248
258
  "lint:knip": "knip",
249
259
  "lint:prettier": "prettier . --check --experimental-cli",
250
260
  "release": "bumpp --commit \"release: v%s\" --all --push --tag",
251
- "test": "vitest run --typecheck",
261
+ "test": "vitest run",
252
262
  "typecheck": "tsc -p .",
253
263
  "typegen": "pnpx jiti scripts/typegen.ts"
254
264
  }