@kazupon/eslint-config 0.1.0 â 0.3.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 +24 -11
- package/dist/configs/comments.d.cts +4 -0
- package/dist/configs/comments.d.ts +4 -0
- package/dist/configs/index.d.cts +2 -0
- package/dist/configs/index.d.ts +2 -0
- package/dist/configs/vue.d.cts +7 -0
- package/dist/configs/vue.d.ts +7 -0
- package/dist/globs.d.cts +1 -0
- package/dist/globs.d.ts +1 -0
- package/dist/index.cjs +58 -22
- package/dist/index.js +54 -7
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# @kazupon/eslint-config
|
|
2
2
|
|
|
3
|
-
[![
|
|
4
|
-
[![CI]
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![CI][ci-src]][ci-href]
|
|
5
5
|
|
|
6
6
|
ESLint config for @kazupon
|
|
7
7
|
|
|
8
8
|
## đ Features
|
|
9
9
|
|
|
10
10
|
- Flat configuration via `defineConfig` like [vite](https://vitejs.dev/config/)
|
|
11
|
-
- Support built-in configurations
|
|
11
|
+
- Support [built-in configurations](#built-in-configurations)
|
|
12
12
|
- `javascript`
|
|
13
|
+
- `comments`
|
|
13
14
|
- `typescript`
|
|
14
15
|
- `prettier`
|
|
16
|
+
- `vue`
|
|
15
17
|
- Support primitive eslint flat configuration
|
|
16
18
|
- Support overrides for built-in configurations
|
|
17
19
|
- `rules`
|
|
@@ -79,9 +81,9 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
79
81
|
"source.fixAll.eslint": "explicit"
|
|
80
82
|
},
|
|
81
83
|
// Enable eslint for supported languages
|
|
82
|
-
"eslint.validate": ["javascript", "typescript"],
|
|
84
|
+
"eslint.validate": ["javascript", "typescript", "vue"],
|
|
83
85
|
// Enable flat configuration
|
|
84
|
-
"eslint.
|
|
86
|
+
"eslint.useFlatConfig": true
|
|
85
87
|
}
|
|
86
88
|
```
|
|
87
89
|
|
|
@@ -89,11 +91,13 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
89
91
|
|
|
90
92
|
The following built-in configurations are supported:
|
|
91
93
|
|
|
92
|
-
| Configuration | Powered by eslint plugin or package
|
|
93
|
-
| ------------- |
|
|
94
|
-
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js)
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
94
|
+
| Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
|
|
95
|
+
| ------------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
96
|
+
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
|
|
97
|
+
| `comments` | [`eslint-plugin-eslint-comments`](https://www.npmjs.com/package/eslint-plugin-eslint-comments) | no (built-in) |
|
|
98
|
+
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
|
|
99
|
+
| `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
|
|
100
|
+
| `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
|
|
97
101
|
|
|
98
102
|
You can use `import` syntax:
|
|
99
103
|
|
|
@@ -107,7 +111,7 @@ export default defineConfig(
|
|
|
107
111
|
)
|
|
108
112
|
```
|
|
109
113
|
|
|
110
|
-
## âī¸ Comparing to [`@antfu/eslint-config`](https://github.com/antfu/eslint-config)
|
|
114
|
+
## âī¸ Comparing to [`@antfu/eslint-config`](https://github.com/antfu/eslint-config) and others
|
|
111
115
|
|
|
112
116
|
- Respect the recommended config by the eslint plugin in built-in configurations
|
|
113
117
|
- Customization is overriding it only
|
|
@@ -124,3 +128,12 @@ Thank you! â¤ī¸
|
|
|
124
128
|
## ÂŠī¸ License
|
|
125
129
|
|
|
126
130
|
[MIT](http://opensource.org/licenses/MIT)
|
|
131
|
+
|
|
132
|
+
<!-- Badges -->
|
|
133
|
+
|
|
134
|
+
[npm-version-src]: https://img.shields.io/npm/v/@kazupon/eslint-config?style=flat
|
|
135
|
+
[npm-version-href]: https://npmjs.com/package/@kazupon/eslint-config
|
|
136
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@kazupon/eslint-config?style=flat
|
|
137
|
+
[npm-downloads-href]: https://npmjs.com/package/@kazupon/eslint-config
|
|
138
|
+
[ci-src]: https://github.com/kazupon/eslint-config/actions/workflows/ci.yml/badge.svg
|
|
139
|
+
[ci-href]: https://github.com/kazupon/eslint-config/actions/workflows/ci.yml
|
package/dist/configs/index.d.cts
CHANGED
package/dist/configs/index.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions } from '../types';
|
|
3
|
+
import type { TypeScriptOptions } from './typescript';
|
|
4
|
+
export interface VueScriptOptions {
|
|
5
|
+
typescript?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function vue(options?: ((VueScriptOptions) & (TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions } from '../types';
|
|
3
|
+
import type { TypeScriptOptions } from './typescript';
|
|
4
|
+
export interface VueScriptOptions {
|
|
5
|
+
typescript?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function vue(options?: ((VueScriptOptions) & (TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
|
package/dist/globs.d.cts
CHANGED
package/dist/globs.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -7,12 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all) __defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
10
|
var __copyProps = (to, from, except, desc) => {
|
|
17
11
|
if (from && typeof from === 'object' || typeof from === 'function') for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
12
|
key = keys[i];
|
|
@@ -27,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
21
|
value: mod,
|
|
28
22
|
enumerable: true
|
|
29
23
|
}) : target, mod));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', {value: true}), mod);
|
|
31
24
|
|
|
32
25
|
//#endregion
|
|
33
26
|
const { FlatConfigComposer } = __toESM(require("eslint-flat-config-utils"));
|
|
@@ -43,7 +36,7 @@ function defineConfig(...configs) {
|
|
|
43
36
|
//#region src/utils.ts
|
|
44
37
|
async function interopDefault(mod) {
|
|
45
38
|
const resolved = await mod;
|
|
46
|
-
return resolved.default || resolved;
|
|
39
|
+
return (resolved).default || resolved;
|
|
47
40
|
}
|
|
48
41
|
async function loadPlugin(name) {
|
|
49
42
|
try {
|
|
@@ -61,7 +54,7 @@ async function javascript(options = {}) {
|
|
|
61
54
|
const js = await loadPlugin('@eslint/js');
|
|
62
55
|
return [{
|
|
63
56
|
name: 'eslint/defaults/rules',
|
|
64
|
-
...js.configs.recommended
|
|
57
|
+
...(js.configs.recommended)
|
|
65
58
|
}, {
|
|
66
59
|
name: '@kazupon/javascript/@eslint/js',
|
|
67
60
|
languageOptions: {
|
|
@@ -86,29 +79,45 @@ async function javascript(options = {}) {
|
|
|
86
79
|
}];
|
|
87
80
|
}
|
|
88
81
|
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/configs/comments.ts
|
|
84
|
+
async function comments(options = {}) {
|
|
85
|
+
const { rules: overrideRules = {} } = options;
|
|
86
|
+
const comments$1 = await loadPlugin('eslint-plugin-eslint-comments');
|
|
87
|
+
return [{
|
|
88
|
+
name: 'eslint-comments/recommended',
|
|
89
|
+
plugins: {'eslint-comments': comments$1},
|
|
90
|
+
rules: {...(comments$1.configs.recommended.rules)}
|
|
91
|
+
}, {
|
|
92
|
+
name: '@kazupon/eslint-comments',
|
|
93
|
+
rules: {...overrideRules}
|
|
94
|
+
}];
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
//#endregion
|
|
90
98
|
//#region src/globs.ts
|
|
91
99
|
const GLOB_JS = '**/*.?([cm])js';
|
|
92
100
|
const GLOB_JSX = '**/*.?([cm])jsx';
|
|
93
101
|
const GLOB_TS = '**/*.?([cm])ts';
|
|
94
102
|
const GLOB_TSX = '**/*.?([cm])tsx';
|
|
103
|
+
const GLOB_VUE = '**/*.vue';
|
|
95
104
|
|
|
96
105
|
//#endregion
|
|
97
106
|
//#region src/configs/typescript.ts
|
|
98
107
|
async function typescript(options = {}) {
|
|
99
108
|
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
|
|
100
109
|
const ts = await loadPlugin('typescript-eslint');
|
|
101
|
-
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) =>
|
|
102
|
-
return [...ts.configs.recommendedTypeChecked, {
|
|
110
|
+
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
|
|
111
|
+
return [...(ts.configs.recommendedTypeChecked), {
|
|
103
112
|
files: [GLOB_JS, GLOB_JSX],
|
|
104
|
-
...ts.configs.disableTypeChecked
|
|
113
|
+
...(ts.configs.disableTypeChecked)
|
|
105
114
|
}, {
|
|
106
115
|
name: '@kazupon/typescipt/typescript-eslint',
|
|
107
116
|
files,
|
|
108
117
|
languageOptions: {
|
|
109
118
|
parser: ts.parser,
|
|
110
119
|
parserOptions: {
|
|
111
|
-
extraFileExtensions: extraFileExtensions.map((ext) =>
|
|
120
|
+
extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
|
|
112
121
|
sourceType: 'module',
|
|
113
122
|
...parserOptions
|
|
114
123
|
}
|
|
@@ -140,14 +149,41 @@ async function prettier(options = {}) {
|
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
//#endregion
|
|
143
|
-
//#region src/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
//#region src/configs/vue.ts
|
|
153
|
+
async function vue(options = {}) {
|
|
154
|
+
const { rules: overrideRules = {}, parserOptions = {project: true} } = options;
|
|
155
|
+
const useTypeScript = !!options.typescript;
|
|
156
|
+
const vue$1 = await loadPlugin('eslint-plugin-vue');
|
|
157
|
+
const vueParser = vue$1.configs['flat/base'][1]['languageOptions']['parser'];
|
|
158
|
+
async function getTypeScriptParser() {
|
|
159
|
+
const ts = await loadPlugin('typescript-eslint');
|
|
160
|
+
return ts.parser;
|
|
161
|
+
}
|
|
162
|
+
const customConfig = {
|
|
163
|
+
name: '@kazupon/vue',
|
|
164
|
+
files: [GLOB_VUE],
|
|
165
|
+
rules: {...overrideRules}
|
|
166
|
+
};
|
|
167
|
+
if (useTypeScript) {
|
|
168
|
+
customConfig.languageOptions = {
|
|
169
|
+
parser: vueParser,
|
|
170
|
+
parserOptions: {
|
|
171
|
+
sourceType: 'module',
|
|
172
|
+
parser: await getTypeScriptParser(),
|
|
173
|
+
ecmaFeatures: {jsx: true},
|
|
174
|
+
extraFileExtensions: ['.vue'],
|
|
175
|
+
...parserOptions
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return [...(vue$1.configs['flat/recommended']), customConfig];
|
|
180
|
+
}
|
|
151
181
|
|
|
152
182
|
//#endregion
|
|
153
|
-
|
|
183
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
184
|
+
exports.comments = comments;
|
|
185
|
+
exports.defineConfig = defineConfig;
|
|
186
|
+
exports.javascript = javascript;
|
|
187
|
+
exports.prettier = prettier;
|
|
188
|
+
exports.typescript = typescript;
|
|
189
|
+
exports.vue = vue;
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ function defineConfig(...configs) {
|
|
|
11
11
|
//#region src/utils.ts
|
|
12
12
|
async function interopDefault(mod) {
|
|
13
13
|
const resolved = await mod;
|
|
14
|
-
return resolved.default || resolved;
|
|
14
|
+
return (resolved).default || resolved;
|
|
15
15
|
}
|
|
16
16
|
async function loadPlugin(name) {
|
|
17
17
|
try {
|
|
@@ -29,7 +29,7 @@ async function javascript(options = {}) {
|
|
|
29
29
|
const js = await loadPlugin('@eslint/js');
|
|
30
30
|
return [{
|
|
31
31
|
name: 'eslint/defaults/rules',
|
|
32
|
-
...js.configs.recommended
|
|
32
|
+
...(js.configs.recommended)
|
|
33
33
|
}, {
|
|
34
34
|
name: '@kazupon/javascript/@eslint/js',
|
|
35
35
|
languageOptions: {
|
|
@@ -54,29 +54,45 @@ async function javascript(options = {}) {
|
|
|
54
54
|
}];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/configs/comments.ts
|
|
59
|
+
async function comments(options = {}) {
|
|
60
|
+
const { rules: overrideRules = {} } = options;
|
|
61
|
+
const comments$1 = await loadPlugin('eslint-plugin-eslint-comments');
|
|
62
|
+
return [{
|
|
63
|
+
name: 'eslint-comments/recommended',
|
|
64
|
+
plugins: {'eslint-comments': comments$1},
|
|
65
|
+
rules: {...(comments$1.configs.recommended.rules)}
|
|
66
|
+
}, {
|
|
67
|
+
name: '@kazupon/eslint-comments',
|
|
68
|
+
rules: {...overrideRules}
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
//#endregion
|
|
58
73
|
//#region src/globs.ts
|
|
59
74
|
const GLOB_JS = '**/*.?([cm])js';
|
|
60
75
|
const GLOB_JSX = '**/*.?([cm])jsx';
|
|
61
76
|
const GLOB_TS = '**/*.?([cm])ts';
|
|
62
77
|
const GLOB_TSX = '**/*.?([cm])tsx';
|
|
78
|
+
const GLOB_VUE = '**/*.vue';
|
|
63
79
|
|
|
64
80
|
//#endregion
|
|
65
81
|
//#region src/configs/typescript.ts
|
|
66
82
|
async function typescript(options = {}) {
|
|
67
83
|
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
|
|
68
84
|
const ts = await loadPlugin('typescript-eslint');
|
|
69
|
-
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) =>
|
|
70
|
-
return [...ts.configs.recommendedTypeChecked, {
|
|
85
|
+
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
|
|
86
|
+
return [...(ts.configs.recommendedTypeChecked), {
|
|
71
87
|
files: [GLOB_JS, GLOB_JSX],
|
|
72
|
-
...ts.configs.disableTypeChecked
|
|
88
|
+
...(ts.configs.disableTypeChecked)
|
|
73
89
|
}, {
|
|
74
90
|
name: '@kazupon/typescipt/typescript-eslint',
|
|
75
91
|
files,
|
|
76
92
|
languageOptions: {
|
|
77
93
|
parser: ts.parser,
|
|
78
94
|
parserOptions: {
|
|
79
|
-
extraFileExtensions: extraFileExtensions.map((ext) =>
|
|
95
|
+
extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
|
|
80
96
|
sourceType: 'module',
|
|
81
97
|
...parserOptions
|
|
82
98
|
}
|
|
@@ -108,4 +124,35 @@ async function prettier(options = {}) {
|
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
//#endregion
|
|
111
|
-
|
|
127
|
+
//#region src/configs/vue.ts
|
|
128
|
+
async function vue(options = {}) {
|
|
129
|
+
const { rules: overrideRules = {}, parserOptions = {project: true} } = options;
|
|
130
|
+
const useTypeScript = !!options.typescript;
|
|
131
|
+
const vue$1 = await loadPlugin('eslint-plugin-vue');
|
|
132
|
+
const vueParser = vue$1.configs['flat/base'][1]['languageOptions']['parser'];
|
|
133
|
+
async function getTypeScriptParser() {
|
|
134
|
+
const ts = await loadPlugin('typescript-eslint');
|
|
135
|
+
return ts.parser;
|
|
136
|
+
}
|
|
137
|
+
const customConfig = {
|
|
138
|
+
name: '@kazupon/vue',
|
|
139
|
+
files: [GLOB_VUE],
|
|
140
|
+
rules: {...overrideRules}
|
|
141
|
+
};
|
|
142
|
+
if (useTypeScript) {
|
|
143
|
+
customConfig.languageOptions = {
|
|
144
|
+
parser: vueParser,
|
|
145
|
+
parserOptions: {
|
|
146
|
+
sourceType: 'module',
|
|
147
|
+
parser: await getTypeScriptParser(),
|
|
148
|
+
ecmaFeatures: {jsx: true},
|
|
149
|
+
extraFileExtensions: ['.vue'],
|
|
150
|
+
...parserOptions
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return [...(vue$1.configs['flat/recommended']), customConfig];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
export { comments, defineConfig, javascript, prettier, typescript, vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kazupon/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "ESLint config for @kazupon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@eslint/js": "^9.0.0",
|
|
40
40
|
"eslint-flat-config-utils": "^0.2.5",
|
|
41
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
41
42
|
"globals": "^15.8.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"eslint": ">=8.56.0 || >=9.0.0",
|
|
45
46
|
"typescript-eslint": ">=7.0.0",
|
|
46
|
-
"eslint-config-prettier": ">=9.1.0"
|
|
47
|
+
"eslint-config-prettier": ">=9.1.0",
|
|
48
|
+
"eslint-plugin-vue": ">=9.24.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependenciesMeta": {
|
|
49
51
|
"typescript-eslint": {
|
|
@@ -51,6 +53,9 @@
|
|
|
51
53
|
},
|
|
52
54
|
"eslint-config-prettier": {
|
|
53
55
|
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"eslint-plugin-vue": {
|
|
58
|
+
"optional": true
|
|
54
59
|
}
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|
|
@@ -60,6 +65,7 @@
|
|
|
60
65
|
"bumpp": "^9.4.1",
|
|
61
66
|
"eslint": "^9.6.0",
|
|
62
67
|
"eslint-config-prettier": "^9.1.0",
|
|
68
|
+
"eslint-plugin-vue": "^9.27.0",
|
|
63
69
|
"gh-changelogen": "^0.2.8",
|
|
64
70
|
"lint-staged": "^15.2.7",
|
|
65
71
|
"npm-run-all2": "^6.2.2",
|