@daopk/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/dist/index.d.ts +5586 -5721
- package/dist/index.js +201 -181
- package/package.json +19 -19
package/dist/index.js
CHANGED
|
@@ -1,207 +1,227 @@
|
|
|
1
|
-
// src/configs/antfu.ts
|
|
2
1
|
import antfuPlugin from "eslint-plugin-antfu";
|
|
2
|
+
import gitignore from "eslint-config-flat-gitignore";
|
|
3
|
+
import importX from "eslint-plugin-import-x";
|
|
4
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
5
|
+
import nodePlugin from "eslint-plugin-n";
|
|
6
|
+
import perfectionistPlugin from "eslint-plugin-perfectionist";
|
|
7
|
+
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
8
|
+
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
|
|
9
|
+
import tsParser from "@typescript-eslint/parser";
|
|
10
|
+
|
|
11
|
+
//#region src/configs/antfu.ts
|
|
3
12
|
function antfu() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
};
|
|
13
|
+
return {
|
|
14
|
+
name: "daopk/antfu",
|
|
15
|
+
plugins: { antfu: antfuPlugin },
|
|
16
|
+
rules: {
|
|
17
|
+
"antfu/consistent-chaining": "error",
|
|
18
|
+
"antfu/consistent-list-newline": "error",
|
|
19
|
+
"antfu/import-dedupe": "error"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/configs/builtin.ts
|
|
18
26
|
function builtin() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
27
|
+
return {
|
|
28
|
+
name: "daopk/eslint",
|
|
29
|
+
rules: {
|
|
30
|
+
"eqeqeq": "error",
|
|
31
|
+
"no-cond-assign": ["error", "always"],
|
|
32
|
+
"no-extra-boolean-cast": "error",
|
|
33
|
+
"no-regex-spaces": "error",
|
|
34
|
+
"no-unused-labels": "error",
|
|
35
|
+
"no-unused-vars": "off",
|
|
36
|
+
"yoda": ["error", "never"]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/configs/ignores.ts
|
|
36
43
|
function ignores(userIgnores = []) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...userIgnores ?? []
|
|
42
|
-
]
|
|
43
|
-
};
|
|
44
|
+
return {
|
|
45
|
+
name: "daopk/ignores",
|
|
46
|
+
ignores: [...gitignore().ignores, ...userIgnores ?? []]
|
|
47
|
+
};
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import unusedImports from "eslint-plugin-unused-imports";
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/configs/imports.ts
|
|
49
52
|
function imports() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
};
|
|
53
|
+
return {
|
|
54
|
+
name: "daopk/imports",
|
|
55
|
+
plugins: {
|
|
56
|
+
"import": importX,
|
|
57
|
+
"unused-imports": unusedImports
|
|
58
|
+
},
|
|
59
|
+
rules: {
|
|
60
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
61
|
+
"import/first": "error",
|
|
62
|
+
"import/no-duplicates": "error",
|
|
63
|
+
"import/no-mutable-exports": "error",
|
|
64
|
+
"import/no-named-default": "error",
|
|
65
|
+
"import/no-self-import": "error",
|
|
66
|
+
"import/no-webpack-loader-syntax": "error",
|
|
67
|
+
"unused-imports/no-unused-imports": "error",
|
|
68
|
+
"unused-imports/no-unused-vars": ["warn", {
|
|
69
|
+
args: "after-used",
|
|
70
|
+
argsIgnorePattern: "^_",
|
|
71
|
+
vars: "all",
|
|
72
|
+
varsIgnorePattern: "^_"
|
|
73
|
+
}]
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/configs/node.ts
|
|
80
80
|
function node() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
rules: {
|
|
87
|
-
"node/prefer-node-protocol": "error"
|
|
88
|
-
}
|
|
89
|
-
};
|
|
81
|
+
return {
|
|
82
|
+
name: "daopk/node",
|
|
83
|
+
plugins: { node: nodePlugin },
|
|
84
|
+
rules: { "node/prefer-node-protocol": "error" }
|
|
85
|
+
};
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/configs/perfectionist.ts
|
|
94
90
|
function perfectionist() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
return {
|
|
92
|
+
name: "daopk/perfectionist",
|
|
93
|
+
plugins: { perfectionist: perfectionistPlugin },
|
|
94
|
+
rules: {
|
|
95
|
+
"perfectionist/sort-exports": ["error", {
|
|
96
|
+
order: "asc",
|
|
97
|
+
type: "natural"
|
|
98
|
+
}],
|
|
99
|
+
"perfectionist/sort-imports": ["error", {
|
|
100
|
+
groups: [
|
|
101
|
+
"type",
|
|
102
|
+
[
|
|
103
|
+
"parent-type",
|
|
104
|
+
"sibling-type",
|
|
105
|
+
"index-type",
|
|
106
|
+
"internal-type"
|
|
107
|
+
],
|
|
108
|
+
"builtin",
|
|
109
|
+
"external",
|
|
110
|
+
"internal",
|
|
111
|
+
[
|
|
112
|
+
"parent",
|
|
113
|
+
"sibling",
|
|
114
|
+
"index"
|
|
115
|
+
],
|
|
116
|
+
"side-effect",
|
|
117
|
+
"object",
|
|
118
|
+
"unknown"
|
|
119
|
+
],
|
|
120
|
+
newlinesBetween: "ignore",
|
|
121
|
+
order: "asc",
|
|
122
|
+
type: "natural"
|
|
123
|
+
}],
|
|
124
|
+
"perfectionist/sort-named-exports": ["error", {
|
|
125
|
+
order: "asc",
|
|
126
|
+
type: "natural"
|
|
127
|
+
}],
|
|
128
|
+
"perfectionist/sort-named-imports": ["error", {
|
|
129
|
+
order: "asc",
|
|
130
|
+
type: "natural"
|
|
131
|
+
}]
|
|
132
|
+
}
|
|
133
|
+
};
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/configs/stylistic.ts
|
|
126
138
|
function stylistic(options = {}) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"stylistic/array-bracket-newline": ["error", "consistent"],
|
|
149
|
-
"stylistic/array-element-newline": ["error", "consistent"]
|
|
150
|
-
}
|
|
151
|
-
};
|
|
139
|
+
const stylisticConfig = stylisticPlugin.configs.customize({
|
|
140
|
+
arrowParens: options.arrowParens ?? true,
|
|
141
|
+
blockSpacing: options.blockSpacing,
|
|
142
|
+
braceStyle: options.braceStyle,
|
|
143
|
+
commaDangle: options.commaDangle,
|
|
144
|
+
indent: options.indent ?? 4,
|
|
145
|
+
jsx: options.jsx,
|
|
146
|
+
pluginName: "stylistic",
|
|
147
|
+
quoteProps: options.quoteProps,
|
|
148
|
+
quotes: options.quotes ?? "single",
|
|
149
|
+
semi: options.semi ?? false
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
name: "daopk/stylistic",
|
|
153
|
+
plugins: { stylistic: { rules: stylisticPlugin.rules } },
|
|
154
|
+
rules: {
|
|
155
|
+
...stylisticConfig.rules,
|
|
156
|
+
"stylistic/array-bracket-newline": ["error", "consistent"],
|
|
157
|
+
"stylistic/array-element-newline": ["error", "consistent"]
|
|
158
|
+
}
|
|
159
|
+
};
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
};
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/configs/typescript.ts
|
|
164
|
+
function typescript({ rules } = {}) {
|
|
165
|
+
return {
|
|
166
|
+
files: ["**/*.ts"],
|
|
167
|
+
languageOptions: {
|
|
168
|
+
ecmaVersion: "latest",
|
|
169
|
+
parser: tsParser,
|
|
170
|
+
sourceType: "module"
|
|
171
|
+
},
|
|
172
|
+
name: "daopk/typescript",
|
|
173
|
+
plugins: { typescript: typescriptPlugin },
|
|
174
|
+
rules: {
|
|
175
|
+
"typescript/consistent-type-imports": ["error", {
|
|
176
|
+
disallowTypeAnnotations: false,
|
|
177
|
+
fixStyle: "separate-type-imports",
|
|
178
|
+
prefer: "type-imports"
|
|
179
|
+
}],
|
|
180
|
+
"typescript/no-unused-vars": "off",
|
|
181
|
+
...rules
|
|
182
|
+
}
|
|
183
|
+
};
|
|
178
184
|
}
|
|
179
185
|
|
|
180
|
-
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/presets/nestjs.ts
|
|
188
|
+
function presetNestjs(options = {}) {
|
|
189
|
+
return [
|
|
190
|
+
ignores(options.ignores),
|
|
191
|
+
builtin(),
|
|
192
|
+
stylistic({
|
|
193
|
+
semi: true,
|
|
194
|
+
jsx: false,
|
|
195
|
+
...options.stylistic
|
|
196
|
+
}),
|
|
197
|
+
typescript({ rules: { "typescript/consistent-type-imports": ["warn", { prefer: "no-type-imports" }] } }),
|
|
198
|
+
imports(),
|
|
199
|
+
antfu(),
|
|
200
|
+
node(),
|
|
201
|
+
perfectionist()
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/index.ts
|
|
181
207
|
function daopk(options = {}, ...userConfigs) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
if (userConfigs.length > 0) {
|
|
201
|
-
configs.push(...userConfigs);
|
|
202
|
-
}
|
|
203
|
-
return configs;
|
|
208
|
+
const configs = [
|
|
209
|
+
ignores(options.ignores),
|
|
210
|
+
builtin(),
|
|
211
|
+
stylistic(options.stylistic),
|
|
212
|
+
typescript(),
|
|
213
|
+
imports(),
|
|
214
|
+
antfu(),
|
|
215
|
+
node(),
|
|
216
|
+
perfectionist()
|
|
217
|
+
];
|
|
218
|
+
if (options.rules) configs.push({
|
|
219
|
+
name: "daopk/rules",
|
|
220
|
+
rules: { ...options.rules }
|
|
221
|
+
});
|
|
222
|
+
if (userConfigs.length > 0) configs.push(...userConfigs);
|
|
223
|
+
return configs;
|
|
204
224
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
};
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
export { daopk as default, presetNestjs };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daopk/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "github:daopk/eslint-config",
|
|
7
7
|
"exports": {
|
|
@@ -13,31 +13,31 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@stylistic/eslint-plugin": "^
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
18
|
-
"@typescript-eslint/parser": "^8.
|
|
16
|
+
"@stylistic/eslint-plugin": "^5.3.1",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
18
|
+
"@typescript-eslint/parser": "^8.43.0",
|
|
19
19
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
20
|
-
"eslint-plugin-antfu": "^3.1.
|
|
21
|
-
"eslint-plugin-import-x": "^4.
|
|
22
|
-
"eslint-plugin-n": "^17.
|
|
23
|
-
"eslint-plugin-perfectionist": "^4.
|
|
24
|
-
"eslint-plugin-unused-imports": "^4.
|
|
20
|
+
"eslint-plugin-antfu": "^3.1.1",
|
|
21
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
22
|
+
"eslint-plugin-n": "^17.21.3",
|
|
23
|
+
"eslint-plugin-perfectionist": "^4.15.0",
|
|
24
|
+
"eslint-plugin-unused-imports": "^4.2.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@eslint/config-inspector": "^1.0
|
|
28
|
-
"@types/node": "^22.
|
|
29
|
-
"bumpp": "^10.
|
|
30
|
-
"eslint": "^9.
|
|
31
|
-
"eslint-typegen": "^2.
|
|
32
|
-
"jiti": "^2.
|
|
33
|
-
"
|
|
34
|
-
"tsx": "^4.
|
|
35
|
-
"typescript": "^5.
|
|
27
|
+
"@eslint/config-inspector": "^1.2.0",
|
|
28
|
+
"@types/node": "^22.18.1",
|
|
29
|
+
"bumpp": "^10.2.3",
|
|
30
|
+
"eslint": "^9.35.0",
|
|
31
|
+
"eslint-typegen": "^2.3.0",
|
|
32
|
+
"jiti": "^2.5.1",
|
|
33
|
+
"tsdown": "^0.15.0",
|
|
34
|
+
"tsx": "^4.20.5",
|
|
35
|
+
"typescript": "^5.9.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "eslint-config-inspector",
|
|
39
39
|
"typegen": "tsx scripts/typegen.ts",
|
|
40
|
-
"build": "pnpm typegen &&
|
|
40
|
+
"build": "pnpm typegen && tsdown",
|
|
41
41
|
"build:inspector": "pnpm build && eslint-config-inspector build",
|
|
42
42
|
"lint": "eslint .",
|
|
43
43
|
"release": "bumpp && pnpm publish"
|