@kazupon/eslint-config 0.1.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/LICENSE +20 -0
- package/README.md +126 -0
- package/dist/config.d.cts +4 -0
- package/dist/config.d.ts +4 -0
- package/dist/configs/index.d.cts +3 -0
- package/dist/configs/index.d.ts +3 -0
- package/dist/configs/javascript.d.cts +4 -0
- package/dist/configs/javascript.d.ts +4 -0
- package/dist/configs/prettier.d.cts +4 -0
- package/dist/configs/prettier.d.ts +4 -0
- package/dist/configs/typescript.d.cts +11 -0
- package/dist/configs/typescript.d.ts +11 -0
- package/dist/globs.d.cts +4 -0
- package/dist/globs.d.ts +4 -0
- package/dist/index.cjs +153 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +111 -0
- package/dist/utils.d.cts +4 -0
- package/dist/utils.d.ts +4 -0
- package/package.json +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 kazuya kawaguchi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @kazupon/eslint-config
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
ESLint config for @kazupon
|
|
7
|
+
|
|
8
|
+
## 🌟 Features
|
|
9
|
+
|
|
10
|
+
- Flat configuration via `defineConfig` like [vite](https://vitejs.dev/config/)
|
|
11
|
+
- Support built-in configurations
|
|
12
|
+
- `javascript`
|
|
13
|
+
- `typescript`
|
|
14
|
+
- `prettier`
|
|
15
|
+
- Support primitive eslint flat configuration
|
|
16
|
+
- Support overrides for built-in configurations
|
|
17
|
+
- `rules`
|
|
18
|
+
|
|
19
|
+
## 💿 Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm i -D @kazupon/eslint-config
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 🚀 Usage
|
|
26
|
+
|
|
27
|
+
### Configurations
|
|
28
|
+
|
|
29
|
+
Add create `eslint.config.mjs` in your project root:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// eslint.config.mjs
|
|
33
|
+
import { defineConfig, javascript } from '@kazupon/eslint-config'
|
|
34
|
+
|
|
35
|
+
// You can put flat configurations (`Linter.FlatConfig | Linter.FlatConfig[]`)
|
|
36
|
+
export default defineConfig(
|
|
37
|
+
// built-in configurations
|
|
38
|
+
javascript({
|
|
39
|
+
// override rules
|
|
40
|
+
rules: {
|
|
41
|
+
'no-console': 'error'
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
// You can put primitive flat configuration, and override it!
|
|
45
|
+
{
|
|
46
|
+
ignores: ['**/dist/**' /* something ignores ... */]
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> [!IMPORTANT]
|
|
52
|
+
> Support flat configuration only, **not supported Legacy style (`.eslintrc`)**
|
|
53
|
+
|
|
54
|
+
### Lint with npm scripts `package.json`
|
|
55
|
+
|
|
56
|
+
For example:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"scripts": {
|
|
61
|
+
"lint": "eslint .",
|
|
62
|
+
"lint:fix": "eslint . --fix"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Lint with VS Code `settings.json`
|
|
68
|
+
|
|
69
|
+
You can lint and auto fix.
|
|
70
|
+
|
|
71
|
+
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
|
|
72
|
+
|
|
73
|
+
Add the following settings to your `.vscode/settings.json`:
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{
|
|
77
|
+
// Auto fix
|
|
78
|
+
"editor.codeActionsOnSave": {
|
|
79
|
+
"source.fixAll.eslint": "explicit"
|
|
80
|
+
},
|
|
81
|
+
// Enable eslint for supported languages
|
|
82
|
+
"eslint.validate": ["javascript", "typescript"],
|
|
83
|
+
// Enable flat configuration
|
|
84
|
+
"eslint.experimental.useFlatConfig": true
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 🔨Built-in configurations
|
|
89
|
+
|
|
90
|
+
The following built-in configurations are supported:
|
|
91
|
+
|
|
92
|
+
| Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
|
|
93
|
+
| ------------- | -------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
94
|
+
| `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
|
|
95
|
+
| `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
|
|
96
|
+
| `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
|
|
97
|
+
|
|
98
|
+
You can use `import` syntax:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import { defineConfig, javascript, typescript } from '@kazupon/eslint-config'
|
|
102
|
+
|
|
103
|
+
export default defineConfig(
|
|
104
|
+
javascript(/* ... */),
|
|
105
|
+
typescript(/* ... */)
|
|
106
|
+
// ...
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## ⚖️ Comparing to [`@antfu/eslint-config`](https://github.com/antfu/eslint-config) an others
|
|
111
|
+
|
|
112
|
+
- Respect the recommended config by the eslint plugin in built-in configurations
|
|
113
|
+
- Customization is overriding it only
|
|
114
|
+
|
|
115
|
+
## 💖 Credit
|
|
116
|
+
|
|
117
|
+
This eslint config is inspired by:
|
|
118
|
+
|
|
119
|
+
- [`@antfu/eslint-config`](https://github.com/antfu/eslint-config), created by [Anthony Fu](https://github.com/antfu)
|
|
120
|
+
- [`@sxzz/eslint-config`](https://github.com/sxzz/eslint-config), created by [Kevin Deng 三咲智子](https://github.com/sxzz)
|
|
121
|
+
|
|
122
|
+
Thank you! ❤️
|
|
123
|
+
|
|
124
|
+
## ©️ License
|
|
125
|
+
|
|
126
|
+
[MIT](http://opensource.org/licenses/MIT)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
import type { Awaitable } from './types';
|
|
4
|
+
export declare function defineConfig(...configs: (Awaitable<((Linter.FlatConfig) | ((Linter.FlatConfig)[]))>)[]): FlatConfigComposer;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
import type { Awaitable } from './types';
|
|
4
|
+
export declare function defineConfig(...configs: (Awaitable<((Linter.FlatConfig) | ((Linter.FlatConfig)[]))>)[]): FlatConfigComposer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions } from '../types';
|
|
3
|
+
export interface TypeScriptOptions {
|
|
4
|
+
extraFileExtensions?: (string)[];
|
|
5
|
+
parserOptions?: TypeScriptParserOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface TypeScriptParserOptions {
|
|
8
|
+
project?: ((boolean) | (string) | ((string)[]));
|
|
9
|
+
tsconfigRootDir?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function typescript(options?: ((TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { OverridesOptions } from '../types';
|
|
3
|
+
export interface TypeScriptOptions {
|
|
4
|
+
extraFileExtensions?: (string)[];
|
|
5
|
+
parserOptions?: TypeScriptParserOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface TypeScriptParserOptions {
|
|
8
|
+
project?: ((boolean) | (string) | ((string)[]));
|
|
9
|
+
tsconfigRootDir?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function typescript(options?: ((TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
|
package/dist/globs.d.cts
ADDED
package/dist/globs.d.ts
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === 'object' || typeof from === 'function') for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
+
key = keys[i];
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, 'default', {
|
|
27
|
+
value: mod,
|
|
28
|
+
enumerable: true
|
|
29
|
+
}) : target, mod));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', {value: true}), mod);
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
const { FlatConfigComposer } = __toESM(require("eslint-flat-config-utils"));
|
|
34
|
+
const { default: globals } = __toESM(require("globals"));
|
|
35
|
+
|
|
36
|
+
//#region src/config.ts
|
|
37
|
+
function defineConfig(...configs) {
|
|
38
|
+
const baseConfigs = [];
|
|
39
|
+
return new FlatConfigComposer().append(...baseConfigs, ...configs);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/utils.ts
|
|
44
|
+
async function interopDefault(mod) {
|
|
45
|
+
const resolved = await mod;
|
|
46
|
+
return resolved.default || resolved;
|
|
47
|
+
}
|
|
48
|
+
async function loadPlugin(name) {
|
|
49
|
+
try {
|
|
50
|
+
return interopDefault(import(name));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error(e);
|
|
53
|
+
throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/configs/javascript.ts
|
|
59
|
+
async function javascript(options = {}) {
|
|
60
|
+
const { rules: overrideRules = {} } = options;
|
|
61
|
+
const js = await loadPlugin('@eslint/js');
|
|
62
|
+
return [{
|
|
63
|
+
name: 'eslint/defaults/rules',
|
|
64
|
+
...js.configs.recommended
|
|
65
|
+
}, {
|
|
66
|
+
name: '@kazupon/javascript/@eslint/js',
|
|
67
|
+
languageOptions: {
|
|
68
|
+
ecmaVersion: 2022,
|
|
69
|
+
globals: {
|
|
70
|
+
...globals.browser,
|
|
71
|
+
...globals.node,
|
|
72
|
+
...globals.es2022,
|
|
73
|
+
document: 'readonly',
|
|
74
|
+
navigator: 'readonly',
|
|
75
|
+
window: 'readonly'
|
|
76
|
+
},
|
|
77
|
+
parserOptions: {
|
|
78
|
+
ecmaFeatures: {jsx: true},
|
|
79
|
+
ecmaVersion: 2022,
|
|
80
|
+
sourceType: 'module'
|
|
81
|
+
},
|
|
82
|
+
sourceType: 'module'
|
|
83
|
+
},
|
|
84
|
+
linterOptions: {reportUnusedDisableDirectives: true},
|
|
85
|
+
rules: {...overrideRules}
|
|
86
|
+
}];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/globs.ts
|
|
91
|
+
const GLOB_JS = '**/*.?([cm])js';
|
|
92
|
+
const GLOB_JSX = '**/*.?([cm])jsx';
|
|
93
|
+
const GLOB_TS = '**/*.?([cm])ts';
|
|
94
|
+
const GLOB_TSX = '**/*.?([cm])tsx';
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/configs/typescript.ts
|
|
98
|
+
async function typescript(options = {}) {
|
|
99
|
+
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
|
|
100
|
+
const ts = await loadPlugin('typescript-eslint');
|
|
101
|
+
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*.${ext}`)];
|
|
102
|
+
return [...ts.configs.recommendedTypeChecked, {
|
|
103
|
+
files: [GLOB_JS, GLOB_JSX],
|
|
104
|
+
...ts.configs.disableTypeChecked
|
|
105
|
+
}, {
|
|
106
|
+
name: '@kazupon/typescipt/typescript-eslint',
|
|
107
|
+
files,
|
|
108
|
+
languageOptions: {
|
|
109
|
+
parser: ts.parser,
|
|
110
|
+
parserOptions: {
|
|
111
|
+
extraFileExtensions: extraFileExtensions.map((ext) => `.${ext}`),
|
|
112
|
+
sourceType: 'module',
|
|
113
|
+
...parserOptions
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
rules: {
|
|
117
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
118
|
+
args: 'all',
|
|
119
|
+
argsIgnorePattern: '^_',
|
|
120
|
+
caughtErrors: 'all',
|
|
121
|
+
caughtErrorsIgnorePattern: '^_',
|
|
122
|
+
destructuredArrayIgnorePattern: '^_',
|
|
123
|
+
varsIgnorePattern: '^_',
|
|
124
|
+
ignoreRestSiblings: true
|
|
125
|
+
}],
|
|
126
|
+
...overrideRules
|
|
127
|
+
}
|
|
128
|
+
}];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/configs/prettier.ts
|
|
133
|
+
async function prettier(options = {}) {
|
|
134
|
+
const { rules: overrideRules = {} } = options;
|
|
135
|
+
const prettier$1 = await loadPlugin('eslint-config-prettier');
|
|
136
|
+
return [prettier$1, {
|
|
137
|
+
name: '@kazupon/prettier',
|
|
138
|
+
rules: {...overrideRules}
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/index.ts
|
|
144
|
+
var src_index_ns = {};
|
|
145
|
+
__export(src_index_ns, {
|
|
146
|
+
defineConfig: () => defineConfig,
|
|
147
|
+
javascript: () => javascript,
|
|
148
|
+
prettier: () => prettier,
|
|
149
|
+
typescript: () => typescript
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
module.exports = __toCommonJS(src_index_ns)
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
+
import { default as globals } from "globals";
|
|
3
|
+
|
|
4
|
+
//#region src/config.ts
|
|
5
|
+
function defineConfig(...configs) {
|
|
6
|
+
const baseConfigs = [];
|
|
7
|
+
return new FlatConfigComposer().append(...baseConfigs, ...configs);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/utils.ts
|
|
12
|
+
async function interopDefault(mod) {
|
|
13
|
+
const resolved = await mod;
|
|
14
|
+
return resolved.default || resolved;
|
|
15
|
+
}
|
|
16
|
+
async function loadPlugin(name) {
|
|
17
|
+
try {
|
|
18
|
+
return interopDefault(import(name));
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/configs/javascript.ts
|
|
27
|
+
async function javascript(options = {}) {
|
|
28
|
+
const { rules: overrideRules = {} } = options;
|
|
29
|
+
const js = await loadPlugin('@eslint/js');
|
|
30
|
+
return [{
|
|
31
|
+
name: 'eslint/defaults/rules',
|
|
32
|
+
...js.configs.recommended
|
|
33
|
+
}, {
|
|
34
|
+
name: '@kazupon/javascript/@eslint/js',
|
|
35
|
+
languageOptions: {
|
|
36
|
+
ecmaVersion: 2022,
|
|
37
|
+
globals: {
|
|
38
|
+
...globals.browser,
|
|
39
|
+
...globals.node,
|
|
40
|
+
...globals.es2022,
|
|
41
|
+
document: 'readonly',
|
|
42
|
+
navigator: 'readonly',
|
|
43
|
+
window: 'readonly'
|
|
44
|
+
},
|
|
45
|
+
parserOptions: {
|
|
46
|
+
ecmaFeatures: {jsx: true},
|
|
47
|
+
ecmaVersion: 2022,
|
|
48
|
+
sourceType: 'module'
|
|
49
|
+
},
|
|
50
|
+
sourceType: 'module'
|
|
51
|
+
},
|
|
52
|
+
linterOptions: {reportUnusedDisableDirectives: true},
|
|
53
|
+
rules: {...overrideRules}
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/globs.ts
|
|
59
|
+
const GLOB_JS = '**/*.?([cm])js';
|
|
60
|
+
const GLOB_JSX = '**/*.?([cm])jsx';
|
|
61
|
+
const GLOB_TS = '**/*.?([cm])ts';
|
|
62
|
+
const GLOB_TSX = '**/*.?([cm])tsx';
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/configs/typescript.ts
|
|
66
|
+
async function typescript(options = {}) {
|
|
67
|
+
const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
|
|
68
|
+
const ts = await loadPlugin('typescript-eslint');
|
|
69
|
+
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*.${ext}`)];
|
|
70
|
+
return [...ts.configs.recommendedTypeChecked, {
|
|
71
|
+
files: [GLOB_JS, GLOB_JSX],
|
|
72
|
+
...ts.configs.disableTypeChecked
|
|
73
|
+
}, {
|
|
74
|
+
name: '@kazupon/typescipt/typescript-eslint',
|
|
75
|
+
files,
|
|
76
|
+
languageOptions: {
|
|
77
|
+
parser: ts.parser,
|
|
78
|
+
parserOptions: {
|
|
79
|
+
extraFileExtensions: extraFileExtensions.map((ext) => `.${ext}`),
|
|
80
|
+
sourceType: 'module',
|
|
81
|
+
...parserOptions
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
rules: {
|
|
85
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
86
|
+
args: 'all',
|
|
87
|
+
argsIgnorePattern: '^_',
|
|
88
|
+
caughtErrors: 'all',
|
|
89
|
+
caughtErrorsIgnorePattern: '^_',
|
|
90
|
+
destructuredArrayIgnorePattern: '^_',
|
|
91
|
+
varsIgnorePattern: '^_',
|
|
92
|
+
ignoreRestSiblings: true
|
|
93
|
+
}],
|
|
94
|
+
...overrideRules
|
|
95
|
+
}
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/configs/prettier.ts
|
|
101
|
+
async function prettier(options = {}) {
|
|
102
|
+
const { rules: overrideRules = {} } = options;
|
|
103
|
+
const prettier$1 = await loadPlugin('eslint-config-prettier');
|
|
104
|
+
return [prettier$1, {
|
|
105
|
+
name: '@kazupon/prettier',
|
|
106
|
+
rules: {...overrideRules}
|
|
107
|
+
}];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { defineConfig, javascript, prettier, typescript };
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Awaitable, InteropModuleDefault } from './types';
|
|
2
|
+
export declare function toArray<T>(value: ((T) | ((T)[]))): (T)[];
|
|
3
|
+
export declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
|
|
4
|
+
export declare function loadPlugin<T = unknown>(name: string): Promise<T>;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Awaitable, InteropModuleDefault } from './types';
|
|
2
|
+
export declare function toArray<T>(value: ((T) | ((T)[]))): (T)[];
|
|
3
|
+
export declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
|
|
4
|
+
export declare function loadPlugin<T = unknown>(name: string): Promise<T>;
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kazupon/eslint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ESLint config for @kazupon",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"config",
|
|
7
|
+
"eslint"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"funding": "https://github.com/sponsors/kazupon",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/kazupon/eslint-config/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/kazupon/eslint-config.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/kazupon/eslint-config#readme",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">= 18.18"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@eslint/js": "^9.0.0",
|
|
40
|
+
"eslint-flat-config-utils": "^0.2.5",
|
|
41
|
+
"globals": "^15.8.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"eslint": ">=8.56.0 || >=9.0.0",
|
|
45
|
+
"typescript-eslint": ">=7.0.0",
|
|
46
|
+
"eslint-config-prettier": ">=9.1.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"typescript-eslint": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"eslint-config-prettier": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@kazupon/prettier-config": "^0.1.1",
|
|
58
|
+
"@types/eslint": "^8.56.10",
|
|
59
|
+
"@types/node": "^20.14.9",
|
|
60
|
+
"bumpp": "^9.4.1",
|
|
61
|
+
"eslint": "^9.6.0",
|
|
62
|
+
"eslint-config-prettier": "^9.1.0",
|
|
63
|
+
"gh-changelogen": "^0.2.8",
|
|
64
|
+
"lint-staged": "^15.2.7",
|
|
65
|
+
"npm-run-all2": "^6.2.2",
|
|
66
|
+
"prettier": "^3.3.2",
|
|
67
|
+
"tsdown": "^0.2.3",
|
|
68
|
+
"tsx": "^4.16.2",
|
|
69
|
+
"typescript": "^5.5.3",
|
|
70
|
+
"typescript-eslint": "^7.15.0"
|
|
71
|
+
},
|
|
72
|
+
"lint-staged": {
|
|
73
|
+
"*.{json,md,yml}": [
|
|
74
|
+
"prettier --write"
|
|
75
|
+
],
|
|
76
|
+
"*.{js,mjs,cjs}": [
|
|
77
|
+
"prettier --write",
|
|
78
|
+
"eslint --fix"
|
|
79
|
+
],
|
|
80
|
+
"*.ts?(x)": [
|
|
81
|
+
"prettier --parser=typescript --write",
|
|
82
|
+
"eslint --fix"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"prettier": "@kazupon/prettier-config",
|
|
86
|
+
"scripts": {
|
|
87
|
+
"changelog": "gh-changelogen --repo=kazupon/eslint-config",
|
|
88
|
+
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
89
|
+
"lint": "run-p \"lint:* {@}\" --",
|
|
90
|
+
"lint:prettier": "prettier . --check",
|
|
91
|
+
"lint:eslint": "eslint .",
|
|
92
|
+
"fix": "run-p \"fix:* {@}\" --",
|
|
93
|
+
"fix:prettier": "prettier . --write",
|
|
94
|
+
"fix:eslint": "eslint . --fix",
|
|
95
|
+
"dev": "pnpx @eslint/config-inspector --config eslint.config.ts",
|
|
96
|
+
"build": "tsdown",
|
|
97
|
+
"build:inspector": "pnpm build && pnpx @eslint/config-inspector build",
|
|
98
|
+
"typecheck": "tsc -p ."
|
|
99
|
+
}
|
|
100
|
+
}
|