@kazupon/eslint-config 0.13.1 → 0.13.3

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.
@@ -4,6 +4,11 @@ import type { OverridesOptions, UnicornRules } from '../types';
4
4
  * eslint unicorn configuration options
5
5
  */
6
6
  export interface UnicornOptions {
7
+ /**
8
+ * use TypeScript
9
+ * @default true
10
+ */
11
+ typescript?: boolean;
7
12
  }
8
13
  /**
9
14
  * `eslint-plugin-unicorn` and overrides configuration options
@@ -4,6 +4,11 @@ import type { OverridesOptions, UnicornRules } from '../types';
4
4
  * eslint unicorn configuration options
5
5
  */
6
6
  export interface UnicornOptions {
7
+ /**
8
+ * use TypeScript
9
+ * @default true
10
+ */
11
+ typescript?: boolean;
7
12
  }
8
13
  /**
9
14
  * `eslint-plugin-unicorn` and overrides configuration options
package/dist/index.cjs CHANGED
@@ -31,6 +31,20 @@ function defineConfig(...configs) {
31
31
  return new FlatConfigComposer().append(...baseConfigs, ...configs);
32
32
  }
33
33
 
34
+ //#endregion
35
+ //#region src/globs.ts
36
+ const GLOB_JS = "**/*.?([cm])js";
37
+ const GLOB_JSX = "**/*.?([cm])jsx";
38
+ const GLOB_TS = "**/*.?([cm])ts";
39
+ const GLOB_TSX = "**/*.?([cm])tsx";
40
+ const GLOB_JSON = "**/*.json";
41
+ const GLOB_JSON5 = "**/*.json5";
42
+ const GLOB_JSONC = "**/*.jsonc";
43
+ const GLOB_YAML = "**/*.y?(a)ml";
44
+ const GLOB_TOML = "**/*.toml";
45
+ const GLOB_VUE = "**/*.vue";
46
+ const GLOB_SVELTE = "**/*.svelte";
47
+
34
48
  //#endregion
35
49
  //#region src/utils.ts
36
50
  async function interopDefault(mod) {
@@ -48,6 +62,9 @@ async function getTypeScriptParser() {
48
62
  const ts = await loadPlugin("typescript-eslint");
49
63
  return ts.parser;
50
64
  }
65
+ function getGlobSourceFiles(useTypeScript = false) {
66
+ return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
67
+ }
51
68
 
52
69
  //#endregion
53
70
  //#region src/configs/javascript.ts
@@ -96,20 +113,6 @@ async function comments(options = {}) {
96
113
  }];
97
114
  }
98
115
 
99
- //#endregion
100
- //#region src/globs.ts
101
- const GLOB_JS = "**/*.?([cm])js";
102
- const GLOB_JSX = "**/*.?([cm])jsx";
103
- const GLOB_TS = "**/*.?([cm])ts";
104
- const GLOB_TSX = "**/*.?([cm])tsx";
105
- const GLOB_JSON = "**/*.json";
106
- const GLOB_JSON5 = "**/*.json5";
107
- const GLOB_JSONC = "**/*.jsonc";
108
- const GLOB_YAML = "**/*.y?(a)ml";
109
- const GLOB_TOML = "**/*.toml";
110
- const GLOB_VUE = "**/*.vue";
111
- const GLOB_SVELTE = "**/*.svelte";
112
-
113
116
  //#endregion
114
117
  //#region src/configs/typescript.ts
