@cany748/eslint-config 3.0.5 → 4.0.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/dist/index.d.ts +5450 -5569
- package/dist/index.js +1098 -1201
- package/package.json +30 -31
package/dist/index.js
CHANGED
|
@@ -1,1266 +1,1163 @@
|
|
|
1
|
-
// src/configs/comments.ts
|
|
2
1
|
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
2
|
+
import pluginPrettier from "eslint-plugin-prettier";
|
|
3
|
+
import configPrettier from "eslint-plugin-prettier/recommended";
|
|
4
|
+
import * as pluginImport from "eslint-plugin-import-x";
|
|
5
|
+
import globals from "globals";
|
|
6
|
+
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
7
|
+
import pluginNode from "eslint-plugin-n";
|
|
8
|
+
import { configs } from "eslint-plugin-regexp";
|
|
9
|
+
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
10
|
+
import { isPackageExists } from "local-pkg";
|
|
11
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
12
|
+
|
|
13
|
+
//#region src/configs/comments.ts
|
|
3
14
|
function comments() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"@eslint-community/eslint-comments/disable-enable-pair": "off"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
];
|
|
15
|
+
return [{
|
|
16
|
+
name: "@eslint-community/eslint-comments",
|
|
17
|
+
plugins: { "@eslint-community/eslint-comments": pluginComments },
|
|
18
|
+
rules: {
|
|
19
|
+
...pluginComments.configs.recommended.rules,
|
|
20
|
+
"@eslint-community/eslint-comments/disable-enable-pair": "off"
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/globs.ts
|
|
27
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
28
|
+
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
29
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
30
|
+
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
31
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
32
|
+
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
33
|
+
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
34
|
+
const GLOB_CSS = "**/*.css";
|
|
35
|
+
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
36
|
+
const GLOB_LESS = "**/*.less";
|
|
37
|
+
const GLOB_SCSS = "**/*.scss";
|
|
38
|
+
const GLOB_JSON = "**/*.json";
|
|
39
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
40
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
41
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
42
|
+
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
43
|
+
const GLOB_SVELTE = "**/*.svelte";
|
|
44
|
+
const GLOB_VUE = "**/*.vue";
|
|
45
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
46
|
+
const GLOB_TOML = "**/*.toml";
|
|
47
|
+
const GLOB_XML = "**/*.xml";
|
|
48
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
49
|
+
const GLOB_ASTRO = "**/*.astro";
|
|
50
|
+
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
51
|
+
const GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
52
|
+
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
53
|
+
const GLOB_TESTS = [
|
|
54
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
55
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
56
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
57
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
58
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
51
59
|
];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const GLOB_ALL_SRC = [
|
|
61
|
+
GLOB_SRC,
|
|
62
|
+
GLOB_STYLE,
|
|
63
|
+
GLOB_JSON,
|
|
64
|
+
GLOB_JSON5,
|
|
65
|
+
GLOB_MARKDOWN,
|
|
66
|
+
GLOB_SVELTE,
|
|
67
|
+
GLOB_VUE,
|
|
68
|
+
GLOB_YAML,
|
|
69
|
+
GLOB_XML,
|
|
70
|
+
GLOB_HTML
|
|
63
71
|
];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
72
|
+
const GLOB_EXCLUDE = [
|
|
73
|
+
"**/node_modules",
|
|
74
|
+
"**/dist",
|
|
75
|
+
"**/build",
|
|
76
|
+
"**/vendor",
|
|
77
|
+
"**/public",
|
|
78
|
+
"**/out",
|
|
79
|
+
"**/package-lock.json",
|
|
80
|
+
"**/yarn.lock",
|
|
81
|
+
"**/pnpm-lock.yaml",
|
|
82
|
+
"**/bun.lockb",
|
|
83
|
+
"**/output",
|
|
84
|
+
"**/coverage",
|
|
85
|
+
"**/temp",
|
|
86
|
+
"**/.temp",
|
|
87
|
+
"**/tmp",
|
|
88
|
+
"**/.tmp",
|
|
89
|
+
"**/.history",
|
|
90
|
+
"**/.vitepress/cache",
|
|
91
|
+
"**/.nuxt",
|
|
92
|
+
"**/.next",
|
|
93
|
+
"**/.svelte-kit",
|
|
94
|
+
"**/.vercel",
|
|
95
|
+
"**/.netlify",
|
|
96
|
+
"**/.changeset",
|
|
97
|
+
"**/.idea",
|
|
98
|
+
"**/.cache",
|
|
99
|
+
"**/.output",
|
|
100
|
+
"**/.vite-inspect",
|
|
101
|
+
"**/.yarn",
|
|
102
|
+
"**/vite.config.*.timestamp-*",
|
|
103
|
+
"**/CHANGELOG*.md",
|
|
104
|
+
"**/*.min.*",
|
|
105
|
+
"**/LICENSE*",
|
|
106
|
+
"**/__snapshots__",
|
|
107
|
+
"**/auto-import?(s).d.ts",
|
|
108
|
+
"**/components.d.ts"
|
|
101
109
|
];
|
|
102
110
|
|
|
103
|
-
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/configs/disables.ts
|
|
104
113
|
function disables() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
rules: {
|
|
149
|
-
"no-console": "off",
|
|
150
|
-
"@typescript-eslint/explicit-function-return-type": "off"
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
];
|
|
114
|
+
return [
|
|
115
|
+
{
|
|
116
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
117
|
+
name: "disables/scripts",
|
|
118
|
+
rules: {
|
|
119
|
+
"no-console": "off",
|
|
120
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
125
|
+
name: "disables/cli",
|
|
126
|
+
rules: { "no-console": "off" }
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
files: ["**/*.d.?([cm])ts"],
|
|
130
|
+
name: "disables/dts",
|
|
131
|
+
rules: {
|
|
132
|
+
"@eslint-community/eslint-comments/no-unlimited-disable": "off",
|
|
133
|
+
"import/no-duplicates": "off",
|
|
134
|
+
"no-restricted-syntax": "off",
|
|
135
|
+
"unused-imports/no-unused-vars": "off"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
140
|
+
name: "disables/test",
|
|
141
|
+
rules: { "no-unused-expressions": "off" }
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
145
|
+
name: "disables/cjs",
|
|
146
|
+
rules: { "@typescript-eslint/no-require-imports": "off" }
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
150
|
+
name: "disables/config-files",
|
|
151
|
+
rules: {
|
|
152
|
+
"no-console": "off",
|
|
153
|
+
"@typescript-eslint/explicit-function-return-type": "off"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
];
|
|
154
157
|
}
|
|
155
158
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
visitorKeys: {
|
|
177
|
-
Program: []
|
|
178
|
-
}
|
|
179
|
-
})
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/utils.ts
|
|
161
|
+
const parserPlain = {
|
|
162
|
+
meta: { name: "parser-plain" },
|
|
163
|
+
parseForESLint: (code) => ({
|
|
164
|
+
ast: {
|
|
165
|
+
body: [],
|
|
166
|
+
comments: [],
|
|
167
|
+
loc: {
|
|
168
|
+
end: code.length,
|
|
169
|
+
start: 0
|
|
170
|
+
},
|
|
171
|
+
range: [0, code.length],
|
|
172
|
+
tokens: [],
|
|
173
|
+
type: "Program"
|
|
174
|
+
},
|
|
175
|
+
scopeManager: null,
|
|
176
|
+
services: { isPlain: true },
|
|
177
|
+
visitorKeys: { Program: [] }
|
|
178
|
+
})
|
|
180
179
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Combine array and non-array configs into a single array.
|
|
182
|
+
*/
|
|
183
|
+
async function combine(...configs$1) {
|
|
184
|
+
const resolved = await Promise.all(configs$1);
|
|
185
|
+
return resolved.flat();
|
|
184
186
|
}
|
|
185
187
|
function toArray(value) {
|
|
186
|
-
|
|
188
|
+
return Array.isArray(value) ? value : [value];
|
|
187
189
|
}
|
|
188
190
|
async function interopDefault(m) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
const resolved = await m;
|
|
192
|
+
return resolved.default || resolved;
|
|
191
193
|
}
|
|
192
194
|
function isInGitHooksOrLintStaged() {
|
|
193
|
-
|
|
194
|
-
(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
195
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
195
196
|
}
|
|
196
197
|
function isInEditorEnv() {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
if (process.env.CI) return false;
|
|
199
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
200
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/configs/formatters.ts
|
|
203
205
|
function formatters(options = true) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
"prettier/prettier": ["error", { parser: "less" }]
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
if (options.graphql) {
|
|
256
|
-
configs2.push({
|
|
257
|
-
files: [GLOB_GRAPHQL],
|
|
258
|
-
languageOptions: {
|
|
259
|
-
parser: parserPlain
|
|
260
|
-
},
|
|
261
|
-
name: "formatter/graphql",
|
|
262
|
-
rules: {
|
|
263
|
-
"prettier/prettier": ["error", { parser: "graphql" }]
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
if (options.html) {
|
|
268
|
-
configs2.push({
|
|
269
|
-
files: [GLOB_HTML],
|
|
270
|
-
languageOptions: {
|
|
271
|
-
parser: parserPlain
|
|
272
|
-
},
|
|
273
|
-
name: "formatter/html",
|
|
274
|
-
rules: {
|
|
275
|
-
"prettier/prettier": ["error", { parser: "html" }]
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
if (options.markdown) {
|
|
280
|
-
configs2.push({
|
|
281
|
-
files: [GLOB_MARKDOWN],
|
|
282
|
-
languageOptions: {
|
|
283
|
-
parser: parserPlain
|
|
284
|
-
},
|
|
285
|
-
name: "formatter/markdown",
|
|
286
|
-
rules: {
|
|
287
|
-
"prettier/prettier": ["error", { parser: "markdown" }]
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
return configs2;
|
|
206
|
+
if (options === true) options = {
|
|
207
|
+
css: true,
|
|
208
|
+
graphql: true,
|
|
209
|
+
html: true,
|
|
210
|
+
markdown: true
|
|
211
|
+
};
|
|
212
|
+
const configs$1 = [{
|
|
213
|
+
name: "formatter/setup",
|
|
214
|
+
plugins: { prettier: pluginPrettier },
|
|
215
|
+
rules: configPrettier.rules
|
|
216
|
+
}];
|
|
217
|
+
if (options.css) configs$1.push({
|
|
218
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
219
|
+
languageOptions: { parser: parserPlain },
|
|
220
|
+
name: "formatter/css",
|
|
221
|
+
rules: { "prettier/prettier": ["error", { parser: "css" }] }
|
|
222
|
+
}, {
|
|
223
|
+
files: [GLOB_SCSS],
|
|
224
|
+
languageOptions: { parser: parserPlain },
|
|
225
|
+
name: "formatter/scss",
|
|
226
|
+
rules: { "prettier/prettier": ["error", { parser: "scss" }] }
|
|
227
|
+
}, {
|
|
228
|
+
files: [GLOB_LESS],
|
|
229
|
+
languageOptions: { parser: parserPlain },
|
|
230
|
+
name: "formatter/less",
|
|
231
|
+
rules: { "prettier/prettier": ["error", { parser: "less" }] }
|
|
232
|
+
});
|
|
233
|
+
if (options.graphql) configs$1.push({
|
|
234
|
+
files: [GLOB_GRAPHQL],
|
|
235
|
+
languageOptions: { parser: parserPlain },
|
|
236
|
+
name: "formatter/graphql",
|
|
237
|
+
rules: { "prettier/prettier": ["error", { parser: "graphql" }] }
|
|
238
|
+
});
|
|
239
|
+
if (options.html) configs$1.push({
|
|
240
|
+
files: [GLOB_HTML],
|
|
241
|
+
languageOptions: { parser: parserPlain },
|
|
242
|
+
name: "formatter/html",
|
|
243
|
+
rules: { "prettier/prettier": ["error", { parser: "html" }] }
|
|
244
|
+
});
|
|
245
|
+
if (options.markdown) configs$1.push({
|
|
246
|
+
files: [GLOB_MARKDOWN],
|
|
247
|
+
languageOptions: { parser: parserPlain },
|
|
248
|
+
name: "formatter/markdown",
|
|
249
|
+
rules: { "prettier/prettier": ["error", { parser: "markdown" }] }
|
|
250
|
+
});
|
|
251
|
+
return configs$1;
|
|
292
252
|
}
|
|
293
253
|
|
|
294
|
-
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/configs/ignores.ts
|
|
295
256
|
function ignores(userIgnores = []) {
|
|
296
|
-
|
|
297
|
-
{
|
|
298
|
-
ignores: [...GLOB_EXCLUDE, ...userIgnores]
|
|
299
|
-
}
|
|
300
|
-
];
|
|
257
|
+
return [{ ignores: [...GLOB_EXCLUDE, ...userIgnores] }];
|
|
301
258
|
}
|
|
302
259
|
|
|
303
|
-
|
|
304
|
-
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/configs/imports.ts
|
|
305
262
|
function imports() {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
];
|
|
263
|
+
return [{
|
|
264
|
+
name: "imports",
|
|
265
|
+
plugins: { import: pluginImport },
|
|
266
|
+
rules: {
|
|
267
|
+
"import/export": "error",
|
|
268
|
+
"import/first": "error",
|
|
269
|
+
"import/newline-after-import": ["error", {
|
|
270
|
+
considerComments: true,
|
|
271
|
+
count: 1
|
|
272
|
+
}],
|
|
273
|
+
"import/no-duplicates": "error",
|
|
274
|
+
"import/no-mutable-exports": "error",
|
|
275
|
+
"import/no-named-default": "error",
|
|
276
|
+
"import/no-self-import": "error",
|
|
277
|
+
"import/no-webpack-loader-syntax": "error",
|
|
278
|
+
"import/order": "error"
|
|
279
|
+
}
|
|
280
|
+
}];
|
|
325
281
|
}
|
|
326
282
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/configs/javascript.ts
|
|
330
285
|
function javascript(options = {}) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
286
|
+
const { isInEditor = false, overrides = {} } = options;
|
|
287
|
+
return [{
|
|
288
|
+
languageOptions: {
|
|
289
|
+
ecmaVersion: 2022,
|
|
290
|
+
globals: {
|
|
291
|
+
...globals.browser,
|
|
292
|
+
...globals.es2021,
|
|
293
|
+
...globals.node,
|
|
294
|
+
document: "readonly",
|
|
295
|
+
navigator: "readonly",
|
|
296
|
+
window: "readonly"
|
|
297
|
+
},
|
|
298
|
+
parserOptions: {
|
|
299
|
+
ecmaFeatures: { jsx: true },
|
|
300
|
+
ecmaVersion: 2022,
|
|
301
|
+
sourceType: "module"
|
|
302
|
+
},
|
|
303
|
+
sourceType: "module"
|
|
304
|
+
},
|
|
305
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
306
|
+
name: "javascript/rules",
|
|
307
|
+
plugins: { "unused-imports": pluginUnusedImports },
|
|
308
|
+
rules: {
|
|
309
|
+
"accessor-pairs": ["error", {
|
|
310
|
+
enforceForClassMembers: true,
|
|
311
|
+
setWithoutGet: true
|
|
312
|
+
}],
|
|
313
|
+
"array-callback-return": "error",
|
|
314
|
+
"block-scoped-var": "error",
|
|
315
|
+
camelcase: ["error", {
|
|
316
|
+
properties: "never",
|
|
317
|
+
ignoreDestructuring: true,
|
|
318
|
+
ignoreGlobals: true,
|
|
319
|
+
ignoreImports: true,
|
|
320
|
+
allow: ["^UNSAFE_"]
|
|
321
|
+
}],
|
|
322
|
+
"constructor-super": "error",
|
|
323
|
+
"default-case-last": "error",
|
|
324
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
325
|
+
eqeqeq: ["error", "smart"],
|
|
326
|
+
"for-direction": "error",
|
|
327
|
+
"getter-return": "error",
|
|
328
|
+
"new-cap": ["error", {
|
|
329
|
+
capIsNew: false,
|
|
330
|
+
newIsCap: true,
|
|
331
|
+
properties: true
|
|
332
|
+
}],
|
|
333
|
+
"no-alert": "error",
|
|
334
|
+
"no-array-constructor": "error",
|
|
335
|
+
"no-async-promise-executor": "error",
|
|
336
|
+
"no-caller": "error",
|
|
337
|
+
"no-case-declarations": "error",
|
|
338
|
+
"no-class-assign": "error",
|
|
339
|
+
"no-compare-neg-zero": "error",
|
|
340
|
+
"no-cond-assign": ["error", "always"],
|
|
341
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
342
|
+
"no-const-assign": "error",
|
|
343
|
+
"no-constant-binary-expression": "error",
|
|
344
|
+
"no-constant-condition": "error",
|
|
345
|
+
"no-control-regex": "error",
|
|
346
|
+
"no-debugger": "error",
|
|
347
|
+
"no-delete-var": "error",
|
|
348
|
+
"no-dupe-args": "error",
|
|
349
|
+
"no-dupe-class-members": "error",
|
|
350
|
+
"no-dupe-else-if": "error",
|
|
351
|
+
"no-dupe-keys": "error",
|
|
352
|
+
"no-duplicate-case": "error",
|
|
353
|
+
"no-empty-character-class": "error",
|
|
354
|
+
"no-empty-pattern": "error",
|
|
355
|
+
"no-empty-static-block": "error",
|
|
356
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
357
|
+
"no-eval": "error",
|
|
358
|
+
"no-ex-assign": "error",
|
|
359
|
+
"no-extend-native": "error",
|
|
360
|
+
"no-extra-bind": "error",
|
|
361
|
+
"no-extra-boolean-cast": "error",
|
|
362
|
+
"no-fallthrough": "error",
|
|
363
|
+
"no-func-assign": "error",
|
|
364
|
+
"no-global-assign": "error",
|
|
365
|
+
"no-implied-eval": "error",
|
|
366
|
+
"no-import-assign": "error",
|
|
367
|
+
"no-invalid-regexp": "error",
|
|
368
|
+
"no-irregular-whitespace": "error",
|
|
369
|
+
"no-iterator": "error",
|
|
370
|
+
"no-labels": ["error", {
|
|
371
|
+
allowLoop: false,
|
|
372
|
+
allowSwitch: false
|
|
373
|
+
}],
|
|
374
|
+
"no-lone-blocks": "error",
|
|
375
|
+
"no-lonely-if": "error",
|
|
376
|
+
"no-loss-of-precision": "error",
|
|
377
|
+
"no-misleading-character-class": "error",
|
|
378
|
+
"no-multi-str": "error",
|
|
379
|
+
"no-new-func": "error",
|
|
380
|
+
"no-new-native-nonconstructor": "error",
|
|
381
|
+
"no-new-wrappers": "error",
|
|
382
|
+
"no-new": "error",
|
|
383
|
+
"no-nonoctal-decimal-escape": "error",
|
|
384
|
+
"no-obj-calls": "error",
|
|
385
|
+
"no-octal-escape": "error",
|
|
386
|
+
"no-octal": "error",
|
|
387
|
+
"no-proto": "error",
|
|
388
|
+
"no-prototype-builtins": "error",
|
|
389
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
390
|
+
"no-regex-spaces": "error",
|
|
391
|
+
"no-restricted-globals": [
|
|
392
|
+
"error",
|
|
393
|
+
{
|
|
394
|
+
message: "Use `globalThis` instead.",
|
|
395
|
+
name: "global"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
message: "Use `globalThis` instead.",
|
|
399
|
+
name: "self"
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"no-restricted-properties": [
|
|
403
|
+
"error",
|
|
404
|
+
{
|
|
405
|
+
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
|
|
406
|
+
property: "__proto__"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
message: "Use `Object.defineProperty` instead.",
|
|
410
|
+
property: "__defineGetter__"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
message: "Use `Object.defineProperty` instead.",
|
|
414
|
+
property: "__defineSetter__"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
418
|
+
property: "__lookupGetter__"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
422
|
+
property: "__lookupSetter__"
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
"no-restricted-syntax": [
|
|
426
|
+
"error",
|
|
427
|
+
"TSEnumDeclaration[const=true]",
|
|
428
|
+
"TSExportAssignment"
|
|
429
|
+
],
|
|
430
|
+
"no-return-assign": ["error", "except-parens"],
|
|
431
|
+
"no-self-assign": ["error", { props: true }],
|
|
432
|
+
"no-self-compare": "error",
|
|
433
|
+
"no-sequences": "error",
|
|
434
|
+
"no-setter-return": "error",
|
|
435
|
+
"no-shadow-restricted-names": "error",
|
|
436
|
+
"no-sparse-arrays": "error",
|
|
437
|
+
"no-template-curly-in-string": "error",
|
|
438
|
+
"no-this-before-super": "error",
|
|
439
|
+
"no-throw-literal": "error",
|
|
440
|
+
"no-undef-init": "error",
|
|
441
|
+
"no-undef": "error",
|
|
442
|
+
"no-unexpected-multiline": "error",
|
|
443
|
+
"no-unmodified-loop-condition": "error",
|
|
444
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
445
|
+
"no-unreachable": "error",
|
|
446
|
+
"no-unreachable-loop": "error",
|
|
447
|
+
"no-unsafe-finally": "error",
|
|
448
|
+
"no-unsafe-negation": "error",
|
|
449
|
+
"no-unsafe-optional-chaining": "error",
|
|
450
|
+
"no-unused-expressions": ["error", {
|
|
451
|
+
allowShortCircuit: true,
|
|
452
|
+
allowTaggedTemplates: true,
|
|
453
|
+
allowTernary: true
|
|
454
|
+
}],
|
|
455
|
+
"no-unused-private-class-members": "error",
|
|
456
|
+
"no-unused-vars": "off",
|
|
457
|
+
"no-use-before-define": ["error", {
|
|
458
|
+
classes: false,
|
|
459
|
+
functions: false,
|
|
460
|
+
variables: true
|
|
461
|
+
}],
|
|
462
|
+
"no-useless-backreference": "error",
|
|
463
|
+
"no-useless-call": "error",
|
|
464
|
+
"no-useless-catch": "error",
|
|
465
|
+
"no-useless-computed-key": "error",
|
|
466
|
+
"no-useless-constructor": "error",
|
|
467
|
+
"no-useless-escape": "error",
|
|
468
|
+
"no-useless-rename": "error",
|
|
469
|
+
"no-useless-return": "error",
|
|
470
|
+
"no-var": "error",
|
|
471
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
472
|
+
"no-with": "error",
|
|
473
|
+
"object-shorthand": [
|
|
474
|
+
"error",
|
|
475
|
+
"always",
|
|
476
|
+
{
|
|
477
|
+
avoidQuotes: true,
|
|
478
|
+
ignoreConstructors: false
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
"one-var": ["error", { initialized: "never" }],
|
|
482
|
+
"prefer-arrow-callback": ["error", {
|
|
483
|
+
allowNamedFunctions: false,
|
|
484
|
+
allowUnboundThis: true
|
|
485
|
+
}],
|
|
486
|
+
"prefer-const": isInEditor ? "warn" : ["error", {
|
|
487
|
+
destructuring: "all",
|
|
488
|
+
ignoreReadBeforeAssign: true
|
|
489
|
+
}],
|
|
490
|
+
"prefer-exponentiation-operator": "error",
|
|
491
|
+
"prefer-promise-reject-errors": "error",
|
|
492
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
493
|
+
"prefer-rest-params": "error",
|
|
494
|
+
"prefer-spread": "error",
|
|
495
|
+
"prefer-template": "error",
|
|
496
|
+
"require-await": "error",
|
|
497
|
+
"require-yield": "error",
|
|
498
|
+
"sort-imports": ["error", {
|
|
499
|
+
allowSeparatedGroups: false,
|
|
500
|
+
ignoreCase: false,
|
|
501
|
+
ignoreDeclarationSort: true,
|
|
502
|
+
ignoreMemberSort: false,
|
|
503
|
+
memberSyntaxSortOrder: [
|
|
504
|
+
"none",
|
|
505
|
+
"all",
|
|
506
|
+
"multiple",
|
|
507
|
+
"single"
|
|
508
|
+
]
|
|
509
|
+
}],
|
|
510
|
+
"symbol-description": "error",
|
|
511
|
+
"unicode-bom": ["error", "never"],
|
|
512
|
+
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
|
|
513
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
514
|
+
args: "after-used",
|
|
515
|
+
argsIgnorePattern: "^_",
|
|
516
|
+
ignoreRestSiblings: true,
|
|
517
|
+
vars: "all",
|
|
518
|
+
varsIgnorePattern: "^_"
|
|
519
|
+
}],
|
|
520
|
+
"use-isnan": ["error", {
|
|
521
|
+
enforceForIndexOf: true,
|
|
522
|
+
enforceForSwitchCase: true
|
|
523
|
+
}],
|
|
524
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
525
|
+
"vars-on-top": "error",
|
|
526
|
+
yoda: ["error", "never"],
|
|
527
|
+
...overrides
|
|
528
|
+
}
|
|
529
|
+
}];
|
|
542
530
|
}
|
|
543
531
|
|
|
544
|
-
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/configs/jsonc.ts
|
|
545
534
|
async function jsonc(options = {}) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
563
|
-
...pluginJsonc.configs.prettier.rules
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
];
|
|
535
|
+
const { files = [
|
|
536
|
+
GLOB_JSON,
|
|
537
|
+
GLOB_JSON5,
|
|
538
|
+
GLOB_JSONC
|
|
539
|
+
] } = options;
|
|
540
|
+
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
541
|
+
return [{
|
|
542
|
+
name: "jsonc",
|
|
543
|
+
files,
|
|
544
|
+
languageOptions: { parser: parserJsonc },
|
|
545
|
+
plugins: { jsonc: pluginJsonc },
|
|
546
|
+
rules: {
|
|
547
|
+
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
548
|
+
...pluginJsonc.configs.prettier.rules
|
|
549
|
+
}
|
|
550
|
+
}];
|
|
567
551
|
}
|
|
568
552
|
|
|
569
|
-
|
|
570
|
-
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/configs/node.ts
|
|
571
555
|
function node() {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
"n/process-exit-as-throw": "error"
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
];
|
|
556
|
+
return [{
|
|
557
|
+
name: "node",
|
|
558
|
+
plugins: { n: pluginNode },
|
|
559
|
+
rules: {
|
|
560
|
+
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
561
|
+
"n/no-deprecated-api": "error",
|
|
562
|
+
"n/no-exports-assign": "error",
|
|
563
|
+
"n/no-new-require": "error",
|
|
564
|
+
"n/no-path-concat": "error",
|
|
565
|
+
"n/prefer-global/buffer": ["error", "always"],
|
|
566
|
+
"n/prefer-global/console": ["error", "always"],
|
|
567
|
+
"n/prefer-global/process": ["error", "always"],
|
|
568
|
+
"n/prefer-global/text-decoder": ["error", "always"],
|
|
569
|
+
"n/prefer-global/text-encoder": ["error", "always"],
|
|
570
|
+
"n/prefer-global/url": ["error", "always"],
|
|
571
|
+
"n/prefer-global/url-search-params": ["error", "always"],
|
|
572
|
+
"n/process-exit-as-throw": "error"
|
|
573
|
+
}
|
|
574
|
+
}];
|
|
595
575
|
}
|
|
596
576
|
|
|
597
|
-
|
|
598
|
-
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/configs/regexp.ts
|
|
599
579
|
function regexp(options = {}) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
];
|
|
580
|
+
const config = configs["flat/recommended"];
|
|
581
|
+
return [{
|
|
582
|
+
...config,
|
|
583
|
+
name: "regexp",
|
|
584
|
+
rules: {
|
|
585
|
+
...config.rules,
|
|
586
|
+
"regexp/no-obscure-range": "off",
|
|
587
|
+
...options.overrides
|
|
588
|
+
}
|
|
589
|
+
}];
|
|
612
590
|
}
|
|
613
591
|
|
|
614
|
-
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/configs/sort.ts
|
|
594
|
+
/**
|
|
595
|
+
* Sort package.json
|
|
596
|
+
*
|
|
597
|
+
* Requires `jsonc` config
|
|
598
|
+
*/
|
|
615
599
|
function sortPackageJson() {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
600
|
+
return [{
|
|
601
|
+
files: ["**/package.json"],
|
|
602
|
+
name: "sort/package-json",
|
|
603
|
+
rules: {
|
|
604
|
+
"jsonc/sort-array-values": ["error", {
|
|
605
|
+
order: { type: "asc" },
|
|
606
|
+
pathPattern: "^files$"
|
|
607
|
+
}],
|
|
608
|
+
"jsonc/sort-keys": [
|
|
609
|
+
"error",
|
|
610
|
+
{
|
|
611
|
+
order: [
|
|
612
|
+
"publisher",
|
|
613
|
+
"name",
|
|
614
|
+
"displayName",
|
|
615
|
+
"type",
|
|
616
|
+
"version",
|
|
617
|
+
"private",
|
|
618
|
+
"packageManager",
|
|
619
|
+
"description",
|
|
620
|
+
"author",
|
|
621
|
+
"contributors",
|
|
622
|
+
"license",
|
|
623
|
+
"funding",
|
|
624
|
+
"homepage",
|
|
625
|
+
"repository",
|
|
626
|
+
"bugs",
|
|
627
|
+
"keywords",
|
|
628
|
+
"categories",
|
|
629
|
+
"sideEffects",
|
|
630
|
+
"imports",
|
|
631
|
+
"exports",
|
|
632
|
+
"main",
|
|
633
|
+
"module",
|
|
634
|
+
"unpkg",
|
|
635
|
+
"jsdelivr",
|
|
636
|
+
"types",
|
|
637
|
+
"typesVersions",
|
|
638
|
+
"bin",
|
|
639
|
+
"icon",
|
|
640
|
+
"files",
|
|
641
|
+
"engines",
|
|
642
|
+
"activationEvents",
|
|
643
|
+
"contributes",
|
|
644
|
+
"scripts",
|
|
645
|
+
"peerDependencies",
|
|
646
|
+
"peerDependenciesMeta",
|
|
647
|
+
"dependencies",
|
|
648
|
+
"optionalDependencies",
|
|
649
|
+
"devDependencies",
|
|
650
|
+
"pnpm",
|
|
651
|
+
"overrides",
|
|
652
|
+
"resolutions",
|
|
653
|
+
"husky",
|
|
654
|
+
"simple-git-hooks",
|
|
655
|
+
"lint-staged",
|
|
656
|
+
"eslintConfig",
|
|
657
|
+
"prettier",
|
|
658
|
+
"stylelint"
|
|
659
|
+
],
|
|
660
|
+
pathPattern: "^$"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
order: { type: "asc" },
|
|
664
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
order: { type: "asc" },
|
|
668
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
order: [
|
|
672
|
+
"types",
|
|
673
|
+
"import",
|
|
674
|
+
"require",
|
|
675
|
+
"default"
|
|
676
|
+
],
|
|
677
|
+
pathPattern: "^exports.*$"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
order: [
|
|
681
|
+
"pre-commit",
|
|
682
|
+
"prepare-commit-msg",
|
|
683
|
+
"commit-msg",
|
|
684
|
+
"post-commit",
|
|
685
|
+
"pre-rebase",
|
|
686
|
+
"post-rewrite",
|
|
687
|
+
"post-checkout",
|
|
688
|
+
"post-merge",
|
|
689
|
+
"pre-push",
|
|
690
|
+
"pre-auto-gc"
|
|
691
|
+
],
|
|
692
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
693
|
+
}
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
}];
|
|
713
697
|
}
|
|
698
|
+
/**
|
|
699
|
+
* Sort tsconfig.json
|
|
700
|
+
*
|
|
701
|
+
* Requires `jsonc` config
|
|
702
|
+
*/
|
|
714
703
|
function sortTsconfig() {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
];
|
|
704
|
+
return [{
|
|
705
|
+
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
706
|
+
name: "sort/tsconfig-json",
|
|
707
|
+
rules: { "jsonc/sort-keys": [
|
|
708
|
+
"error",
|
|
709
|
+
{
|
|
710
|
+
order: [
|
|
711
|
+
"extends",
|
|
712
|
+
"compilerOptions",
|
|
713
|
+
"references",
|
|
714
|
+
"files",
|
|
715
|
+
"include",
|
|
716
|
+
"exclude"
|
|
717
|
+
],
|
|
718
|
+
pathPattern: "^$"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
order: [
|
|
722
|
+
"incremental",
|
|
723
|
+
"composite",
|
|
724
|
+
"tsBuildInfoFile",
|
|
725
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
726
|
+
"disableSolutionSearching",
|
|
727
|
+
"disableReferencedProjectLoad",
|
|
728
|
+
"target",
|
|
729
|
+
"jsx",
|
|
730
|
+
"jsxFactory",
|
|
731
|
+
"jsxFragmentFactory",
|
|
732
|
+
"jsxImportSource",
|
|
733
|
+
"lib",
|
|
734
|
+
"moduleDetection",
|
|
735
|
+
"noLib",
|
|
736
|
+
"reactNamespace",
|
|
737
|
+
"useDefineForClassFields",
|
|
738
|
+
"emitDecoratorMetadata",
|
|
739
|
+
"experimentalDecorators",
|
|
740
|
+
"libReplacement",
|
|
741
|
+
"baseUrl",
|
|
742
|
+
"rootDir",
|
|
743
|
+
"rootDirs",
|
|
744
|
+
"customConditions",
|
|
745
|
+
"module",
|
|
746
|
+
"moduleResolution",
|
|
747
|
+
"moduleSuffixes",
|
|
748
|
+
"noResolve",
|
|
749
|
+
"paths",
|
|
750
|
+
"resolveJsonModule",
|
|
751
|
+
"resolvePackageJsonExports",
|
|
752
|
+
"resolvePackageJsonImports",
|
|
753
|
+
"typeRoots",
|
|
754
|
+
"types",
|
|
755
|
+
"allowArbitraryExtensions",
|
|
756
|
+
"allowImportingTsExtensions",
|
|
757
|
+
"allowUmdGlobalAccess",
|
|
758
|
+
"allowJs",
|
|
759
|
+
"checkJs",
|
|
760
|
+
"maxNodeModuleJsDepth",
|
|
761
|
+
"strict",
|
|
762
|
+
"strictBindCallApply",
|
|
763
|
+
"strictFunctionTypes",
|
|
764
|
+
"strictNullChecks",
|
|
765
|
+
"strictPropertyInitialization",
|
|
766
|
+
"allowUnreachableCode",
|
|
767
|
+
"allowUnusedLabels",
|
|
768
|
+
"alwaysStrict",
|
|
769
|
+
"exactOptionalPropertyTypes",
|
|
770
|
+
"noFallthroughCasesInSwitch",
|
|
771
|
+
"noImplicitAny",
|
|
772
|
+
"noImplicitOverride",
|
|
773
|
+
"noImplicitReturns",
|
|
774
|
+
"noImplicitThis",
|
|
775
|
+
"noPropertyAccessFromIndexSignature",
|
|
776
|
+
"noUncheckedIndexedAccess",
|
|
777
|
+
"noUnusedLocals",
|
|
778
|
+
"noUnusedParameters",
|
|
779
|
+
"useUnknownInCatchVariables",
|
|
780
|
+
"declaration",
|
|
781
|
+
"declarationDir",
|
|
782
|
+
"declarationMap",
|
|
783
|
+
"downlevelIteration",
|
|
784
|
+
"emitBOM",
|
|
785
|
+
"emitDeclarationOnly",
|
|
786
|
+
"importHelpers",
|
|
787
|
+
"importsNotUsedAsValues",
|
|
788
|
+
"inlineSourceMap",
|
|
789
|
+
"inlineSources",
|
|
790
|
+
"mapRoot",
|
|
791
|
+
"newLine",
|
|
792
|
+
"noEmit",
|
|
793
|
+
"noEmitHelpers",
|
|
794
|
+
"noEmitOnError",
|
|
795
|
+
"outDir",
|
|
796
|
+
"outFile",
|
|
797
|
+
"preserveConstEnums",
|
|
798
|
+
"preserveValueImports",
|
|
799
|
+
"removeComments",
|
|
800
|
+
"sourceMap",
|
|
801
|
+
"sourceRoot",
|
|
802
|
+
"stripInternal",
|
|
803
|
+
"allowSyntheticDefaultImports",
|
|
804
|
+
"esModuleInterop",
|
|
805
|
+
"forceConsistentCasingInFileNames",
|
|
806
|
+
"isolatedDeclarations",
|
|
807
|
+
"isolatedModules",
|
|
808
|
+
"preserveSymlinks",
|
|
809
|
+
"verbatimModuleSyntax",
|
|
810
|
+
"erasableSyntaxOnly",
|
|
811
|
+
"skipDefaultLibCheck",
|
|
812
|
+
"skipLibCheck"
|
|
813
|
+
],
|
|
814
|
+
pathPattern: "^compilerOptions$"
|
|
815
|
+
}
|
|
816
|
+
] }
|
|
817
|
+
}];
|
|
832
818
|
}
|
|
833
819
|
|
|
834
|
-
|
|
835
|
-
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region src/configs/test.ts
|
|
822
|
+
let _pluginTest;
|
|
836
823
|
async function test(options = {}) {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
...overrides
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
];
|
|
824
|
+
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
825
|
+
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
|
|
826
|
+
_pluginTest = _pluginTest || {
|
|
827
|
+
...pluginVitest,
|
|
828
|
+
rules: {
|
|
829
|
+
...pluginVitest.rules,
|
|
830
|
+
...pluginNoOnlyTests.rules
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
return [{
|
|
834
|
+
files,
|
|
835
|
+
name: "test",
|
|
836
|
+
plugins: { test: _pluginTest },
|
|
837
|
+
rules: {
|
|
838
|
+
"test/consistent-test-it": ["error", {
|
|
839
|
+
fn: "it",
|
|
840
|
+
withinDescribe: "it"
|
|
841
|
+
}],
|
|
842
|
+
"test/no-identical-title": "error",
|
|
843
|
+
"test/no-import-node-test": "error",
|
|
844
|
+
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
845
|
+
"test/prefer-hooks-in-order": "error",
|
|
846
|
+
"test/prefer-lowercase-title": "error",
|
|
847
|
+
"no-unused-expressions": "off",
|
|
848
|
+
"n/prefer-global/process": "off",
|
|
849
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
850
|
+
...overrides
|
|
851
|
+
}
|
|
852
|
+
}];
|
|
870
853
|
}
|
|
871
854
|
|
|
872
|
-
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/configs/typescript.ts
|
|
873
857
|
async function typescript(options = {}) {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
} : {},
|
|
979
|
-
...overridesTypeAware
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
] : []
|
|
983
|
-
];
|
|
858
|
+
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
859
|
+
const files = options.files ?? [
|
|
860
|
+
GLOB_TS,
|
|
861
|
+
GLOB_TSX,
|
|
862
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
863
|
+
];
|
|
864
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
865
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
|
|
866
|
+
const tsconfigPath = options?.tsconfigPath;
|
|
867
|
+
const isTypeAware = !!tsconfigPath;
|
|
868
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
869
|
+
function makeParser(typeAware, files$1, ignores$1) {
|
|
870
|
+
return {
|
|
871
|
+
files: files$1,
|
|
872
|
+
...ignores$1 ? { ignores: ignores$1 } : {},
|
|
873
|
+
languageOptions: {
|
|
874
|
+
parser: parserTs,
|
|
875
|
+
parserOptions: {
|
|
876
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
877
|
+
sourceType: "module",
|
|
878
|
+
...typeAware ? {
|
|
879
|
+
projectService: {
|
|
880
|
+
allowDefaultProject: ["./*.js"],
|
|
881
|
+
defaultProject: tsconfigPath
|
|
882
|
+
},
|
|
883
|
+
tsconfigRootDir: process.cwd()
|
|
884
|
+
} : {},
|
|
885
|
+
...parserOptions
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
return [
|
|
892
|
+
{
|
|
893
|
+
name: "typescript/setup",
|
|
894
|
+
plugins: { "@typescript-eslint": pluginTs }
|
|
895
|
+
},
|
|
896
|
+
...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
|
|
897
|
+
{
|
|
898
|
+
files,
|
|
899
|
+
name: "typescript/rules",
|
|
900
|
+
rules: {
|
|
901
|
+
...pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
902
|
+
...pluginTs.configs.strict.rules,
|
|
903
|
+
"@typescript-eslint/consistent-type-assertions": "error",
|
|
904
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
905
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
906
|
+
disallowTypeAnnotations: false,
|
|
907
|
+
prefer: "type-imports",
|
|
908
|
+
fixStyle: "inline-type-imports"
|
|
909
|
+
}],
|
|
910
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
911
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
912
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
913
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
914
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
915
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
916
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
917
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
918
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
919
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
920
|
+
"no-dupe-class-members": "off",
|
|
921
|
+
"@typescript-eslint/no-dupe-class-members": "error",
|
|
922
|
+
"no-invalid-this": "off",
|
|
923
|
+
"@typescript-eslint/no-invalid-this": "error",
|
|
924
|
+
"no-redeclare": "off",
|
|
925
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
926
|
+
"no-unused-expressions": "off",
|
|
927
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
928
|
+
allowShortCircuit: true,
|
|
929
|
+
allowTernary: true,
|
|
930
|
+
allowTaggedTemplates: true
|
|
931
|
+
}],
|
|
932
|
+
"no-use-before-define": "off",
|
|
933
|
+
"@typescript-eslint/no-use-before-define": "error",
|
|
934
|
+
...type === "lib" ? { "@typescript-eslint/explicit-function-return-type": ["error", {
|
|
935
|
+
allowExpressions: true,
|
|
936
|
+
allowHigherOrderFunctions: true,
|
|
937
|
+
allowIIFEs: true
|
|
938
|
+
}] } : {},
|
|
939
|
+
...overrides
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
...isTypeAware ? [{
|
|
943
|
+
files: filesTypeAware,
|
|
944
|
+
ignores: ignoresTypeAware,
|
|
945
|
+
name: "typescript/rules-type-aware",
|
|
946
|
+
rules: {
|
|
947
|
+
...tsconfigPath ? {
|
|
948
|
+
...pluginTs.configs["recommended-type-checked-only"].rules,
|
|
949
|
+
"@typescript-eslint/no-confusing-void-expression": "error",
|
|
950
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
951
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
952
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
953
|
+
"dot-notation": "off",
|
|
954
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
955
|
+
"no-throw-literal": "off",
|
|
956
|
+
"@typescript-eslint/only-throw-error": "error"
|
|
957
|
+
} : {},
|
|
958
|
+
...overridesTypeAware
|
|
959
|
+
}
|
|
960
|
+
}] : []
|
|
961
|
+
];
|
|
984
962
|
}
|
|
985
963
|
|
|
986
|
-
|
|
987
|
-
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region src/configs/unicorn.ts
|
|
988
966
|
function unicorn() {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
"unicorn/prevent-abbreviations": "off"
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
];
|
|
967
|
+
return [{
|
|
968
|
+
name: "unicorn",
|
|
969
|
+
plugins: { unicorn: pluginUnicorn },
|
|
970
|
+
rules: {
|
|
971
|
+
...pluginUnicorn.configs.recommended.rules,
|
|
972
|
+
"unicorn/consistent-function-scoping": "off",
|
|
973
|
+
"unicorn/filename-case": "off",
|
|
974
|
+
"unicorn/import-style": "off",
|
|
975
|
+
"unicorn/no-array-callback-reference": "off",
|
|
976
|
+
"unicorn/no-null": "off",
|
|
977
|
+
"unicorn/prefer-string-replace-all": "off",
|
|
978
|
+
"unicorn/prefer-structured-clone": "off",
|
|
979
|
+
"unicorn/prefer-top-level-await": "off",
|
|
980
|
+
"unicorn/prevent-abbreviations": "off"
|
|
981
|
+
}
|
|
982
|
+
}];
|
|
1009
983
|
}
|
|
1010
984
|
|
|
1011
|
-
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/configs/unocss.ts
|
|
1012
987
|
async function unocss() {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
];
|
|
988
|
+
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
989
|
+
return [{
|
|
990
|
+
...pluginUnoCSS.configs.flat,
|
|
991
|
+
name: "unocss"
|
|
992
|
+
}];
|
|
1020
993
|
}
|
|
1021
994
|
|
|
1022
|
-
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/configs/vue.ts
|
|
1023
997
|
async function vue(options = {}) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
998
|
+
const { files = [GLOB_VUE], overrides = {}, vueVersion = 3 } = options;
|
|
999
|
+
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
1000
|
+
return [{
|
|
1001
|
+
files,
|
|
1002
|
+
languageOptions: {
|
|
1003
|
+
parser: parserVue,
|
|
1004
|
+
globals: {
|
|
1005
|
+
computed: "readonly",
|
|
1006
|
+
defineEmits: "readonly",
|
|
1007
|
+
defineExpose: "readonly",
|
|
1008
|
+
defineProps: "readonly",
|
|
1009
|
+
onMounted: "readonly",
|
|
1010
|
+
onUnmounted: "readonly",
|
|
1011
|
+
reactive: "readonly",
|
|
1012
|
+
ref: "readonly",
|
|
1013
|
+
shallowReactive: "readonly",
|
|
1014
|
+
shallowRef: "readonly",
|
|
1015
|
+
toRef: "readonly",
|
|
1016
|
+
toRefs: "readonly",
|
|
1017
|
+
watch: "readonly",
|
|
1018
|
+
watchEffect: "readonly"
|
|
1019
|
+
},
|
|
1020
|
+
parserOptions: {
|
|
1021
|
+
ecmaFeatures: { jsx: true },
|
|
1022
|
+
extraFileExtensions: [".vue"],
|
|
1023
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1024
|
+
sourceType: "module"
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
name: "vue",
|
|
1028
|
+
processor: pluginVue.processors[".vue"],
|
|
1029
|
+
plugins: { vue: pluginVue },
|
|
1030
|
+
rules: {
|
|
1031
|
+
...pluginVue.configs.base.rules,
|
|
1032
|
+
...vueVersion === 2 ? {
|
|
1033
|
+
...pluginVue.configs["vue2-essential"].rules,
|
|
1034
|
+
...pluginVue.configs["vue2-strongly-recommended"].rules,
|
|
1035
|
+
...pluginVue.configs["vue2-recommended"].rules
|
|
1036
|
+
} : {
|
|
1037
|
+
...pluginVue.configs.essential.rules,
|
|
1038
|
+
...pluginVue.configs["strongly-recommended"].rules,
|
|
1039
|
+
...pluginVue.configs.recommended.rules
|
|
1040
|
+
},
|
|
1041
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
1042
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1043
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
1044
|
+
"vue/define-macros-order": ["error", { order: [
|
|
1045
|
+
"defineOptions",
|
|
1046
|
+
"defineModel",
|
|
1047
|
+
"defineProps",
|
|
1048
|
+
"defineEmits",
|
|
1049
|
+
"defineSlots"
|
|
1050
|
+
] }],
|
|
1051
|
+
"vue/dot-notation": "error",
|
|
1052
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
1053
|
+
"vue/html-comment-content-spacing": [
|
|
1054
|
+
"error",
|
|
1055
|
+
"always",
|
|
1056
|
+
{ exceptions: ["-"] }
|
|
1057
|
+
],
|
|
1058
|
+
"vue/no-constant-condition": "error",
|
|
1059
|
+
"vue/no-empty-pattern": "error",
|
|
1060
|
+
"vue/no-irregular-whitespace": "error",
|
|
1061
|
+
"vue/no-loss-of-precision": "error",
|
|
1062
|
+
"vue/no-restricted-syntax": [
|
|
1063
|
+
"error",
|
|
1064
|
+
"DebuggerStatement",
|
|
1065
|
+
"LabeledStatement",
|
|
1066
|
+
"WithStatement"
|
|
1067
|
+
],
|
|
1068
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1069
|
+
"vue/no-sparse-arrays": "error",
|
|
1070
|
+
"vue/no-unused-refs": "error",
|
|
1071
|
+
"vue/no-useless-v-bind": "error",
|
|
1072
|
+
"vue/no-v-html": "off",
|
|
1073
|
+
"vue/object-shorthand": [
|
|
1074
|
+
"error",
|
|
1075
|
+
"always",
|
|
1076
|
+
{
|
|
1077
|
+
avoidQuotes: true,
|
|
1078
|
+
ignoreConstructors: false
|
|
1079
|
+
}
|
|
1080
|
+
],
|
|
1081
|
+
"vue/prefer-separate-static-class": "error",
|
|
1082
|
+
"vue/prefer-template": "error",
|
|
1083
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1084
|
+
"vue/component-tags-order": "off",
|
|
1085
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1086
|
+
...overrides
|
|
1087
|
+
}
|
|
1088
|
+
}];
|
|
1107
1089
|
}
|
|
1108
1090
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
"settings"
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region src/factory.ts
|
|
1093
|
+
const flatConfigProps = [
|
|
1094
|
+
"name",
|
|
1095
|
+
"languageOptions",
|
|
1096
|
+
"linterOptions",
|
|
1097
|
+
"processor",
|
|
1098
|
+
"plugins",
|
|
1099
|
+
"rules",
|
|
1100
|
+
"settings"
|
|
1120
1101
|
];
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
if (enableVue) {
|
|
1182
|
-
configs2.push(
|
|
1183
|
-
vue({
|
|
1184
|
-
...typeof enableVue === "boolean" ? {} : enableVue || {},
|
|
1185
|
-
typescript: !!enableTypeScript
|
|
1186
|
-
})
|
|
1187
|
-
);
|
|
1188
|
-
}
|
|
1189
|
-
if (enableUnoCSS) {
|
|
1190
|
-
configs2.push(unocss());
|
|
1191
|
-
}
|
|
1192
|
-
if (enableJSONC) {
|
|
1193
|
-
configs2.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
|
|
1194
|
-
}
|
|
1195
|
-
if (enableFormatters) {
|
|
1196
|
-
configs2.push(formatters(enableFormatters));
|
|
1197
|
-
}
|
|
1198
|
-
configs2.push(disables());
|
|
1199
|
-
if ("files" in options) {
|
|
1200
|
-
throw new Error(
|
|
1201
|
-
'[@cany748/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1205
|
-
if (key in options) acc[key] = options[key];
|
|
1206
|
-
return acc;
|
|
1207
|
-
}, {});
|
|
1208
|
-
if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
|
|
1209
|
-
let composer = new FlatConfigComposer();
|
|
1210
|
-
composer = composer.append(...configs2, ...userConfigs);
|
|
1211
|
-
return composer;
|
|
1212
|
-
};
|
|
1213
|
-
export {
|
|
1214
|
-
GLOB_ALL_SRC,
|
|
1215
|
-
GLOB_ASTRO,
|
|
1216
|
-
GLOB_ASTRO_TS,
|
|
1217
|
-
GLOB_CSS,
|
|
1218
|
-
GLOB_EXCLUDE,
|
|
1219
|
-
GLOB_GRAPHQL,
|
|
1220
|
-
GLOB_HTML,
|
|
1221
|
-
GLOB_JS,
|
|
1222
|
-
GLOB_JSON,
|
|
1223
|
-
GLOB_JSON5,
|
|
1224
|
-
GLOB_JSONC,
|
|
1225
|
-
GLOB_JSX,
|
|
1226
|
-
GLOB_LESS,
|
|
1227
|
-
GLOB_MARKDOWN,
|
|
1228
|
-
GLOB_MARKDOWN_CODE,
|
|
1229
|
-
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
1230
|
-
GLOB_POSTCSS,
|
|
1231
|
-
GLOB_SCSS,
|
|
1232
|
-
GLOB_SRC,
|
|
1233
|
-
GLOB_SRC_EXT,
|
|
1234
|
-
GLOB_STYLE,
|
|
1235
|
-
GLOB_SVELTE,
|
|
1236
|
-
GLOB_TESTS,
|
|
1237
|
-
GLOB_TOML,
|
|
1238
|
-
GLOB_TS,
|
|
1239
|
-
GLOB_TSX,
|
|
1240
|
-
GLOB_VUE,
|
|
1241
|
-
GLOB_XML,
|
|
1242
|
-
GLOB_YAML,
|
|
1243
|
-
combine,
|
|
1244
|
-
comments,
|
|
1245
|
-
disables,
|
|
1246
|
-
factoryConfig,
|
|
1247
|
-
formatters,
|
|
1248
|
-
ignores,
|
|
1249
|
-
imports,
|
|
1250
|
-
interopDefault,
|
|
1251
|
-
isInEditorEnv,
|
|
1252
|
-
isInGitHooksOrLintStaged,
|
|
1253
|
-
javascript,
|
|
1254
|
-
jsonc,
|
|
1255
|
-
node,
|
|
1256
|
-
parserPlain,
|
|
1257
|
-
regexp,
|
|
1258
|
-
sortPackageJson,
|
|
1259
|
-
sortTsconfig,
|
|
1260
|
-
test,
|
|
1261
|
-
toArray,
|
|
1262
|
-
typescript,
|
|
1263
|
-
unicorn,
|
|
1264
|
-
unocss,
|
|
1265
|
-
vue
|
|
1102
|
+
const VuePackages = [
|
|
1103
|
+
"vue",
|
|
1104
|
+
"nuxt",
|
|
1105
|
+
"vitepress",
|
|
1106
|
+
"@slidev/cli"
|
|
1107
|
+
];
|
|
1108
|
+
/**
|
|
1109
|
+
* Construct an array of ESLint flat config items.
|
|
1110
|
+
*
|
|
1111
|
+
* @param {OptionsConfig & TypedFlatConfigItem} options
|
|
1112
|
+
* The options for generating the ESLint configurations.
|
|
1113
|
+
* @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
|
|
1114
|
+
* The user configurations to be merged with the generated configurations.
|
|
1115
|
+
* @returns {Promise<TypedFlatConfigItem[]>}
|
|
1116
|
+
* The merged ESLint configurations.
|
|
1117
|
+
*/
|
|
1118
|
+
const factoryConfig = function(options = {}, ...userConfigs) {
|
|
1119
|
+
const { componentExts = [], formatters: enableFormatters = true, gitignore: enableGitignore = true, jsonc: enableJSONC = true, regexp: enableRegexp = true, test: enableTest = true, typescript: enableTypeScript = isPackageExists("typescript"), unocss: enableUnoCSS = isPackageExists("unocss"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
1120
|
+
let isInEditor = options.isInEditor;
|
|
1121
|
+
if (isInEditor == null) {
|
|
1122
|
+
isInEditor = isInEditorEnv();
|
|
1123
|
+
if (isInEditor) console.log("[@cany748/eslint-config] Detected running in editor, some rules are disabled.");
|
|
1124
|
+
}
|
|
1125
|
+
const configs$1 = [];
|
|
1126
|
+
if (enableGitignore) if (typeof enableGitignore === "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
|
|
1127
|
+
else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1128
|
+
configs$1.push(comments(), ignores(options.ignores), imports(), javascript({
|
|
1129
|
+
isInEditor,
|
|
1130
|
+
overrides: options.javascript?.overrides
|
|
1131
|
+
}), node(), unicorn());
|
|
1132
|
+
if (enableVue) componentExts.push("vue");
|
|
1133
|
+
if (enableTypeScript) configs$1.push(typescript({
|
|
1134
|
+
...typeof enableTypeScript === "boolean" ? {} : enableTypeScript || {},
|
|
1135
|
+
componentExts,
|
|
1136
|
+
type: options.type
|
|
1137
|
+
}));
|
|
1138
|
+
if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1139
|
+
if (enableTest) configs$1.push(test({
|
|
1140
|
+
isInEditor,
|
|
1141
|
+
overrides: typeof enableTest === "boolean" ? {} : enableTest?.overrides
|
|
1142
|
+
}));
|
|
1143
|
+
if (enableVue) configs$1.push(vue({
|
|
1144
|
+
...typeof enableVue === "boolean" ? {} : enableVue || {},
|
|
1145
|
+
typescript: !!enableTypeScript
|
|
1146
|
+
}));
|
|
1147
|
+
if (enableUnoCSS) configs$1.push(unocss());
|
|
1148
|
+
if (enableJSONC) configs$1.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
|
|
1149
|
+
if (enableFormatters) configs$1.push(formatters(enableFormatters));
|
|
1150
|
+
configs$1.push(disables());
|
|
1151
|
+
if ("files" in options) throw new Error("[@cany748/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
1152
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1153
|
+
if (key in options) acc[key] = options[key];
|
|
1154
|
+
return acc;
|
|
1155
|
+
}, {});
|
|
1156
|
+
if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
|
|
1157
|
+
let composer = new FlatConfigComposer();
|
|
1158
|
+
composer = composer.append(...configs$1, ...userConfigs);
|
|
1159
|
+
return composer;
|
|
1266
1160
|
};
|
|
1161
|
+
|
|
1162
|
+
//#endregion
|
|
1163
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, combine, comments, disables, factoryConfig, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, javascript, jsonc, node, parserPlain, regexp, sortPackageJson, sortTsconfig, test, toArray, typescript, unicorn, unocss, vue };
|