@lincy/eslint-config 5.5.1 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +2062 -2537
- package/dist/index.d.cts +9004 -9383
- package/dist/index.d.ts +9004 -9383
- package/dist/index.js +1977 -2436
- package/package.json +77 -81
package/dist/index.cjs
CHANGED
|
@@ -1,2659 +1,2184 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
//#region rolldown:runtime
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
9
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
19
18
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
-
GLOB_CSS: () => GLOB_CSS,
|
|
35
|
-
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
36
|
-
GLOB_GRAPHQL: () => GLOB_GRAPHQL,
|
|
37
|
-
GLOB_HTML: () => GLOB_HTML,
|
|
38
|
-
GLOB_JS: () => GLOB_JS,
|
|
39
|
-
GLOB_JSON: () => GLOB_JSON,
|
|
40
|
-
GLOB_JSON5: () => GLOB_JSON5,
|
|
41
|
-
GLOB_JSONC: () => GLOB_JSONC,
|
|
42
|
-
GLOB_JSX: () => GLOB_JSX,
|
|
43
|
-
GLOB_LESS: () => GLOB_LESS,
|
|
44
|
-
GLOB_MARKDOWN: () => GLOB_MARKDOWN,
|
|
45
|
-
GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
|
|
46
|
-
GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
|
|
47
|
-
GLOB_POSTCSS: () => GLOB_POSTCSS,
|
|
48
|
-
GLOB_SCSS: () => GLOB_SCSS,
|
|
49
|
-
GLOB_SRC: () => GLOB_SRC,
|
|
50
|
-
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
51
|
-
GLOB_STYLE: () => GLOB_STYLE,
|
|
52
|
-
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
53
|
-
GLOB_SVG: () => GLOB_SVG,
|
|
54
|
-
GLOB_TESTS: () => GLOB_TESTS,
|
|
55
|
-
GLOB_TOML: () => GLOB_TOML,
|
|
56
|
-
GLOB_TS: () => GLOB_TS,
|
|
57
|
-
GLOB_TSX: () => GLOB_TSX,
|
|
58
|
-
GLOB_VUE: () => GLOB_VUE,
|
|
59
|
-
GLOB_XML: () => GLOB_XML,
|
|
60
|
-
GLOB_YAML: () => GLOB_YAML,
|
|
61
|
-
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
62
|
-
combine: () => combine,
|
|
63
|
-
comments: () => comments,
|
|
64
|
-
default: () => index_default,
|
|
65
|
-
defaultPluginRenaming: () => defaultPluginRenaming,
|
|
66
|
-
disables: () => disables,
|
|
67
|
-
ensurePackages: () => ensurePackages,
|
|
68
|
-
formatters: () => formatters,
|
|
69
|
-
getOverrides: () => getOverrides,
|
|
70
|
-
ignores: () => ignores,
|
|
71
|
-
imports: () => imports,
|
|
72
|
-
interopDefault: () => interopDefault,
|
|
73
|
-
isInEditorEnv: () => isInEditorEnv,
|
|
74
|
-
isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
|
|
75
|
-
isPackageInScope: () => isPackageInScope,
|
|
76
|
-
javascript: () => javascript,
|
|
77
|
-
jsdoc: () => jsdoc,
|
|
78
|
-
jsonc: () => jsonc,
|
|
79
|
-
jsx: () => jsx,
|
|
80
|
-
lincy: () => lincy,
|
|
81
|
-
markdown: () => markdown,
|
|
82
|
-
node: () => node,
|
|
83
|
-
parserPlain: () => parserPlain,
|
|
84
|
-
perfectionist: () => perfectionist,
|
|
85
|
-
pnpm: () => pnpm,
|
|
86
|
-
react: () => react,
|
|
87
|
-
regexp: () => regexp,
|
|
88
|
-
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
89
|
-
renameRules: () => renameRules,
|
|
90
|
-
resolveSubOptions: () => resolveSubOptions,
|
|
91
|
-
sortPackageJson: () => sortPackageJson,
|
|
92
|
-
sortTsconfig: () => sortTsconfig,
|
|
93
|
-
stylistic: () => stylistic,
|
|
94
|
-
test: () => test,
|
|
95
|
-
toArray: () => toArray,
|
|
96
|
-
toml: () => toml,
|
|
97
|
-
typescript: () => typescript,
|
|
98
|
-
unicorn: () => unicorn,
|
|
99
|
-
unocss: () => unocss,
|
|
100
|
-
vue: () => vue,
|
|
101
|
-
yaml: () => yaml
|
|
102
|
-
});
|
|
103
|
-
module.exports = __toCommonJS(index_exports);
|
|
104
|
-
|
|
105
|
-
// node_modules/.pnpm/tsup@8.4.0_jiti@2.4.2_postcss@8.4.49_tsx@4.19.3_typescript@5.8.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
106
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
107
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
108
|
-
|
|
109
|
-
// src/factory.ts
|
|
110
|
-
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
111
|
-
var import_local_pkg4 = require("local-pkg");
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
112
23
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
const eslint_flat_config_utils = __toESM(require("eslint-flat-config-utils"));
|
|
26
|
+
const local_pkg = __toESM(require("local-pkg"));
|
|
27
|
+
const __eslint_community_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"));
|
|
28
|
+
const eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"));
|
|
29
|
+
const eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"));
|
|
30
|
+
const eslint_plugin_n = __toESM(require("eslint-plugin-n"));
|
|
31
|
+
const eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"));
|
|
32
|
+
const eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"));
|
|
33
|
+
const eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"));
|
|
34
|
+
const node_process = __toESM(require("node:process"));
|
|
35
|
+
const node_url = __toESM(require("node:url"));
|
|
36
|
+
const globals = __toESM(require("globals"));
|
|
37
|
+
const eslint_merge_processors = __toESM(require("eslint-merge-processors"));
|
|
38
|
+
const eslint_parser_plain = __toESM(require("eslint-parser-plain"));
|
|
39
|
+
const eslint_plugin_regexp = __toESM(require("eslint-plugin-regexp"));
|
|
121
40
|
|
|
122
|
-
|
|
41
|
+
//#region src/configs/comments.ts
|
|
123
42
|
async function comments(options = {}) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"eslint-comments/no-unlimited-disable": "error",
|
|
137
|
-
"eslint-comments/no-unused-enable": "error",
|
|
138
|
-
...overrides
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
];
|
|
43
|
+
const { overrides = {} } = options;
|
|
44
|
+
return [{
|
|
45
|
+
name: "eslint/comments/rules",
|
|
46
|
+
plugins: { "eslint-comments": __eslint_community_eslint_plugin_eslint_comments.default },
|
|
47
|
+
rules: {
|
|
48
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
49
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
50
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
51
|
+
"eslint-comments/no-unused-enable": "error",
|
|
52
|
+
...overrides
|
|
53
|
+
}
|
|
54
|
+
}];
|
|
142
55
|
}
|
|
143
56
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/globs.ts
|
|
59
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
60
|
+
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
61
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
62
|
+
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
63
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
64
|
+
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
65
|
+
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
66
|
+
const GLOB_CSS = "**/*.css";
|
|
67
|
+
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
68
|
+
const GLOB_LESS = "**/*.less";
|
|
69
|
+
const GLOB_SCSS = "**/*.scss";
|
|
70
|
+
const GLOB_JSON = "**/*.json";
|
|
71
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
72
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
73
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
74
|
+
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
75
|
+
const GLOB_SVELTE = "**/*.svelte";
|
|
76
|
+
const GLOB_VUE = "**/*.vue";
|
|
77
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
78
|
+
const GLOB_TOML = "**/*.toml";
|
|
79
|
+
const GLOB_XML = "**/*.xml";
|
|
80
|
+
const GLOB_SVG = "**/*.svg";
|
|
81
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
82
|
+
const GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
83
|
+
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
84
|
+
const GLOB_TESTS = [
|
|
85
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
86
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
87
|
+
`**/*.test.${GLOB_SRC_EXT}`
|
|
174
88
|
];
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
89
|
+
const GLOB_ALL_SRC = [
|
|
90
|
+
GLOB_SRC,
|
|
91
|
+
GLOB_STYLE,
|
|
92
|
+
GLOB_JSON,
|
|
93
|
+
GLOB_JSON5,
|
|
94
|
+
GLOB_MARKDOWN,
|
|
95
|
+
GLOB_SVELTE,
|
|
96
|
+
GLOB_VUE,
|
|
97
|
+
GLOB_YAML,
|
|
98
|
+
GLOB_HTML
|
|
185
99
|
];
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
100
|
+
const GLOB_EXCLUDE = [
|
|
101
|
+
"**/node_modules",
|
|
102
|
+
"**/dist",
|
|
103
|
+
"**/package-lock.json",
|
|
104
|
+
"**/yarn.lock",
|
|
105
|
+
"**/pnpm-lock.yaml",
|
|
106
|
+
"**/output",
|
|
107
|
+
"**/coverage",
|
|
108
|
+
"**/tmp",
|
|
109
|
+
"**/temp",
|
|
110
|
+
"**/.tmp",
|
|
111
|
+
"**/.temp",
|
|
112
|
+
"**/.history",
|
|
113
|
+
"**/.vitepress/cache",
|
|
114
|
+
"**/.nuxt",
|
|
115
|
+
"**/.next",
|
|
116
|
+
"**/.vercel",
|
|
117
|
+
"**/.changeset",
|
|
118
|
+
"**/.idea",
|
|
119
|
+
"**/.output",
|
|
120
|
+
"**/.vite-inspect",
|
|
121
|
+
"**/.yarn",
|
|
122
|
+
"**/vite.config.*.timestamp-*",
|
|
123
|
+
"**/CHANGELOG*.md",
|
|
124
|
+
"**/*.min.*",
|
|
125
|
+
"**/LICENSE*",
|
|
126
|
+
"**/__snapshots__",
|
|
127
|
+
"**/auto-import?(s).d.ts",
|
|
128
|
+
"**/components.d.ts"
|
|
215
129
|
];
|
|
216
130
|
|
|
217
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/configs/disables.ts
|
|
218
133
|
async function disables() {
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
];
|
|
134
|
+
return [
|
|
135
|
+
{
|
|
136
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
137
|
+
name: "eslint/disables/scripts",
|
|
138
|
+
rules: {
|
|
139
|
+
"antfu/no-top-level-await": "off",
|
|
140
|
+
"no-console": "off",
|
|
141
|
+
"ts/explicit-function-return-type": "off"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
146
|
+
name: "eslint/disables/cli",
|
|
147
|
+
rules: {
|
|
148
|
+
"antfu/no-top-level-await": "off",
|
|
149
|
+
"no-console": "off"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
154
|
+
name: "eslint/disables/bin",
|
|
155
|
+
rules: {
|
|
156
|
+
"antfu/no-import-dist": "off",
|
|
157
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
files: ["**/*.d.?([cm])ts"],
|
|
162
|
+
name: "eslint/disables/dts",
|
|
163
|
+
rules: {
|
|
164
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
165
|
+
"import/no-duplicates": "off",
|
|
166
|
+
"no-restricted-syntax": "off",
|
|
167
|
+
"unused-imports/no-unused-vars": "off"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
172
|
+
name: "eslint/disables/cjs",
|
|
173
|
+
rules: { "ts/no-require-imports": "off" }
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
177
|
+
name: "eslint/disables/config-files",
|
|
178
|
+
rules: {
|
|
179
|
+
"antfu/no-top-level-await": "off",
|
|
180
|
+
"no-console": "off",
|
|
181
|
+
"ts/explicit-function-return-type": "off"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
];
|
|
272
185
|
}
|
|
273
186
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
Program: []
|
|
297
|
-
}
|
|
298
|
-
})
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/utils.ts
|
|
189
|
+
const scopeUrl = (0, node_url.fileURLToPath)(new URL(".", require("url").pathToFileURL(__filename).href));
|
|
190
|
+
const isCwdInScope = (0, local_pkg.isPackageExists)("@antfu/eslint-config");
|
|
191
|
+
const parserPlain = {
|
|
192
|
+
meta: { name: "parser-plain" },
|
|
193
|
+
parseForESLint: (code) => ({
|
|
194
|
+
ast: {
|
|
195
|
+
body: [],
|
|
196
|
+
comments: [],
|
|
197
|
+
loc: {
|
|
198
|
+
end: code.length,
|
|
199
|
+
start: 0
|
|
200
|
+
},
|
|
201
|
+
range: [0, code.length],
|
|
202
|
+
tokens: [],
|
|
203
|
+
type: "Program"
|
|
204
|
+
},
|
|
205
|
+
scopeManager: null,
|
|
206
|
+
services: { isPlain: true },
|
|
207
|
+
visitorKeys: { Program: [] }
|
|
208
|
+
})
|
|
299
209
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Combine array and non-array configs into a single array.
|
|
212
|
+
*/
|
|
213
|
+
async function combine(...configs$1) {
|
|
214
|
+
const resolved = await Promise.all(configs$1);
|
|
215
|
+
return resolved.flat();
|
|
303
216
|
}
|
|
304
217
|
function renameRules(rules, map) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return [to + key.slice(from.length), value];
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return [key, value];
|
|
313
|
-
})
|
|
314
|
-
);
|
|
218
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
219
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
220
|
+
return [key, value];
|
|
221
|
+
}));
|
|
315
222
|
}
|
|
316
|
-
function renamePluginInConfigs(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return [map[key], value];
|
|
327
|
-
}
|
|
328
|
-
return [key, value];
|
|
329
|
-
})
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
return clone;
|
|
333
|
-
});
|
|
223
|
+
function renamePluginInConfigs(configs$1, map) {
|
|
224
|
+
return configs$1.map((i) => {
|
|
225
|
+
const clone = { ...i };
|
|
226
|
+
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
227
|
+
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
228
|
+
if (key in map) return [map[key], value];
|
|
229
|
+
return [key, value];
|
|
230
|
+
}));
|
|
231
|
+
return clone;
|
|
232
|
+
});
|
|
334
233
|
}
|
|
335
234
|
function toArray(value) {
|
|
336
|
-
|
|
235
|
+
return Array.isArray(value) ? value : [value];
|
|
337
236
|
}
|
|
338
237
|
async function interopDefault(m) {
|
|
339
|
-
|
|
340
|
-
|
|
238
|
+
const resolved = await m;
|
|
239
|
+
return resolved.default || resolved;
|
|
341
240
|
}
|
|
342
241
|
function isPackageInScope(name) {
|
|
343
|
-
|
|
242
|
+
return (0, local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
344
243
|
}
|
|
345
244
|
async function ensurePackages(packages) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const result = await p.confirm({
|
|
353
|
-
// message: `${nonExistingPackages.length === 1 ? 'Package is' : 'Packages are'} required for this config: ${nonExistingPackages.join(', ')}. Do you want to install them?`,
|
|
354
|
-
message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?`
|
|
355
|
-
});
|
|
356
|
-
if (result)
|
|
357
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
245
|
+
if (node_process.default.env.CI || node_process.default.stdout.isTTY === false || isCwdInScope === false) return;
|
|
246
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
247
|
+
if (nonExistingPackages.length === 0) return;
|
|
248
|
+
const p = await import("@clack/prompts");
|
|
249
|
+
const result = await p.confirm({ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?` });
|
|
250
|
+
if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
358
251
|
}
|
|
359
252
|
function isInEditorEnv() {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return false;
|
|
364
|
-
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
|
|
253
|
+
if (node_process.default.env.CI) return false;
|
|
254
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
255
|
+
return !!(node_process.default.env.VSCODE_PID || node_process.default.env.VSCODE_CWD || node_process.default.env.JETBRAINS_IDE || node_process.default.env.VIM || node_process.default.env.NVIM);
|
|
365
256
|
}
|
|
366
257
|
function isInGitHooksOrLintStaged() {
|
|
367
|
-
|
|
258
|
+
return !!(node_process.default.env.GIT_PARAMS || node_process.default.env.VSCODE_GIT_COMMAND || node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
368
259
|
}
|
|
369
260
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/configs/stylistic.ts
|
|
263
|
+
const StylisticConfigDefaults = {
|
|
264
|
+
indent: 4,
|
|
265
|
+
jsx: true,
|
|
266
|
+
lessOpinionated: false,
|
|
267
|
+
quotes: "single",
|
|
268
|
+
semi: false
|
|
377
269
|
};
|
|
378
270
|
async function stylistic(options = {}) {
|
|
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
|
-
"style/yield-star-spacing": ["error", { after: true, before: false }],
|
|
421
|
-
...overrides
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
];
|
|
271
|
+
const { overrides = {}, stylistic: stylistic$1 = StylisticConfigDefaults } = options;
|
|
272
|
+
const { indent, jsx: jsx$1, lessOpinionated, quotes, semi } = typeof stylistic$1 === "boolean" ? StylisticConfigDefaults : {
|
|
273
|
+
...StylisticConfigDefaults,
|
|
274
|
+
...stylistic$1
|
|
275
|
+
};
|
|
276
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
277
|
+
const config = pluginStylistic.configs.customize({
|
|
278
|
+
indent,
|
|
279
|
+
jsx: jsx$1,
|
|
280
|
+
pluginName: "style",
|
|
281
|
+
quotes,
|
|
282
|
+
semi
|
|
283
|
+
});
|
|
284
|
+
return [{
|
|
285
|
+
name: "eslint/stylistic/rules",
|
|
286
|
+
plugins: {
|
|
287
|
+
antfu: eslint_plugin_antfu.default,
|
|
288
|
+
style: pluginStylistic
|
|
289
|
+
},
|
|
290
|
+
rules: {
|
|
291
|
+
...config.rules,
|
|
292
|
+
"antfu/consistent-chaining": "error",
|
|
293
|
+
"antfu/consistent-list-newline": "off",
|
|
294
|
+
...lessOpinionated ? { curly: ["error", "all"] } : {
|
|
295
|
+
"antfu/curly": "error",
|
|
296
|
+
"antfu/if-newline": "error",
|
|
297
|
+
"antfu/top-level-function": "error"
|
|
298
|
+
},
|
|
299
|
+
"style/brace-style": ["error", "stroustrup"],
|
|
300
|
+
"style/generator-star-spacing": ["error", {
|
|
301
|
+
after: true,
|
|
302
|
+
before: false
|
|
303
|
+
}],
|
|
304
|
+
"style/multiline-ternary": ["error", "never"],
|
|
305
|
+
"style/yield-star-spacing": ["error", {
|
|
306
|
+
after: true,
|
|
307
|
+
before: false
|
|
308
|
+
}],
|
|
309
|
+
...overrides
|
|
310
|
+
}
|
|
311
|
+
}];
|
|
425
312
|
}
|
|
426
313
|
|
|
427
|
-
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/configs/formatters.ts
|
|
428
316
|
function mergePrettierOptions(options, overrides = {}) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
...options.plugins || []
|
|
435
|
-
]
|
|
436
|
-
};
|
|
317
|
+
return {
|
|
318
|
+
...options,
|
|
319
|
+
...overrides,
|
|
320
|
+
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
321
|
+
};
|
|
437
322
|
}
|
|
438
|
-
async function formatters(options = {},
|
|
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
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
configs2.push({
|
|
559
|
-
files: [GLOB_HTML],
|
|
560
|
-
languageOptions: {
|
|
561
|
-
parser: parserPlain
|
|
562
|
-
},
|
|
563
|
-
name: "eslint/formatter/html",
|
|
564
|
-
rules: {
|
|
565
|
-
"format/prettier": [
|
|
566
|
-
"error",
|
|
567
|
-
mergePrettierOptions(prettierOptions, {
|
|
568
|
-
parser: "html"
|
|
569
|
-
})
|
|
570
|
-
]
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
if (options.xml) {
|
|
575
|
-
configs2.push({
|
|
576
|
-
files: [GLOB_XML],
|
|
577
|
-
languageOptions: {
|
|
578
|
-
parser: parserPlain
|
|
579
|
-
},
|
|
580
|
-
name: "eslint/formatter/xml",
|
|
581
|
-
rules: {
|
|
582
|
-
"format/prettier": [
|
|
583
|
-
"error",
|
|
584
|
-
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
|
|
585
|
-
parser: "xml",
|
|
586
|
-
plugins: [
|
|
587
|
-
"@prettier/plugin-xml"
|
|
588
|
-
]
|
|
589
|
-
})
|
|
590
|
-
]
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
if (options.svg) {
|
|
595
|
-
configs2.push({
|
|
596
|
-
files: [GLOB_SVG],
|
|
597
|
-
languageOptions: {
|
|
598
|
-
parser: parserPlain
|
|
599
|
-
},
|
|
600
|
-
name: "eslint/formatter/svg",
|
|
601
|
-
rules: {
|
|
602
|
-
"format/prettier": [
|
|
603
|
-
"error",
|
|
604
|
-
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
|
|
605
|
-
parser: "xml",
|
|
606
|
-
plugins: [
|
|
607
|
-
"@prettier/plugin-xml"
|
|
608
|
-
]
|
|
609
|
-
})
|
|
610
|
-
]
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
if (options.markdown) {
|
|
615
|
-
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
616
|
-
configs2.push({
|
|
617
|
-
files: [GLOB_MARKDOWN],
|
|
618
|
-
ignores: [],
|
|
619
|
-
languageOptions: {
|
|
620
|
-
parser: parserPlain
|
|
621
|
-
},
|
|
622
|
-
name: "eslint/formatter/markdown",
|
|
623
|
-
rules: {
|
|
624
|
-
[`format/${formater}`]: [
|
|
625
|
-
"error",
|
|
626
|
-
formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
627
|
-
embeddedLanguageFormatting: "off",
|
|
628
|
-
parser: "markdown"
|
|
629
|
-
}) : {
|
|
630
|
-
...dprintOptions,
|
|
631
|
-
language: "markdown"
|
|
632
|
-
}
|
|
633
|
-
]
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
if (options.graphql) {
|
|
638
|
-
configs2.push({
|
|
639
|
-
files: [GLOB_GRAPHQL],
|
|
640
|
-
languageOptions: {
|
|
641
|
-
parser: parserPlain
|
|
642
|
-
},
|
|
643
|
-
name: "eslint/formatter/graphql",
|
|
644
|
-
rules: {
|
|
645
|
-
"format/prettier": [
|
|
646
|
-
"error",
|
|
647
|
-
mergePrettierOptions(prettierOptions, {
|
|
648
|
-
parser: "graphql"
|
|
649
|
-
})
|
|
650
|
-
]
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
return configs2;
|
|
323
|
+
async function formatters(options = {}, stylistic$1 = {}) {
|
|
324
|
+
const defaultIndent = 4;
|
|
325
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
326
|
+
if (options === true) {
|
|
327
|
+
const isPrettierPluginXmlInScope$1 = isPackageInScope("@prettier/plugin-xml");
|
|
328
|
+
options = {
|
|
329
|
+
css: false,
|
|
330
|
+
graphql: true,
|
|
331
|
+
html: true,
|
|
332
|
+
markdown: true,
|
|
333
|
+
svg: isPrettierPluginXmlInScope$1,
|
|
334
|
+
xml: isPrettierPluginXmlInScope$1
|
|
335
|
+
};
|
|
336
|
+
} else options = {
|
|
337
|
+
css: options.css ?? false,
|
|
338
|
+
graphql: options.graphql ?? true,
|
|
339
|
+
html: options.html ?? true,
|
|
340
|
+
markdown: options.markdown ?? true,
|
|
341
|
+
svg: isPrettierPluginXmlInScope,
|
|
342
|
+
xml: isPrettierPluginXmlInScope
|
|
343
|
+
};
|
|
344
|
+
await ensurePackages(["eslint-plugin-format", options.xml || options.svg ? "@prettier/plugin-xml" : void 0]);
|
|
345
|
+
const { indent, quotes, semi } = {
|
|
346
|
+
...StylisticConfigDefaults,
|
|
347
|
+
...stylistic$1
|
|
348
|
+
};
|
|
349
|
+
const prettierOptions = Object.assign({
|
|
350
|
+
endOfLine: "lf",
|
|
351
|
+
printWidth: 200,
|
|
352
|
+
semi,
|
|
353
|
+
singleQuote: quotes === "single",
|
|
354
|
+
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
355
|
+
trailingComma: "all",
|
|
356
|
+
useTabs: indent === "tab"
|
|
357
|
+
}, options.prettierOptions || {});
|
|
358
|
+
const prettierXmlOptions = {
|
|
359
|
+
xmlQuoteAttributes: "double",
|
|
360
|
+
xmlSelfClosingSpace: true,
|
|
361
|
+
xmlSortAttributesByKey: false,
|
|
362
|
+
xmlWhitespaceSensitivity: "ignore"
|
|
363
|
+
};
|
|
364
|
+
const dprintOptions = Object.assign({
|
|
365
|
+
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
366
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
367
|
+
useTabs: indent === "tab"
|
|
368
|
+
}, options.dprintOptions || {});
|
|
369
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
370
|
+
const configs$1 = [{
|
|
371
|
+
name: "eslint/formatter/setup",
|
|
372
|
+
plugins: { format: pluginFormat }
|
|
373
|
+
}];
|
|
374
|
+
if (options.css) configs$1.push({
|
|
375
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
376
|
+
languageOptions: { parser: parserPlain },
|
|
377
|
+
name: "eslint/formatter/css",
|
|
378
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
|
|
379
|
+
}, {
|
|
380
|
+
files: [GLOB_SCSS],
|
|
381
|
+
languageOptions: { parser: parserPlain },
|
|
382
|
+
name: "eslint/formatter/scss",
|
|
383
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
|
|
384
|
+
}, {
|
|
385
|
+
files: [GLOB_LESS],
|
|
386
|
+
languageOptions: { parser: parserPlain },
|
|
387
|
+
name: "eslint/formatter/less",
|
|
388
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
389
|
+
});
|
|
390
|
+
if (options.html) configs$1.push({
|
|
391
|
+
files: [GLOB_HTML],
|
|
392
|
+
languageOptions: { parser: parserPlain },
|
|
393
|
+
name: "eslint/formatter/html",
|
|
394
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
395
|
+
});
|
|
396
|
+
if (options.xml) configs$1.push({
|
|
397
|
+
files: [GLOB_XML],
|
|
398
|
+
languageOptions: { parser: parserPlain },
|
|
399
|
+
name: "eslint/formatter/xml",
|
|
400
|
+
rules: { "format/prettier": ["error", mergePrettierOptions({
|
|
401
|
+
...prettierXmlOptions,
|
|
402
|
+
...prettierOptions
|
|
403
|
+
}, {
|
|
404
|
+
parser: "xml",
|
|
405
|
+
plugins: ["@prettier/plugin-xml"]
|
|
406
|
+
})] }
|
|
407
|
+
});
|
|
408
|
+
if (options.svg) configs$1.push({
|
|
409
|
+
files: [GLOB_SVG],
|
|
410
|
+
languageOptions: { parser: parserPlain },
|
|
411
|
+
name: "eslint/formatter/svg",
|
|
412
|
+
rules: { "format/prettier": ["error", mergePrettierOptions({
|
|
413
|
+
...prettierXmlOptions,
|
|
414
|
+
...prettierOptions
|
|
415
|
+
}, {
|
|
416
|
+
parser: "xml",
|
|
417
|
+
plugins: ["@prettier/plugin-xml"]
|
|
418
|
+
})] }
|
|
419
|
+
});
|
|
420
|
+
if (options.markdown) {
|
|
421
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
422
|
+
configs$1.push({
|
|
423
|
+
files: [GLOB_MARKDOWN],
|
|
424
|
+
ignores: [],
|
|
425
|
+
languageOptions: { parser: parserPlain },
|
|
426
|
+
name: "eslint/formatter/markdown",
|
|
427
|
+
rules: { [`format/${formater}`]: ["error", formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
428
|
+
embeddedLanguageFormatting: "off",
|
|
429
|
+
parser: "markdown"
|
|
430
|
+
}) : {
|
|
431
|
+
...dprintOptions,
|
|
432
|
+
language: "markdown"
|
|
433
|
+
}] }
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (options.graphql) configs$1.push({
|
|
437
|
+
files: [GLOB_GRAPHQL],
|
|
438
|
+
languageOptions: { parser: parserPlain },
|
|
439
|
+
name: "eslint/formatter/graphql",
|
|
440
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
441
|
+
});
|
|
442
|
+
return configs$1;
|
|
655
443
|
}
|
|
656
444
|
|
|
657
|
-
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/configs/ignores.ts
|
|
658
447
|
async function ignores(options = {}) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
ignores: [
|
|
665
|
-
...GLOB_EXCLUDE,
|
|
666
|
-
...ignores2
|
|
667
|
-
],
|
|
668
|
-
name: "eslint/ignores"
|
|
669
|
-
}
|
|
670
|
-
];
|
|
448
|
+
const { ignores: ignores$1 = [] } = options;
|
|
449
|
+
return [{
|
|
450
|
+
ignores: [...GLOB_EXCLUDE, ...ignores$1],
|
|
451
|
+
name: "eslint/ignores"
|
|
452
|
+
}];
|
|
671
453
|
}
|
|
672
454
|
|
|
673
|
-
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/configs/imports.ts
|
|
674
457
|
async function imports(options = {}) {
|
|
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
|
-
...overrides
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
];
|
|
458
|
+
const { overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
459
|
+
return [{
|
|
460
|
+
name: "eslint/imports/rules",
|
|
461
|
+
plugins: {
|
|
462
|
+
antfu: eslint_plugin_antfu.default,
|
|
463
|
+
import: eslint_plugin_import_x
|
|
464
|
+
},
|
|
465
|
+
rules: {
|
|
466
|
+
"antfu/import-dedupe": "error",
|
|
467
|
+
"antfu/no-import-dist": "error",
|
|
468
|
+
"antfu/no-import-node-modules-by-path": "error",
|
|
469
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
470
|
+
"import/first": "error",
|
|
471
|
+
"import/no-duplicates": "error",
|
|
472
|
+
"import/no-mutable-exports": "error",
|
|
473
|
+
"import/no-named-default": "error",
|
|
474
|
+
"import/no-self-import": "error",
|
|
475
|
+
"import/no-webpack-loader-syntax": "error",
|
|
476
|
+
...stylistic$1 ? { "import/newline-after-import": ["error", {
|
|
477
|
+
considerComments: true,
|
|
478
|
+
count: 1
|
|
479
|
+
}] } : {},
|
|
480
|
+
...overrides
|
|
481
|
+
}
|
|
482
|
+
}];
|
|
704
483
|
}
|
|
705
484
|
|
|
706
|
-
|
|
707
|
-
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/configs/javascript.ts
|
|
708
487
|
async function javascript(options = {}) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
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
|
-
|
|
488
|
+
const { isInEditor = false, overrides = {} } = options;
|
|
489
|
+
return [{
|
|
490
|
+
languageOptions: {
|
|
491
|
+
ecmaVersion: 2022,
|
|
492
|
+
globals: {
|
|
493
|
+
...globals.default.browser,
|
|
494
|
+
...globals.default.es2021,
|
|
495
|
+
...globals.default.node,
|
|
496
|
+
document: "readonly",
|
|
497
|
+
navigator: "readonly",
|
|
498
|
+
window: "readonly"
|
|
499
|
+
},
|
|
500
|
+
parserOptions: {
|
|
501
|
+
ecmaFeatures: { jsx: true },
|
|
502
|
+
ecmaVersion: 2022,
|
|
503
|
+
sourceType: "module"
|
|
504
|
+
},
|
|
505
|
+
sourceType: "module"
|
|
506
|
+
},
|
|
507
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
508
|
+
name: "eslint/javascript/setup"
|
|
509
|
+
}, {
|
|
510
|
+
name: "eslint/javascript/rules",
|
|
511
|
+
plugins: {
|
|
512
|
+
"antfu": eslint_plugin_antfu.default,
|
|
513
|
+
"unused-imports": eslint_plugin_unused_imports.default
|
|
514
|
+
},
|
|
515
|
+
rules: {
|
|
516
|
+
"accessor-pairs": ["error", {
|
|
517
|
+
enforceForClassMembers: true,
|
|
518
|
+
setWithoutGet: true
|
|
519
|
+
}],
|
|
520
|
+
"antfu/no-top-level-await": "error",
|
|
521
|
+
"array-callback-return": "error",
|
|
522
|
+
"block-scoped-var": "error",
|
|
523
|
+
"constructor-super": "error",
|
|
524
|
+
"default-case-last": "error",
|
|
525
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
526
|
+
"eqeqeq": ["error", "smart"],
|
|
527
|
+
"new-cap": ["error", {
|
|
528
|
+
capIsNew: false,
|
|
529
|
+
newIsCap: true,
|
|
530
|
+
properties: true
|
|
531
|
+
}],
|
|
532
|
+
"no-alert": "error",
|
|
533
|
+
"no-array-constructor": "error",
|
|
534
|
+
"no-async-promise-executor": "error",
|
|
535
|
+
"no-caller": "error",
|
|
536
|
+
"no-case-declarations": "error",
|
|
537
|
+
"no-class-assign": "error",
|
|
538
|
+
"no-compare-neg-zero": "error",
|
|
539
|
+
"no-cond-assign": ["error", "always"],
|
|
540
|
+
"no-console": "off",
|
|
541
|
+
"no-const-assign": "error",
|
|
542
|
+
"no-control-regex": "error",
|
|
543
|
+
"no-debugger": "error",
|
|
544
|
+
"no-delete-var": "error",
|
|
545
|
+
"no-dupe-args": "error",
|
|
546
|
+
"no-dupe-class-members": "error",
|
|
547
|
+
"no-dupe-keys": "error",
|
|
548
|
+
"no-duplicate-case": "error",
|
|
549
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
550
|
+
"no-empty-character-class": "error",
|
|
551
|
+
"no-empty-pattern": "error",
|
|
552
|
+
"no-eval": "error",
|
|
553
|
+
"no-ex-assign": "error",
|
|
554
|
+
"no-extend-native": "error",
|
|
555
|
+
"no-extra-bind": "error",
|
|
556
|
+
"no-extra-boolean-cast": "error",
|
|
557
|
+
"no-fallthrough": "error",
|
|
558
|
+
"no-func-assign": "error",
|
|
559
|
+
"no-global-assign": "error",
|
|
560
|
+
"no-implied-eval": "error",
|
|
561
|
+
"no-import-assign": "error",
|
|
562
|
+
"no-invalid-regexp": "error",
|
|
563
|
+
"no-irregular-whitespace": "error",
|
|
564
|
+
"no-iterator": "error",
|
|
565
|
+
"no-labels": ["error", {
|
|
566
|
+
allowLoop: false,
|
|
567
|
+
allowSwitch: false
|
|
568
|
+
}],
|
|
569
|
+
"no-lone-blocks": "error",
|
|
570
|
+
"no-loss-of-precision": "error",
|
|
571
|
+
"no-misleading-character-class": "error",
|
|
572
|
+
"no-multi-str": "error",
|
|
573
|
+
"no-new": "error",
|
|
574
|
+
"no-new-func": "error",
|
|
575
|
+
"no-new-native-nonconstructor": "error",
|
|
576
|
+
"no-new-wrappers": "error",
|
|
577
|
+
"no-obj-calls": "error",
|
|
578
|
+
"no-octal": "error",
|
|
579
|
+
"no-octal-escape": "error",
|
|
580
|
+
"no-proto": "error",
|
|
581
|
+
"no-prototype-builtins": "error",
|
|
582
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
583
|
+
"no-regex-spaces": "error",
|
|
584
|
+
"no-restricted-globals": [
|
|
585
|
+
"error",
|
|
586
|
+
{
|
|
587
|
+
message: "Use `globalThis` instead.",
|
|
588
|
+
name: "global"
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
message: "Use `globalThis` instead.",
|
|
592
|
+
name: "self"
|
|
593
|
+
}
|
|
594
|
+
],
|
|
595
|
+
"no-restricted-properties": [
|
|
596
|
+
"error",
|
|
597
|
+
{
|
|
598
|
+
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
|
|
599
|
+
property: "__proto__"
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
message: "Use `Object.defineProperty` instead.",
|
|
603
|
+
property: "__defineGetter__"
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
message: "Use `Object.defineProperty` instead.",
|
|
607
|
+
property: "__defineSetter__"
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
611
|
+
property: "__lookupGetter__"
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
615
|
+
property: "__lookupSetter__"
|
|
616
|
+
}
|
|
617
|
+
],
|
|
618
|
+
"no-restricted-syntax": [
|
|
619
|
+
"error",
|
|
620
|
+
"TSEnumDeclaration[const=true]",
|
|
621
|
+
"TSExportAssignment"
|
|
622
|
+
],
|
|
623
|
+
"no-self-assign": ["error", { props: true }],
|
|
624
|
+
"no-self-compare": "error",
|
|
625
|
+
"no-sequences": "error",
|
|
626
|
+
"no-shadow-restricted-names": "error",
|
|
627
|
+
"no-sparse-arrays": "error",
|
|
628
|
+
"no-template-curly-in-string": "error",
|
|
629
|
+
"no-this-before-super": "error",
|
|
630
|
+
"no-throw-literal": "error",
|
|
631
|
+
"no-undef": "error",
|
|
632
|
+
"no-undef-init": "error",
|
|
633
|
+
"no-unexpected-multiline": "error",
|
|
634
|
+
"no-unmodified-loop-condition": "error",
|
|
635
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
636
|
+
"no-unreachable": "error",
|
|
637
|
+
"no-unreachable-loop": "error",
|
|
638
|
+
"no-unsafe-finally": "error",
|
|
639
|
+
"no-unsafe-negation": "error",
|
|
640
|
+
"no-unused-expressions": ["error", {
|
|
641
|
+
allowShortCircuit: true,
|
|
642
|
+
allowTaggedTemplates: true,
|
|
643
|
+
allowTernary: true
|
|
644
|
+
}],
|
|
645
|
+
"no-unused-vars": ["warn", {
|
|
646
|
+
args: "none",
|
|
647
|
+
caughtErrors: "none",
|
|
648
|
+
ignoreRestSiblings: true,
|
|
649
|
+
vars: "all"
|
|
650
|
+
}],
|
|
651
|
+
"no-use-before-define": ["error", {
|
|
652
|
+
classes: false,
|
|
653
|
+
functions: false,
|
|
654
|
+
variables: true
|
|
655
|
+
}],
|
|
656
|
+
"no-useless-backreference": "error",
|
|
657
|
+
"no-useless-call": "error",
|
|
658
|
+
"no-useless-catch": "error",
|
|
659
|
+
"no-useless-computed-key": "error",
|
|
660
|
+
"no-useless-constructor": "error",
|
|
661
|
+
"no-useless-rename": "error",
|
|
662
|
+
"no-useless-return": "error",
|
|
663
|
+
"no-var": "error",
|
|
664
|
+
"no-with": "error",
|
|
665
|
+
"object-shorthand": [
|
|
666
|
+
"error",
|
|
667
|
+
"always",
|
|
668
|
+
{
|
|
669
|
+
avoidQuotes: true,
|
|
670
|
+
ignoreConstructors: false
|
|
671
|
+
}
|
|
672
|
+
],
|
|
673
|
+
"one-var": ["error", { initialized: "never" }],
|
|
674
|
+
"prefer-arrow-callback": ["error", {
|
|
675
|
+
allowNamedFunctions: false,
|
|
676
|
+
allowUnboundThis: true
|
|
677
|
+
}],
|
|
678
|
+
"prefer-const": [isInEditor ? "warn" : "error", {
|
|
679
|
+
destructuring: "all",
|
|
680
|
+
ignoreReadBeforeAssign: true
|
|
681
|
+
}],
|
|
682
|
+
"prefer-exponentiation-operator": "error",
|
|
683
|
+
"prefer-promise-reject-errors": "error",
|
|
684
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
685
|
+
"prefer-rest-params": "error",
|
|
686
|
+
"prefer-spread": "error",
|
|
687
|
+
"prefer-template": "error",
|
|
688
|
+
"symbol-description": "error",
|
|
689
|
+
"unicode-bom": ["error", "never"],
|
|
690
|
+
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
|
|
691
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
692
|
+
args: "after-used",
|
|
693
|
+
argsIgnorePattern: "^_",
|
|
694
|
+
ignoreRestSiblings: true,
|
|
695
|
+
vars: "all",
|
|
696
|
+
varsIgnorePattern: "^_"
|
|
697
|
+
}],
|
|
698
|
+
"use-isnan": ["error", {
|
|
699
|
+
enforceForIndexOf: true,
|
|
700
|
+
enforceForSwitchCase: true
|
|
701
|
+
}],
|
|
702
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
703
|
+
"vars-on-top": "error",
|
|
704
|
+
"yoda": ["error", "never"],
|
|
705
|
+
...overrides
|
|
706
|
+
}
|
|
707
|
+
}];
|
|
911
708
|
}
|
|
912
709
|
|
|
913
|
-
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/configs/jsdoc.ts
|
|
914
712
|
async function jsdoc(options = {}) {
|
|
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
|
-
"jsdoc/check-alignment": "warn",
|
|
943
|
-
"jsdoc/multiline-blocks": "warn"
|
|
944
|
-
} : {},
|
|
945
|
-
...overrides
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
];
|
|
713
|
+
const { overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
714
|
+
return [{
|
|
715
|
+
name: "eslint/jsdoc/rules",
|
|
716
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
717
|
+
rules: {
|
|
718
|
+
"jsdoc/check-access": "warn",
|
|
719
|
+
"jsdoc/check-param-names": "warn",
|
|
720
|
+
"jsdoc/check-property-names": "warn",
|
|
721
|
+
"jsdoc/check-types": "warn",
|
|
722
|
+
"jsdoc/empty-tags": "warn",
|
|
723
|
+
"jsdoc/implements-on-classes": "warn",
|
|
724
|
+
"jsdoc/no-defaults": "warn",
|
|
725
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
726
|
+
"jsdoc/require-param-name": "warn",
|
|
727
|
+
"jsdoc/require-property": "warn",
|
|
728
|
+
"jsdoc/require-property-description": "warn",
|
|
729
|
+
"jsdoc/require-property-name": "warn",
|
|
730
|
+
"jsdoc/require-returns-check": "warn",
|
|
731
|
+
"jsdoc/require-returns-description": "warn",
|
|
732
|
+
"jsdoc/require-yields-check": "warn",
|
|
733
|
+
...stylistic$1 ? {
|
|
734
|
+
"jsdoc/check-alignment": "warn",
|
|
735
|
+
"jsdoc/multiline-blocks": "warn"
|
|
736
|
+
} : {},
|
|
737
|
+
...overrides
|
|
738
|
+
}
|
|
739
|
+
}];
|
|
949
740
|
}
|
|
950
741
|
|
|
951
|
-
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/configs/jsonc.ts
|
|
952
744
|
async function jsonc(options = {}) {
|
|
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
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
"jsonc/quote-props": "error",
|
|
1015
|
-
"jsonc/quotes": "error"
|
|
1016
|
-
} : {},
|
|
1017
|
-
...overrides
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
];
|
|
745
|
+
const { files = [
|
|
746
|
+
GLOB_JSON,
|
|
747
|
+
GLOB_JSON5,
|
|
748
|
+
GLOB_JSONC
|
|
749
|
+
], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
750
|
+
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
751
|
+
return [{
|
|
752
|
+
name: "eslint/jsonc/setup",
|
|
753
|
+
plugins: { jsonc: pluginJsonc }
|
|
754
|
+
}, {
|
|
755
|
+
files,
|
|
756
|
+
languageOptions: { parser: parserJsonc },
|
|
757
|
+
name: "eslint/jsonc/rules",
|
|
758
|
+
rules: {
|
|
759
|
+
"jsonc/no-bigint-literals": "error",
|
|
760
|
+
"jsonc/no-binary-expression": "error",
|
|
761
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
762
|
+
"jsonc/no-dupe-keys": "error",
|
|
763
|
+
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
764
|
+
"jsonc/no-floating-decimal": "error",
|
|
765
|
+
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
766
|
+
"jsonc/no-infinity": "error",
|
|
767
|
+
"jsonc/no-multi-str": "error",
|
|
768
|
+
"jsonc/no-nan": "error",
|
|
769
|
+
"jsonc/no-number-props": "error",
|
|
770
|
+
"jsonc/no-numeric-separators": "error",
|
|
771
|
+
"jsonc/no-octal": "error",
|
|
772
|
+
"jsonc/no-octal-escape": "error",
|
|
773
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
774
|
+
"jsonc/no-parenthesized": "error",
|
|
775
|
+
"jsonc/no-plus-sign": "error",
|
|
776
|
+
"jsonc/no-regexp-literals": "error",
|
|
777
|
+
"jsonc/no-sparse-arrays": "error",
|
|
778
|
+
"jsonc/no-template-literals": "error",
|
|
779
|
+
"jsonc/no-undefined-value": "error",
|
|
780
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
781
|
+
"jsonc/no-useless-escape": "error",
|
|
782
|
+
"jsonc/space-unary-ops": "error",
|
|
783
|
+
"jsonc/valid-json-number": "error",
|
|
784
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
785
|
+
...stylistic$1 ? {
|
|
786
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
787
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
788
|
+
"jsonc/comma-style": ["error", "last"],
|
|
789
|
+
"jsonc/indent": ["error", 2],
|
|
790
|
+
"jsonc/key-spacing": ["error", {
|
|
791
|
+
afterColon: true,
|
|
792
|
+
beforeColon: false
|
|
793
|
+
}],
|
|
794
|
+
"jsonc/object-curly-newline": ["error", {
|
|
795
|
+
consistent: true,
|
|
796
|
+
multiline: true
|
|
797
|
+
}],
|
|
798
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
799
|
+
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
800
|
+
"jsonc/quote-props": "error",
|
|
801
|
+
"jsonc/quotes": "error"
|
|
802
|
+
} : {},
|
|
803
|
+
...overrides
|
|
804
|
+
}
|
|
805
|
+
}];
|
|
1021
806
|
}
|
|
1022
807
|
|
|
1023
|
-
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/configs/jsx.ts
|
|
1024
810
|
async function jsx() {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
ecmaFeatures: {
|
|
1031
|
-
jsx: true
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
},
|
|
1035
|
-
name: "eslint/jsx/setup"
|
|
1036
|
-
}
|
|
1037
|
-
];
|
|
811
|
+
return [{
|
|
812
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
813
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
814
|
+
name: "eslint/jsx/setup"
|
|
815
|
+
}];
|
|
1038
816
|
}
|
|
1039
817
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/configs/markdown.ts
|
|
1043
820
|
async function markdown(options = {}) {
|
|
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
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
"unused-imports/no-unused-vars": "off",
|
|
1112
|
-
// Type aware rules
|
|
1113
|
-
...{
|
|
1114
|
-
"ts/await-thenable": "off",
|
|
1115
|
-
"ts/dot-notation": "off",
|
|
1116
|
-
"ts/no-floating-promises": "off",
|
|
1117
|
-
"ts/no-for-in-array": "off",
|
|
1118
|
-
"ts/no-implied-eval": "off",
|
|
1119
|
-
"ts/no-misused-promises": "off",
|
|
1120
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
1121
|
-
"ts/no-unsafe-argument": "off",
|
|
1122
|
-
"ts/no-unsafe-assignment": "off",
|
|
1123
|
-
"ts/no-unsafe-call": "off",
|
|
1124
|
-
"ts/no-unsafe-member-access": "off",
|
|
1125
|
-
"ts/no-unsafe-return": "off",
|
|
1126
|
-
"ts/restrict-plus-operands": "off",
|
|
1127
|
-
"ts/restrict-template-expressions": "off",
|
|
1128
|
-
"ts/unbound-method": "off"
|
|
1129
|
-
},
|
|
1130
|
-
...overrides
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
];
|
|
821
|
+
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
|
|
822
|
+
const markdown$1 = await interopDefault(import("@eslint/markdown"));
|
|
823
|
+
return [
|
|
824
|
+
{
|
|
825
|
+
name: "eslint/markdown/setup",
|
|
826
|
+
plugins: { markdown: markdown$1 }
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
files,
|
|
830
|
+
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
831
|
+
name: "eslint/markdown/processor",
|
|
832
|
+
processor: (0, eslint_merge_processors.mergeProcessors)([markdown$1.processors.markdown, eslint_merge_processors.processorPassThrough])
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
files,
|
|
836
|
+
languageOptions: { parser: eslint_parser_plain },
|
|
837
|
+
name: "eslint/markdown/parser"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
|
|
841
|
+
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
842
|
+
name: "eslint/markdown/disables",
|
|
843
|
+
rules: {
|
|
844
|
+
"antfu/no-top-level-await": "off",
|
|
845
|
+
"import/newline-after-import": "off",
|
|
846
|
+
"no-alert": "off",
|
|
847
|
+
"no-console": "off",
|
|
848
|
+
"no-labels": "off",
|
|
849
|
+
"no-lone-blocks": "off",
|
|
850
|
+
"no-restricted-syntax": "off",
|
|
851
|
+
"no-undef": "off",
|
|
852
|
+
"no-unused-expressions": "off",
|
|
853
|
+
"no-unused-labels": "off",
|
|
854
|
+
"no-unused-vars": "off",
|
|
855
|
+
"node/prefer-global/process": "off",
|
|
856
|
+
"style/comma-dangle": "off",
|
|
857
|
+
"style/eol-last": "off",
|
|
858
|
+
"ts/consistent-type-imports": "off",
|
|
859
|
+
"ts/explicit-function-return-type": "off",
|
|
860
|
+
"ts/no-namespace": "off",
|
|
861
|
+
"ts/no-redeclare": "off",
|
|
862
|
+
"ts/no-require-imports": "off",
|
|
863
|
+
"ts/no-unused-expressions": "off",
|
|
864
|
+
"ts/no-unused-vars": "off",
|
|
865
|
+
"ts/no-use-before-define": "off",
|
|
866
|
+
"unicode-bom": "off",
|
|
867
|
+
"unused-imports/no-unused-imports": "off",
|
|
868
|
+
"unused-imports/no-unused-vars": "off",
|
|
869
|
+
"ts/await-thenable": "off",
|
|
870
|
+
"ts/dot-notation": "off",
|
|
871
|
+
"ts/no-floating-promises": "off",
|
|
872
|
+
"ts/no-for-in-array": "off",
|
|
873
|
+
"ts/no-implied-eval": "off",
|
|
874
|
+
"ts/no-misused-promises": "off",
|
|
875
|
+
"ts/no-unnecessary-type-assertion": "off",
|
|
876
|
+
"ts/no-unsafe-argument": "off",
|
|
877
|
+
"ts/no-unsafe-assignment": "off",
|
|
878
|
+
"ts/no-unsafe-call": "off",
|
|
879
|
+
"ts/no-unsafe-member-access": "off",
|
|
880
|
+
"ts/no-unsafe-return": "off",
|
|
881
|
+
"ts/restrict-plus-operands": "off",
|
|
882
|
+
"ts/restrict-template-expressions": "off",
|
|
883
|
+
"ts/unbound-method": "off",
|
|
884
|
+
...overrides
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
];
|
|
1134
888
|
}
|
|
1135
889
|
|
|
1136
|
-
|
|
890
|
+
//#endregion
|
|
891
|
+
//#region src/configs/node.ts
|
|
1137
892
|
async function node(options = {}) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
"node/prefer-global/process": ["error", "never"],
|
|
1155
|
-
"node/process-exit-as-throw": "error",
|
|
1156
|
-
...overrides
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
];
|
|
893
|
+
const { overrides = {} } = options;
|
|
894
|
+
return [{
|
|
895
|
+
name: "eslint/node/rules",
|
|
896
|
+
plugins: { node: eslint_plugin_n.default },
|
|
897
|
+
rules: {
|
|
898
|
+
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
899
|
+
"node/no-deprecated-api": "error",
|
|
900
|
+
"node/no-exports-assign": "error",
|
|
901
|
+
"node/no-new-require": "error",
|
|
902
|
+
"node/no-path-concat": "error",
|
|
903
|
+
"node/prefer-global/buffer": ["error", "never"],
|
|
904
|
+
"node/prefer-global/process": ["error", "never"],
|
|
905
|
+
"node/process-exit-as-throw": "error",
|
|
906
|
+
...overrides
|
|
907
|
+
}
|
|
908
|
+
}];
|
|
1160
909
|
}
|
|
1161
910
|
|
|
1162
|
-
|
|
911
|
+
//#endregion
|
|
912
|
+
//#region src/configs/perfectionist.ts
|
|
913
|
+
/**
|
|
914
|
+
* Optional perfectionist plugin for props and items sorting.
|
|
915
|
+
*
|
|
916
|
+
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
917
|
+
*/
|
|
1163
918
|
async function perfectionist(options = {}) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
919
|
+
const { overrides = {} } = options;
|
|
920
|
+
return [{
|
|
921
|
+
name: "eslint/perfectionist/setup",
|
|
922
|
+
plugins: { perfectionist: eslint_plugin_perfectionist.default },
|
|
923
|
+
rules: {
|
|
924
|
+
"perfectionist/sort-exports": ["error", {
|
|
925
|
+
order: "asc",
|
|
926
|
+
type: "natural"
|
|
927
|
+
}],
|
|
928
|
+
"perfectionist/sort-imports": ["error", {
|
|
929
|
+
groups: [
|
|
930
|
+
"type",
|
|
931
|
+
"builtin-type",
|
|
932
|
+
[
|
|
933
|
+
"index-type",
|
|
934
|
+
"parent-type",
|
|
935
|
+
"sibling-type",
|
|
936
|
+
"internal-type"
|
|
937
|
+
],
|
|
938
|
+
"builtin",
|
|
939
|
+
"external",
|
|
940
|
+
"internal",
|
|
941
|
+
[
|
|
942
|
+
"index",
|
|
943
|
+
"parent",
|
|
944
|
+
"sibling"
|
|
945
|
+
],
|
|
946
|
+
"side-effect",
|
|
947
|
+
"object",
|
|
948
|
+
"unknown"
|
|
949
|
+
],
|
|
950
|
+
internalPattern: ["^~/.*", "^@/.*"],
|
|
951
|
+
newlinesBetween: "ignore",
|
|
952
|
+
order: "asc",
|
|
953
|
+
type: "natural"
|
|
954
|
+
}],
|
|
955
|
+
"perfectionist/sort-named-exports": ["error", {
|
|
956
|
+
order: "asc",
|
|
957
|
+
type: "natural"
|
|
958
|
+
}],
|
|
959
|
+
"perfectionist/sort-named-imports": ["error", {
|
|
960
|
+
order: "asc",
|
|
961
|
+
type: "natural"
|
|
962
|
+
}],
|
|
963
|
+
...overrides
|
|
964
|
+
}
|
|
965
|
+
}];
|
|
1199
966
|
}
|
|
1200
967
|
|
|
1201
|
-
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region src/configs/pnpm.ts
|
|
1202
970
|
async function pnpm() {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
"pnpm/json-valid-catalog": "error"
|
|
1229
|
-
}
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
files: ["pnpm-workspace.yaml"],
|
|
1233
|
-
languageOptions: {
|
|
1234
|
-
parser: yamlParser
|
|
1235
|
-
},
|
|
1236
|
-
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
1237
|
-
plugins: {
|
|
1238
|
-
pnpm: pluginPnpm
|
|
1239
|
-
},
|
|
1240
|
-
rules: {
|
|
1241
|
-
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1242
|
-
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
];
|
|
971
|
+
const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
972
|
+
interopDefault(import("eslint-plugin-pnpm")),
|
|
973
|
+
interopDefault(import("yaml-eslint-parser")),
|
|
974
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
975
|
+
]);
|
|
976
|
+
return [{
|
|
977
|
+
files: ["package.json", "**/package.json"],
|
|
978
|
+
languageOptions: { parser: jsoncParser },
|
|
979
|
+
name: "eslint/pnpm/package-json",
|
|
980
|
+
plugins: { pnpm: pluginPnpm },
|
|
981
|
+
rules: {
|
|
982
|
+
"pnpm/json-enforce-catalog": "error",
|
|
983
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
984
|
+
"pnpm/json-valid-catalog": "error"
|
|
985
|
+
}
|
|
986
|
+
}, {
|
|
987
|
+
files: ["pnpm-workspace.yaml"],
|
|
988
|
+
languageOptions: { parser: yamlParser },
|
|
989
|
+
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
990
|
+
plugins: { pnpm: pluginPnpm },
|
|
991
|
+
rules: {
|
|
992
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
993
|
+
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
994
|
+
}
|
|
995
|
+
}];
|
|
1246
996
|
}
|
|
1247
997
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/configs/react.ts
|
|
1000
|
+
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
1001
|
+
const RemixPackages = [
|
|
1002
|
+
"@remix-run/node",
|
|
1003
|
+
"@remix-run/react",
|
|
1004
|
+
"@remix-run/serve",
|
|
1005
|
+
"@remix-run/dev"
|
|
1252
1006
|
];
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
];
|
|
1259
|
-
var ReactRouterPackages = [
|
|
1260
|
-
"@react-router/node",
|
|
1261
|
-
"@react-router/react",
|
|
1262
|
-
"@react-router/serve",
|
|
1263
|
-
"@react-router/dev"
|
|
1264
|
-
];
|
|
1265
|
-
var NextJsPackages = [
|
|
1266
|
-
"next"
|
|
1007
|
+
const ReactRouterPackages = [
|
|
1008
|
+
"@react-router/node",
|
|
1009
|
+
"@react-router/react",
|
|
1010
|
+
"@react-router/serve",
|
|
1011
|
+
"@react-router/dev"
|
|
1267
1012
|
];
|
|
1013
|
+
const NextJsPackages = ["next"];
|
|
1268
1014
|
async function react(options = {}) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
"react/no-implicit-key": "warn",
|
|
1407
|
-
"react/no-missing-key": "error",
|
|
1408
|
-
"react/no-nested-component-definitions": "error",
|
|
1409
|
-
"react/no-prop-types": "error",
|
|
1410
|
-
"react/no-redundant-should-component-update": "error",
|
|
1411
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1412
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1413
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1414
|
-
"react/no-string-refs": "error",
|
|
1415
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1416
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1417
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1418
|
-
"react/no-unstable-context-value": "warn",
|
|
1419
|
-
"react/no-unstable-default-props": "warn",
|
|
1420
|
-
"react/no-unused-class-component-members": "warn",
|
|
1421
|
-
"react/no-unused-state": "warn",
|
|
1422
|
-
"react/no-use-context": "warn",
|
|
1423
|
-
"react/no-useless-forward-ref": "warn",
|
|
1424
|
-
"react/use-jsx-vars": "warn",
|
|
1425
|
-
// overrides
|
|
1426
|
-
...overrides
|
|
1427
|
-
}
|
|
1428
|
-
},
|
|
1429
|
-
...isTypeAware ? [{
|
|
1430
|
-
files: filesTypeAware,
|
|
1431
|
-
ignores: ignoresTypeAware,
|
|
1432
|
-
name: "eslint/react/type-aware-rules",
|
|
1433
|
-
rules: {
|
|
1434
|
-
...typeAwareRules
|
|
1435
|
-
}
|
|
1436
|
-
}] : []
|
|
1437
|
-
];
|
|
1015
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {}, tsconfigPath } = options;
|
|
1016
|
+
await ensurePackages([
|
|
1017
|
+
"@eslint-react/eslint-plugin",
|
|
1018
|
+
"eslint-plugin-react-hooks",
|
|
1019
|
+
"eslint-plugin-react-refresh"
|
|
1020
|
+
]);
|
|
1021
|
+
const isTypeAware = !!tsconfigPath;
|
|
1022
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
|
|
1023
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1024
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1025
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1026
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1027
|
+
]);
|
|
1028
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1029
|
+
const isUsingRemix = RemixPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1030
|
+
const isUsingReactRouter = ReactRouterPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1031
|
+
const isUsingNext = NextJsPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1032
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
1033
|
+
return [
|
|
1034
|
+
{
|
|
1035
|
+
name: "eslint/react/setup",
|
|
1036
|
+
plugins: {
|
|
1037
|
+
"react": plugins["@eslint-react"],
|
|
1038
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
1039
|
+
"react-hooks": pluginReactHooks,
|
|
1040
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1041
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1042
|
+
"react-refresh": pluginReactRefresh,
|
|
1043
|
+
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
files,
|
|
1048
|
+
languageOptions: {
|
|
1049
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
1050
|
+
sourceType: "module"
|
|
1051
|
+
},
|
|
1052
|
+
name: "eslint/react/rules",
|
|
1053
|
+
rules: {
|
|
1054
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1055
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1056
|
+
"react-dom/no-find-dom-node": "error",
|
|
1057
|
+
"react-dom/no-flush-sync": "error",
|
|
1058
|
+
"react-dom/no-hydrate": "error",
|
|
1059
|
+
"react-dom/no-missing-button-type": "warn",
|
|
1060
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
1061
|
+
"react-dom/no-namespace": "error",
|
|
1062
|
+
"react-dom/no-render": "error",
|
|
1063
|
+
"react-dom/no-render-return-value": "error",
|
|
1064
|
+
"react-dom/no-script-url": "warn",
|
|
1065
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1066
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
1067
|
+
"react-dom/no-use-form-state": "error",
|
|
1068
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
1069
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1070
|
+
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
1071
|
+
"react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
|
|
1072
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1073
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1074
|
+
"react-refresh/only-export-components": ["warn", {
|
|
1075
|
+
allowConstantExport: isAllowConstantExport,
|
|
1076
|
+
allowExportNames: [...isUsingNext ? [
|
|
1077
|
+
"dynamic",
|
|
1078
|
+
"dynamicParams",
|
|
1079
|
+
"revalidate",
|
|
1080
|
+
"fetchCache",
|
|
1081
|
+
"runtime",
|
|
1082
|
+
"preferredRegion",
|
|
1083
|
+
"maxDuration",
|
|
1084
|
+
"config",
|
|
1085
|
+
"generateStaticParams",
|
|
1086
|
+
"metadata",
|
|
1087
|
+
"generateMetadata",
|
|
1088
|
+
"viewport",
|
|
1089
|
+
"generateViewport"
|
|
1090
|
+
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1091
|
+
"meta",
|
|
1092
|
+
"links",
|
|
1093
|
+
"headers",
|
|
1094
|
+
"loader",
|
|
1095
|
+
"action"
|
|
1096
|
+
] : []]
|
|
1097
|
+
}],
|
|
1098
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1099
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1100
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1101
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1102
|
+
"react/jsx-no-duplicate-props": "warn",
|
|
1103
|
+
"react/jsx-uses-vars": "warn",
|
|
1104
|
+
"react/no-access-state-in-setstate": "error",
|
|
1105
|
+
"react/no-array-index-key": "warn",
|
|
1106
|
+
"react/no-children-count": "warn",
|
|
1107
|
+
"react/no-children-for-each": "warn",
|
|
1108
|
+
"react/no-children-map": "warn",
|
|
1109
|
+
"react/no-children-only": "warn",
|
|
1110
|
+
"react/no-children-to-array": "warn",
|
|
1111
|
+
"react/no-clone-element": "warn",
|
|
1112
|
+
"react/no-comment-textnodes": "warn",
|
|
1113
|
+
"react/no-component-will-mount": "error",
|
|
1114
|
+
"react/no-component-will-receive-props": "error",
|
|
1115
|
+
"react/no-component-will-update": "error",
|
|
1116
|
+
"react/no-context-provider": "warn",
|
|
1117
|
+
"react/no-create-ref": "error",
|
|
1118
|
+
"react/no-default-props": "error",
|
|
1119
|
+
"react/no-direct-mutation-state": "error",
|
|
1120
|
+
"react/no-duplicate-jsx-props": "warn",
|
|
1121
|
+
"react/no-duplicate-key": "warn",
|
|
1122
|
+
"react/no-forward-ref": "warn",
|
|
1123
|
+
"react/no-implicit-key": "warn",
|
|
1124
|
+
"react/no-missing-key": "error",
|
|
1125
|
+
"react/no-nested-component-definitions": "error",
|
|
1126
|
+
"react/no-prop-types": "error",
|
|
1127
|
+
"react/no-redundant-should-component-update": "error",
|
|
1128
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
1129
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
1130
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
1131
|
+
"react/no-string-refs": "error",
|
|
1132
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
1133
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1134
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
1135
|
+
"react/no-unstable-context-value": "warn",
|
|
1136
|
+
"react/no-unstable-default-props": "warn",
|
|
1137
|
+
"react/no-unused-class-component-members": "warn",
|
|
1138
|
+
"react/no-unused-state": "warn",
|
|
1139
|
+
"react/no-use-context": "warn",
|
|
1140
|
+
"react/no-useless-forward-ref": "warn",
|
|
1141
|
+
"react/use-jsx-vars": "warn",
|
|
1142
|
+
...overrides
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
...isTypeAware ? [{
|
|
1146
|
+
files: filesTypeAware,
|
|
1147
|
+
ignores: ignoresTypeAware,
|
|
1148
|
+
name: "eslint/react/type-aware-rules",
|
|
1149
|
+
rules: { ...typeAwareRules }
|
|
1150
|
+
}] : []
|
|
1151
|
+
];
|
|
1438
1152
|
}
|
|
1439
1153
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/configs/regexp.ts
|
|
1442
1156
|
async function regexp(options = {}) {
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
...config,
|
|
1457
|
-
name: "eslint/regexp/rules",
|
|
1458
|
-
rules: {
|
|
1459
|
-
...rules,
|
|
1460
|
-
...options.overrides
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
];
|
|
1157
|
+
const config = eslint_plugin_regexp.configs["flat/recommended"];
|
|
1158
|
+
const rules = { ...config.rules };
|
|
1159
|
+
if (options.level === "warn") {
|
|
1160
|
+
for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
|
|
1161
|
+
}
|
|
1162
|
+
return [{
|
|
1163
|
+
...config,
|
|
1164
|
+
name: "eslint/regexp/rules",
|
|
1165
|
+
rules: {
|
|
1166
|
+
...rules,
|
|
1167
|
+
...options.overrides
|
|
1168
|
+
}
|
|
1169
|
+
}];
|
|
1464
1170
|
}
|
|
1465
1171
|
|
|
1466
|
-
|
|
1172
|
+
//#endregion
|
|
1173
|
+
//#region src/configs/sort.ts
|
|
1174
|
+
/**
|
|
1175
|
+
* Sort package.json
|
|
1176
|
+
*
|
|
1177
|
+
* Requires `jsonc` config
|
|
1178
|
+
*/
|
|
1467
1179
|
async function sortPackageJson() {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}
|
|
1564
|
-
]
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
];
|
|
1180
|
+
return [{
|
|
1181
|
+
files: ["**/package.json"],
|
|
1182
|
+
name: "eslint/sort/package-json",
|
|
1183
|
+
rules: {
|
|
1184
|
+
"jsonc/sort-array-values": ["error", {
|
|
1185
|
+
order: { type: "asc" },
|
|
1186
|
+
pathPattern: "^files$"
|
|
1187
|
+
}],
|
|
1188
|
+
"jsonc/sort-keys": [
|
|
1189
|
+
"error",
|
|
1190
|
+
{
|
|
1191
|
+
order: [
|
|
1192
|
+
"publisher",
|
|
1193
|
+
"name",
|
|
1194
|
+
"displayName",
|
|
1195
|
+
"type",
|
|
1196
|
+
"version",
|
|
1197
|
+
"private",
|
|
1198
|
+
"packageManager",
|
|
1199
|
+
"description",
|
|
1200
|
+
"contributors",
|
|
1201
|
+
"author",
|
|
1202
|
+
"license",
|
|
1203
|
+
"funding",
|
|
1204
|
+
"homepage",
|
|
1205
|
+
"repository",
|
|
1206
|
+
"bugs",
|
|
1207
|
+
"keywords",
|
|
1208
|
+
"categories",
|
|
1209
|
+
"sideEffects",
|
|
1210
|
+
"imports",
|
|
1211
|
+
"exports",
|
|
1212
|
+
"main",
|
|
1213
|
+
"module",
|
|
1214
|
+
"unpkg",
|
|
1215
|
+
"jsdelivr",
|
|
1216
|
+
"types",
|
|
1217
|
+
"typesVersions",
|
|
1218
|
+
"bin",
|
|
1219
|
+
"icon",
|
|
1220
|
+
"files",
|
|
1221
|
+
"engines",
|
|
1222
|
+
"activationEvents",
|
|
1223
|
+
"contributes",
|
|
1224
|
+
"scripts",
|
|
1225
|
+
"peerDependencies",
|
|
1226
|
+
"peerDependenciesMeta",
|
|
1227
|
+
"dependencies",
|
|
1228
|
+
"optionalDependencies",
|
|
1229
|
+
"devDependencies",
|
|
1230
|
+
"pnpm",
|
|
1231
|
+
"overrides",
|
|
1232
|
+
"resolutions",
|
|
1233
|
+
"husky",
|
|
1234
|
+
"simple-git-hooks",
|
|
1235
|
+
"lint-staged",
|
|
1236
|
+
"eslintConfig"
|
|
1237
|
+
],
|
|
1238
|
+
pathPattern: "^$"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
order: { type: "asc" },
|
|
1242
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
order: { type: "asc" },
|
|
1246
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
order: [
|
|
1250
|
+
"types",
|
|
1251
|
+
"import",
|
|
1252
|
+
"require",
|
|
1253
|
+
"default"
|
|
1254
|
+
],
|
|
1255
|
+
pathPattern: "^exports.*$"
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
order: [
|
|
1259
|
+
"pre-commit",
|
|
1260
|
+
"prepare-commit-msg",
|
|
1261
|
+
"commit-msg",
|
|
1262
|
+
"post-commit",
|
|
1263
|
+
"pre-rebase",
|
|
1264
|
+
"post-rewrite",
|
|
1265
|
+
"post-checkout",
|
|
1266
|
+
"post-merge",
|
|
1267
|
+
"pre-push",
|
|
1268
|
+
"pre-auto-gc"
|
|
1269
|
+
],
|
|
1270
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
1271
|
+
}
|
|
1272
|
+
]
|
|
1273
|
+
}
|
|
1274
|
+
}];
|
|
1568
1275
|
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Sort tsconfig.json
|
|
1278
|
+
*
|
|
1279
|
+
* Requires `jsonc` config
|
|
1280
|
+
*/
|
|
1569
1281
|
function sortTsconfig() {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
"verbatimModuleSyntax",
|
|
1684
|
-
"erasableSyntaxOnly",
|
|
1685
|
-
/* Completeness */
|
|
1686
|
-
"skipDefaultLibCheck",
|
|
1687
|
-
"skipLibCheck"
|
|
1688
|
-
],
|
|
1689
|
-
pathPattern: "^compilerOptions$"
|
|
1690
|
-
}
|
|
1691
|
-
]
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
];
|
|
1282
|
+
return [{
|
|
1283
|
+
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
1284
|
+
name: "eslint/sort/tsconfig",
|
|
1285
|
+
rules: { "jsonc/sort-keys": [
|
|
1286
|
+
"error",
|
|
1287
|
+
{
|
|
1288
|
+
order: [
|
|
1289
|
+
"extends",
|
|
1290
|
+
"compilerOptions",
|
|
1291
|
+
"references",
|
|
1292
|
+
"files",
|
|
1293
|
+
"include",
|
|
1294
|
+
"exclude"
|
|
1295
|
+
],
|
|
1296
|
+
pathPattern: "^$"
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
order: [
|
|
1300
|
+
"incremental",
|
|
1301
|
+
"composite",
|
|
1302
|
+
"tsBuildInfoFile",
|
|
1303
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
1304
|
+
"disableSolutionSearching",
|
|
1305
|
+
"disableReferencedProjectLoad",
|
|
1306
|
+
"target",
|
|
1307
|
+
"jsx",
|
|
1308
|
+
"jsxFactory",
|
|
1309
|
+
"jsxFragmentFactory",
|
|
1310
|
+
"jsxImportSource",
|
|
1311
|
+
"lib",
|
|
1312
|
+
"moduleDetection",
|
|
1313
|
+
"noLib",
|
|
1314
|
+
"reactNamespace",
|
|
1315
|
+
"useDefineForClassFields",
|
|
1316
|
+
"emitDecoratorMetadata",
|
|
1317
|
+
"experimentalDecorators",
|
|
1318
|
+
"libReplacement",
|
|
1319
|
+
"baseUrl",
|
|
1320
|
+
"rootDir",
|
|
1321
|
+
"rootDirs",
|
|
1322
|
+
"customConditions",
|
|
1323
|
+
"module",
|
|
1324
|
+
"moduleResolution",
|
|
1325
|
+
"moduleSuffixes",
|
|
1326
|
+
"noResolve",
|
|
1327
|
+
"paths",
|
|
1328
|
+
"resolveJsonModule",
|
|
1329
|
+
"resolvePackageJsonExports",
|
|
1330
|
+
"resolvePackageJsonImports",
|
|
1331
|
+
"typeRoots",
|
|
1332
|
+
"types",
|
|
1333
|
+
"allowArbitraryExtensions",
|
|
1334
|
+
"allowImportingTsExtensions",
|
|
1335
|
+
"allowUmdGlobalAccess",
|
|
1336
|
+
"allowJs",
|
|
1337
|
+
"checkJs",
|
|
1338
|
+
"maxNodeModuleJsDepth",
|
|
1339
|
+
"strict",
|
|
1340
|
+
"strictBindCallApply",
|
|
1341
|
+
"strictFunctionTypes",
|
|
1342
|
+
"strictNullChecks",
|
|
1343
|
+
"strictPropertyInitialization",
|
|
1344
|
+
"allowUnreachableCode",
|
|
1345
|
+
"allowUnusedLabels",
|
|
1346
|
+
"alwaysStrict",
|
|
1347
|
+
"exactOptionalPropertyTypes",
|
|
1348
|
+
"noFallthroughCasesInSwitch",
|
|
1349
|
+
"noImplicitAny",
|
|
1350
|
+
"noImplicitOverride",
|
|
1351
|
+
"noImplicitReturns",
|
|
1352
|
+
"noImplicitThis",
|
|
1353
|
+
"noPropertyAccessFromIndexSignature",
|
|
1354
|
+
"noUncheckedIndexedAccess",
|
|
1355
|
+
"noUnusedLocals",
|
|
1356
|
+
"noUnusedParameters",
|
|
1357
|
+
"useUnknownInCatchVariables",
|
|
1358
|
+
"declaration",
|
|
1359
|
+
"declarationDir",
|
|
1360
|
+
"declarationMap",
|
|
1361
|
+
"downlevelIteration",
|
|
1362
|
+
"emitBOM",
|
|
1363
|
+
"emitDeclarationOnly",
|
|
1364
|
+
"importHelpers",
|
|
1365
|
+
"importsNotUsedAsValues",
|
|
1366
|
+
"inlineSourceMap",
|
|
1367
|
+
"inlineSources",
|
|
1368
|
+
"mapRoot",
|
|
1369
|
+
"newLine",
|
|
1370
|
+
"noEmit",
|
|
1371
|
+
"noEmitHelpers",
|
|
1372
|
+
"noEmitOnError",
|
|
1373
|
+
"outDir",
|
|
1374
|
+
"outFile",
|
|
1375
|
+
"preserveConstEnums",
|
|
1376
|
+
"preserveValueImports",
|
|
1377
|
+
"removeComments",
|
|
1378
|
+
"sourceMap",
|
|
1379
|
+
"sourceRoot",
|
|
1380
|
+
"stripInternal",
|
|
1381
|
+
"allowSyntheticDefaultImports",
|
|
1382
|
+
"esModuleInterop",
|
|
1383
|
+
"forceConsistentCasingInFileNames",
|
|
1384
|
+
"isolatedModules",
|
|
1385
|
+
"preserveSymlinks",
|
|
1386
|
+
"verbatimModuleSyntax",
|
|
1387
|
+
"erasableSyntaxOnly",
|
|
1388
|
+
"skipDefaultLibCheck",
|
|
1389
|
+
"skipLibCheck"
|
|
1390
|
+
],
|
|
1391
|
+
pathPattern: "^compilerOptions$"
|
|
1392
|
+
}
|
|
1393
|
+
] }
|
|
1394
|
+
}];
|
|
1695
1395
|
}
|
|
1696
1396
|
|
|
1697
|
-
|
|
1397
|
+
//#endregion
|
|
1398
|
+
//#region src/configs/test.ts
|
|
1698
1399
|
async function test(options = {}) {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1731
|
-
"test/no-identical-title": "error",
|
|
1732
|
-
"test/no-import-node-test": "error",
|
|
1733
|
-
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
1734
|
-
"test/prefer-hooks-in-order": "error",
|
|
1735
|
-
"test/prefer-lowercase-title": "error",
|
|
1736
|
-
// Disables
|
|
1737
|
-
...{
|
|
1738
|
-
"antfu/no-top-level-await": "off",
|
|
1739
|
-
"no-unused-expressions": "off",
|
|
1740
|
-
"node/prefer-global/process": "off",
|
|
1741
|
-
"ts/explicit-function-return-type": "off"
|
|
1742
|
-
},
|
|
1743
|
-
...overrides
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
];
|
|
1400
|
+
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
1401
|
+
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
|
|
1402
|
+
return [{
|
|
1403
|
+
name: "eslint/test/setup",
|
|
1404
|
+
plugins: { test: {
|
|
1405
|
+
...pluginVitest,
|
|
1406
|
+
rules: {
|
|
1407
|
+
...pluginVitest.rules,
|
|
1408
|
+
...pluginNoOnlyTests.rules
|
|
1409
|
+
}
|
|
1410
|
+
} }
|
|
1411
|
+
}, {
|
|
1412
|
+
files,
|
|
1413
|
+
name: "eslint/test/rules",
|
|
1414
|
+
rules: {
|
|
1415
|
+
"test/consistent-test-it": ["error", {
|
|
1416
|
+
fn: "it",
|
|
1417
|
+
withinDescribe: "it"
|
|
1418
|
+
}],
|
|
1419
|
+
"test/no-identical-title": "error",
|
|
1420
|
+
"test/no-import-node-test": "error",
|
|
1421
|
+
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
1422
|
+
"test/prefer-hooks-in-order": "error",
|
|
1423
|
+
"test/prefer-lowercase-title": "error",
|
|
1424
|
+
"antfu/no-top-level-await": "off",
|
|
1425
|
+
"no-unused-expressions": "off",
|
|
1426
|
+
"node/prefer-global/process": "off",
|
|
1427
|
+
"ts/explicit-function-return-type": "off",
|
|
1428
|
+
...overrides
|
|
1429
|
+
}
|
|
1430
|
+
}];
|
|
1747
1431
|
}
|
|
1748
1432
|
|
|
1749
|
-
|
|
1433
|
+
//#endregion
|
|
1434
|
+
//#region src/configs/toml.ts
|
|
1750
1435
|
async function toml(options = {}) {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
"toml/tables-order": "error",
|
|
1788
|
-
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1789
|
-
...stylistic2 ? {
|
|
1790
|
-
"toml/array-bracket-newline": "error",
|
|
1791
|
-
"toml/array-bracket-spacing": "error",
|
|
1792
|
-
"toml/array-element-newline": "error",
|
|
1793
|
-
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1794
|
-
"toml/inline-table-curly-spacing": "error",
|
|
1795
|
-
"toml/key-spacing": "error",
|
|
1796
|
-
"toml/padding-line-between-pairs": "error",
|
|
1797
|
-
"toml/padding-line-between-tables": "error",
|
|
1798
|
-
"toml/quoted-keys": "error",
|
|
1799
|
-
"toml/spaced-comment": "error",
|
|
1800
|
-
"toml/table-bracket-spacing": "error"
|
|
1801
|
-
} : {},
|
|
1802
|
-
...overrides
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
];
|
|
1436
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
1437
|
+
const { indent = 4 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
1438
|
+
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1439
|
+
return [{
|
|
1440
|
+
name: "eslint/toml/setup",
|
|
1441
|
+
plugins: { toml: pluginToml }
|
|
1442
|
+
}, {
|
|
1443
|
+
files,
|
|
1444
|
+
languageOptions: { parser: parserToml },
|
|
1445
|
+
name: "eslint/toml/rules",
|
|
1446
|
+
rules: {
|
|
1447
|
+
"style/spaced-comment": "off",
|
|
1448
|
+
"toml/comma-style": "error",
|
|
1449
|
+
"toml/keys-order": "error",
|
|
1450
|
+
"toml/no-space-dots": "error",
|
|
1451
|
+
"toml/no-unreadable-number-separator": "error",
|
|
1452
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
1453
|
+
"toml/precision-of-integer": "error",
|
|
1454
|
+
"toml/tables-order": "error",
|
|
1455
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1456
|
+
...stylistic$1 ? {
|
|
1457
|
+
"toml/array-bracket-newline": "error",
|
|
1458
|
+
"toml/array-bracket-spacing": "error",
|
|
1459
|
+
"toml/array-element-newline": "error",
|
|
1460
|
+
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1461
|
+
"toml/inline-table-curly-spacing": "error",
|
|
1462
|
+
"toml/key-spacing": "error",
|
|
1463
|
+
"toml/padding-line-between-pairs": "error",
|
|
1464
|
+
"toml/padding-line-between-tables": "error",
|
|
1465
|
+
"toml/quoted-keys": "error",
|
|
1466
|
+
"toml/spaced-comment": "error",
|
|
1467
|
+
"toml/table-bracket-spacing": "error"
|
|
1468
|
+
} : {},
|
|
1469
|
+
...overrides
|
|
1470
|
+
}
|
|
1471
|
+
}];
|
|
1806
1472
|
}
|
|
1807
1473
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1474
|
+
//#endregion
|
|
1475
|
+
//#region src/configs/typescript.ts
|
|
1810
1476
|
async function typescript(options = {}) {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
ignoreRestSiblings: true,
|
|
1947
|
-
varsIgnorePattern: "^_"
|
|
1948
|
-
}
|
|
1949
|
-
],
|
|
1950
|
-
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1951
|
-
"ts/no-useless-constructor": "off",
|
|
1952
|
-
"ts/no-wrapper-object-types": "error",
|
|
1953
|
-
"ts/triple-slash-reference": "off",
|
|
1954
|
-
"ts/unified-signatures": "off",
|
|
1955
|
-
"unused-imports/no-unused-vars": "off",
|
|
1956
|
-
...type === "lib" ? {
|
|
1957
|
-
"ts/explicit-function-return-type": ["error", {
|
|
1958
|
-
allowExpressions: true,
|
|
1959
|
-
allowHigherOrderFunctions: true,
|
|
1960
|
-
allowIIFEs: true
|
|
1961
|
-
}]
|
|
1962
|
-
} : {},
|
|
1963
|
-
...overrides
|
|
1964
|
-
}
|
|
1965
|
-
},
|
|
1966
|
-
...isTypeAware ? [{
|
|
1967
|
-
files: filesTypeAware,
|
|
1968
|
-
ignores: ignoresTypeAware,
|
|
1969
|
-
name: "eslint/typescript/rules-type-aware",
|
|
1970
|
-
rules: {
|
|
1971
|
-
...typeAwareRules,
|
|
1972
|
-
...overrides
|
|
1973
|
-
}
|
|
1974
|
-
}] : []
|
|
1975
|
-
];
|
|
1477
|
+
const { componentExts = [], overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1478
|
+
const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
1479
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
|
|
1480
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1481
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1482
|
+
const isTypeAware = !!tsconfigPath;
|
|
1483
|
+
const typeAwareRules = {
|
|
1484
|
+
"dot-notation": "off",
|
|
1485
|
+
"no-implied-eval": "off",
|
|
1486
|
+
"ts/await-thenable": "error",
|
|
1487
|
+
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1488
|
+
"ts/no-floating-promises": "error",
|
|
1489
|
+
"ts/no-for-in-array": "error",
|
|
1490
|
+
"ts/no-implied-eval": "error",
|
|
1491
|
+
"ts/no-misused-promises": "error",
|
|
1492
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
1493
|
+
"ts/no-unsafe-argument": "error",
|
|
1494
|
+
"ts/no-unsafe-assignment": "error",
|
|
1495
|
+
"ts/no-unsafe-call": "error",
|
|
1496
|
+
"ts/no-unsafe-member-access": "error",
|
|
1497
|
+
"ts/no-unsafe-return": "error",
|
|
1498
|
+
"ts/promise-function-async": "error",
|
|
1499
|
+
"ts/restrict-plus-operands": "error",
|
|
1500
|
+
"ts/restrict-template-expressions": "error",
|
|
1501
|
+
"ts/return-await": ["error", "in-try-catch"],
|
|
1502
|
+
"ts/strict-boolean-expressions": ["error", {
|
|
1503
|
+
allowNullableBoolean: true,
|
|
1504
|
+
allowNullableObject: true
|
|
1505
|
+
}],
|
|
1506
|
+
"ts/switch-exhaustiveness-check": "error",
|
|
1507
|
+
"ts/unbound-method": "error"
|
|
1508
|
+
};
|
|
1509
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1510
|
+
function makeParser(typeAware, files$1, ignores$1) {
|
|
1511
|
+
return {
|
|
1512
|
+
files: files$1,
|
|
1513
|
+
...ignores$1 ? { ignores: ignores$1 } : {},
|
|
1514
|
+
languageOptions: {
|
|
1515
|
+
parser: parserTs,
|
|
1516
|
+
parserOptions: {
|
|
1517
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1518
|
+
sourceType: "module",
|
|
1519
|
+
...typeAware ? {
|
|
1520
|
+
projectService: {
|
|
1521
|
+
allowDefaultProject: ["./*.js"],
|
|
1522
|
+
defaultProject: tsconfigPath
|
|
1523
|
+
},
|
|
1524
|
+
tsconfigRootDir: node_process.default.cwd()
|
|
1525
|
+
} : {},
|
|
1526
|
+
...parserOptions
|
|
1527
|
+
}
|
|
1528
|
+
},
|
|
1529
|
+
name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
return [
|
|
1533
|
+
{
|
|
1534
|
+
name: "eslint/typescript/setup",
|
|
1535
|
+
plugins: {
|
|
1536
|
+
antfu: eslint_plugin_antfu.default,
|
|
1537
|
+
ts: pluginTs
|
|
1538
|
+
}
|
|
1539
|
+
},
|
|
1540
|
+
...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
|
|
1541
|
+
{
|
|
1542
|
+
files,
|
|
1543
|
+
name: "eslint/typescript/rules",
|
|
1544
|
+
rules: {
|
|
1545
|
+
...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
|
|
1546
|
+
...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
|
|
1547
|
+
"no-dupe-class-members": "off",
|
|
1548
|
+
"no-redeclare": "off",
|
|
1549
|
+
"no-unused-expressions": "off",
|
|
1550
|
+
"no-use-before-define": "off",
|
|
1551
|
+
"no-useless-constructor": "off",
|
|
1552
|
+
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
1553
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1554
|
+
"ts/consistent-type-imports": ["error", {
|
|
1555
|
+
disallowTypeAnnotations: false,
|
|
1556
|
+
fixStyle: "separate-type-imports",
|
|
1557
|
+
prefer: "type-imports"
|
|
1558
|
+
}],
|
|
1559
|
+
"ts/method-signature-style": ["error", "property"],
|
|
1560
|
+
"ts/no-dupe-class-members": "error",
|
|
1561
|
+
"ts/no-dynamic-delete": "off",
|
|
1562
|
+
"ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
|
|
1563
|
+
"ts/no-explicit-any": "off",
|
|
1564
|
+
"ts/no-extraneous-class": "off",
|
|
1565
|
+
"ts/no-import-type-side-effects": "error",
|
|
1566
|
+
"ts/no-invalid-void-type": "off",
|
|
1567
|
+
"ts/no-non-null-assertion": "off",
|
|
1568
|
+
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1569
|
+
"ts/no-require-imports": "error",
|
|
1570
|
+
"ts/no-unused-expressions": ["error", {
|
|
1571
|
+
allowShortCircuit: true,
|
|
1572
|
+
allowTaggedTemplates: true,
|
|
1573
|
+
allowTernary: true
|
|
1574
|
+
}],
|
|
1575
|
+
"ts/no-unused-vars": ["warn", {
|
|
1576
|
+
args: "all",
|
|
1577
|
+
argsIgnorePattern: "^_",
|
|
1578
|
+
caughtErrors: "all",
|
|
1579
|
+
caughtErrorsIgnorePattern: "^_",
|
|
1580
|
+
destructuredArrayIgnorePattern: "^_",
|
|
1581
|
+
ignoreRestSiblings: true,
|
|
1582
|
+
varsIgnorePattern: "^_"
|
|
1583
|
+
}],
|
|
1584
|
+
"ts/no-use-before-define": ["error", {
|
|
1585
|
+
classes: false,
|
|
1586
|
+
functions: false,
|
|
1587
|
+
variables: true
|
|
1588
|
+
}],
|
|
1589
|
+
"ts/no-useless-constructor": "off",
|
|
1590
|
+
"ts/no-wrapper-object-types": "error",
|
|
1591
|
+
"ts/triple-slash-reference": "off",
|
|
1592
|
+
"ts/unified-signatures": "off",
|
|
1593
|
+
"unused-imports/no-unused-vars": "off",
|
|
1594
|
+
...type === "lib" ? { "ts/explicit-function-return-type": ["error", {
|
|
1595
|
+
allowExpressions: true,
|
|
1596
|
+
allowHigherOrderFunctions: true,
|
|
1597
|
+
allowIIFEs: true
|
|
1598
|
+
}] } : {},
|
|
1599
|
+
...overrides
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
...isTypeAware ? [{
|
|
1603
|
+
files: filesTypeAware,
|
|
1604
|
+
ignores: ignoresTypeAware,
|
|
1605
|
+
name: "eslint/typescript/rules-type-aware",
|
|
1606
|
+
rules: {
|
|
1607
|
+
...typeAwareRules,
|
|
1608
|
+
...overrides
|
|
1609
|
+
}
|
|
1610
|
+
}] : []
|
|
1611
|
+
];
|
|
1976
1612
|
}
|
|
1977
1613
|
|
|
1978
|
-
|
|
1614
|
+
//#endregion
|
|
1615
|
+
//#region src/configs/unicorn.ts
|
|
1979
1616
|
async function unicorn(options = {}) {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
...options.overrides
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
];
|
|
1617
|
+
return [{
|
|
1618
|
+
name: "eslint/unicorn/rules",
|
|
1619
|
+
plugins: { unicorn: eslint_plugin_unicorn.default },
|
|
1620
|
+
rules: {
|
|
1621
|
+
...options.allRecommended ? eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
|
|
1622
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1623
|
+
"unicorn/error-message": "error",
|
|
1624
|
+
"unicorn/escape-case": "error",
|
|
1625
|
+
"unicorn/new-for-builtins": "error",
|
|
1626
|
+
"unicorn/no-instanceof-array": "error",
|
|
1627
|
+
"unicorn/no-new-array": "error",
|
|
1628
|
+
"unicorn/no-new-buffer": "error",
|
|
1629
|
+
"unicorn/number-literal-case": "error",
|
|
1630
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1631
|
+
"unicorn/prefer-includes": "error",
|
|
1632
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1633
|
+
"unicorn/prefer-number-properties": "error",
|
|
1634
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1635
|
+
"unicorn/prefer-type-error": "error",
|
|
1636
|
+
"unicorn/throw-new-error": "error"
|
|
1637
|
+
},
|
|
1638
|
+
...options.overrides
|
|
1639
|
+
}
|
|
1640
|
+
}];
|
|
2008
1641
|
}
|
|
2009
1642
|
|
|
2010
|
-
|
|
1643
|
+
//#endregion
|
|
1644
|
+
//#region src/configs/unocss.ts
|
|
2011
1645
|
async function unocss(options = {}) {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
return [
|
|
2026
|
-
{
|
|
2027
|
-
name: "eslint/unocss/rules",
|
|
2028
|
-
plugins: {
|
|
2029
|
-
unocss: pluginUnoCSS
|
|
2030
|
-
},
|
|
2031
|
-
rules: {
|
|
2032
|
-
"unocss/order": "off",
|
|
2033
|
-
...attributify ? {
|
|
2034
|
-
"unocss/order-attributify": "warn"
|
|
2035
|
-
} : {},
|
|
2036
|
-
...strict ? {
|
|
2037
|
-
"unocss/blocklist": "error"
|
|
2038
|
-
} : {},
|
|
2039
|
-
...overrides
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
];
|
|
1646
|
+
const { attributify = true, overrides = {}, strict = false } = options;
|
|
1647
|
+
await ensurePackages(["@unocss/eslint-plugin"]);
|
|
1648
|
+
const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
|
|
1649
|
+
return [{
|
|
1650
|
+
name: "eslint/unocss/rules",
|
|
1651
|
+
plugins: { unocss: pluginUnoCSS },
|
|
1652
|
+
rules: {
|
|
1653
|
+
"unocss/order": "off",
|
|
1654
|
+
...attributify ? { "unocss/order-attributify": "warn" } : {},
|
|
1655
|
+
...strict ? { "unocss/blocklist": "error" } : {},
|
|
1656
|
+
...overrides
|
|
1657
|
+
}
|
|
1658
|
+
}];
|
|
2043
1659
|
}
|
|
2044
1660
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
var vueVersion = pkg && pkg.version;
|
|
1661
|
+
//#endregion
|
|
1662
|
+
//#region src/configs/vue.ts
|
|
1663
|
+
const pkg = (0, local_pkg.getPackageInfoSync)("vue");
|
|
1664
|
+
let vueVersion = pkg && pkg.version;
|
|
2050
1665
|
vueVersion = vueVersion && vueVersion[0];
|
|
2051
1666
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
2052
1667
|
async function vue(options = {}) {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
1668
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
1669
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1670
|
+
const { indent = 4 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
1671
|
+
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1672
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1673
|
+
interopDefault(import("vue-eslint-parser")),
|
|
1674
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
1675
|
+
]);
|
|
1676
|
+
return [{
|
|
1677
|
+
languageOptions: { globals: {
|
|
1678
|
+
computed: "readonly",
|
|
1679
|
+
defineEmits: "readonly",
|
|
1680
|
+
defineExpose: "readonly",
|
|
1681
|
+
defineProps: "readonly",
|
|
1682
|
+
onMounted: "readonly",
|
|
1683
|
+
onUnmounted: "readonly",
|
|
1684
|
+
reactive: "readonly",
|
|
1685
|
+
ref: "readonly",
|
|
1686
|
+
shallowReactive: "readonly",
|
|
1687
|
+
shallowRef: "readonly",
|
|
1688
|
+
toRef: "readonly",
|
|
1689
|
+
toRefs: "readonly",
|
|
1690
|
+
watch: "readonly",
|
|
1691
|
+
watchEffect: "readonly"
|
|
1692
|
+
} },
|
|
1693
|
+
name: "eslint/vue/setup",
|
|
1694
|
+
plugins: { vue: pluginVue }
|
|
1695
|
+
}, {
|
|
1696
|
+
files,
|
|
1697
|
+
languageOptions: {
|
|
1698
|
+
parser: parserVue,
|
|
1699
|
+
parserOptions: {
|
|
1700
|
+
ecmaFeatures: { jsx: true },
|
|
1701
|
+
extraFileExtensions: [".vue"],
|
|
1702
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1703
|
+
sourceType: "module"
|
|
1704
|
+
}
|
|
1705
|
+
},
|
|
1706
|
+
name: "eslint/vue/rules",
|
|
1707
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, eslint_merge_processors.mergeProcessors)([pluginVue.processors[".vue"], processorVueBlocks({
|
|
1708
|
+
...sfcBlocks,
|
|
1709
|
+
blocks: {
|
|
1710
|
+
styles: true,
|
|
1711
|
+
...sfcBlocks.blocks
|
|
1712
|
+
}
|
|
1713
|
+
})]),
|
|
1714
|
+
rules: {
|
|
1715
|
+
...pluginVue.configs.base.rules,
|
|
1716
|
+
...vueVersion === "2" ? {
|
|
1717
|
+
...pluginVue.configs["vue2-essential"].rules,
|
|
1718
|
+
...pluginVue.configs["vue2-strongly-recommended"].rules,
|
|
1719
|
+
...pluginVue.configs["vue2-recommended"].rules
|
|
1720
|
+
} : {
|
|
1721
|
+
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
|
|
1722
|
+
...acc,
|
|
1723
|
+
...c
|
|
1724
|
+
}), {}),
|
|
1725
|
+
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
1726
|
+
...acc,
|
|
1727
|
+
...c
|
|
1728
|
+
}), {}),
|
|
1729
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
1730
|
+
...acc,
|
|
1731
|
+
...c
|
|
1732
|
+
}), {})
|
|
1733
|
+
},
|
|
1734
|
+
"antfu/no-top-level-await": "off",
|
|
1735
|
+
"node/prefer-global/process": "off",
|
|
1736
|
+
"ts/explicit-function-return-type": "off",
|
|
1737
|
+
"vue/block-order": ["error", { order: [
|
|
1738
|
+
"template",
|
|
1739
|
+
"script",
|
|
1740
|
+
"style"
|
|
1741
|
+
] }],
|
|
1742
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
1743
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1744
|
+
"vue/custom-event-name-casing": vueVersion === "3" ? ["error", "camelCase"] : ["error", "kebab-case"],
|
|
1745
|
+
...vueVersion === "2" ? { "vue/require-explicit-emits": "off" } : null,
|
|
1746
|
+
"no-irregular-whitespace": "off",
|
|
1747
|
+
"vue/define-macros-order": ["error", { order: [
|
|
1748
|
+
"defineOptions",
|
|
1749
|
+
"defineProps",
|
|
1750
|
+
"defineEmits",
|
|
1751
|
+
"defineSlots"
|
|
1752
|
+
] }],
|
|
1753
|
+
"vue/dot-location": ["error", "property"],
|
|
1754
|
+
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1755
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
1756
|
+
"vue/html-indent": [
|
|
1757
|
+
"error",
|
|
1758
|
+
indent,
|
|
1759
|
+
{
|
|
1760
|
+
alignAttributesVertically: true,
|
|
1761
|
+
attribute: 1,
|
|
1762
|
+
baseIndent: 1,
|
|
1763
|
+
closeBracket: 0,
|
|
1764
|
+
ignores: []
|
|
1765
|
+
}
|
|
1766
|
+
],
|
|
1767
|
+
"vue/html-self-closing": ["error", {
|
|
1768
|
+
html: {
|
|
1769
|
+
component: "any",
|
|
1770
|
+
normal: "any",
|
|
1771
|
+
void: "never"
|
|
1772
|
+
},
|
|
1773
|
+
math: "always",
|
|
1774
|
+
svg: "always"
|
|
1775
|
+
}],
|
|
1776
|
+
"vue/max-attributes-per-line": "off",
|
|
1777
|
+
"vue/multi-word-component-names": "off",
|
|
1778
|
+
"vue/no-constant-condition": "warn",
|
|
1779
|
+
"vue/no-dupe-keys": "off",
|
|
1780
|
+
"vue/no-empty-pattern": "error",
|
|
1781
|
+
"vue/no-extra-parens": ["error", "functions"],
|
|
1782
|
+
"vue/no-irregular-whitespace": ["error", {
|
|
1783
|
+
skipComments: false,
|
|
1784
|
+
skipHTMLAttributeValues: false,
|
|
1785
|
+
skipHTMLTextContents: true,
|
|
1786
|
+
skipRegExps: false,
|
|
1787
|
+
skipStrings: true,
|
|
1788
|
+
skipTemplates: false
|
|
1789
|
+
}],
|
|
1790
|
+
"vue/no-loss-of-precision": "error",
|
|
1791
|
+
"vue/no-restricted-syntax": [
|
|
1792
|
+
"error",
|
|
1793
|
+
"DebuggerStatement",
|
|
1794
|
+
"LabeledStatement",
|
|
1795
|
+
"WithStatement"
|
|
1796
|
+
],
|
|
1797
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1798
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
1799
|
+
"vue/no-sparse-arrays": "error",
|
|
1800
|
+
"vue/no-unused-refs": "warn",
|
|
1801
|
+
"vue/no-useless-v-bind": "error",
|
|
1802
|
+
"vue/no-v-html": "off",
|
|
1803
|
+
"vue/no-v-text-v-html-on-component": "off",
|
|
1804
|
+
"vue/object-shorthand": [
|
|
1805
|
+
"error",
|
|
1806
|
+
"always",
|
|
1807
|
+
{
|
|
1808
|
+
avoidQuotes: true,
|
|
1809
|
+
ignoreConstructors: false
|
|
1810
|
+
}
|
|
1811
|
+
],
|
|
1812
|
+
"vue/prefer-separate-static-class": "error",
|
|
1813
|
+
"vue/prefer-template": "error",
|
|
1814
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1815
|
+
"vue/require-default-prop": "off",
|
|
1816
|
+
"vue/require-prop-types": "off",
|
|
1817
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
1818
|
+
"vue/space-infix-ops": "error",
|
|
1819
|
+
"vue/space-unary-ops": ["error", {
|
|
1820
|
+
nonwords: false,
|
|
1821
|
+
words: true
|
|
1822
|
+
}],
|
|
1823
|
+
...stylistic$1 ? {
|
|
1824
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
1825
|
+
"vue/arrow-spacing": ["error", {
|
|
1826
|
+
after: true,
|
|
1827
|
+
before: true
|
|
1828
|
+
}],
|
|
1829
|
+
"vue/block-spacing": ["error", "always"],
|
|
1830
|
+
"vue/block-tag-newline": ["error", {
|
|
1831
|
+
multiline: "always",
|
|
1832
|
+
singleline: "always"
|
|
1833
|
+
}],
|
|
1834
|
+
"vue/brace-style": [
|
|
1835
|
+
"error",
|
|
1836
|
+
"stroustrup",
|
|
1837
|
+
{ allowSingleLine: false }
|
|
1838
|
+
],
|
|
1839
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1840
|
+
"vue/comma-spacing": ["error", {
|
|
1841
|
+
after: true,
|
|
1842
|
+
before: false
|
|
1843
|
+
}],
|
|
1844
|
+
"vue/comma-style": ["error", "last"],
|
|
1845
|
+
"vue/html-comment-content-spacing": [
|
|
1846
|
+
"error",
|
|
1847
|
+
"always",
|
|
1848
|
+
{ exceptions: ["-"] }
|
|
1849
|
+
],
|
|
1850
|
+
"vue/key-spacing": ["error", {
|
|
1851
|
+
afterColon: true,
|
|
1852
|
+
beforeColon: false
|
|
1853
|
+
}],
|
|
1854
|
+
"vue/keyword-spacing": ["error", {
|
|
1855
|
+
after: true,
|
|
1856
|
+
before: true
|
|
1857
|
+
}],
|
|
1858
|
+
"vue/object-curly-newline": "off",
|
|
1859
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
1860
|
+
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1861
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
1862
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1863
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
1864
|
+
"vue/space-in-parens": ["error", "never"],
|
|
1865
|
+
"vue/template-curly-spacing": "error"
|
|
1866
|
+
} : {},
|
|
1867
|
+
...overrides
|
|
1868
|
+
}
|
|
1869
|
+
}];
|
|
2242
1870
|
}
|
|
2243
1871
|
|
|
2244
|
-
|
|
1872
|
+
//#endregion
|
|
1873
|
+
//#region src/configs/yaml.ts
|
|
2245
1874
|
async function yaml(options = {}) {
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
"onlyBuiltDependenciesFile",
|
|
2321
|
-
"packageExtensions",
|
|
2322
|
-
"peerDependencyRules",
|
|
2323
|
-
"supportedArchitectures"
|
|
2324
|
-
],
|
|
2325
|
-
pathPattern: "^$"
|
|
2326
|
-
},
|
|
2327
|
-
{
|
|
2328
|
-
order: { type: "asc" },
|
|
2329
|
-
pathPattern: ".*"
|
|
2330
|
-
}
|
|
2331
|
-
]
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
];
|
|
1875
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
1876
|
+
const { quotes = "single" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
1877
|
+
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
1878
|
+
return [
|
|
1879
|
+
{
|
|
1880
|
+
name: "eslint/yaml/setup",
|
|
1881
|
+
plugins: { yaml: pluginYaml }
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
files,
|
|
1885
|
+
languageOptions: { parser: parserYaml },
|
|
1886
|
+
name: "eslint/yaml/rules",
|
|
1887
|
+
rules: {
|
|
1888
|
+
"style/spaced-comment": "off",
|
|
1889
|
+
"yaml/block-mapping": "error",
|
|
1890
|
+
"yaml/block-sequence": "error",
|
|
1891
|
+
"yaml/no-empty-key": "error",
|
|
1892
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
1893
|
+
"yaml/no-irregular-whitespace": "error",
|
|
1894
|
+
"yaml/plain-scalar": "error",
|
|
1895
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
1896
|
+
...stylistic$1 ? {
|
|
1897
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
1898
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
1899
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
1900
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
1901
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
1902
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
1903
|
+
"yaml/indent": ["error", 2],
|
|
1904
|
+
"yaml/key-spacing": "error",
|
|
1905
|
+
"yaml/no-tab-indent": "error",
|
|
1906
|
+
"yaml/quotes": ["error", {
|
|
1907
|
+
avoidEscape: true,
|
|
1908
|
+
prefer: quotes === "backtick" ? "single" : quotes
|
|
1909
|
+
}],
|
|
1910
|
+
"yaml/spaced-comment": "error"
|
|
1911
|
+
} : {},
|
|
1912
|
+
...overrides
|
|
1913
|
+
}
|
|
1914
|
+
},
|
|
1915
|
+
{
|
|
1916
|
+
files: ["pnpm-workspace.yaml"],
|
|
1917
|
+
name: "eslint/yaml/pnpm-workspace",
|
|
1918
|
+
rules: { "yaml/sort-keys": [
|
|
1919
|
+
"error",
|
|
1920
|
+
{
|
|
1921
|
+
order: [
|
|
1922
|
+
"packages",
|
|
1923
|
+
"overrides",
|
|
1924
|
+
"patchedDependencies",
|
|
1925
|
+
"hoistPattern",
|
|
1926
|
+
"catalog",
|
|
1927
|
+
"catalogs",
|
|
1928
|
+
"allowedDeprecatedVersions",
|
|
1929
|
+
"allowNonAppliedPatches",
|
|
1930
|
+
"configDependencies",
|
|
1931
|
+
"ignoredBuiltDependencies",
|
|
1932
|
+
"ignoredOptionalDependencies",
|
|
1933
|
+
"neverBuiltDependencies",
|
|
1934
|
+
"onlyBuiltDependencies",
|
|
1935
|
+
"onlyBuiltDependenciesFile",
|
|
1936
|
+
"packageExtensions",
|
|
1937
|
+
"peerDependencyRules",
|
|
1938
|
+
"supportedArchitectures"
|
|
1939
|
+
],
|
|
1940
|
+
pathPattern: "^$"
|
|
1941
|
+
},
|
|
1942
|
+
{
|
|
1943
|
+
order: { type: "asc" },
|
|
1944
|
+
pathPattern: ".*"
|
|
1945
|
+
}
|
|
1946
|
+
] }
|
|
1947
|
+
}
|
|
1948
|
+
];
|
|
2335
1949
|
}
|
|
2336
1950
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region src/factory.ts
|
|
1953
|
+
const flatConfigProps = [
|
|
1954
|
+
"name",
|
|
1955
|
+
"languageOptions",
|
|
1956
|
+
"linterOptions",
|
|
1957
|
+
"processor",
|
|
1958
|
+
"plugins",
|
|
1959
|
+
"rules",
|
|
1960
|
+
"settings"
|
|
2346
1961
|
];
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
1962
|
+
const VuePackages = [
|
|
1963
|
+
"vue",
|
|
1964
|
+
"nuxt",
|
|
1965
|
+
"vitepress",
|
|
1966
|
+
"@slidev/cli"
|
|
2352
1967
|
];
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
1968
|
+
const defaultPluginRenaming = {
|
|
1969
|
+
"@eslint-react": "react",
|
|
1970
|
+
"@eslint-react/dom": "react-dom",
|
|
1971
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1972
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1973
|
+
"@stylistic": "style",
|
|
1974
|
+
"@typescript-eslint": "ts",
|
|
1975
|
+
"import-x": "import",
|
|
1976
|
+
"n": "node",
|
|
1977
|
+
"vitest": "test",
|
|
1978
|
+
"yml": "yaml"
|
|
2364
1979
|
};
|
|
1980
|
+
/**
|
|
1981
|
+
* 构建 ESLint 平面配置项数组
|
|
1982
|
+
*
|
|
1983
|
+
* @param {OptionsConfig & TypedFlatConfigItem} options
|
|
1984
|
+
* 生成 ESLint 配置的选项
|
|
1985
|
+
* @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
|
|
1986
|
+
* 要与生成的配置合并的用户配置
|
|
1987
|
+
* @returns {Promise<TypedFlatConfigItem[]>}
|
|
1988
|
+
* 合并的 ESLint 配置
|
|
1989
|
+
*/
|
|
2365
1990
|
function lincy(options = {}, ...userConfigs) {
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
}));
|
|
2475
|
-
}
|
|
2476
|
-
if (enableVue) {
|
|
2477
|
-
configs2.push(vue({
|
|
2478
|
-
...resolveSubOptions(options, "vue"),
|
|
2479
|
-
overrides: getOverrides(options, "vue"),
|
|
2480
|
-
stylistic: stylisticOptions,
|
|
2481
|
-
typescript: !!enableTypeScript
|
|
2482
|
-
}));
|
|
2483
|
-
}
|
|
2484
|
-
if (enableReact) {
|
|
2485
|
-
configs2.push(react({
|
|
2486
|
-
...typescriptOptions,
|
|
2487
|
-
...resolveSubOptions(options, "react"),
|
|
2488
|
-
overrides: getOverrides(options, "react"),
|
|
2489
|
-
tsconfigPath
|
|
2490
|
-
}));
|
|
2491
|
-
}
|
|
2492
|
-
if (enableUnoCSS) {
|
|
2493
|
-
configs2.push(unocss({
|
|
2494
|
-
...resolveSubOptions(options, "unocss"),
|
|
2495
|
-
overrides: getOverrides(options, "unocss")
|
|
2496
|
-
}));
|
|
2497
|
-
}
|
|
2498
|
-
if (options.jsonc ?? true) {
|
|
2499
|
-
configs2.push(
|
|
2500
|
-
jsonc({
|
|
2501
|
-
...resolveSubOptions(options, "jsonc"),
|
|
2502
|
-
overrides: getOverrides(options, "jsonc"),
|
|
2503
|
-
stylistic: stylisticOptions
|
|
2504
|
-
}),
|
|
2505
|
-
sortPackageJson(),
|
|
2506
|
-
sortTsconfig()
|
|
2507
|
-
);
|
|
2508
|
-
}
|
|
2509
|
-
if (enableCatalogs) {
|
|
2510
|
-
configs2.push(
|
|
2511
|
-
pnpm()
|
|
2512
|
-
);
|
|
2513
|
-
}
|
|
2514
|
-
if (options.yaml ?? true) {
|
|
2515
|
-
configs2.push(yaml({
|
|
2516
|
-
...resolveSubOptions(options, "yaml"),
|
|
2517
|
-
overrides: getOverrides(options, "yaml"),
|
|
2518
|
-
stylistic: stylisticOptions
|
|
2519
|
-
}));
|
|
2520
|
-
}
|
|
2521
|
-
if (options.toml ?? true) {
|
|
2522
|
-
configs2.push(toml({
|
|
2523
|
-
overrides: getOverrides(options, "toml"),
|
|
2524
|
-
stylistic: stylisticOptions
|
|
2525
|
-
}));
|
|
2526
|
-
}
|
|
2527
|
-
if (options.markdown ?? true) {
|
|
2528
|
-
configs2.push(
|
|
2529
|
-
markdown(
|
|
2530
|
-
{
|
|
2531
|
-
...resolveSubOptions(options, "markdown"),
|
|
2532
|
-
componentExts,
|
|
2533
|
-
overrides: getOverrides(options, "markdown")
|
|
2534
|
-
}
|
|
2535
|
-
)
|
|
2536
|
-
);
|
|
2537
|
-
}
|
|
2538
|
-
if (options.formatters) {
|
|
2539
|
-
configs2.push(formatters(
|
|
2540
|
-
options.formatters,
|
|
2541
|
-
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2542
|
-
));
|
|
2543
|
-
}
|
|
2544
|
-
configs2.push(
|
|
2545
|
-
disables()
|
|
2546
|
-
);
|
|
2547
|
-
if ("files" in options) {
|
|
2548
|
-
throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
|
|
2549
|
-
}
|
|
2550
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2551
|
-
if (key in options)
|
|
2552
|
-
acc[key] = options[key];
|
|
2553
|
-
return acc;
|
|
2554
|
-
}, {});
|
|
2555
|
-
if (Object.keys(fusedConfig).length)
|
|
2556
|
-
configs2.push([fusedConfig]);
|
|
2557
|
-
let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
2558
|
-
composer = composer.append(
|
|
2559
|
-
...configs2,
|
|
2560
|
-
...userConfigs
|
|
2561
|
-
);
|
|
2562
|
-
if (autoRenamePlugins) {
|
|
2563
|
-
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2564
|
-
}
|
|
2565
|
-
if (isInEditor) {
|
|
2566
|
-
composer = composer.disableRulesFix([
|
|
2567
|
-
"unused-imports/no-unused-imports",
|
|
2568
|
-
"test/no-only-tests",
|
|
2569
|
-
"prefer-const"
|
|
2570
|
-
], {
|
|
2571
|
-
builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules)
|
|
2572
|
-
});
|
|
2573
|
-
}
|
|
2574
|
-
return composer;
|
|
1991
|
+
const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, ignores: ignoresList = [], jsx: enableJsx = true, overrides = {}, pnpm: enableCatalogs = false, react: enableReact = false, regexp: enableRegexp = true, typescript: enableTypeScript = (0, local_pkg.isPackageExists)("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => (0, local_pkg.isPackageExists)(i)) } = options;
|
|
1992
|
+
let isInEditor = options.isInEditor;
|
|
1993
|
+
if (isInEditor == null) {
|
|
1994
|
+
isInEditor = isInEditorEnv();
|
|
1995
|
+
if (isInEditor) console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
1996
|
+
}
|
|
1997
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1998
|
+
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
1999
|
+
const configs$1 = [];
|
|
2000
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2001
|
+
name: "eslint/gitignore",
|
|
2002
|
+
...enableGitignore
|
|
2003
|
+
})]));
|
|
2004
|
+
else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2005
|
+
name: "eslint/gitignore",
|
|
2006
|
+
strict: false
|
|
2007
|
+
})]));
|
|
2008
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2009
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2010
|
+
configs$1.push(ignores({ ignores: [...overrides.ignores || [], ...ignoresList] }), javascript({
|
|
2011
|
+
isInEditor,
|
|
2012
|
+
overrides: getOverrides(options, "javascript")
|
|
2013
|
+
}), comments({ overrides: overrides.comments }), node({ overrides: overrides.node }), jsdoc({
|
|
2014
|
+
overrides: overrides.jsdoc,
|
|
2015
|
+
stylistic: stylisticOptions
|
|
2016
|
+
}), imports({
|
|
2017
|
+
overrides: overrides.imports,
|
|
2018
|
+
stylistic: stylisticOptions
|
|
2019
|
+
}), perfectionist({ overrides: overrides.perfectionist }));
|
|
2020
|
+
if (enableUnicorn) configs$1.push(unicorn({
|
|
2021
|
+
...enableUnicorn === true ? {} : enableUnicorn,
|
|
2022
|
+
overrides: overrides.unicorn
|
|
2023
|
+
}));
|
|
2024
|
+
if (enableVue) componentExts.push("vue");
|
|
2025
|
+
if (enableJsx) configs$1.push(jsx());
|
|
2026
|
+
if (enableTypeScript) configs$1.push(typescript({
|
|
2027
|
+
...typescriptOptions,
|
|
2028
|
+
componentExts,
|
|
2029
|
+
overrides: getOverrides(options, "typescript"),
|
|
2030
|
+
tsconfigPath,
|
|
2031
|
+
type: options.type
|
|
2032
|
+
}));
|
|
2033
|
+
if (stylisticOptions) configs$1.push(stylistic({
|
|
2034
|
+
overrides: getOverrides(options, "stylistic"),
|
|
2035
|
+
stylistic: stylisticOptions
|
|
2036
|
+
}));
|
|
2037
|
+
if (enableRegexp) configs$1.push(regexp({
|
|
2038
|
+
...resolveSubOptions(options, "regexp"),
|
|
2039
|
+
...getOverrides(options, "regexp")
|
|
2040
|
+
}));
|
|
2041
|
+
if (options.test ?? true) configs$1.push(test({
|
|
2042
|
+
...resolveSubOptions(options, "test"),
|
|
2043
|
+
isInEditor,
|
|
2044
|
+
overrides: getOverrides(options, "test")
|
|
2045
|
+
}));
|
|
2046
|
+
if (enableVue) configs$1.push(vue({
|
|
2047
|
+
...resolveSubOptions(options, "vue"),
|
|
2048
|
+
overrides: getOverrides(options, "vue"),
|
|
2049
|
+
stylistic: stylisticOptions,
|
|
2050
|
+
typescript: !!enableTypeScript
|
|
2051
|
+
}));
|
|
2052
|
+
if (enableReact) configs$1.push(react({
|
|
2053
|
+
...typescriptOptions,
|
|
2054
|
+
...resolveSubOptions(options, "react"),
|
|
2055
|
+
overrides: getOverrides(options, "react"),
|
|
2056
|
+
tsconfigPath
|
|
2057
|
+
}));
|
|
2058
|
+
if (enableUnoCSS) configs$1.push(unocss({
|
|
2059
|
+
...resolveSubOptions(options, "unocss"),
|
|
2060
|
+
overrides: getOverrides(options, "unocss")
|
|
2061
|
+
}));
|
|
2062
|
+
if (options.jsonc ?? true) configs$1.push(jsonc({
|
|
2063
|
+
...resolveSubOptions(options, "jsonc"),
|
|
2064
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2065
|
+
stylistic: stylisticOptions
|
|
2066
|
+
}), sortPackageJson(), sortTsconfig());
|
|
2067
|
+
if (enableCatalogs) configs$1.push(pnpm());
|
|
2068
|
+
if (options.yaml ?? true) configs$1.push(yaml({
|
|
2069
|
+
...resolveSubOptions(options, "yaml"),
|
|
2070
|
+
overrides: getOverrides(options, "yaml"),
|
|
2071
|
+
stylistic: stylisticOptions
|
|
2072
|
+
}));
|
|
2073
|
+
if (options.toml ?? true) configs$1.push(toml({
|
|
2074
|
+
overrides: getOverrides(options, "toml"),
|
|
2075
|
+
stylistic: stylisticOptions
|
|
2076
|
+
}));
|
|
2077
|
+
if (options.markdown ?? true) configs$1.push(markdown({
|
|
2078
|
+
...resolveSubOptions(options, "markdown"),
|
|
2079
|
+
componentExts,
|
|
2080
|
+
overrides: getOverrides(options, "markdown")
|
|
2081
|
+
}));
|
|
2082
|
+
if (options.formatters) configs$1.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2083
|
+
configs$1.push(disables());
|
|
2084
|
+
if ("files" in options) throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
|
|
2085
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2086
|
+
if (key in options) acc[key] = options[key];
|
|
2087
|
+
return acc;
|
|
2088
|
+
}, {});
|
|
2089
|
+
if (Object.keys(fusedConfig).length) configs$1.push([fusedConfig]);
|
|
2090
|
+
let composer = new eslint_flat_config_utils.FlatConfigComposer();
|
|
2091
|
+
composer = composer.append(...configs$1, ...userConfigs);
|
|
2092
|
+
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2093
|
+
if (isInEditor) composer = composer.disableRulesFix([
|
|
2094
|
+
"unused-imports/no-unused-imports",
|
|
2095
|
+
"test/no-only-tests",
|
|
2096
|
+
"prefer-const"
|
|
2097
|
+
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
2098
|
+
return composer;
|
|
2575
2099
|
}
|
|
2576
2100
|
function resolveSubOptions(options, key) {
|
|
2577
|
-
|
|
2101
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
2578
2102
|
}
|
|
2579
2103
|
function getOverrides(options, key) {
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2104
|
+
const sub = resolveSubOptions(options, key);
|
|
2105
|
+
return {
|
|
2106
|
+
...options.overrides?.[key],
|
|
2107
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2108
|
+
};
|
|
2585
2109
|
}
|
|
2586
2110
|
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2111
|
+
//#endregion
|
|
2112
|
+
//#region src/index.ts
|
|
2113
|
+
var src_default = lincy;
|
|
2114
|
+
|
|
2115
|
+
//#endregion
|
|
2116
|
+
exports.GLOB_ALL_SRC = GLOB_ALL_SRC;
|
|
2117
|
+
exports.GLOB_CSS = GLOB_CSS;
|
|
2118
|
+
exports.GLOB_EXCLUDE = GLOB_EXCLUDE;
|
|
2119
|
+
exports.GLOB_GRAPHQL = GLOB_GRAPHQL;
|
|
2120
|
+
exports.GLOB_HTML = GLOB_HTML;
|
|
2121
|
+
exports.GLOB_JS = GLOB_JS;
|
|
2122
|
+
exports.GLOB_JSON = GLOB_JSON;
|
|
2123
|
+
exports.GLOB_JSON5 = GLOB_JSON5;
|
|
2124
|
+
exports.GLOB_JSONC = GLOB_JSONC;
|
|
2125
|
+
exports.GLOB_JSX = GLOB_JSX;
|
|
2126
|
+
exports.GLOB_LESS = GLOB_LESS;
|
|
2127
|
+
exports.GLOB_MARKDOWN = GLOB_MARKDOWN;
|
|
2128
|
+
exports.GLOB_MARKDOWN_CODE = GLOB_MARKDOWN_CODE;
|
|
2129
|
+
exports.GLOB_MARKDOWN_IN_MARKDOWN = GLOB_MARKDOWN_IN_MARKDOWN;
|
|
2130
|
+
exports.GLOB_POSTCSS = GLOB_POSTCSS;
|
|
2131
|
+
exports.GLOB_SCSS = GLOB_SCSS;
|
|
2132
|
+
exports.GLOB_SRC = GLOB_SRC;
|
|
2133
|
+
exports.GLOB_SRC_EXT = GLOB_SRC_EXT;
|
|
2134
|
+
exports.GLOB_STYLE = GLOB_STYLE;
|
|
2135
|
+
exports.GLOB_SVELTE = GLOB_SVELTE;
|
|
2136
|
+
exports.GLOB_SVG = GLOB_SVG;
|
|
2137
|
+
exports.GLOB_TESTS = GLOB_TESTS;
|
|
2138
|
+
exports.GLOB_TOML = GLOB_TOML;
|
|
2139
|
+
exports.GLOB_TS = GLOB_TS;
|
|
2140
|
+
exports.GLOB_TSX = GLOB_TSX;
|
|
2141
|
+
exports.GLOB_VUE = GLOB_VUE;
|
|
2142
|
+
exports.GLOB_XML = GLOB_XML;
|
|
2143
|
+
exports.GLOB_YAML = GLOB_YAML;
|
|
2144
|
+
exports.StylisticConfigDefaults = StylisticConfigDefaults;
|
|
2145
|
+
exports.combine = combine;
|
|
2146
|
+
exports.comments = comments;
|
|
2147
|
+
exports.default = src_default;
|
|
2148
|
+
exports.defaultPluginRenaming = defaultPluginRenaming;
|
|
2149
|
+
exports.disables = disables;
|
|
2150
|
+
exports.ensurePackages = ensurePackages;
|
|
2151
|
+
exports.formatters = formatters;
|
|
2152
|
+
exports.getOverrides = getOverrides;
|
|
2153
|
+
exports.ignores = ignores;
|
|
2154
|
+
exports.imports = imports;
|
|
2155
|
+
exports.interopDefault = interopDefault;
|
|
2156
|
+
exports.isInEditorEnv = isInEditorEnv;
|
|
2157
|
+
exports.isInGitHooksOrLintStaged = isInGitHooksOrLintStaged;
|
|
2158
|
+
exports.isPackageInScope = isPackageInScope;
|
|
2159
|
+
exports.javascript = javascript;
|
|
2160
|
+
exports.jsdoc = jsdoc;
|
|
2161
|
+
exports.jsonc = jsonc;
|
|
2162
|
+
exports.jsx = jsx;
|
|
2163
|
+
exports.lincy = lincy;
|
|
2164
|
+
exports.markdown = markdown;
|
|
2165
|
+
exports.node = node;
|
|
2166
|
+
exports.parserPlain = parserPlain;
|
|
2167
|
+
exports.perfectionist = perfectionist;
|
|
2168
|
+
exports.pnpm = pnpm;
|
|
2169
|
+
exports.react = react;
|
|
2170
|
+
exports.regexp = regexp;
|
|
2171
|
+
exports.renamePluginInConfigs = renamePluginInConfigs;
|
|
2172
|
+
exports.renameRules = renameRules;
|
|
2173
|
+
exports.resolveSubOptions = resolveSubOptions;
|
|
2174
|
+
exports.sortPackageJson = sortPackageJson;
|
|
2175
|
+
exports.sortTsconfig = sortTsconfig;
|
|
2176
|
+
exports.stylistic = stylistic;
|
|
2177
|
+
exports.test = test;
|
|
2178
|
+
exports.toArray = toArray;
|
|
2179
|
+
exports.toml = toml;
|
|
2180
|
+
exports.typescript = typescript;
|
|
2181
|
+
exports.unicorn = unicorn;
|
|
2182
|
+
exports.unocss = unocss;
|
|
2183
|
+
exports.vue = vue;
|
|
2184
|
+
exports.yaml = yaml;
|