@lincy/eslint-config 5.5.2 → 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/dist/index.cjs CHANGED
@@ -1,2659 +1,2184 @@
1
- "use strict";
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
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
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
- // src/plugins.ts
114
- var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
115
- var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
116
- var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
117
- var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
118
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
119
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
120
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
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
- // src/configs/comments.ts
41
+ //#region src/configs/comments.ts
123
42
  async function comments(options = {}) {
124
- const {
125
- overrides = {}
126
- } = options;
127
- return [
128
- {
129
- name: "eslint/comments/rules",
130
- plugins: {
131
- "eslint-comments": import_eslint_plugin_eslint_comments.default
132
- },
133
- rules: {
134
- "eslint-comments/no-aggregating-enable": "error",
135
- "eslint-comments/no-duplicate-disable": "error",
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
- // src/globs.ts
145
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
146
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
147
- var GLOB_JS = "**/*.?([cm])js";
148
- var GLOB_JSX = "**/*.?([cm])jsx";
149
- var GLOB_TS = "**/*.?([cm])ts";
150
- var GLOB_TSX = "**/*.?([cm])tsx";
151
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
152
- var GLOB_CSS = "**/*.css";
153
- var GLOB_POSTCSS = "**/*.{p,post}css";
154
- var GLOB_LESS = "**/*.less";
155
- var GLOB_SCSS = "**/*.scss";
156
- var GLOB_JSON = "**/*.json";
157
- var GLOB_JSON5 = "**/*.json5";
158
- var GLOB_JSONC = "**/*.jsonc";
159
- var GLOB_MARKDOWN = "**/*.md";
160
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
161
- var GLOB_SVELTE = "**/*.svelte";
162
- var GLOB_VUE = "**/*.vue";
163
- var GLOB_YAML = "**/*.y?(a)ml";
164
- var GLOB_TOML = "**/*.toml";
165
- var GLOB_XML = "**/*.xml";
166
- var GLOB_SVG = "**/*.svg";
167
- var GLOB_HTML = "**/*.htm?(l)";
168
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
169
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
170
- var GLOB_TESTS = [
171
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
172
- `**/*.spec.${GLOB_SRC_EXT}`,
173
- `**/*.test.${GLOB_SRC_EXT}`
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
- var GLOB_ALL_SRC = [
176
- GLOB_SRC,
177
- GLOB_STYLE,
178
- GLOB_JSON,
179
- GLOB_JSON5,
180
- GLOB_MARKDOWN,
181
- GLOB_SVELTE,
182
- GLOB_VUE,
183
- GLOB_YAML,
184
- GLOB_HTML
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
- var GLOB_EXCLUDE = [
187
- "**/node_modules",
188
- "**/dist",
189
- "**/package-lock.json",
190
- "**/yarn.lock",
191
- "**/pnpm-lock.yaml",
192
- "**/output",
193
- "**/coverage",
194
- "**/tmp",
195
- "**/temp",
196
- "**/.tmp",
197
- "**/.temp",
198
- "**/.history",
199
- "**/.vitepress/cache",
200
- "**/.nuxt",
201
- "**/.next",
202
- "**/.vercel",
203
- "**/.changeset",
204
- "**/.idea",
205
- "**/.output",
206
- "**/.vite-inspect",
207
- "**/.yarn",
208
- "**/vite.config.*.timestamp-*",
209
- "**/CHANGELOG*.md",
210
- "**/*.min.*",
211
- "**/LICENSE*",
212
- "**/__snapshots__",
213
- "**/auto-import?(s).d.ts",
214
- "**/components.d.ts"
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
- // src/configs/disables.ts
131
+ //#endregion
132
+ //#region src/configs/disables.ts
218
133
  async function disables() {
219
- return [
220
- {
221
- files: [`**/scripts/${GLOB_SRC}`],
222
- name: "eslint/disables/scripts",
223
- rules: {
224
- "antfu/no-top-level-await": "off",
225
- "no-console": "off",
226
- "ts/explicit-function-return-type": "off"
227
- }
228
- },
229
- {
230
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
231
- name: "eslint/disables/cli",
232
- rules: {
233
- "antfu/no-top-level-await": "off",
234
- "no-console": "off"
235
- }
236
- },
237
- {
238
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
239
- name: "eslint/disables/bin",
240
- rules: {
241
- "antfu/no-import-dist": "off",
242
- "antfu/no-import-node-modules-by-path": "off"
243
- }
244
- },
245
- {
246
- files: ["**/*.d.?([cm])ts"],
247
- name: "eslint/disables/dts",
248
- rules: {
249
- "eslint-comments/no-unlimited-disable": "off",
250
- "import/no-duplicates": "off",
251
- "no-restricted-syntax": "off",
252
- "unused-imports/no-unused-vars": "off"
253
- }
254
- },
255
- {
256
- files: ["**/*.js", "**/*.cjs"],
257
- name: "eslint/disables/cjs",
258
- rules: {
259
- "ts/no-require-imports": "off"
260
- }
261
- },
262
- {
263
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
264
- name: "eslint/disables/config-files",
265
- rules: {
266
- "antfu/no-top-level-await": "off",
267
- "no-console": "off",
268
- "ts/explicit-function-return-type": "off"
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
- // src/utils.ts
275
- var import_node_process = __toESM(require("process"), 1);
276
- var import_node_url = require("url");
277
- var import_local_pkg = require("local-pkg");
278
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
279
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@antfu/eslint-config");
280
- var parserPlain = {
281
- meta: {
282
- name: "parser-plain"
283
- },
284
- parseForESLint: (code) => ({
285
- ast: {
286
- body: [],
287
- comments: [],
288
- loc: { end: code.length, start: 0 },
289
- range: [0, code.length],
290
- tokens: [],
291
- type: "Program"
292
- },
293
- scopeManager: null,
294
- services: { isPlain: true },
295
- visitorKeys: {
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
- async function combine(...configs2) {
301
- const resolved = await Promise.all(configs2);
302
- return resolved.flat();
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
- return Object.fromEntries(
306
- Object.entries(rules).map(([key, value]) => {
307
- for (const [from, to] of Object.entries(map)) {
308
- if (key.startsWith(`${from}/`)) {
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(configs2, map) {
317
- return configs2.map((i) => {
318
- const clone = { ...i };
319
- if (clone.rules) {
320
- clone.rules = renameRules(clone.rules, map);
321
- }
322
- if (clone.plugins) {
323
- clone.plugins = Object.fromEntries(
324
- Object.entries(clone.plugins).map(([key, value]) => {
325
- if (key in map) {
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
- return Array.isArray(value) ? value : [value];
235
+ return Array.isArray(value) ? value : [value];
337
236
  }
338
237
  async function interopDefault(m) {
339
- const resolved = await m;
340
- return resolved.default || resolved;
238
+ const resolved = await m;
239
+ return resolved.default || resolved;
341
240
  }
342
241
  function isPackageInScope(name) {
343
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
242
+ return (0, local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
344
243
  }
345
244
  async function ensurePackages(packages) {
346
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
347
- return;
348
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
349
- if (nonExistingPackages.length === 0)
350
- return;
351
- const p = await import("@clack/prompts");
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
- if (import_node_process.default.env.CI)
361
- return false;
362
- if (isInGitHooksOrLintStaged())
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
- return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
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
- // src/configs/stylistic.ts
371
- var StylisticConfigDefaults = {
372
- indent: 4,
373
- jsx: true,
374
- lessOpinionated: false,
375
- quotes: "single",
376
- semi: false
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
- const {
380
- overrides = {},
381
- stylistic: stylistic2 = StylisticConfigDefaults
382
- } = options;
383
- const {
384
- indent,
385
- jsx: jsx2,
386
- lessOpinionated,
387
- quotes,
388
- semi
389
- } = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
390
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
391
- const config = pluginStylistic.configs.customize({
392
- indent,
393
- jsx: jsx2,
394
- pluginName: "style",
395
- quotes,
396
- semi
397
- });
398
- return [
399
- {
400
- name: "eslint/stylistic/rules",
401
- plugins: {
402
- antfu: import_eslint_plugin_antfu.default,
403
- style: pluginStylistic
404
- },
405
- rules: {
406
- ...config.rules,
407
- "antfu/consistent-chaining": "error",
408
- "antfu/consistent-list-newline": "off",
409
- ...lessOpinionated ? {
410
- curly: ["error", "all"]
411
- } : {
412
- "antfu/curly": "error",
413
- "antfu/if-newline": "error",
414
- "antfu/top-level-function": "error"
415
- },
416
- // 覆盖`stylistic`默认规则
417
- "style/brace-style": ["error", "stroustrup"],
418
- "style/generator-star-spacing": ["error", { after: true, before: false }],
419
- "style/multiline-ternary": ["error", "never"],
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
- // src/configs/formatters.ts
314
+ //#endregion
315
+ //#region src/configs/formatters.ts
428
316
  function mergePrettierOptions(options, overrides = {}) {
429
- return {
430
- ...options,
431
- ...overrides,
432
- plugins: [
433
- ...overrides.plugins || [],
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 = {}, stylistic2 = {}) {
439
- const defaultIndent = 4;
440
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
441
- if (options === true) {
442
- const isPrettierPluginXmlInScope2 = isPackageInScope("@prettier/plugin-xml");
443
- options = {
444
- css: false,
445
- graphql: true,
446
- html: true,
447
- markdown: true,
448
- svg: isPrettierPluginXmlInScope2,
449
- xml: isPrettierPluginXmlInScope2
450
- };
451
- } else {
452
- options = {
453
- css: options.css ?? false,
454
- graphql: options.graphql ?? true,
455
- html: options.html ?? true,
456
- markdown: options.markdown ?? true,
457
- svg: isPrettierPluginXmlInScope,
458
- xml: isPrettierPluginXmlInScope
459
- };
460
- }
461
- await ensurePackages([
462
- "eslint-plugin-format",
463
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
464
- ]);
465
- const {
466
- indent,
467
- quotes,
468
- semi
469
- } = {
470
- ...StylisticConfigDefaults,
471
- ...stylistic2
472
- };
473
- const prettierOptions = Object.assign(
474
- {
475
- endOfLine: "lf",
476
- printWidth: 200,
477
- semi,
478
- singleQuote: quotes === "single",
479
- tabWidth: typeof indent === "number" ? indent : defaultIndent,
480
- trailingComma: "all",
481
- useTabs: indent === "tab"
482
- },
483
- options.prettierOptions || {}
484
- );
485
- const prettierXmlOptions = {
486
- xmlQuoteAttributes: "double",
487
- xmlSelfClosingSpace: true,
488
- xmlSortAttributesByKey: false,
489
- xmlWhitespaceSensitivity: "ignore"
490
- };
491
- const dprintOptions = Object.assign(
492
- {
493
- indentWidth: typeof indent === "number" ? indent : defaultIndent,
494
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
495
- useTabs: indent === "tab"
496
- },
497
- options.dprintOptions || {}
498
- );
499
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
500
- const configs2 = [
501
- {
502
- name: "eslint/formatter/setup",
503
- plugins: {
504
- format: pluginFormat
505
- }
506
- }
507
- ];
508
- if (options.css) {
509
- configs2.push(
510
- {
511
- files: [GLOB_CSS, GLOB_POSTCSS],
512
- languageOptions: {
513
- parser: parserPlain
514
- },
515
- name: "eslint/formatter/css",
516
- rules: {
517
- "format/prettier": [
518
- "error",
519
- mergePrettierOptions(prettierOptions, {
520
- parser: "css"
521
- })
522
- ]
523
- }
524
- },
525
- {
526
- files: [GLOB_SCSS],
527
- languageOptions: {
528
- parser: parserPlain
529
- },
530
- name: "eslint/formatter/scss",
531
- rules: {
532
- "format/prettier": [
533
- "error",
534
- mergePrettierOptions(prettierOptions, {
535
- parser: "scss"
536
- })
537
- ]
538
- }
539
- },
540
- {
541
- files: [GLOB_LESS],
542
- languageOptions: {
543
- parser: parserPlain
544
- },
545
- name: "eslint/formatter/less",
546
- rules: {
547
- "format/prettier": [
548
- "error",
549
- mergePrettierOptions(prettierOptions, {
550
- parser: "less"
551
- })
552
- ]
553
- }
554
- }
555
- );
556
- }
557
- if (options.html) {
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
- // src/configs/ignores.ts
445
+ //#endregion
446
+ //#region src/configs/ignores.ts
658
447
  async function ignores(options = {}) {
659
- const {
660
- ignores: ignores2 = []
661
- } = options;
662
- return [
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
- // src/configs/imports.ts
455
+ //#endregion
456
+ //#region src/configs/imports.ts
674
457
  async function imports(options = {}) {
675
- const {
676
- overrides = {},
677
- stylistic: stylistic2 = true
678
- } = options;
679
- return [
680
- {
681
- name: "eslint/imports/rules",
682
- plugins: {
683
- antfu: import_eslint_plugin_antfu.default,
684
- import: pluginImport
685
- },
686
- rules: {
687
- "antfu/import-dedupe": "error",
688
- "antfu/no-import-dist": "error",
689
- "antfu/no-import-node-modules-by-path": "error",
690
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
691
- "import/first": "error",
692
- "import/no-duplicates": "error",
693
- "import/no-mutable-exports": "error",
694
- "import/no-named-default": "error",
695
- "import/no-self-import": "error",
696
- "import/no-webpack-loader-syntax": "error",
697
- ...stylistic2 ? {
698
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
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
- // src/configs/javascript.ts
707
- var import_globals = __toESM(require("globals"), 1);
485
+ //#endregion
486
+ //#region src/configs/javascript.ts
708
487
  async function javascript(options = {}) {
709
- const {
710
- isInEditor = false,
711
- overrides = {}
712
- } = options;
713
- return [
714
- {
715
- languageOptions: {
716
- ecmaVersion: 2022,
717
- globals: {
718
- ...import_globals.default.browser,
719
- ...import_globals.default.es2021,
720
- ...import_globals.default.node,
721
- document: "readonly",
722
- navigator: "readonly",
723
- window: "readonly"
724
- },
725
- parserOptions: {
726
- ecmaFeatures: {
727
- jsx: true
728
- },
729
- ecmaVersion: 2022,
730
- sourceType: "module"
731
- },
732
- sourceType: "module"
733
- },
734
- linterOptions: {
735
- reportUnusedDisableDirectives: true
736
- },
737
- name: "eslint/javascript/setup"
738
- },
739
- {
740
- name: "eslint/javascript/rules",
741
- plugins: {
742
- "antfu": import_eslint_plugin_antfu.default,
743
- "unused-imports": import_eslint_plugin_unused_imports.default
744
- },
745
- rules: {
746
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
747
- "antfu/no-top-level-await": "error",
748
- "array-callback-return": "error",
749
- "block-scoped-var": "error",
750
- "constructor-super": "error",
751
- "default-case-last": "error",
752
- "dot-notation": ["error", { allowKeywords: true }],
753
- "eqeqeq": ["error", "smart"],
754
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
755
- "no-alert": "error",
756
- "no-array-constructor": "error",
757
- "no-async-promise-executor": "error",
758
- "no-caller": "error",
759
- "no-case-declarations": "error",
760
- "no-class-assign": "error",
761
- "no-compare-neg-zero": "error",
762
- "no-cond-assign": ["error", "always"],
763
- // 'no-console': ['error', { allow: ['warn', 'error'] }],
764
- "no-console": "off",
765
- "no-const-assign": "error",
766
- "no-control-regex": "error",
767
- "no-debugger": "error",
768
- "no-delete-var": "error",
769
- "no-dupe-args": "error",
770
- "no-dupe-class-members": "error",
771
- "no-dupe-keys": "error",
772
- "no-duplicate-case": "error",
773
- "no-empty": ["error", { allowEmptyCatch: true }],
774
- "no-empty-character-class": "error",
775
- "no-empty-pattern": "error",
776
- "no-eval": "error",
777
- "no-ex-assign": "error",
778
- "no-extend-native": "error",
779
- "no-extra-bind": "error",
780
- "no-extra-boolean-cast": "error",
781
- "no-fallthrough": "error",
782
- "no-func-assign": "error",
783
- "no-global-assign": "error",
784
- "no-implied-eval": "error",
785
- "no-import-assign": "error",
786
- "no-invalid-regexp": "error",
787
- "no-irregular-whitespace": "error",
788
- "no-iterator": "error",
789
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
790
- "no-lone-blocks": "error",
791
- "no-loss-of-precision": "error",
792
- "no-misleading-character-class": "error",
793
- "no-multi-str": "error",
794
- "no-new": "error",
795
- "no-new-func": "error",
796
- "no-new-native-nonconstructor": "error",
797
- "no-new-wrappers": "error",
798
- "no-obj-calls": "error",
799
- "no-octal": "error",
800
- "no-octal-escape": "error",
801
- "no-proto": "error",
802
- "no-prototype-builtins": "error",
803
- "no-redeclare": ["error", { builtinGlobals: false }],
804
- "no-regex-spaces": "error",
805
- "no-restricted-globals": [
806
- "error",
807
- { message: "Use `globalThis` instead.", name: "global" },
808
- { message: "Use `globalThis` instead.", name: "self" }
809
- ],
810
- "no-restricted-properties": [
811
- "error",
812
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
813
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
814
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
815
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
816
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
817
- ],
818
- "no-restricted-syntax": [
819
- "error",
820
- "TSEnumDeclaration[const=true]",
821
- "TSExportAssignment"
822
- ],
823
- "no-self-assign": ["error", { props: true }],
824
- "no-self-compare": "error",
825
- "no-sequences": "error",
826
- "no-shadow-restricted-names": "error",
827
- "no-sparse-arrays": "error",
828
- "no-template-curly-in-string": "error",
829
- "no-this-before-super": "error",
830
- "no-throw-literal": "error",
831
- "no-undef": "error",
832
- "no-undef-init": "error",
833
- "no-unexpected-multiline": "error",
834
- "no-unmodified-loop-condition": "error",
835
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
836
- "no-unreachable": "error",
837
- "no-unreachable-loop": "error",
838
- "no-unsafe-finally": "error",
839
- "no-unsafe-negation": "error",
840
- "no-unused-expressions": ["error", {
841
- allowShortCircuit: true,
842
- allowTaggedTemplates: true,
843
- allowTernary: true
844
- }],
845
- "no-unused-vars": ["warn", {
846
- args: "none",
847
- caughtErrors: "none",
848
- ignoreRestSiblings: true,
849
- vars: "all"
850
- }],
851
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
852
- "no-useless-backreference": "error",
853
- "no-useless-call": "error",
854
- "no-useless-catch": "error",
855
- "no-useless-computed-key": "error",
856
- "no-useless-constructor": "error",
857
- "no-useless-rename": "error",
858
- "no-useless-return": "error",
859
- "no-var": "error",
860
- "no-with": "error",
861
- "object-shorthand": [
862
- "error",
863
- "always",
864
- {
865
- avoidQuotes: true,
866
- ignoreConstructors: false
867
- }
868
- ],
869
- "one-var": ["error", { initialized: "never" }],
870
- "prefer-arrow-callback": [
871
- "error",
872
- {
873
- allowNamedFunctions: false,
874
- allowUnboundThis: true
875
- }
876
- ],
877
- "prefer-const": [
878
- isInEditor ? "warn" : "error",
879
- {
880
- destructuring: "all",
881
- ignoreReadBeforeAssign: true
882
- }
883
- ],
884
- "prefer-exponentiation-operator": "error",
885
- "prefer-promise-reject-errors": "error",
886
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
887
- "prefer-rest-params": "error",
888
- "prefer-spread": "error",
889
- "prefer-template": "error",
890
- "symbol-description": "error",
891
- "unicode-bom": ["error", "never"],
892
- "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
893
- "unused-imports/no-unused-vars": [
894
- "error",
895
- {
896
- args: "after-used",
897
- argsIgnorePattern: "^_",
898
- ignoreRestSiblings: true,
899
- vars: "all",
900
- varsIgnorePattern: "^_"
901
- }
902
- ],
903
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
904
- "valid-typeof": ["error", { requireStringLiterals: true }],
905
- "vars-on-top": "error",
906
- "yoda": ["error", "never"],
907
- ...overrides
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
- // src/configs/jsdoc.ts
710
+ //#endregion
711
+ //#region src/configs/jsdoc.ts
914
712
  async function jsdoc(options = {}) {
915
- const {
916
- overrides = {},
917
- stylistic: stylistic2 = true
918
- } = options;
919
- return [
920
- {
921
- name: "eslint/jsdoc/rules",
922
- plugins: {
923
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
924
- },
925
- rules: {
926
- "jsdoc/check-access": "warn",
927
- "jsdoc/check-param-names": "warn",
928
- "jsdoc/check-property-names": "warn",
929
- "jsdoc/check-types": "warn",
930
- "jsdoc/empty-tags": "warn",
931
- "jsdoc/implements-on-classes": "warn",
932
- "jsdoc/no-defaults": "warn",
933
- "jsdoc/no-multi-asterisks": "warn",
934
- "jsdoc/require-param-name": "warn",
935
- "jsdoc/require-property": "warn",
936
- "jsdoc/require-property-description": "warn",
937
- "jsdoc/require-property-name": "warn",
938
- "jsdoc/require-returns-check": "warn",
939
- "jsdoc/require-returns-description": "warn",
940
- "jsdoc/require-yields-check": "warn",
941
- ...stylistic2 ? {
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
- // src/configs/jsonc.ts
742
+ //#endregion
743
+ //#region src/configs/jsonc.ts
952
744
  async function jsonc(options = {}) {
953
- const {
954
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
955
- overrides = {},
956
- stylistic: stylistic2 = true
957
- } = options;
958
- const [
959
- pluginJsonc,
960
- parserJsonc
961
- ] = await Promise.all([
962
- interopDefault(import("eslint-plugin-jsonc")),
963
- interopDefault(import("jsonc-eslint-parser"))
964
- ]);
965
- return [
966
- {
967
- name: "eslint/jsonc/setup",
968
- plugins: {
969
- jsonc: pluginJsonc
970
- }
971
- },
972
- {
973
- files,
974
- languageOptions: {
975
- parser: parserJsonc
976
- },
977
- name: "eslint/jsonc/rules",
978
- rules: {
979
- "jsonc/no-bigint-literals": "error",
980
- "jsonc/no-binary-expression": "error",
981
- "jsonc/no-binary-numeric-literals": "error",
982
- "jsonc/no-dupe-keys": "error",
983
- "jsonc/no-escape-sequence-in-identifier": "error",
984
- "jsonc/no-floating-decimal": "error",
985
- "jsonc/no-hexadecimal-numeric-literals": "error",
986
- "jsonc/no-infinity": "error",
987
- "jsonc/no-multi-str": "error",
988
- "jsonc/no-nan": "error",
989
- "jsonc/no-number-props": "error",
990
- "jsonc/no-numeric-separators": "error",
991
- "jsonc/no-octal": "error",
992
- "jsonc/no-octal-escape": "error",
993
- "jsonc/no-octal-numeric-literals": "error",
994
- "jsonc/no-parenthesized": "error",
995
- "jsonc/no-plus-sign": "error",
996
- "jsonc/no-regexp-literals": "error",
997
- "jsonc/no-sparse-arrays": "error",
998
- "jsonc/no-template-literals": "error",
999
- "jsonc/no-undefined-value": "error",
1000
- "jsonc/no-unicode-codepoint-escapes": "error",
1001
- "jsonc/no-useless-escape": "error",
1002
- "jsonc/space-unary-ops": "error",
1003
- "jsonc/valid-json-number": "error",
1004
- "jsonc/vue-custom-block/no-parsing-error": "error",
1005
- ...stylistic2 ? {
1006
- "jsonc/array-bracket-spacing": ["error", "never"],
1007
- "jsonc/comma-dangle": ["error", "never"],
1008
- "jsonc/comma-style": ["error", "last"],
1009
- "jsonc/indent": ["error", 2],
1010
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1011
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
1012
- "jsonc/object-curly-spacing": ["error", "always"],
1013
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
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
- // src/configs/jsx.ts
808
+ //#endregion
809
+ //#region src/configs/jsx.ts
1024
810
  async function jsx() {
1025
- return [
1026
- {
1027
- files: [GLOB_JSX, GLOB_TSX],
1028
- languageOptions: {
1029
- parserOptions: {
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
- // src/configs/markdown.ts
1041
- var import_eslint_merge_processors = require("eslint-merge-processors");
1042
- var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
818
+ //#endregion
819
+ //#region src/configs/markdown.ts
1043
820
  async function markdown(options = {}) {
1044
- const {
1045
- componentExts = [],
1046
- files = [GLOB_MARKDOWN],
1047
- overrides = {}
1048
- } = options;
1049
- const markdown2 = await interopDefault(import("@eslint/markdown"));
1050
- return [
1051
- {
1052
- name: "eslint/markdown/setup",
1053
- plugins: {
1054
- markdown: markdown2
1055
- }
1056
- },
1057
- {
1058
- files,
1059
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1060
- name: "eslint/markdown/processor",
1061
- processor: (0, import_eslint_merge_processors.mergeProcessors)([
1062
- markdown2.processors.markdown,
1063
- import_eslint_merge_processors.processorPassThrough
1064
- ])
1065
- },
1066
- {
1067
- files,
1068
- languageOptions: {
1069
- parser: parserPlain2
1070
- },
1071
- name: "eslint/markdown/parser"
1072
- },
1073
- {
1074
- files: [
1075
- GLOB_MARKDOWN_CODE,
1076
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1077
- ],
1078
- languageOptions: {
1079
- parserOptions: {
1080
- ecmaFeatures: {
1081
- impliedStrict: true
1082
- }
1083
- }
1084
- },
1085
- name: "eslint/markdown/disables",
1086
- rules: {
1087
- "antfu/no-top-level-await": "off",
1088
- "import/newline-after-import": "off",
1089
- "no-alert": "off",
1090
- "no-console": "off",
1091
- "no-labels": "off",
1092
- "no-lone-blocks": "off",
1093
- "no-restricted-syntax": "off",
1094
- "no-undef": "off",
1095
- "no-unused-expressions": "off",
1096
- "no-unused-labels": "off",
1097
- "no-unused-vars": "off",
1098
- "node/prefer-global/process": "off",
1099
- "style/comma-dangle": "off",
1100
- "style/eol-last": "off",
1101
- "ts/consistent-type-imports": "off",
1102
- "ts/explicit-function-return-type": "off",
1103
- "ts/no-namespace": "off",
1104
- "ts/no-redeclare": "off",
1105
- "ts/no-require-imports": "off",
1106
- "ts/no-unused-expressions": "off",
1107
- "ts/no-unused-vars": "off",
1108
- "ts/no-use-before-define": "off",
1109
- "unicode-bom": "off",
1110
- "unused-imports/no-unused-imports": "off",
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
- // src/configs/node.ts
890
+ //#endregion
891
+ //#region src/configs/node.ts
1137
892
  async function node(options = {}) {
1138
- const {
1139
- overrides = {}
1140
- } = options;
1141
- return [
1142
- {
1143
- name: "eslint/node/rules",
1144
- plugins: {
1145
- node: import_eslint_plugin_n.default
1146
- },
1147
- rules: {
1148
- "node/handle-callback-err": ["error", "^(err|error)$"],
1149
- "node/no-deprecated-api": "error",
1150
- "node/no-exports-assign": "error",
1151
- "node/no-new-require": "error",
1152
- "node/no-path-concat": "error",
1153
- "node/prefer-global/buffer": ["error", "never"],
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
- // src/configs/perfectionist.ts
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
- const {
1165
- overrides = {}
1166
- } = options;
1167
- return [
1168
- {
1169
- name: "eslint/perfectionist/setup",
1170
- plugins: {
1171
- perfectionist: import_eslint_plugin_perfectionist.default
1172
- },
1173
- rules: {
1174
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1175
- "perfectionist/sort-imports": ["error", {
1176
- groups: [
1177
- "type",
1178
- "builtin-type",
1179
- ["index-type", "parent-type", "sibling-type", "internal-type"],
1180
- "builtin",
1181
- "external",
1182
- "internal",
1183
- ["index", "parent", "sibling"],
1184
- "side-effect",
1185
- "object",
1186
- "unknown"
1187
- ],
1188
- internalPattern: ["^~/.*", "^@/.*"],
1189
- newlinesBetween: "ignore",
1190
- order: "asc",
1191
- type: "natural"
1192
- }],
1193
- "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1194
- "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }],
1195
- ...overrides
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
- // src/configs/pnpm.ts
968
+ //#endregion
969
+ //#region src/configs/pnpm.ts
1202
970
  async function pnpm() {
1203
- const [
1204
- pluginPnpm,
1205
- yamlParser,
1206
- jsoncParser
1207
- ] = await Promise.all([
1208
- interopDefault(import("eslint-plugin-pnpm")),
1209
- interopDefault(import("yaml-eslint-parser")),
1210
- interopDefault(import("jsonc-eslint-parser"))
1211
- ]);
1212
- return [
1213
- {
1214
- files: [
1215
- "package.json",
1216
- "**/package.json"
1217
- ],
1218
- languageOptions: {
1219
- parser: jsoncParser
1220
- },
1221
- name: "eslint/pnpm/package-json",
1222
- plugins: {
1223
- pnpm: pluginPnpm
1224
- },
1225
- rules: {
1226
- "pnpm/json-enforce-catalog": "error",
1227
- "pnpm/json-prefer-workspace-settings": "error",
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
- // src/configs/react.ts
1249
- var import_local_pkg2 = require("local-pkg");
1250
- var ReactRefreshAllowConstantExportPackages = [
1251
- "vite"
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
- var RemixPackages = [
1254
- "@remix-run/node",
1255
- "@remix-run/react",
1256
- "@remix-run/serve",
1257
- "@remix-run/dev"
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
- const {
1270
- files = [GLOB_SRC],
1271
- filesTypeAware = [GLOB_TS, GLOB_TSX],
1272
- ignoresTypeAware = [
1273
- `${GLOB_MARKDOWN}/**`
1274
- ],
1275
- overrides = {},
1276
- tsconfigPath
1277
- } = options;
1278
- await ensurePackages([
1279
- "@eslint-react/eslint-plugin",
1280
- "eslint-plugin-react-hooks",
1281
- "eslint-plugin-react-refresh"
1282
- ]);
1283
- const isTypeAware = !!tsconfigPath;
1284
- const typeAwareRules = {
1285
- "react/no-leaked-conditional-rendering": "warn"
1286
- };
1287
- const [
1288
- pluginReact,
1289
- pluginReactHooks,
1290
- pluginReactRefresh
1291
- ] = await Promise.all([
1292
- interopDefault(import("@eslint-react/eslint-plugin")),
1293
- interopDefault(import("eslint-plugin-react-hooks")),
1294
- interopDefault(import("eslint-plugin-react-refresh"))
1295
- ]);
1296
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1297
- (i) => (0, import_local_pkg2.isPackageExists)(i)
1298
- );
1299
- const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1300
- const isUsingReactRouter = ReactRouterPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1301
- const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1302
- const plugins = pluginReact.configs.all.plugins;
1303
- return [
1304
- {
1305
- name: "eslint/react/setup",
1306
- plugins: {
1307
- "react": plugins["@eslint-react"],
1308
- "react-dom": plugins["@eslint-react/dom"],
1309
- "react-hooks": pluginReactHooks,
1310
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1311
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1312
- "react-refresh": pluginReactRefresh,
1313
- "react-web-api": plugins["@eslint-react/web-api"]
1314
- }
1315
- },
1316
- {
1317
- files,
1318
- languageOptions: {
1319
- parserOptions: {
1320
- ecmaFeatures: {
1321
- jsx: true
1322
- }
1323
- },
1324
- sourceType: "module"
1325
- },
1326
- name: "eslint/react/rules",
1327
- rules: {
1328
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1329
- "react-dom/no-dangerously-set-innerhtml": "warn",
1330
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1331
- "react-dom/no-find-dom-node": "error",
1332
- "react-dom/no-flush-sync": "error",
1333
- "react-dom/no-hydrate": "error",
1334
- "react-dom/no-missing-button-type": "warn",
1335
- "react-dom/no-missing-iframe-sandbox": "warn",
1336
- "react-dom/no-namespace": "error",
1337
- "react-dom/no-render": "error",
1338
- "react-dom/no-render-return-value": "error",
1339
- "react-dom/no-script-url": "warn",
1340
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1341
- "react-dom/no-unsafe-target-blank": "warn",
1342
- "react-dom/no-use-form-state": "error",
1343
- "react-dom/no-void-elements-with-children": "error",
1344
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1345
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1346
- "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1347
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1348
- "react-hooks/exhaustive-deps": "warn",
1349
- "react-hooks/rules-of-hooks": "error",
1350
- // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
1351
- "react-refresh/only-export-components": [
1352
- "warn",
1353
- {
1354
- allowConstantExport: isAllowConstantExport,
1355
- allowExportNames: [
1356
- ...isUsingNext ? [
1357
- "dynamic",
1358
- "dynamicParams",
1359
- "revalidate",
1360
- "fetchCache",
1361
- "runtime",
1362
- "preferredRegion",
1363
- "maxDuration",
1364
- "config",
1365
- "generateStaticParams",
1366
- "metadata",
1367
- "generateMetadata",
1368
- "viewport",
1369
- "generateViewport"
1370
- ] : [],
1371
- ...isUsingRemix || isUsingReactRouter ? [
1372
- "meta",
1373
- "links",
1374
- "headers",
1375
- "loader",
1376
- "action"
1377
- ] : []
1378
- ]
1379
- }
1380
- ],
1381
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1382
- "react-web-api/no-leaked-event-listener": "warn",
1383
- "react-web-api/no-leaked-interval": "warn",
1384
- "react-web-api/no-leaked-resize-observer": "warn",
1385
- "react-web-api/no-leaked-timeout": "warn",
1386
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1387
- "react/no-access-state-in-setstate": "error",
1388
- "react/no-array-index-key": "warn",
1389
- "react/no-children-count": "warn",
1390
- "react/no-children-for-each": "warn",
1391
- "react/no-children-map": "warn",
1392
- "react/no-children-only": "warn",
1393
- "react/no-children-to-array": "warn",
1394
- "react/no-clone-element": "warn",
1395
- "react/no-comment-textnodes": "warn",
1396
- "react/no-component-will-mount": "error",
1397
- "react/no-component-will-receive-props": "error",
1398
- "react/no-component-will-update": "error",
1399
- "react/no-context-provider": "warn",
1400
- "react/no-create-ref": "error",
1401
- "react/no-default-props": "error",
1402
- "react/no-direct-mutation-state": "error",
1403
- "react/no-duplicate-jsx-props": "warn",
1404
- "react/no-duplicate-key": "warn",
1405
- "react/no-forward-ref": "warn",
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
- // src/configs/regexp.ts
1441
- var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1154
+ //#endregion
1155
+ //#region src/configs/regexp.ts
1442
1156
  async function regexp(options = {}) {
1443
- const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1444
- const rules = {
1445
- ...config.rules
1446
- };
1447
- if (options.level === "warn") {
1448
- for (const key in rules) {
1449
- if (rules[key] === "error") {
1450
- rules[key] = "warn";
1451
- }
1452
- }
1453
- }
1454
- return [
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
- // src/configs/sort.ts
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
- return [
1469
- {
1470
- files: ["**/package.json"],
1471
- name: "eslint/sort/package-json",
1472
- rules: {
1473
- "jsonc/sort-array-values": [
1474
- "error",
1475
- {
1476
- order: { type: "asc" },
1477
- pathPattern: "^files$"
1478
- }
1479
- ],
1480
- "jsonc/sort-keys": [
1481
- "error",
1482
- {
1483
- order: [
1484
- "publisher",
1485
- "name",
1486
- "displayName",
1487
- "type",
1488
- "version",
1489
- "private",
1490
- "packageManager",
1491
- "description",
1492
- "contributors",
1493
- "author",
1494
- "license",
1495
- "funding",
1496
- "homepage",
1497
- "repository",
1498
- "bugs",
1499
- "keywords",
1500
- "categories",
1501
- "sideEffects",
1502
- "exports",
1503
- "main",
1504
- "module",
1505
- "unpkg",
1506
- "jsdelivr",
1507
- "types",
1508
- "typesVersions",
1509
- "bin",
1510
- "icon",
1511
- "files",
1512
- "engines",
1513
- "activationEvents",
1514
- "contributes",
1515
- "scripts",
1516
- "peerDependencies",
1517
- "peerDependenciesMeta",
1518
- "dependencies",
1519
- "optionalDependencies",
1520
- "devDependencies",
1521
- "pnpm",
1522
- "overrides",
1523
- "resolutions",
1524
- "husky",
1525
- "simple-git-hooks",
1526
- "lint-staged",
1527
- "eslintConfig"
1528
- ],
1529
- pathPattern: "^$"
1530
- },
1531
- {
1532
- order: { type: "asc" },
1533
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1534
- },
1535
- {
1536
- order: { type: "asc" },
1537
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1538
- },
1539
- {
1540
- order: [
1541
- "types",
1542
- "import",
1543
- "require",
1544
- "default"
1545
- ],
1546
- pathPattern: "^exports.*$"
1547
- },
1548
- {
1549
- order: [
1550
- // client hooks only
1551
- "pre-commit",
1552
- "prepare-commit-msg",
1553
- "commit-msg",
1554
- "post-commit",
1555
- "pre-rebase",
1556
- "post-rewrite",
1557
- "post-checkout",
1558
- "post-merge",
1559
- "pre-push",
1560
- "pre-auto-gc"
1561
- ],
1562
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
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
- return [
1571
- {
1572
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1573
- name: "eslint/sort/tsconfig",
1574
- rules: {
1575
- "jsonc/sort-keys": [
1576
- "error",
1577
- {
1578
- order: [
1579
- "extends",
1580
- "compilerOptions",
1581
- "references",
1582
- "files",
1583
- "include",
1584
- "exclude"
1585
- ],
1586
- pathPattern: "^$"
1587
- },
1588
- {
1589
- order: [
1590
- /* Projects */
1591
- "incremental",
1592
- "composite",
1593
- "tsBuildInfoFile",
1594
- "disableSourceOfProjectReferenceRedirect",
1595
- "disableSolutionSearching",
1596
- "disableReferencedProjectLoad",
1597
- /* Language and Environment */
1598
- "target",
1599
- "jsx",
1600
- "jsxFactory",
1601
- "jsxFragmentFactory",
1602
- "jsxImportSource",
1603
- "lib",
1604
- "moduleDetection",
1605
- "noLib",
1606
- "reactNamespace",
1607
- "useDefineForClassFields",
1608
- "emitDecoratorMetadata",
1609
- "experimentalDecorators",
1610
- "libReplacement",
1611
- /* Modules */
1612
- "baseUrl",
1613
- "rootDir",
1614
- "rootDirs",
1615
- "customConditions",
1616
- "module",
1617
- "moduleResolution",
1618
- "moduleSuffixes",
1619
- "noResolve",
1620
- "paths",
1621
- "resolveJsonModule",
1622
- "resolvePackageJsonExports",
1623
- "resolvePackageJsonImports",
1624
- "typeRoots",
1625
- "types",
1626
- "allowArbitraryExtensions",
1627
- "allowImportingTsExtensions",
1628
- "allowUmdGlobalAccess",
1629
- /* JavaScript Support */
1630
- "allowJs",
1631
- "checkJs",
1632
- "maxNodeModuleJsDepth",
1633
- /* Type Checking */
1634
- "strict",
1635
- "strictBindCallApply",
1636
- "strictFunctionTypes",
1637
- "strictNullChecks",
1638
- "strictPropertyInitialization",
1639
- "allowUnreachableCode",
1640
- "allowUnusedLabels",
1641
- "alwaysStrict",
1642
- "exactOptionalPropertyTypes",
1643
- "noFallthroughCasesInSwitch",
1644
- "noImplicitAny",
1645
- "noImplicitOverride",
1646
- "noImplicitReturns",
1647
- "noImplicitThis",
1648
- "noPropertyAccessFromIndexSignature",
1649
- "noUncheckedIndexedAccess",
1650
- "noUnusedLocals",
1651
- "noUnusedParameters",
1652
- "useUnknownInCatchVariables",
1653
- /* Emit */
1654
- "declaration",
1655
- "declarationDir",
1656
- "declarationMap",
1657
- "downlevelIteration",
1658
- "emitBOM",
1659
- "emitDeclarationOnly",
1660
- "importHelpers",
1661
- "importsNotUsedAsValues",
1662
- "inlineSourceMap",
1663
- "inlineSources",
1664
- "mapRoot",
1665
- "newLine",
1666
- "noEmit",
1667
- "noEmitHelpers",
1668
- "noEmitOnError",
1669
- "outDir",
1670
- "outFile",
1671
- "preserveConstEnums",
1672
- "preserveValueImports",
1673
- "removeComments",
1674
- "sourceMap",
1675
- "sourceRoot",
1676
- "stripInternal",
1677
- /* Interop Constraints */
1678
- "allowSyntheticDefaultImports",
1679
- "esModuleInterop",
1680
- "forceConsistentCasingInFileNames",
1681
- "isolatedModules",
1682
- "preserveSymlinks",
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
- // src/configs/test.ts
1397
+ //#endregion
1398
+ //#region src/configs/test.ts
1698
1399
  async function test(options = {}) {
1699
- const {
1700
- files = GLOB_TESTS,
1701
- isInEditor = false,
1702
- overrides = {}
1703
- } = options;
1704
- const [
1705
- pluginVitest,
1706
- pluginNoOnlyTests
1707
- ] = await Promise.all([
1708
- interopDefault(import("@vitest/eslint-plugin")),
1709
- // @ts-expect-error missing types
1710
- interopDefault(import("eslint-plugin-no-only-tests"))
1711
- ]);
1712
- return [
1713
- {
1714
- name: "eslint/test/setup",
1715
- plugins: {
1716
- test: {
1717
- ...pluginVitest,
1718
- rules: {
1719
- ...pluginVitest.rules,
1720
- // extend `test/no-only-tests` rule
1721
- ...pluginNoOnlyTests.rules
1722
- }
1723
- }
1724
- }
1725
- },
1726
- {
1727
- files,
1728
- name: "eslint/test/rules",
1729
- rules: {
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
- // src/configs/toml.ts
1433
+ //#endregion
1434
+ //#region src/configs/toml.ts
1750
1435
  async function toml(options = {}) {
1751
- const {
1752
- files = [GLOB_TOML],
1753
- overrides = {},
1754
- stylistic: stylistic2 = true
1755
- } = options;
1756
- const {
1757
- indent = 4
1758
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1759
- const [
1760
- pluginToml,
1761
- parserToml
1762
- ] = await Promise.all([
1763
- interopDefault(import("eslint-plugin-toml")),
1764
- interopDefault(import("toml-eslint-parser"))
1765
- ]);
1766
- return [
1767
- {
1768
- name: "eslint/toml/setup",
1769
- plugins: {
1770
- toml: pluginToml
1771
- }
1772
- },
1773
- {
1774
- files,
1775
- languageOptions: {
1776
- parser: parserToml
1777
- },
1778
- name: "eslint/toml/rules",
1779
- rules: {
1780
- "style/spaced-comment": "off",
1781
- "toml/comma-style": "error",
1782
- "toml/keys-order": "error",
1783
- "toml/no-space-dots": "error",
1784
- "toml/no-unreadable-number-separator": "error",
1785
- "toml/precision-of-fractional-seconds": "error",
1786
- "toml/precision-of-integer": "error",
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
- // src/configs/typescript.ts
1809
- var import_node_process2 = __toESM(require("process"), 1);
1474
+ //#endregion
1475
+ //#region src/configs/typescript.ts
1810
1476
  async function typescript(options = {}) {
1811
- const {
1812
- componentExts = [],
1813
- overrides = {},
1814
- parserOptions = {},
1815
- type = "app"
1816
- } = options;
1817
- const files = options.files ?? [
1818
- GLOB_SRC,
1819
- ...componentExts.map((ext) => `**/*.${ext}`)
1820
- ];
1821
- const ignoresTypeAware = options.ignoresTypeAware ?? [
1822
- `${GLOB_MARKDOWN}/**`
1823
- ];
1824
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1825
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1826
- const isTypeAware = !!tsconfigPath;
1827
- const typeAwareRules = {
1828
- "dot-notation": "off",
1829
- "no-implied-eval": "off",
1830
- "ts/await-thenable": "error",
1831
- "ts/dot-notation": ["error", { allowKeywords: true }],
1832
- "ts/no-floating-promises": "error",
1833
- "ts/no-for-in-array": "error",
1834
- "ts/no-implied-eval": "error",
1835
- "ts/no-misused-promises": "error",
1836
- "ts/no-unnecessary-type-assertion": "error",
1837
- "ts/no-unsafe-argument": "error",
1838
- "ts/no-unsafe-assignment": "error",
1839
- "ts/no-unsafe-call": "error",
1840
- "ts/no-unsafe-member-access": "error",
1841
- "ts/no-unsafe-return": "error",
1842
- "ts/promise-function-async": "error",
1843
- "ts/restrict-plus-operands": "error",
1844
- "ts/restrict-template-expressions": "error",
1845
- "ts/return-await": ["error", "in-try-catch"],
1846
- "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1847
- "ts/switch-exhaustiveness-check": "error",
1848
- "ts/unbound-method": "error"
1849
- };
1850
- const [
1851
- pluginTs,
1852
- parserTs
1853
- ] = await Promise.all([
1854
- interopDefault(import("@typescript-eslint/eslint-plugin")),
1855
- interopDefault(import("@typescript-eslint/parser"))
1856
- ]);
1857
- function makeParser(typeAware, files2, ignores2) {
1858
- return {
1859
- files: files2,
1860
- ...ignores2 ? { ignores: ignores2 } : {},
1861
- languageOptions: {
1862
- parser: parserTs,
1863
- parserOptions: {
1864
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1865
- sourceType: "module",
1866
- ...typeAware ? {
1867
- projectService: {
1868
- allowDefaultProject: ["./*.js"],
1869
- defaultProject: tsconfigPath
1870
- },
1871
- tsconfigRootDir: import_node_process2.default.cwd()
1872
- } : {},
1873
- ...parserOptions
1874
- }
1875
- },
1876
- name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1877
- };
1878
- }
1879
- return [
1880
- {
1881
- // Install the plugins without globs, so they can be configured separately.
1882
- name: "eslint/typescript/setup",
1883
- plugins: {
1884
- antfu: import_eslint_plugin_antfu.default,
1885
- ts: pluginTs
1886
- }
1887
- },
1888
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
1889
- ...isTypeAware ? [
1890
- makeParser(false, files),
1891
- makeParser(true, filesTypeAware, ignoresTypeAware)
1892
- ] : [
1893
- makeParser(false, files)
1894
- ],
1895
- {
1896
- files,
1897
- name: "eslint/typescript/rules",
1898
- rules: {
1899
- ...renameRules(
1900
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
1901
- { "@typescript-eslint": "ts" }
1902
- ),
1903
- ...renameRules(
1904
- pluginTs.configs.strict.rules,
1905
- { "@typescript-eslint": "ts" }
1906
- ),
1907
- "no-dupe-class-members": "off",
1908
- "no-redeclare": "off",
1909
- "no-unused-expressions": "off",
1910
- "no-use-before-define": "off",
1911
- "no-useless-constructor": "off",
1912
- "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1913
- "ts/consistent-type-definitions": ["error", "interface"],
1914
- "ts/consistent-type-imports": ["error", {
1915
- disallowTypeAnnotations: false,
1916
- fixStyle: "separate-type-imports",
1917
- prefer: "type-imports"
1918
- }],
1919
- "ts/method-signature-style": ["error", "property"],
1920
- "ts/no-dupe-class-members": "error",
1921
- "ts/no-dynamic-delete": "off",
1922
- "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1923
- "ts/no-explicit-any": "off",
1924
- "ts/no-extraneous-class": "off",
1925
- "ts/no-import-type-side-effects": "error",
1926
- "ts/no-invalid-void-type": "off",
1927
- "ts/no-non-null-assertion": "off",
1928
- "ts/no-redeclare": ["error", { builtinGlobals: false }],
1929
- "ts/no-require-imports": "error",
1930
- "ts/no-unused-expressions": ["error", {
1931
- // allowShortCircuit 设置为 true 将允许你在表达式中使用短路计算(默认值:false)
1932
- allowShortCircuit: true,
1933
- // allowTaggedTemplates 设置为 true 将使你能够在表达式中使用标记模板字面量(默认值:false)
1934
- allowTaggedTemplates: true,
1935
- // allowTernary 设置为 true 将使你能够在表达式中使用三元运算符,类似于短路计算(默认值:false)
1936
- allowTernary: true
1937
- }],
1938
- "ts/no-unused-vars": [
1939
- "warn",
1940
- {
1941
- args: "all",
1942
- argsIgnorePattern: "^_",
1943
- caughtErrors: "all",
1944
- caughtErrorsIgnorePattern: "^_",
1945
- destructuredArrayIgnorePattern: "^_",
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
- // src/configs/unicorn.ts
1614
+ //#endregion
1615
+ //#region src/configs/unicorn.ts
1979
1616
  async function unicorn(options = {}) {
1980
- return [
1981
- {
1982
- name: "eslint/unicorn/rules",
1983
- plugins: {
1984
- unicorn: import_eslint_plugin_unicorn.default
1985
- },
1986
- rules: {
1987
- ...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
1988
- "unicorn/consistent-empty-array-spread": "error",
1989
- "unicorn/error-message": "error",
1990
- "unicorn/escape-case": "error",
1991
- "unicorn/new-for-builtins": "error",
1992
- "unicorn/no-instanceof-array": "error",
1993
- "unicorn/no-new-array": "error",
1994
- "unicorn/no-new-buffer": "error",
1995
- "unicorn/number-literal-case": "error",
1996
- "unicorn/prefer-dom-node-text-content": "error",
1997
- "unicorn/prefer-includes": "error",
1998
- "unicorn/prefer-node-protocol": "error",
1999
- "unicorn/prefer-number-properties": "error",
2000
- "unicorn/prefer-string-starts-ends-with": "error",
2001
- "unicorn/prefer-type-error": "error",
2002
- "unicorn/throw-new-error": "error"
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
- // src/configs/unocss.ts
1643
+ //#endregion
1644
+ //#region src/configs/unocss.ts
2011
1645
  async function unocss(options = {}) {
2012
- const {
2013
- attributify = true,
2014
- overrides = {},
2015
- strict = false
2016
- } = options;
2017
- await ensurePackages([
2018
- "@unocss/eslint-plugin"
2019
- ]);
2020
- const [
2021
- pluginUnoCSS
2022
- ] = await Promise.all([
2023
- interopDefault(import("@unocss/eslint-plugin"))
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
- // src/configs/vue.ts
2046
- var import_eslint_merge_processors2 = require("eslint-merge-processors");
2047
- var import_local_pkg3 = require("local-pkg");
2048
- var pkg = (0, import_local_pkg3.getPackageInfoSync)("vue");
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
- const {
2054
- files = [GLOB_VUE],
2055
- overrides = {},
2056
- stylistic: stylistic2 = true
2057
- } = options;
2058
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2059
- const {
2060
- indent = 4
2061
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2062
- const [
2063
- pluginVue,
2064
- parserVue,
2065
- processorVueBlocks
2066
- ] = await Promise.all([
2067
- interopDefault(import("eslint-plugin-vue")),
2068
- interopDefault(import("vue-eslint-parser")),
2069
- interopDefault(import("eslint-processor-vue-blocks"))
2070
- ]);
2071
- return [
2072
- {
2073
- // This allows Vue plugin to work with auto imports
2074
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2075
- languageOptions: {
2076
- globals: {
2077
- computed: "readonly",
2078
- defineEmits: "readonly",
2079
- defineExpose: "readonly",
2080
- defineProps: "readonly",
2081
- onMounted: "readonly",
2082
- onUnmounted: "readonly",
2083
- reactive: "readonly",
2084
- ref: "readonly",
2085
- shallowReactive: "readonly",
2086
- shallowRef: "readonly",
2087
- toRef: "readonly",
2088
- toRefs: "readonly",
2089
- watch: "readonly",
2090
- watchEffect: "readonly"
2091
- }
2092
- },
2093
- name: "eslint/vue/setup",
2094
- plugins: {
2095
- vue: pluginVue
2096
- }
2097
- },
2098
- {
2099
- files,
2100
- languageOptions: {
2101
- parser: parserVue,
2102
- parserOptions: {
2103
- ecmaFeatures: {
2104
- jsx: true
2105
- },
2106
- extraFileExtensions: [".vue"],
2107
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2108
- sourceType: "module"
2109
- }
2110
- },
2111
- name: "eslint/vue/rules",
2112
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
2113
- pluginVue.processors[".vue"],
2114
- processorVueBlocks({
2115
- ...sfcBlocks,
2116
- blocks: {
2117
- styles: true,
2118
- ...sfcBlocks.blocks
2119
- }
2120
- })
2121
- ]),
2122
- rules: {
2123
- ...pluginVue.configs.base.rules,
2124
- ...vueVersion === "2" ? {
2125
- ...pluginVue.configs["vue2-essential"].rules,
2126
- ...pluginVue.configs["vue2-strongly-recommended"].rules,
2127
- ...pluginVue.configs["vue2-recommended"].rules
2128
- } : {
2129
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2130
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2131
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {})
2132
- },
2133
- "antfu/no-top-level-await": "off",
2134
- "node/prefer-global/process": "off",
2135
- "ts/explicit-function-return-type": "off",
2136
- "vue/block-order": ["error", {
2137
- order: ["template", "script", "style"]
2138
- }],
2139
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
2140
- "vue/component-options-name-casing": ["error", "PascalCase"],
2141
- "vue/custom-event-name-casing": vueVersion === "3" ? ["error", "camelCase"] : ["error", "kebab-case"],
2142
- ...vueVersion === "2" ? {
2143
- "vue/require-explicit-emits": "off"
2144
- } : null,
2145
- "no-irregular-whitespace": "off",
2146
- "vue/define-macros-order": ["error", {
2147
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
2148
- }],
2149
- "vue/dot-location": ["error", "property"],
2150
- "vue/dot-notation": ["error", { allowKeywords: true }],
2151
- "vue/eqeqeq": ["error", "smart"],
2152
- "vue/html-indent": ["error", indent, {
2153
- alignAttributesVertically: true,
2154
- attribute: 1,
2155
- baseIndent: 1,
2156
- closeBracket: 0,
2157
- ignores: []
2158
- }],
2159
- "vue/html-self-closing": ["error", {
2160
- html: {
2161
- component: "any",
2162
- normal: "any",
2163
- void: "never"
2164
- },
2165
- math: "always",
2166
- svg: "always"
2167
- }],
2168
- "vue/max-attributes-per-line": "off",
2169
- "vue/multi-word-component-names": "off",
2170
- "vue/no-constant-condition": "warn",
2171
- "vue/no-dupe-keys": "off",
2172
- "vue/no-empty-pattern": "error",
2173
- "vue/no-extra-parens": ["error", "functions"],
2174
- "vue/no-irregular-whitespace": ["error", {
2175
- skipComments: false,
2176
- skipHTMLAttributeValues: false,
2177
- skipHTMLTextContents: true,
2178
- skipRegExps: false,
2179
- skipStrings: true,
2180
- skipTemplates: false
2181
- }],
2182
- "vue/no-loss-of-precision": "error",
2183
- "vue/no-restricted-syntax": [
2184
- "error",
2185
- "DebuggerStatement",
2186
- "LabeledStatement",
2187
- "WithStatement"
2188
- ],
2189
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
2190
- "vue/no-setup-props-reactivity-loss": "off",
2191
- "vue/no-sparse-arrays": "error",
2192
- "vue/no-unused-refs": "warn",
2193
- "vue/no-useless-v-bind": "error",
2194
- "vue/no-v-html": "off",
2195
- "vue/no-v-text-v-html-on-component": "off",
2196
- "vue/object-shorthand": [
2197
- "error",
2198
- "always",
2199
- {
2200
- avoidQuotes: true,
2201
- ignoreConstructors: false
2202
- }
2203
- ],
2204
- "vue/prefer-separate-static-class": "error",
2205
- "vue/prefer-template": "error",
2206
- "vue/prop-name-casing": ["error", "camelCase"],
2207
- "vue/require-default-prop": "off",
2208
- "vue/require-prop-types": "off",
2209
- "vue/singleline-html-element-content-newline": "off",
2210
- "vue/space-infix-ops": "error",
2211
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
2212
- ...stylistic2 ? {
2213
- "vue/array-bracket-spacing": ["error", "never"],
2214
- "vue/arrow-spacing": ["error", { after: true, before: true }],
2215
- "vue/block-spacing": ["error", "always"],
2216
- "vue/block-tag-newline": ["error", {
2217
- multiline: "always",
2218
- singleline: "always"
2219
- }],
2220
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: false }],
2221
- "vue/comma-dangle": ["error", "always-multiline"],
2222
- "vue/comma-spacing": ["error", { after: true, before: false }],
2223
- "vue/comma-style": ["error", "last"],
2224
- "vue/html-comment-content-spacing": ["error", "always", {
2225
- exceptions: ["-"]
2226
- }],
2227
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
2228
- "vue/keyword-spacing": ["error", { after: true, before: true }],
2229
- "vue/object-curly-newline": "off",
2230
- "vue/object-curly-spacing": ["error", "always"],
2231
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
2232
- "vue/operator-linebreak": ["error", "before"],
2233
- "vue/padding-line-between-blocks": ["error", "always"],
2234
- "vue/quote-props": ["error", "consistent-as-needed"],
2235
- "vue/space-in-parens": ["error", "never"],
2236
- "vue/template-curly-spacing": "error"
2237
- } : {},
2238
- ...overrides
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
- // src/configs/yaml.ts
1872
+ //#endregion
1873
+ //#region src/configs/yaml.ts
2245
1874
  async function yaml(options = {}) {
2246
- const {
2247
- files = [GLOB_YAML],
2248
- overrides = {},
2249
- stylistic: stylistic2 = true
2250
- } = options;
2251
- const {
2252
- quotes = "single"
2253
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2254
- const [
2255
- pluginYaml,
2256
- parserYaml
2257
- ] = await Promise.all([
2258
- interopDefault(import("eslint-plugin-yml")),
2259
- interopDefault(import("yaml-eslint-parser"))
2260
- ]);
2261
- return [
2262
- {
2263
- name: "eslint/yaml/setup",
2264
- plugins: {
2265
- yaml: pluginYaml
2266
- }
2267
- },
2268
- {
2269
- files,
2270
- languageOptions: {
2271
- parser: parserYaml
2272
- },
2273
- name: "eslint/yaml/rules",
2274
- rules: {
2275
- "style/spaced-comment": "off",
2276
- "yaml/block-mapping": "error",
2277
- "yaml/block-sequence": "error",
2278
- "yaml/no-empty-key": "error",
2279
- "yaml/no-empty-sequence-entry": "error",
2280
- "yaml/no-irregular-whitespace": "error",
2281
- "yaml/plain-scalar": "error",
2282
- "yaml/vue-custom-block/no-parsing-error": "error",
2283
- ...stylistic2 ? {
2284
- "yaml/block-mapping-question-indicator-newline": "error",
2285
- "yaml/block-sequence-hyphen-indicator-newline": "error",
2286
- "yaml/flow-mapping-curly-newline": "error",
2287
- "yaml/flow-mapping-curly-spacing": "error",
2288
- "yaml/flow-sequence-bracket-newline": "error",
2289
- "yaml/flow-sequence-bracket-spacing": "error",
2290
- "yaml/indent": ["error", 2],
2291
- "yaml/key-spacing": "error",
2292
- "yaml/no-tab-indent": "error",
2293
- "yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2294
- "yaml/spaced-comment": "error"
2295
- } : {},
2296
- ...overrides
2297
- }
2298
- },
2299
- {
2300
- files: ["pnpm-workspace.yaml"],
2301
- name: "eslint/yaml/pnpm-workspace",
2302
- rules: {
2303
- "yaml/sort-keys": [
2304
- "error",
2305
- {
2306
- order: [
2307
- "packages",
2308
- "overrides",
2309
- "patchedDependencies",
2310
- "hoistPattern",
2311
- "catalog",
2312
- "catalogs",
2313
- "allowedDeprecatedVersions",
2314
- "allowNonAppliedPatches",
2315
- "configDependencies",
2316
- "ignoredBuiltDependencies",
2317
- "ignoredOptionalDependencies",
2318
- "neverBuiltDependencies",
2319
- "onlyBuiltDependencies",
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
- // src/factory.ts
2338
- var flatConfigProps = [
2339
- "name",
2340
- "languageOptions",
2341
- "linterOptions",
2342
- "processor",
2343
- "plugins",
2344
- "rules",
2345
- "settings"
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
- var VuePackages = [
2348
- "vue",
2349
- "nuxt",
2350
- "vitepress",
2351
- "@slidev/cli"
1962
+ const VuePackages = [
1963
+ "vue",
1964
+ "nuxt",
1965
+ "vitepress",
1966
+ "@slidev/cli"
2352
1967
  ];
2353
- var defaultPluginRenaming = {
2354
- "@eslint-react": "react",
2355
- "@eslint-react/dom": "react-dom",
2356
- "@eslint-react/hooks-extra": "react-hooks-extra",
2357
- "@eslint-react/naming-convention": "react-naming-convention",
2358
- "@stylistic": "style",
2359
- "@typescript-eslint": "ts",
2360
- "import-x": "import",
2361
- "n": "node",
2362
- "vitest": "test",
2363
- "yml": "yaml"
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
- const {
2367
- autoRenamePlugins = true,
2368
- componentExts = [],
2369
- gitignore: enableGitignore = true,
2370
- ignores: ignoresList = [],
2371
- jsx: enableJsx = true,
2372
- overrides = {},
2373
- pnpm: enableCatalogs = false,
2374
- react: enableReact = false,
2375
- regexp: enableRegexp = true,
2376
- typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
2377
- unicorn: enableUnicorn = true,
2378
- unocss: enableUnoCSS = false,
2379
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2380
- } = options;
2381
- let isInEditor = options.isInEditor;
2382
- if (isInEditor == null) {
2383
- isInEditor = isInEditorEnv();
2384
- if (isInEditor)
2385
- console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
2386
- }
2387
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2388
- if (stylisticOptions && !("jsx" in stylisticOptions))
2389
- stylisticOptions.jsx = enableJsx;
2390
- const configs2 = [];
2391
- if (enableGitignore) {
2392
- if (typeof enableGitignore !== "boolean") {
2393
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2394
- name: "eslint/gitignore",
2395
- ...enableGitignore
2396
- })]));
2397
- } else {
2398
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2399
- name: "eslint/gitignore",
2400
- strict: false
2401
- })]));
2402
- }
2403
- }
2404
- const typescriptOptions = resolveSubOptions(options, "typescript");
2405
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2406
- configs2.push(
2407
- ignores({
2408
- ignores: [
2409
- ...overrides.ignores || [],
2410
- ...ignoresList
2411
- ]
2412
- }),
2413
- javascript({
2414
- isInEditor,
2415
- overrides: getOverrides(options, "javascript")
2416
- }),
2417
- comments({
2418
- overrides: overrides.comments
2419
- }),
2420
- node({
2421
- overrides: overrides.node
2422
- }),
2423
- jsdoc({
2424
- overrides: overrides.jsdoc,
2425
- stylistic: stylisticOptions
2426
- }),
2427
- imports({
2428
- overrides: overrides.imports,
2429
- stylistic: stylisticOptions
2430
- }),
2431
- // Optional plugins (installed but not enabled by default)
2432
- perfectionist({
2433
- overrides: overrides.perfectionist
2434
- })
2435
- );
2436
- if (enableUnicorn) {
2437
- configs2.push(unicorn({
2438
- ...enableUnicorn === true ? {} : enableUnicorn,
2439
- overrides: overrides.unicorn
2440
- }));
2441
- }
2442
- if (enableVue) {
2443
- componentExts.push("vue");
2444
- }
2445
- if (enableJsx) {
2446
- configs2.push(jsx());
2447
- }
2448
- if (enableTypeScript) {
2449
- configs2.push(typescript({
2450
- ...typescriptOptions,
2451
- componentExts,
2452
- overrides: getOverrides(options, "typescript"),
2453
- tsconfigPath,
2454
- type: options.type
2455
- }));
2456
- }
2457
- if (stylisticOptions) {
2458
- configs2.push(stylistic({
2459
- overrides: getOverrides(options, "stylistic"),
2460
- stylistic: stylisticOptions
2461
- }));
2462
- }
2463
- if (enableRegexp) {
2464
- configs2.push(regexp({
2465
- ...resolveSubOptions(options, "regexp"),
2466
- ...getOverrides(options, "regexp")
2467
- }));
2468
- }
2469
- if (options.test ?? true) {
2470
- configs2.push(test({
2471
- ...resolveSubOptions(options, "test"),
2472
- isInEditor,
2473
- overrides: getOverrides(options, "test")
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
- return typeof options[key] === "boolean" ? {} : options[key] || {};
2101
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2578
2102
  }
2579
2103
  function getOverrides(options, key) {
2580
- const sub = resolveSubOptions(options, key);
2581
- return {
2582
- ...options.overrides?.[key],
2583
- ..."overrides" in sub ? sub.overrides : {}
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
- // src/index.ts
2588
- var index_default = lincy;
2589
- // Annotate the CommonJS export names for ESM import in node:
2590
- 0 && (module.exports = {
2591
- GLOB_ALL_SRC,
2592
- GLOB_CSS,
2593
- GLOB_EXCLUDE,
2594
- GLOB_GRAPHQL,
2595
- GLOB_HTML,
2596
- GLOB_JS,
2597
- GLOB_JSON,
2598
- GLOB_JSON5,
2599
- GLOB_JSONC,
2600
- GLOB_JSX,
2601
- GLOB_LESS,
2602
- GLOB_MARKDOWN,
2603
- GLOB_MARKDOWN_CODE,
2604
- GLOB_MARKDOWN_IN_MARKDOWN,
2605
- GLOB_POSTCSS,
2606
- GLOB_SCSS,
2607
- GLOB_SRC,
2608
- GLOB_SRC_EXT,
2609
- GLOB_STYLE,
2610
- GLOB_SVELTE,
2611
- GLOB_SVG,
2612
- GLOB_TESTS,
2613
- GLOB_TOML,
2614
- GLOB_TS,
2615
- GLOB_TSX,
2616
- GLOB_VUE,
2617
- GLOB_XML,
2618
- GLOB_YAML,
2619
- StylisticConfigDefaults,
2620
- combine,
2621
- comments,
2622
- defaultPluginRenaming,
2623
- disables,
2624
- ensurePackages,
2625
- formatters,
2626
- getOverrides,
2627
- ignores,
2628
- imports,
2629
- interopDefault,
2630
- isInEditorEnv,
2631
- isInGitHooksOrLintStaged,
2632
- isPackageInScope,
2633
- javascript,
2634
- jsdoc,
2635
- jsonc,
2636
- jsx,
2637
- lincy,
2638
- markdown,
2639
- node,
2640
- parserPlain,
2641
- perfectionist,
2642
- pnpm,
2643
- react,
2644
- regexp,
2645
- renamePluginInConfigs,
2646
- renameRules,
2647
- resolveSubOptions,
2648
- sortPackageJson,
2649
- sortTsconfig,
2650
- stylistic,
2651
- test,
2652
- toArray,
2653
- toml,
2654
- typescript,
2655
- unicorn,
2656
- unocss,
2657
- vue,
2658
- yaml
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;