@kazupon/eslint-config 0.12.0 → 0.13.1
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 +19 -17
- package/dist/configs/index.d.cts +1 -0
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/react.d.cts +26 -0
- package/dist/configs/react.d.ts +26 -0
- package/dist/index.cjs +45 -8
- package/dist/index.js +40 -9
- package/dist/types/gens/eslint.d.cts +2 -1
- package/dist/types/gens/eslint.d.ts +2 -1
- package/dist/types/gens/react.d.cts +1053 -0
- package/dist/types/gens/react.d.ts +1053 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/overrides.d.cts +1 -0
- package/dist/types/overrides.d.ts +1 -0
- package/dist/utils.d.cts +6 -0
- package/dist/utils.d.ts +6 -0
- package/package.json +16 -1
package/README.md
CHANGED
|
@@ -17,8 +17,9 @@ ESLint config for @kazupon
|
|
|
17
17
|
- `promise`
|
|
18
18
|
- `unicorn`
|
|
19
19
|
- `prettier`
|
|
20
|
-
- `vue
|
|
21
|
-
- `
|
|
20
|
+
- `vue`
|
|
21
|
+
- `react`
|
|
22
|
+
- `svelte`
|
|
22
23
|
- `jsonc`
|
|
23
24
|
- `yml`
|
|
24
25
|
- `toml`
|
|
@@ -109,21 +110,22 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
109
110
|
|
|
110
111
|
The following built-in configurations are supported:
|
|
111
112
|
|
|
112
|
-
| Configuration | Powered by eslint plugin or package
|
|
113
|
-
| ------------- |
|
|
114
|
-
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js)
|
|
115
|
-
| `comments` | [`@eslint-community/eslint-plugin-eslint-comments`](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments)
|
|
116
|
-
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint)
|
|
117
|
-
| `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc)
|
|
118
|
-
| `regexp` | [`eslint-plugin-regexp`](https://www.npmjs.com/package/eslint-plugin-regexp)
|
|
119
|
-
| `promise` | [`eslint-plugin-promise`](https://www.npmjs.com/package/eslint-plugin-promise)
|
|
120
|
-
| `unicorn` | [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn)
|
|
121
|
-
| `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier)
|
|
122
|
-
| `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue)
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
113
|
+
| Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
|
|
114
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
115
|
+
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
|
|
116
|
+
| `comments` | [`@eslint-community/eslint-plugin-eslint-comments`](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments) | no (built-in) |
|
|
117
|
+
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
|
|
118
|
+
| `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) | yes |
|
|
119
|
+
| `regexp` | [`eslint-plugin-regexp`](https://www.npmjs.com/package/eslint-plugin-regexp) | yes |
|
|
120
|
+
| `promise` | [`eslint-plugin-promise`](https://www.npmjs.com/package/eslint-plugin-promise) | yes |
|
|
121
|
+
| `unicorn` | [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn) | yes |
|
|
122
|
+
| `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
|
|
123
|
+
| `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
|
|
124
|
+
| `react` | [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), [`eslint-plugin-react-refresh`](https://www.npmjs.com/package/eslint-plugin-react-refresh) | yes |
|
|
125
|
+
| `svelte` | [`eslint-plugin-svelte`](https://www.npmjs.com/package/eslint-plugin-svelte) | yes |
|
|
126
|
+
| `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
|
|
127
|
+
| `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
|
|
128
|
+
| `toml` | [`eslint-plugin-toml`](https://www.npmjs.com/package/eslint-plugin-toml) | yes |
|
|
127
129
|
|
|
128
130
|
You can use `import` syntax:
|
|
129
131
|
|
package/dist/configs/index.d.cts
CHANGED
package/dist/configs/index.d.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { TypeScriptOptions } from './typescript';
|
|
3
|
+
import type { OverridesOptions, ReactRules } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* eslint react configuration options
|
|
6
|
+
*/
|
|
7
|
+
export interface ReactOptions {
|
|
8
|
+
/**
|
|
9
|
+
* use TypeScript
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
typescript?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* enable `eslint-plugin-react-refresh` recommended rules
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
refresh?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `eslint-plugin-react` and overrides configuration options
|
|
21
|
+
* @param {ReactOptions & OverridesOptions} options
|
|
22
|
+
* eslint react configuration options for regular expressions
|
|
23
|
+
* @returns {Promise<Linter.Config[]>}
|
|
24
|
+
* eslint flat configurations with `eslint-plugin-react` and overrides
|
|
25
|
+
*/
|
|
26
|
+
export declare function react(options?: ReactOptions & TypeScriptOptions & OverridesOptions<ReactRules>): Promise<Linter.Config[]>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { TypeScriptOptions } from './typescript';
|
|
3
|
+
import type { OverridesOptions, ReactRules } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* eslint react configuration options
|
|
6
|
+
*/
|
|
7
|
+
export interface ReactOptions {
|
|
8
|
+
/**
|
|
9
|
+
* use TypeScript
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
typescript?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* enable `eslint-plugin-react-refresh` recommended rules
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
refresh?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `eslint-plugin-react` and overrides configuration options
|
|
21
|
+
* @param {ReactOptions & OverridesOptions} options
|
|
22
|
+
* eslint react configuration options for regular expressions
|
|
23
|
+
* @returns {Promise<Linter.Config[]>}
|
|
24
|
+
* eslint flat configurations with `eslint-plugin-react` and overrides
|
|
25
|
+
*/
|
|
26
|
+
export declare function react(options?: ReactOptions & TypeScriptOptions & OverridesOptions<ReactRules>): Promise<Linter.Config[]>;
|
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,10 @@ async function loadPlugin(name) {
|
|
|
44
44
|
});
|
|
45
45
|
return interopDefault(mod);
|
|
46
46
|
}
|
|
47
|
+
async function getTypeScriptParser() {
|
|
48
|
+
const ts = await loadPlugin("typescript-eslint");
|
|
49
|
+
return ts.parser;
|
|
50
|
+
}
|
|
47
51
|
|
|
48
52
|
//#endregion
|
|
49
53
|
//#region src/configs/javascript.ts
|
|
@@ -333,10 +337,6 @@ async function vue(options = {}) {
|
|
|
333
337
|
const useTypeScript = !!options.typescript;
|
|
334
338
|
const vue$1 = await loadPlugin("eslint-plugin-vue");
|
|
335
339
|
const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
336
|
-
async function getTypeScriptParser() {
|
|
337
|
-
const ts = await loadPlugin("typescript-eslint");
|
|
338
|
-
return ts.parser;
|
|
339
|
-
}
|
|
340
340
|
const customConfig = {
|
|
341
341
|
name: "@kazupon/vue",
|
|
342
342
|
files: [GLOB_VUE],
|
|
@@ -357,6 +357,41 @@ async function vue(options = {}) {
|
|
|
357
357
|
return [...vue$1.configs["flat/recommended"], customConfig];
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/configs/react.ts
|
|
362
|
+
async function react(options = {}) {
|
|
363
|
+
const { rules: overrideRules = {}, settings = {} } = options;
|
|
364
|
+
const useTypeScript = !options.typescript;
|
|
365
|
+
const enableRefresh = !!options.refresh;
|
|
366
|
+
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
|
+
const customConfig = {
|
|
371
|
+
name: "@kazupon/react",
|
|
372
|
+
files: getFiles(),
|
|
373
|
+
rules: { ...overrideRules }
|
|
374
|
+
};
|
|
375
|
+
const configs = [{
|
|
376
|
+
name: "react/flat/recommended",
|
|
377
|
+
files: getFiles(),
|
|
378
|
+
settings,
|
|
379
|
+
...react$1.configs.flat.recommended
|
|
380
|
+
}, {
|
|
381
|
+
name: "react-hooks/flat",
|
|
382
|
+
files: getFiles(),
|
|
383
|
+
plugins: { "react-hooks": reactHooks }
|
|
384
|
+
}];
|
|
385
|
+
if (enableRefresh) {
|
|
386
|
+
configs.push({
|
|
387
|
+
name: "react-refresh/flat",
|
|
388
|
+
files: getFiles(),
|
|
389
|
+
plugins: { "react-refresh": reactRefresh }
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return [...configs, customConfig];
|
|
393
|
+
}
|
|
394
|
+
|
|
360
395
|
//#endregion
|
|
361
396
|
//#region src/configs/svelte.ts
|
|
362
397
|
async function svelte(options = {}) {
|
|
@@ -364,10 +399,6 @@ async function svelte(options = {}) {
|
|
|
364
399
|
const useTypeScript = !!options.typescript;
|
|
365
400
|
const svelte$1 = await loadPlugin("eslint-plugin-svelte");
|
|
366
401
|
const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
367
|
-
async function getTypeScriptParser() {
|
|
368
|
-
const ts = await loadPlugin("typescript-eslint");
|
|
369
|
-
return ts.parser;
|
|
370
|
-
}
|
|
371
402
|
const customConfig = {
|
|
372
403
|
name: "@kazupon/svelte",
|
|
373
404
|
files: [GLOB_SVELTE],
|
|
@@ -431,6 +462,12 @@ Object.defineProperty(exports, 'promise', {
|
|
|
431
462
|
return promise;
|
|
432
463
|
}
|
|
433
464
|
});
|
|
465
|
+
Object.defineProperty(exports, 'react', {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
get: function () {
|
|
468
|
+
return react;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
434
471
|
Object.defineProperty(exports, 'regexp', {
|
|
435
472
|
enumerable: true,
|
|
436
473
|
get: function () {
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,10 @@ async function loadPlugin(name) {
|
|
|
20
20
|
});
|
|
21
21
|
return interopDefault(mod);
|
|
22
22
|
}
|
|
23
|
+
async function getTypeScriptParser() {
|
|
24
|
+
const ts = await loadPlugin("typescript-eslint");
|
|
25
|
+
return ts.parser;
|
|
26
|
+
}
|
|
23
27
|
|
|
24
28
|
//#endregion
|
|
25
29
|
//#region src/configs/javascript.ts
|
|
@@ -309,10 +313,6 @@ async function vue(options = {}) {
|
|
|
309
313
|
const useTypeScript = !!options.typescript;
|
|
310
314
|
const vue$1 = await loadPlugin("eslint-plugin-vue");
|
|
311
315
|
const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
312
|
-
async function getTypeScriptParser() {
|
|
313
|
-
const ts = await loadPlugin("typescript-eslint");
|
|
314
|
-
return ts.parser;
|
|
315
|
-
}
|
|
316
316
|
const customConfig = {
|
|
317
317
|
name: "@kazupon/vue",
|
|
318
318
|
files: [GLOB_VUE],
|
|
@@ -333,6 +333,41 @@ async function vue(options = {}) {
|
|
|
333
333
|
return [...vue$1.configs["flat/recommended"], customConfig];
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/configs/react.ts
|
|
338
|
+
async function react(options = {}) {
|
|
339
|
+
const { rules: overrideRules = {}, settings = {} } = options;
|
|
340
|
+
const useTypeScript = !options.typescript;
|
|
341
|
+
const enableRefresh = !!options.refresh;
|
|
342
|
+
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
|
+
const customConfig = {
|
|
347
|
+
name: "@kazupon/react",
|
|
348
|
+
files: getFiles(),
|
|
349
|
+
rules: { ...overrideRules }
|
|
350
|
+
};
|
|
351
|
+
const configs = [{
|
|
352
|
+
name: "react/flat/recommended",
|
|
353
|
+
files: getFiles(),
|
|
354
|
+
settings,
|
|
355
|
+
...react$1.configs.flat.recommended
|
|
356
|
+
}, {
|
|
357
|
+
name: "react-hooks/flat",
|
|
358
|
+
files: getFiles(),
|
|
359
|
+
plugins: { "react-hooks": reactHooks }
|
|
360
|
+
}];
|
|
361
|
+
if (enableRefresh) {
|
|
362
|
+
configs.push({
|
|
363
|
+
name: "react-refresh/flat",
|
|
364
|
+
files: getFiles(),
|
|
365
|
+
plugins: { "react-refresh": reactRefresh }
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return [...configs, customConfig];
|
|
369
|
+
}
|
|
370
|
+
|
|
336
371
|
//#endregion
|
|
337
372
|
//#region src/configs/svelte.ts
|
|
338
373
|
async function svelte(options = {}) {
|
|
@@ -340,10 +375,6 @@ async function svelte(options = {}) {
|
|
|
340
375
|
const useTypeScript = !!options.typescript;
|
|
341
376
|
const svelte$1 = await loadPlugin("eslint-plugin-svelte");
|
|
342
377
|
const svelteParser = svelte$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
343
|
-
async function getTypeScriptParser() {
|
|
344
|
-
const ts = await loadPlugin("typescript-eslint");
|
|
345
|
-
return ts.parser;
|
|
346
|
-
}
|
|
347
378
|
const customConfig = {
|
|
348
379
|
name: "@kazupon/svelte",
|
|
349
380
|
files: [GLOB_SVELTE],
|
|
@@ -365,4 +396,4 @@ async function svelte(options = {}) {
|
|
|
365
396
|
}
|
|
366
397
|
|
|
367
398
|
//#endregion
|
|
368
|
-
export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, promise, regexp, svelte, toml, typescript, unicorn, vue, yaml, yml };
|
|
399
|
+
export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vue, yaml, yml };
|
|
@@ -4,6 +4,7 @@ import type { JsdocRules } from './jsdoc';
|
|
|
4
4
|
import type { JsoncRules } from './jsonc';
|
|
5
5
|
import type { PrettierRules } from './prettier';
|
|
6
6
|
import type { PromiseRules } from './promise';
|
|
7
|
+
import type { ReactRules } from './react';
|
|
7
8
|
import type { RegexpRules } from './regexp';
|
|
8
9
|
import type { SvelteRules } from './svelte';
|
|
9
10
|
import type { TomlRules } from './toml';
|
|
@@ -13,7 +14,7 @@ import type { VueRules } from './vue';
|
|
|
13
14
|
import type { YmlRules } from './yml';
|
|
14
15
|
declare module 'eslint' {
|
|
15
16
|
namespace Linter {
|
|
16
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
17
|
+
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -4,6 +4,7 @@ import type { JsdocRules } from './jsdoc';
|
|
|
4
4
|
import type { JsoncRules } from './jsonc';
|
|
5
5
|
import type { PrettierRules } from './prettier';
|
|
6
6
|
import type { PromiseRules } from './promise';
|
|
7
|
+
import type { ReactRules } from './react';
|
|
7
8
|
import type { RegexpRules } from './regexp';
|
|
8
9
|
import type { SvelteRules } from './svelte';
|
|
9
10
|
import type { TomlRules } from './toml';
|
|
@@ -13,7 +14,7 @@ import type { VueRules } from './vue';
|
|
|
13
14
|
import type { YmlRules } from './yml';
|
|
14
15
|
declare module 'eslint' {
|
|
15
16
|
namespace Linter {
|
|
16
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
17
|
+
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|