@lincy/eslint-config 5.5.2 → 5.6.1

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