115
118
  async function typescript(options = {}) {
@@ -221,9 +224,14 @@ async function toml(options = {}) {
221
224
  //#region src/configs/unicorn.ts
222
225
  async function unicorn(options = {}) {
223
226
  const { rules: overrideRules = {} } = options;
227
+ const useTypeScript = !options.typescript;
224
228
  const unicorn$1 = await loadPlugin("eslint-plugin-unicorn");
225
- return [unicorn$1.configs["flat/recommended"], {
229
+ return [{
230
+ files: getGlobSourceFiles(useTypeScript),
231
+ ...unicorn$1.configs["flat/recommended"]
232
+ }, {
226
233
  name: "@kazupon/unicorn",
234
+ files: getGlobSourceFiles(useTypeScript),
227
235
  rules: { ...overrideRules }
228
236
  }];
229
237
  }
@@ -364,28 +372,25 @@ async function react(options = {}) {
364
372
  const useTypeScript = !options.typescript;
365
373
  const enableRefresh = !!options.refresh;
366
374
  const [react$1, reactHooks, reactRefresh] = await Promise.all([loadPlugin("eslint-plugin-react"), loadPlugin("eslint-plugin-react-hooks"), enableRefresh ? loadPlugin("eslint-plugin-react-refresh") : null]);
367
- function getFiles() {
368
- return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
369
- }
370
375
  const customConfig = {
371
376
  name: "@kazupon/react",
372
- files: getFiles(),
377
+ files: getGlobSourceFiles(useTypeScript),
373
378
  rules: { ...overrideRules }
374
379
  };
375
380
  const configs = [{
376
381
  name: "react/flat/recommended",
377
- files: getFiles(),
382
+ files: getGlobSourceFiles(useTypeScript),
378
383
  settings,
379
384
  ...react$1.configs.flat.recommended
380
385
  }, {
381
386
  name: "react-hooks/flat",
382
- files: getFiles(),
387
+ files: getGlobSourceFiles(useTypeScript),
383
388
  plugins: { "react-hooks": reactHooks }
384
389
  }];
385
390
  if (enableRefresh) {
386
391
  configs.push({
387
392
  name: "react-refresh/flat",
388
- files: getFiles(),
393
+ files: getGlobSourceFiles(useTypeScript),
389
394
  plugins: { "react-refresh": reactRefresh }
390
395
  });
391
396
  }
package/dist/index.js CHANGED
@@ -7,6 +7,20 @@ function defineConfig(...configs) {
7
7
  return new FlatConfigComposer().append(...baseConfigs, ...configs);
8
8
  }
9
9
 
10
+ //#endregion
11
+ //#region src/globs.ts
12
+ const GLOB_JS = "**/*.?([cm])js";
13
+ const GLOB_JSX = "**/*.?([cm])jsx";
14
+ const GLOB_TS = "**/*.?([cm])ts";
15
+ const GLOB_TSX = "**/*.?([cm])tsx";
16
+ const GLOB_JSON = "**/*.json";
17
+ const GLOB_JSON5 = "**/*.json5";
18
+ const GLOB_JSONC = "**/*.jsonc";
19
+ const GLOB_YAML = "**/*.y?(a)ml";
20
+ const GLOB_TOML = "**/*.toml";
21
+ const GLOB_VUE = "**/*.vue";
22
+ const GLOB_SVELTE = "**/*.svelte";
23
+
10
24
  //#endregion
11
25
  //#region src/utils.ts
12
26
  async function interopDefault(mod) {
@@ -24,6 +38,9 @@ async function getTypeScriptParser() {
24
38
  const ts = await loadPlugin("typescript-eslint");
25
39
  return ts.parser;
26
40
  }
41
+ function getGlobSourceFiles(useTypeScript = false) {
42
+ return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
43
+ }
27
44
 
28
45
  //#endregion
29
46
  //#region src/configs/javascript.ts
@@ -72,20 +89,6 @@ async function comments(options = {}) {
72
89
  }];
73
90
  }
74
91
 
75
- //#endregion
76
- //#region src/globs.ts
77
- const GLOB_JS = "**/*.?([cm])js";
78
- const GLOB_JSX = "**/*.?([cm])jsx";
79
- const GLOB_TS = "**/*.?([cm])ts";
80
- const GLOB_TSX = "**/*.?([cm])tsx";
81
- const GLOB_JSON = "**/*.json";
82
- const GLOB_JSON5 = "**/*.json5";
83
- const GLOB_JSONC = "**/*.jsonc";
84
- const GLOB_YAML = "**/*.y?(a)ml";
85
- const GLOB_TOML = "**/*.toml";
86
- const GLOB_VUE = "**/*.vue";
87
- const GLOB_SVELTE = "**/*.svelte";
88
-
89
92
  //#endregion
90
93
  //#region src/configs/typescript.ts
91
94
  async function typescript(options = {}) {
@@ -197,9 +200,14 @@ async function toml(options = {}) {
197
200
  //#region src/configs/unicorn.ts
198
201
  async function unicorn(options = {}) {
199
202
  const { rules: overrideRules = {} } = options;
203
+ const useTypeScript = !options.typescript;
200
204
  const unicorn$1 = await loadPlugin("eslint-plugin-unicorn");
201
- return [unicorn$1.configs["flat/recommended"], {
205
+ return [{
206
+ files: getGlobSourceFiles(useTypeScript),
207
+ ...unicorn$1.configs["flat/recommended"]
208
+ }, {
202
209
  name: "@kazupon/unicorn",
210
+ files: getGlobSourceFiles(useTypeScript),
203
211
  rules: { ...overrideRules }
204
212
  }];
205
213
  }
@@ -340,28 +348,25 @@ async function react(options = {}) {
340
348
  const useTypeScript = !options.typescript;
341
349
  const enableRefresh = !!options.refresh;
342
350
  const [react$1, reactHooks, reactRefresh] = await Promise.all([loadPlugin("eslint-plugin-react"), loadPlugin("eslint-plugin-react-hooks"), enableRefresh ? loadPlugin("eslint-plugin-react-refresh") : null]);
343
- function getFiles() {
344
- return [GLOB_JS, GLOB_JSX, ...useTypeScript ? [GLOB_TS, GLOB_TSX] : []];
345
- }
346
351
  const customConfig = {
347
352
  name: "@kazupon/react",
348
- files: getFiles(),
353
+ files: getGlobSourceFiles(useTypeScript),
349
354
  rules: { ...overrideRules }
350
355
  };
351
356
  const configs = [{
352
357
  name: "react/flat/recommended",
353
- files: getFiles(),
358
+ files: getGlobSourceFiles(useTypeScript),
354
359
  settings,
355
360
  ...react$1.configs.flat.recommended
356
361
  }, {
357
362
  name: "react-hooks/flat",
358
- files: getFiles(),
363
+ files: getGlobSourceFiles(useTypeScript),
359
364
  plugins: { "react-hooks": reactHooks }
360
365
  }];
361
366
  if (enableRefresh) {
362
367
  configs.push({
363
368
  name: "react-refresh/flat",
364
- files: getFiles(),
369
+ files: getGlobSourceFiles(useTypeScript),
365
370
  plugins: { "react-refresh": reactRefresh }
366
371
  });
367
372
  }
package/dist/utils.d.cts CHANGED
@@ -29,3 +29,9 @@ export declare function loadPlugin<T = unknown>(name: string): Promise<T>;
29
29
  * @returns {Promise<typeof import('typescript-eslint')['parser']>} TypeScript parser
30
30
  */
31
31
  export declare function getTypeScriptParser(): Promise<(typeof import('typescript-eslint'))['parser']>;
32
+ /**
33
+ * get glob source files
34
+ * @param {boolean} useTypeScript use TypeScript, default `false`
35
+ * @returns {string[]} files
36
+ */
37
+ export declare function getGlobSourceFiles(useTypeScript?: boolean): string[];
package/dist/utils.d.ts CHANGED
@@ -29,3 +29,9 @@ export declare function loadPlugin<T = unknown>(name: string): Promise<T>;
29
29
  * @returns {Promise<typeof import('typescript-eslint')['parser']>} TypeScript parser
30
30
  */
31
31
  export declare function getTypeScriptParser(): Promise<(typeof import('typescript-eslint'))['parser']>;
32
+ /**
33
+ * get glob source files
34
+ * @param {boolean} useTypeScript use TypeScript, default `false`
35
+ * @returns {string[]} files
36
+ */
37
+ export declare function getGlobSourceFiles(useTypeScript?: boolean): string[];
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.13.1",
4
+ "version": "0.13.3",
5
5
  "author": {
6
6
  "email": "kawakazu80@gmail.com",
7
7
  "name": "kazuya kawaguchi"
@@ -129,7 +129,7 @@
129
129
  "eslint-plugin-unicorn": "^54.0.0",
130
130
  "eslint-plugin-vue": "^9.27.0",
131
131
  "eslint-plugin-yml": "^1.14.0",
132
- "eslint-typegen": "^0.3.0",
132
+ "eslint-typegen": "^0.3.1",
133
133
  "gh-changelogen": "^0.2.8",
134
134
  "lint-staged": "^15.2.7",
135
135
  "npm-run-all2": "^6.2.2",