@th1o/frontend-lint 0.0.1

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