@kazupon/eslint-config 0.14.1 → 0.16.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.
- package/README.md +25 -21
- package/dist/configs/imports.d.cts +16 -0
- package/dist/configs/imports.d.ts +16 -0
- package/dist/configs/index.d.cts +2 -0
- package/dist/configs/index.d.ts +2 -0
- package/dist/configs/vitest.d.cts +22 -0
- package/dist/configs/vitest.d.ts +22 -0
- package/dist/configs/vue.d.cts +18 -3
- package/dist/configs/vue.d.ts +18 -3
- package/dist/globs.d.cts +2 -0
- package/dist/globs.d.ts +2 -0
- package/dist/index.cjs +116 -4
- package/dist/index.js +105 -5
- package/dist/types/gens/eslint.d.cts +3 -1
- package/dist/types/gens/eslint.d.ts +3 -1
- package/dist/types/gens/imports.d.cts +42 -0
- package/dist/types/gens/imports.d.ts +42 -0
- package/dist/types/gens/vitest.d.cts +377 -0
- package/dist/types/gens/vitest.d.ts +377 -0
- package/dist/types/gens/vue.d.cts +281 -0
- package/dist/types/gens/vue.d.ts +281 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +28 -3
package/README.md
CHANGED
|
@@ -8,10 +8,11 @@ ESLint config for @kazupon
|
|
|
8
8
|
## 🌟 Features
|
|
9
9
|
|
|
10
10
|
- Flat configuration via [vite](https://vitejs.dev/config/) flavor `defineConfig`
|
|
11
|
-
- Support [built-in configurations](#built-in-configurations)
|
|
11
|
+
- Support [built-in preset configurations](#built-in-preset-configurations)
|
|
12
12
|
- `javascript`
|
|
13
13
|
- `comments`
|
|
14
14
|
- `typescript`
|
|
15
|
+
- `imports`
|
|
15
16
|
- `jsdoc`
|
|
16
17
|
- `regexp`
|
|
17
18
|
- `promise`
|
|
@@ -20,6 +21,7 @@ ESLint config for @kazupon
|
|
|
20
21
|
- `vue`
|
|
21
22
|
- `react`
|
|
22
23
|
- `svelte`
|
|
24
|
+
- `vitest`
|
|
23
25
|
- `jsonc`
|
|
24
26
|
- `yml`
|
|
25
27
|
- `toml`
|
|
@@ -106,26 +108,28 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
106
108
|
}
|
|
107
109
|
```
|
|
108
110
|
|
|
109
|
-
## 🔨Built-in configurations
|
|
110
|
-
|
|
111
|
-
The following built-in configurations are supported:
|
|
112
|
-
|
|
113
|
-
| Configuration | Powered by eslint plugin or package
|
|
114
|
-
| ------------- |
|
|
115
|
-
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js)
|
|
116
|
-
| `comments` | [`@eslint-community/eslint-plugin-eslint-comments`](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments)
|
|
117
|
-
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint)
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
111
|
+
## 🔨Built-in preset configurations
|
|
112
|
+
|
|
113
|
+
The following built-in preset configurations are supported:
|
|
114
|
+
|
|
115
|
+
| Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
|
|
116
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
117
|
+
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
|
|
118
|
+
| `comments` | [`@eslint-community/eslint-plugin-eslint-comments`](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments) | no (built-in) |
|
|
119
|
+
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
|
|
120
|
+
| `imports` | [`eslint-plugin-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports) | yes |
|
|
121
|
+
| `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) | yes |
|
|
122
|
+
| `regexp` | [`eslint-plugin-regexp`](https://www.npmjs.com/package/eslint-plugin-regexp) | yes |
|
|
123
|
+
| `promise` | [`eslint-plugin-promise`](https://www.npmjs.com/package/eslint-plugin-promise) | yes |
|
|
124
|
+
| `unicorn` | [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn) | yes |
|
|
125
|
+
| `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
|
|
126
|
+
| `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue), [`eslint-plugin-vue-composable`](https://www.npmjs.com/package/eslint-plugin-vue-composable), [`eslint-plugin-vue-scoped-css`](https://www.npmjs.com/package/eslint-plugin-vue-scoped-css), [`eslint-plugin-vuejs-accessibility`](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility)) | yes |
|
|
127
|
+
| `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 |
|
|
128
|
+
| `svelte` | [`eslint-plugin-svelte`](https://www.npmjs.com/package/eslint-plugin-svelte) | yes |
|
|
129
|
+
| `vitest` | [`@vitest/eslint-plugin`](https://www.npmjs.com/package/@vitest/eslint-plugin) | yes |
|
|
130
|
+
| `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
|
|
131
|
+
| `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
|
|
132
|
+
| `toml` | [`eslint-plugin-toml`](https://www.npmjs.com/package/eslint-plugin-toml) | yes |
|
|
129
133
|
|
|
130
134
|
You can use `import` syntax:
|
|
131
135
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions, ImportsRules } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* imports configuration options
|
|
5
|
+
*/
|
|
6
|
+
export interface ImportsOptions {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `eslint-plugin-unused-imports` and overrides configuration options
|
|
10
|
+
* @description **if you want to use this preset, you need to put after `javascirpt` and `typescript` presets**
|
|
11
|
+
* @param {ImportsOptions & OverridesOptions} options
|
|
12
|
+
* import configuration options
|
|
13
|
+
* @returns {Promise<Linter.Config[]>}
|
|
14
|
+
* eslint flat configurations with `eslint-plugin-unused-imports` and overrides
|
|
15
|
+
*/
|
|
16
|
+
export declare function imports(options?: ImportsRules & OverridesOptions<ImportsRules>): Promise<Linter.Config[]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions, ImportsRules } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* imports configuration options
|
|
5
|
+
*/
|
|
6
|
+
export interface ImportsOptions {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `eslint-plugin-unused-imports` and overrides configuration options
|
|
10
|
+
* @description **if you want to use this preset, you need to put after `javascirpt` and `typescript` presets**
|
|
11
|
+
* @param {ImportsOptions & OverridesOptions} options
|
|
12
|
+
* import configuration options
|
|
13
|
+
* @returns {Promise<Linter.Config[]>}
|
|
14
|
+
* eslint flat configurations with `eslint-plugin-unused-imports` and overrides
|
|
15
|
+
*/
|
|
16
|
+
export declare function imports(options?: ImportsRules & OverridesOptions<ImportsRules>): Promise<Linter.Config[]>;
|
package/dist/configs/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './javascript';
|
|
|
2
2
|
export * from './comments';
|
|
3
3
|
export * from './typescript';
|
|
4
4
|
export * from './jsdoc';
|
|
5
|
+
export * from './imports';
|
|
5
6
|
export * from './promise';
|
|
6
7
|
export * from './regexp';
|
|
7
8
|
export * from './toml';
|
|
@@ -12,3 +13,4 @@ export * from './yml';
|
|
|
12
13
|
export * from './vue';
|
|
13
14
|
export * from './react';
|
|
14
15
|
export * from './svelte';
|
|
16
|
+
export * from './vitest';
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './javascript';
|
|
|
2
2
|
export * from './comments';
|
|
3
3
|
export * from './typescript';
|
|
4
4
|
export * from './jsdoc';
|
|
5
|
+
export * from './imports';
|
|
5
6
|
export * from './promise';
|
|
6
7
|
export * from './regexp';
|
|
7
8
|
export * from './toml';
|
|
@@ -12,3 +13,4 @@ export * from './yml';
|
|
|
12
13
|
export * from './vue';
|
|
13
14
|
export * from './react';
|
|
14
15
|
export * from './svelte';
|
|
16
|
+
export * from './vitest';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions, VitestRules } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* eslint vitest configuration options
|
|
5
|
+
*/
|
|
6
|
+
export interface VitestOptions {
|
|
7
|
+
/**
|
|
8
|
+
* use type testing
|
|
9
|
+
* @description about type testing, see https://vitest.dev/guide/testing-types,
|
|
10
|
+
* and about eslint config, see https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#enabling-with-type-testing
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
typeTesting?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `@vitest/eslint-plugin` and overrides configuration options
|
|
17
|
+
* @param {VitestOptions & OverridesOptions} options
|
|
18
|
+
* eslint vitest configuration options
|
|
19
|
+
* @returns {Promise<Linter.Config[]>}
|
|
20
|
+
* eslint flat configurations with `@vitest/eslint-plugin` and overrides
|
|
21
|
+
*/
|
|
22
|
+
export declare function vitest(options?: VitestOptions & OverridesOptions<VitestRules>): Promise<Linter.Config[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions, VitestRules } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* eslint vitest configuration options
|
|
5
|
+
*/
|
|
6
|
+
export interface VitestOptions {
|
|
7
|
+
/**
|
|
8
|
+
* use type testing
|
|
9
|
+
* @description about type testing, see https://vitest.dev/guide/testing-types,
|
|
10
|
+
* and about eslint config, see https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#enabling-with-type-testing
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
typeTesting?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `@vitest/eslint-plugin` and overrides configuration options
|
|
17
|
+
* @param {VitestOptions & OverridesOptions} options
|
|
18
|
+
* eslint vitest configuration options
|
|
19
|
+
* @returns {Promise<Linter.Config[]>}
|
|
20
|
+
* eslint flat configurations with `@vitest/eslint-plugin` and overrides
|
|
21
|
+
*/
|
|
22
|
+
export declare function vitest(options?: VitestOptions & OverridesOptions<VitestRules>): Promise<Linter.Config[]>;
|
package/dist/configs/vue.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
|
-
import type { TypeScriptOptions } from './typescript';
|
|
3
2
|
import type { OverridesOptions, VueRules } from '../types';
|
|
3
|
+
import type { TypeScriptOptions } from './typescript';
|
|
4
4
|
/**
|
|
5
5
|
* Vue configuration options
|
|
6
6
|
*/
|
|
@@ -10,12 +10,27 @@ export interface VueScriptOptions {
|
|
|
10
10
|
* @default false
|
|
11
11
|
*/
|
|
12
12
|
typescript?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* enable `eslint-plugin-vue-composable` rules
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
composable?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* enable `eslint-plugin-vue-scoped-css` rules
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
scopedCss?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* enable `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` rules
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
a11y?: boolean;
|
|
13
28
|
}
|
|
14
29
|
/**
|
|
15
|
-
* `eslint-plugin-vue` and overrides configuration options
|
|
30
|
+
* `eslint-plugin-vue`, `eslint-plugin-vue-composable`, `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` and overrides configuration options
|
|
16
31
|
* @param {VueScriptOptions & TypeScriptOptions & OverridesOptions} options
|
|
17
32
|
* eslint configuration options for Vue
|
|
18
33
|
* @returns {Promise<Linter.Config[]>}
|
|
19
|
-
* eslint flat configurations with `eslint-plugin-vue` and overrides
|
|
34
|
+
* eslint flat configurations with `eslint-plugin-vue`, `eslint-plugin-vue-composable`, `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` and overrides
|
|
20
35
|
*/
|
|
21
36
|
export declare function vue(options?: VueScriptOptions & TypeScriptOptions & OverridesOptions<VueRules>): Promise<Linter.Config[]>;
|
package/dist/configs/vue.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
|
-
import type { TypeScriptOptions } from './typescript';
|
|
3
2
|
import type { OverridesOptions, VueRules } from '../types';
|
|
3
|
+
import type { TypeScriptOptions } from './typescript';
|
|
4
4
|
/**
|
|
5
5
|
* Vue configuration options
|
|
6
6
|
*/
|
|
@@ -10,12 +10,27 @@ export interface VueScriptOptions {
|
|
|
10
10
|
* @default false
|
|
11
11
|
*/
|
|
12
12
|
typescript?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* enable `eslint-plugin-vue-composable` rules
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
composable?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* enable `eslint-plugin-vue-scoped-css` rules
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
scopedCss?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* enable `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` rules
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
a11y?: boolean;
|
|
13
28
|
}
|
|
14
29
|
/**
|
|
15
|
-
* `eslint-plugin-vue` and overrides configuration options
|
|
30
|
+
* `eslint-plugin-vue`, `eslint-plugin-vue-composable`, `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` and overrides configuration options
|
|
16
31
|
* @param {VueScriptOptions & TypeScriptOptions & OverridesOptions} options
|
|
17
32
|
* eslint configuration options for Vue
|
|
18
33
|
* @returns {Promise<Linter.Config[]>}
|
|
19
|
-
* eslint flat configurations with `eslint-plugin-vue` and overrides
|
|
34
|
+
* eslint flat configurations with `eslint-plugin-vue`, `eslint-plugin-vue-composable`, `eslint-plugin-vue-eslint-plugin-vuejs-accessibility` and overrides
|
|
20
35
|
*/
|
|
21
36
|
export declare function vue(options?: VueScriptOptions & TypeScriptOptions & OverridesOptions<VueRules>): Promise<Linter.Config[]>;
|
package/dist/globs.d.cts
CHANGED
|
@@ -9,3 +9,5 @@ export declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
|
9
9
|
export declare const GLOB_TOML = "**/*.toml";
|
|
10
10
|
export declare const GLOB_VUE = "**/*.vue";
|
|
11
11
|
export declare const GLOB_SVELTE = "**/*.svelte";
|
|
12
|
+
export declare const GLOB_TESTS: string[];
|
|
13
|
+
export declare const GLOB_TESTS_TYPE: string[];
|
package/dist/globs.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
|
9
9
|
export declare const GLOB_TOML = "**/*.toml";
|
|
10
10
|
export declare const GLOB_VUE = "**/*.vue";
|
|
11
11
|
export declare const GLOB_SVELTE = "**/*.svelte";
|
|
12
|
+
export declare const GLOB_TESTS: string[];
|
|
13
|
+
export declare const GLOB_TESTS_TYPE: string[];
|
package/dist/index.cjs
CHANGED
|
@@ -44,9 +44,12 @@ const GLOB_YAML = "**/*.y?(a)ml";
|
|
|
44
44
|
const GLOB_TOML = "**/*.toml";
|
|
45
45
|
const GLOB_VUE = "**/*.vue";
|
|
46
46
|
const GLOB_SVELTE = "**/*.svelte";
|
|
47
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
48
|
+
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}`];
|
|
49
|
+
const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
|
|
47
50
|
|
|
48
51
|
//#endregion
|
|
49
|
-
//#region node_modules/.pnpm/@kazupon+jts-utils@0.
|
|
52
|
+
//#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
|
|
50
53
|
async function interopDefault(mod) {
|
|
51
54
|
const resolved = await mod;
|
|
52
55
|
return resolved.default || resolved;
|
|
@@ -174,6 +177,41 @@ async function jsdoc(options = {}) {
|
|
|
174
177
|
}];
|
|
175
178
|
}
|
|
176
179
|
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/configs/imports.ts
|
|
182
|
+
const IMPORTS_FILES = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX];
|
|
183
|
+
async function imports(options = {}) {
|
|
184
|
+
const { rules: overrideRules = {} } = options;
|
|
185
|
+
const unused = await loadPlugin("eslint-plugin-unused-imports");
|
|
186
|
+
const configs = [{
|
|
187
|
+
name: "unused-imports",
|
|
188
|
+
plugins: { "unused-imports": unused },
|
|
189
|
+
files: IMPORTS_FILES,
|
|
190
|
+
rules: {
|
|
191
|
+
"no-unused-vars": "off",
|
|
192
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
193
|
+
"unused-imports/no-unused-imports": "error",
|
|
194
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
195
|
+
args: "all",
|
|
196
|
+
argsIgnorePattern: "^_",
|
|
197
|
+
caughtErrors: "all",
|
|
198
|
+
caughtErrorsIgnorePattern: "^_",
|
|
199
|
+
destructuredArrayIgnorePattern: "^_",
|
|
200
|
+
vars: "all",
|
|
201
|
+
varsIgnorePattern: "^_",
|
|
202
|
+
ignoreRestSiblings: true
|
|
203
|
+
}]
|
|
204
|
+
}
|
|
205
|
+
}];
|
|
206
|
+
const overriddenConfig = {
|
|
207
|
+
name: "@kazupon/imports",
|
|
208
|
+
files: IMPORTS_FILES,
|
|
209
|
+
rules: { ...overrideRules }
|
|
210
|
+
};
|
|
211
|
+
configs.push(overriddenConfig);
|
|
212
|
+
return configs;
|
|
213
|
+
}
|
|
214
|
+
|
|
177
215
|
//#endregion
|
|
178
216
|
//#region src/configs/promise.ts
|
|
179
217
|
async function promise(options = {}) {
|
|
@@ -345,15 +383,45 @@ const yaml = yml;
|
|
|
345
383
|
//#region src/configs/vue.ts
|
|
346
384
|
async function vue(options = {}) {
|
|
347
385
|
const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
|
|
348
|
-
const useTypeScript = !!options.typescript;
|
|
349
386
|
const vue$1 = await loadPlugin("eslint-plugin-vue");
|
|
350
387
|
const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
388
|
+
const configs = [];
|
|
389
|
+
configs.push(...vue$1.configs["flat/recommended"]);
|
|
390
|
+
if (options.composable) {
|
|
391
|
+
const composable = await loadPlugin("eslint-plugin-vue-composable");
|
|
392
|
+
const composableBase = { ...composable.configs["flat/recommended"][0] };
|
|
393
|
+
delete composableBase.languageOptions;
|
|
394
|
+
configs.push(composableBase, composable.configs["flat/recommended"][1]);
|
|
395
|
+
}
|
|
396
|
+
if (options.scopedCss) {
|
|
397
|
+
const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
|
|
398
|
+
const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
|
|
399
|
+
return config.name ? config : {
|
|
400
|
+
name: `vue/scoped-css/recommended/${index}`,
|
|
401
|
+
...config
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
configs.push(scopedCssMapped[0], scopedCssMapped[2]);
|
|
405
|
+
}
|
|
406
|
+
if (options.a11y) {
|
|
407
|
+
const a11y = await loadPlugin("eslint-plugin-vuejs-accessibility");
|
|
408
|
+
const a11yBase = { ...a11y.configs["flat/recommended"][0] };
|
|
409
|
+
delete a11yBase.languageOptions;
|
|
410
|
+
configs.push(a11yBase);
|
|
411
|
+
const a11yRules = {
|
|
412
|
+
...a11y.configs["flat/recommended"][1],
|
|
413
|
+
name: "vuejs-accessibility:rules"
|
|
414
|
+
};
|
|
415
|
+
delete a11yRules.languageOptions;
|
|
416
|
+
delete a11yRules.plugins;
|
|
417
|
+
configs.push(a11yRules);
|
|
418
|
+
}
|
|
351
419
|
const customConfig = {
|
|
352
420
|
name: "@kazupon/vue",
|
|
353
421
|
files: [GLOB_VUE],
|
|
354
422
|
rules: { ...overrideRules }
|
|
355
423
|
};
|
|
356
|
-
if (
|
|
424
|
+
if (options.typescript) {
|
|
357
425
|
customConfig.languageOptions = {
|
|
358
426
|
parser: vueParser,
|
|
359
427
|
parserOptions: {
|
|
@@ -365,7 +433,8 @@ async function vue(options = {}) {
|
|
|
365
433
|
}
|
|
366
434
|
};
|
|
367
435
|
}
|
|
368
|
-
|
|
436
|
+
configs.push(customConfig);
|
|
437
|
+
return configs;
|
|
369
438
|
}
|
|
370
439
|
|
|
371
440
|
//#endregion
|
|
@@ -427,6 +496,37 @@ async function svelte(options = {}) {
|
|
|
427
496
|
return [...svelte$1.configs["flat/recommended"], customConfig];
|
|
428
497
|
}
|
|
429
498
|
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/configs/vitest.ts
|
|
501
|
+
async function vitest(options = {}) {
|
|
502
|
+
const { rules: overrideRules = {}, files: overrideFiles = [] } = options;
|
|
503
|
+
const typeTesting = !!options.typeTesting;
|
|
504
|
+
const vitest$1 = await loadPlugin("@vitest/eslint-plugin");
|
|
505
|
+
const configs = [];
|
|
506
|
+
const base = {
|
|
507
|
+
files: GLOB_TESTS,
|
|
508
|
+
...vitest$1.configs["recommended"]
|
|
509
|
+
};
|
|
510
|
+
if (base.name == undefined) {
|
|
511
|
+
base.name = "@vitest/eslint-plugin";
|
|
512
|
+
}
|
|
513
|
+
if (typeTesting) {
|
|
514
|
+
base.files = [...base.files, ...GLOB_TESTS_TYPE];
|
|
515
|
+
base.settings = { vitest: { typecheck: true } };
|
|
516
|
+
base.languageOptions = { globals: { ...vitest$1.environments.env.globals } };
|
|
517
|
+
}
|
|
518
|
+
configs.push(base);
|
|
519
|
+
const custom = {
|
|
520
|
+
name: "@kazupon/vitest",
|
|
521
|
+
rules: { ...overrideRules }
|
|
522
|
+
};
|
|
523
|
+
if (overrideFiles.length > 0) {
|
|
524
|
+
custom.files = overrideFiles;
|
|
525
|
+
}
|
|
526
|
+
configs.push(custom);
|
|
527
|
+
return configs;
|
|
528
|
+
}
|
|
529
|
+
|
|
430
530
|
//#endregion
|
|
431
531
|
Object.defineProperty(exports, 'comments', {
|
|
432
532
|
enumerable: true,
|
|
@@ -440,6 +540,12 @@ Object.defineProperty(exports, 'defineConfig', {
|
|
|
440
540
|
return defineConfig;
|
|
441
541
|
}
|
|
442
542
|
});
|
|
543
|
+
Object.defineProperty(exports, 'imports', {
|
|
544
|
+
enumerable: true,
|
|
545
|
+
get: function () {
|
|
546
|
+
return imports;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
443
549
|
Object.defineProperty(exports, 'javascript', {
|
|
444
550
|
enumerable: true,
|
|
445
551
|
get: function () {
|
|
@@ -506,6 +612,12 @@ Object.defineProperty(exports, 'unicorn', {
|
|
|
506
612
|
return unicorn;
|
|
507
613
|
}
|
|
508
614
|
});
|
|
615
|
+
Object.defineProperty(exports, 'vitest', {
|
|
616
|
+
enumerable: true,
|
|
617
|
+
get: function () {
|
|
618
|
+
return vitest;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
509
621
|
Object.defineProperty(exports, 'vue', {
|
|
510
622
|
enumerable: true,
|
|
511
623
|
get: function () {
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,12 @@ const GLOB_YAML = "**/*.y?(a)ml";
|
|
|
20
20
|
const GLOB_TOML = "**/*.toml";
|
|
21
21
|
const GLOB_VUE = "**/*.vue";
|
|
22
22
|
const GLOB_SVELTE = "**/*.svelte";
|
|
23
|
+
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}`];
|
|
25
|
+
const GLOB_TESTS_TYPE = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
//#region node_modules/.pnpm/@kazupon+jts-utils@0.
|
|
28
|
+
//#region node_modules/.pnpm/@kazupon+jts-utils@0.2.0/node_modules/@kazupon/jts-utils/dist/module/index.mjs
|
|
26
29
|
async function interopDefault(mod) {
|
|
27
30
|
const resolved = await mod;
|
|
28
31
|
return resolved.default || resolved;
|
|
@@ -150,6 +153,41 @@ async function jsdoc(options = {}) {
|
|
|
150
153
|
}];
|
|
151
154
|
}
|
|
152
155
|
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/configs/imports.ts
|
|
158
|
+
const IMPORTS_FILES = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX];
|
|
159
|
+
async function imports(options = {}) {
|
|
160
|
+
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
|
+
}]
|
|
180
|
+
}
|
|
181
|
+
}];
|
|
182
|
+
const overriddenConfig = {
|
|
183
|
+
name: "@kazupon/imports",
|
|
184
|
+
files: IMPORTS_FILES,
|
|
185
|
+
rules: { ...overrideRules }
|
|
186
|
+
};
|
|
187
|
+
configs.push(overriddenConfig);
|
|
188
|
+
return configs;
|
|
189
|
+
}
|
|
190
|
+
|
|
153
191
|
//#endregion
|
|
154
192
|
//#region src/configs/promise.ts
|
|
155
193
|
async function promise(options = {}) {
|
|
@@ -321,15 +359,45 @@ const yaml = yml;
|
|
|
321
359
|
//#region src/configs/vue.ts
|
|
322
360
|
async function vue(options = {}) {
|
|
323
361
|
const { rules: overrideRules = {}, parserOptions = { project: true } } = options;
|
|
324
|
-
const useTypeScript = !!options.typescript;
|
|
325
362
|
const vue$1 = await loadPlugin("eslint-plugin-vue");
|
|
326
363
|
const vueParser = vue$1.configs["flat/base"][1]["languageOptions"]["parser"];
|
|
364
|
+
const configs = [];
|
|
365
|
+
configs.push(...vue$1.configs["flat/recommended"]);
|
|
366
|
+
if (options.composable) {
|
|
367
|
+
const composable = await loadPlugin("eslint-plugin-vue-composable");
|
|
368
|
+
const composableBase = { ...composable.configs["flat/recommended"][0] };
|
|
369
|
+
delete composableBase.languageOptions;
|
|
370
|
+
configs.push(composableBase, composable.configs["flat/recommended"][1]);
|
|
371
|
+
}
|
|
372
|
+
if (options.scopedCss) {
|
|
373
|
+
const scopedCss = await loadPlugin("eslint-plugin-vue-scoped-css");
|
|
374
|
+
const scopedCssMapped = scopedCss.configs["flat/recommended"].map((config, index) => {
|
|
375
|
+
return config.name ? config : {
|
|
376
|
+
name: `vue/scoped-css/recommended/${index}`,
|
|
377
|
+
...config
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
configs.push(scopedCssMapped[0], scopedCssMapped[2]);
|
|
381
|
+
}
|
|
382
|
+
if (options.a11y) {
|
|
383
|
+
const a11y = await loadPlugin("eslint-plugin-vuejs-accessibility");
|
|
384
|
+
const a11yBase = { ...a11y.configs["flat/recommended"][0] };
|
|
385
|
+
delete a11yBase.languageOptions;
|
|
386
|
+
configs.push(a11yBase);
|
|
387
|
+
const a11yRules = {
|
|
388
|
+
...a11y.configs["flat/recommended"][1],
|
|
389
|
+
name: "vuejs-accessibility:rules"
|
|
390
|
+
};
|
|
391
|
+
delete a11yRules.languageOptions;
|
|
392
|
+
delete a11yRules.plugins;
|
|
393
|
+
configs.push(a11yRules);
|
|
394
|
+
}
|
|
327
395
|
const customConfig = {
|
|
328
396
|
name: "@kazupon/vue",
|
|
329
397
|
files: [GLOB_VUE],
|
|
330
398
|
rules: { ...overrideRules }
|
|
331
399
|
};
|
|
332
|
-
if (
|
|
400
|
+
if (options.typescript) {
|
|
333
401
|
customConfig.languageOptions = {
|
|
334
402
|
parser: vueParser,
|
|
335
403
|
parserOptions: {
|
|
@@ -341,7 +409,8 @@ async function vue(options = {}) {
|
|
|
341
409
|
}
|
|
342
410
|
};
|
|
343
411
|
}
|
|
344
|
-
|
|
412
|
+
configs.push(customConfig);
|
|
413
|
+
return configs;
|
|
345
414
|
}
|
|
346
415
|
|
|
347
416
|
//#endregion
|
|
@@ -404,4 +473,35 @@ async function svelte(options = {}) {
|
|
|
404
473
|
}
|
|
405
474
|
|
|
406
475
|
//#endregion
|
|
407
|
-
|
|
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");
|
|
481
|
+
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 } };
|
|
493
|
+
}
|
|
494
|
+
configs.push(base);
|
|
495
|
+
const custom = {
|
|
496
|
+
name: "@kazupon/vitest",
|
|
497
|
+
rules: { ...overrideRules }
|
|
498
|
+
};
|
|
499
|
+
if (overrideFiles.length > 0) {
|
|
500
|
+
custom.files = overrideFiles;
|
|
501
|
+
}
|
|
502
|
+
configs.push(custom);
|
|
503
|
+
return configs;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
//#endregion
|
|
507
|
+
export { comments, defineConfig, imports, javascript, jsdoc, jsonc, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommentsRules } from './comments';
|
|
2
|
+
import type { ImportsRules } from './imports';
|
|
2
3
|
import type { JavascriptRules } from './javascript';
|
|
3
4
|
import type { JsdocRules } from './jsdoc';
|
|
4
5
|
import type { JsoncRules } from './jsonc';
|
|
@@ -10,11 +11,12 @@ import type { SvelteRules } from './svelte';
|
|
|
10
11
|
import type { TomlRules } from './toml';
|
|
11
12
|
import type { TypescriptRules } from './typescript';
|
|
12
13
|
import type { UnicornRules } from './unicorn';
|
|
14
|
+
import type { VitestRules } from './vitest';
|
|
13
15
|
import type { VueRules } from './vue';
|
|
14
16
|
import type { YmlRules } from './yml';
|
|
15
17
|
declare module 'eslint' {
|
|
16
18
|
namespace Linter {
|
|
17
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
19
|
+
interface RulesRecord extends CommentsRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommentsRules } from './comments';
|
|
2
|
+
import type { ImportsRules } from './imports';
|
|
2
3
|
import type { JavascriptRules } from './javascript';
|
|
3
4
|
import type { JsdocRules } from './jsdoc';
|
|
4
5
|
import type { JsoncRules } from './jsonc';
|
|
@@ -10,11 +11,12 @@ import type { SvelteRules } from './svelte';
|
|
|
10
11
|
import type { TomlRules } from './toml';
|
|
11
12
|
import type { TypescriptRules } from './typescript';
|
|
12
13
|
import type { UnicornRules } from './unicorn';
|
|
14
|
+
import type { VitestRules } from './vitest';
|
|
13
15
|
import type { VueRules } from './vue';
|
|
14
16
|
import type { YmlRules } from './yml';
|
|
15
17
|
declare module 'eslint' {
|
|
16
18
|
namespace Linter {
|
|
17
|
-
interface RulesRecord extends CommentsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VueRules, YmlRules {
|
|
19
|
+
interface RulesRecord extends CommentsRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|