@svifty7/eslint-config 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2204 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let eslint_plugin_command_config = require("eslint-plugin-command/config");
29
+ eslint_plugin_command_config = __toESM(eslint_plugin_command_config);
30
+ let node_url = require("node:url");
31
+ let local_pkg = require("local-pkg");
32
+ let globals = require("globals");
33
+ globals = __toESM(globals);
34
+ let eslint_merge_processors = require("eslint-merge-processors");
35
+ let eslint_plugin_regexp = require("eslint-plugin-regexp");
36
+ let eslint_flat_config_utils = require("eslint-flat-config-utils");
37
+ let _eslint_community_eslint_plugin_eslint_comments = require("@eslint-community/eslint-plugin-eslint-comments");
38
+ let eslint_plugin_antfu = require("eslint-plugin-antfu");
39
+ let eslint_plugin_import_x = require("eslint-plugin-import-x");
40
+ let eslint_plugin_unused_imports = require("eslint-plugin-unused-imports");
41
+ let eslint_plugin_n = require("eslint-plugin-n");
42
+ let eslint_plugin_perfectionist = require("eslint-plugin-perfectionist");
43
+ let eslint_plugin_unicorn = require("eslint-plugin-unicorn");
44
+
45
+ //#region src/configs/command.ts
46
+ function command() {
47
+ return [{
48
+ ...(0, eslint_plugin_command_config.default)(),
49
+ name: "svifty7/command/rules"
50
+ }];
51
+ }
52
+
53
+ //#endregion
54
+ //#region src/configs/comments.ts
55
+ function comments() {
56
+ return [{
57
+ name: "eslint-comments/rules",
58
+ plugins: { "eslint-comments": _eslint_community_eslint_plugin_eslint_comments.default },
59
+ rules: {
60
+ "eslint-comments/no-aggregating-enable": "error",
61
+ "eslint-comments/no-duplicate-disable": "error",
62
+ "eslint-comments/no-unlimited-disable": "error",
63
+ "eslint-comments/no-unused-enable": "error"
64
+ }
65
+ }];
66
+ }
67
+
68
+ //#endregion
69
+ //#region src/globs.ts
70
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
71
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
72
+ const GLOB_JS = "**/*.?([cm])js";
73
+ const GLOB_JSX = "**/*.?([cm])jsx";
74
+ const GLOB_TS = "**/*.?([cm])ts";
75
+ const GLOB_TSX = "**/*.?([cm])tsx";
76
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
77
+ const GLOB_CSS = "**/*.css";
78
+ const GLOB_POSTCSS = "**/*.{p,post}css";
79
+ const GLOB_LESS = "**/*.less";
80
+ const GLOB_SCSS = "**/*.scss";
81
+ const GLOB_JSON = "**/*.json";
82
+ const GLOB_JSON5 = "**/*.json5";
83
+ const GLOB_JSONC = "**/*.jsonc";
84
+ const GLOB_MARKDOWN = "**/*.md";
85
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
86
+ const GLOB_VUE = "**/*.vue";
87
+ const GLOB_YAML = "**/*.y?(a)ml";
88
+ const GLOB_TOML = "**/*.toml";
89
+ const GLOB_XML = "**/*.xml";
90
+ const GLOB_SVG = "**/*.svg";
91
+ const GLOB_HTML = "**/*.htm?(l)";
92
+ const GLOB_GRAPHQL = "**/*.{g,graph}ql";
93
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
94
+ const GLOB_TESTS = [
95
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
96
+ `**/*.spec.${GLOB_SRC_EXT}`,
97
+ `**/*.test.${GLOB_SRC_EXT}`,
98
+ `**/*.bench.${GLOB_SRC_EXT}`,
99
+ `**/*.benchmark.${GLOB_SRC_EXT}`
100
+ ];
101
+ const GLOB_ALL_SRC = [
102
+ GLOB_SRC,
103
+ GLOB_STYLE,
104
+ GLOB_JSON,
105
+ GLOB_JSON5,
106
+ GLOB_MARKDOWN,
107
+ GLOB_VUE,
108
+ GLOB_YAML,
109
+ GLOB_XML,
110
+ GLOB_HTML
111
+ ];
112
+ const GLOB_EXCLUDE = [
113
+ "**/node_modules",
114
+ "**/dist",
115
+ "**/package-lock.json",
116
+ "**/yarn.lock",
117
+ "**/pnpm-lock.yaml",
118
+ "**/bun.lockb",
119
+ "**/output",
120
+ "**/coverage",
121
+ "**/temp",
122
+ "**/.temp",
123
+ "**/tmp",
124
+ "**/.tmp",
125
+ "**/.history",
126
+ "**/.vitepress/cache",
127
+ "**/.nuxt",
128
+ "**/.next",
129
+ "**/.vercel",
130
+ "**/.changeset",
131
+ "**/.idea",
132
+ "**/.cache",
133
+ "**/.output",
134
+ "**/.vite-inspect",
135
+ "**/.yarn",
136
+ "**/vite.config.*.timestamp-*",
137
+ "**/CHANGELOG*.md",
138
+ "**/*.min.*",
139
+ "**/LICENSE*",
140
+ "**/__snapshots__",
141
+ "**/auto-import?(s).d.ts",
142
+ "**/components.d.ts"
143
+ ];
144
+
145
+ //#endregion
146
+ //#region src/configs/disables.ts
147
+ function disables() {
148
+ return [
149
+ {
150
+ files: [`**/scripts/${GLOB_SRC}`],
151
+ name: "svifty7/disables/scripts",
152
+ rules: {
153
+ "antfu/no-top-level-await": "off",
154
+ "no-console": "off",
155
+ "ts/explicit-function-return-type": "off"
156
+ }
157
+ },
158
+ {
159
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
160
+ name: "svifty7/disables/cli",
161
+ rules: {
162
+ "antfu/no-top-level-await": "off",
163
+ "no-console": "off"
164
+ }
165
+ },
166
+ {
167
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
168
+ name: "svifty7/disables/bin",
169
+ rules: {
170
+ "antfu/no-import-dist": "off",
171
+ "antfu/no-import-node-modules-by-path": "off"
172
+ }
173
+ },
174
+ {
175
+ files: ["**/*.d.?([cm])ts"],
176
+ name: "svifty7/disables/dts",
177
+ rules: {
178
+ "eslint-comments/no-unlimited-disable": "off",
179
+ "import/no-duplicates": "off",
180
+ "no-restricted-syntax": "off",
181
+ "unused-imports/no-unused-vars": "off"
182
+ }
183
+ },
184
+ {
185
+ files: ["**/*.js", "**/*.cjs"],
186
+ name: "svifty7/disables/cjs",
187
+ rules: { "ts/no-require-imports": "off" }
188
+ },
189
+ {
190
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
191
+ name: "svifty7/disables/config-files",
192
+ rules: {
193
+ "antfu/no-top-level-await": "off",
194
+ "no-console": "off",
195
+ "ts/explicit-function-return-type": "off"
196
+ }
197
+ },
198
+ {
199
+ name: "svifty7/disables/prettier",
200
+ rules: {
201
+ "no-unexpected-multiline": "off",
202
+ "style/array-bracket-newline": "off",
203
+ "style/array-bracket-spacing": "off",
204
+ "style/array-element-newline": "off",
205
+ "style/arrow-parens": "off",
206
+ "style/arrow-spacing": "off",
207
+ "style/block-spacing": "off",
208
+ "style/brace-style": "off",
209
+ "style/comma-dangle": "off",
210
+ "style/comma-spacing": "off",
211
+ "style/comma-style": "off",
212
+ "style/computed-property-spacing": "off",
213
+ "style/dot-location": "off",
214
+ "style/eol-last": "off",
215
+ "style/func-call-spacing": "off",
216
+ "style/function-call-argument-newline": "off",
217
+ "style/function-call-spacing": "off",
218
+ "style/function-paren-newline": "off",
219
+ "style/generator-star-spacing": "off",
220
+ "style/implicit-arrow-linebreak": "off",
221
+ "style/indent": "off",
222
+ "style/indent-binary-ops": "off",
223
+ "style/jsx-child-element-spacing": "off",
224
+ "style/jsx-closing-bracket-location": "off",
225
+ "style/jsx-closing-tag-location": "off",
226
+ "style/jsx-curly-newline": "off",
227
+ "style/jsx-curly-spacing": "off",
228
+ "style/jsx-equals-spacing": "off",
229
+ "style/jsx-first-prop-new-line": "off",
230
+ "style/jsx-indent-props": "off",
231
+ "style/jsx-max-props-per-line": "off",
232
+ "style/jsx-newline": "off",
233
+ "style/jsx-one-expression-per-line": "off",
234
+ "style/jsx-props-no-multi-spaces": "off",
235
+ "style/jsx-quotes": "off",
236
+ "style/jsx-tag-spacing": "off",
237
+ "style/jsx-wrap-multilines": "off",
238
+ "style/key-spacing": "off",
239
+ "style/keyword-spacing": "off",
240
+ "style/linebreak-style": "off",
241
+ "style/lines-around-comment": "off",
242
+ "style/max-len": "off",
243
+ "style/max-statements-per-line": "off",
244
+ "style/member-delimiter-style": "off",
245
+ "style/multiline-ternary": "off",
246
+ "style/new-parens": "off",
247
+ "style/newline-per-chained-call": "off",
248
+ "style/no-confusing-arrow": "off",
249
+ "style/no-extra-parens": "off",
250
+ "style/no-extra-semi": "off",
251
+ "style/no-floating-decimal": "off",
252
+ "style/no-mixed-operators": "off",
253
+ "style/no-mixed-spaces-and-tabs": "off",
254
+ "style/no-multi-spaces": "off",
255
+ "style/no-multiple-empty-lines": "off",
256
+ "style/no-tabs": "off",
257
+ "style/no-trailing-spaces": "off",
258
+ "style/no-whitespace-before-property": "off",
259
+ "style/nonblock-statement-body-position": "off",
260
+ "style/object-curly-newline": "off",
261
+ "style/object-curly-spacing": "off",
262
+ "style/object-property-newline": "off",
263
+ "style/one-var-declaration-per-line": "off",
264
+ "style/operator-linebreak": "off",
265
+ "style/padded-blocks": "off",
266
+ "style/quote-props": "off",
267
+ "style/quotes": "off",
268
+ "style/rest-spread-spacing": "off",
269
+ "style/semi": "off",
270
+ "style/semi-spacing": "off",
271
+ "style/semi-style": "off",
272
+ "style/space-before-blocks": "off",
273
+ "style/space-before-function-paren": "off",
274
+ "style/space-in-parens": "off",
275
+ "style/space-infix-ops": "off",
276
+ "style/space-unary-ops": "off",
277
+ "style/switch-colon-spacing": "off",
278
+ "style/template-curly-spacing": "off",
279
+ "style/template-tag-spacing": "off",
280
+ "style/type-annotation-spacing": "off",
281
+ "style/type-generic-spacing": "off",
282
+ "style/type-named-tuple-spacing": "off",
283
+ "style/wrap-iife": "off",
284
+ "style/wrap-regex": "off",
285
+ "style/yield-star-spacing": "off",
286
+ "unicorn/empty-brace-spaces": "off",
287
+ "unicorn/no-nested-ternary": "off",
288
+ "unicorn/number-literal-case": "off",
289
+ "unicorn/template-indent": "off",
290
+ "vue/array-bracket-newline": "off",
291
+ "vue/array-bracket-spacing": "off",
292
+ "vue/array-element-newline": "off",
293
+ "vue/arrow-spacing": "off",
294
+ "vue/block-spacing": "off",
295
+ "vue/block-tag-newline": "off",
296
+ "vue/brace-style": "off",
297
+ "vue/comma-dangle": "off",
298
+ "vue/comma-spacing": "off",
299
+ "vue/comma-style": "off",
300
+ "vue/dot-location": "off",
301
+ "vue/func-call-spacing": "off",
302
+ "vue/html-closing-bracket-newline": "off",
303
+ "vue/html-closing-bracket-spacing": "off",
304
+ "vue/html-end-tags": "off",
305
+ "vue/html-indent": "off",
306
+ "vue/html-quotes": "off",
307
+ "vue/html-self-closing": "off",
308
+ "vue/key-spacing": "off",
309
+ "vue/keyword-spacing": "off",
310
+ "vue/max-attributes-per-line": "off",
311
+ "vue/max-len": "off",
312
+ "vue/multiline-html-element-content-newline": "off",
313
+ "vue/multiline-ternary": "off",
314
+ "vue/mustache-interpolation-spacing": "off",
315
+ "vue/no-extra-parens": "off",
316
+ "vue/no-multi-spaces": "off",
317
+ "vue/no-spaces-around-equal-signs-in-attribute": "off",
318
+ "vue/object-curly-newline": "off",
319
+ "vue/object-curly-spacing": "off",
320
+ "vue/object-property-newline": "off",
321
+ "vue/operator-linebreak": "off",
322
+ "vue/quote-props": "off",
323
+ "vue/script-indent": "off",
324
+ "vue/singleline-html-element-content-newline": "off",
325
+ "vue/space-in-parens": "off",
326
+ "vue/space-infix-ops": "off",
327
+ "vue/space-unary-ops": "off",
328
+ "vue/template-curly-spacing": "off"
329
+ }
330
+ }
331
+ ];
332
+ }
333
+
334
+ //#endregion
335
+ //#region src/utils.ts
336
+ const parserPlain = {
337
+ meta: { name: "parser-plain" },
338
+ parseForESLint: (code) => ({
339
+ ast: {
340
+ body: [],
341
+ comments: [],
342
+ loc: {
343
+ end: code.length,
344
+ start: 0
345
+ },
346
+ range: [0, code.length],
347
+ tokens: [],
348
+ type: "Program"
349
+ },
350
+ scopeManager: null,
351
+ services: { isPlain: true },
352
+ visitorKeys: { Program: [] }
353
+ })
354
+ };
355
+ /**
356
+ * Combine array and non-array configs into a single array.
357
+ */
358
+ async function combine(...configs$1) {
359
+ return (await Promise.all(configs$1)).flat();
360
+ }
361
+ /**
362
+ * Rename plugin prefixes in a rule object.
363
+ * Accepts a map of prefixes to rename.
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * import { renameRules } from '@svifty7/eslint-config'
368
+ *
369
+ * export default [{
370
+ * rules: renameRules(
371
+ * {
372
+ * '@typescript-eslint/indent': 'error'
373
+ * },
374
+ * { '@typescript-eslint': 'ts' }
375
+ * )
376
+ * }]
377
+ * ```
378
+ */
379
+ function renameRules(rules, map) {
380
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
381
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
382
+ return [key, value];
383
+ }));
384
+ }
385
+ async function interopDefault(m) {
386
+ const resolved = await m;
387
+ return resolved.default || resolved;
388
+ }
389
+ function isInEditorEnv() {
390
+ if (process.env.CI) return false;
391
+ if (isInGitHooksOrLintStaged()) return false;
392
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
393
+ }
394
+ function isInGitHooksOrLintStaged() {
395
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
396
+ }
397
+
398
+ //#endregion
399
+ //#region src/configs/stylistic.ts
400
+ const StylisticConfigDefaults = {
401
+ indent: 2,
402
+ quotes: "single",
403
+ semi: true,
404
+ jsx: true,
405
+ arrowParens: true,
406
+ braceStyle: "1tbs",
407
+ blockSpacing: true,
408
+ quoteProps: "consistent-as-needed",
409
+ commaDangle: "always-multiline",
410
+ pluginName: "style",
411
+ severity: "error",
412
+ experimental: false
413
+ };
414
+ async function stylistic(options = {}) {
415
+ const stylisticConfig = {
416
+ ...StylisticConfigDefaults,
417
+ ...options
418
+ };
419
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
420
+ const config = pluginStylistic.configs.customize(stylisticConfig);
421
+ return [{
422
+ name: "svifty7/stylistic/rules",
423
+ plugins: {
424
+ antfu: eslint_plugin_antfu.default,
425
+ style: pluginStylistic
426
+ },
427
+ rules: {
428
+ ...config.rules,
429
+ "antfu/consistent-chaining": "error",
430
+ "antfu/consistent-list-newline": "off",
431
+ "antfu/curly": "off",
432
+ "antfu/if-newline": "off",
433
+ "antfu/top-level-function": "error",
434
+ "style/jsx-curly-brace-presence": "off",
435
+ "style/jsx-self-closing-comp": "off",
436
+ "style/jsx-sort-props": "off",
437
+ "style/lines-between-class-members": [
438
+ "error",
439
+ "always",
440
+ { exceptAfterSingleLine: false }
441
+ ],
442
+ "style/padding-line-between-statements": [
443
+ "error",
444
+ {
445
+ blankLine: "always",
446
+ prev: [
447
+ "block-like",
448
+ "break",
449
+ "class",
450
+ "const",
451
+ "debugger",
452
+ "directive",
453
+ "throw",
454
+ "try",
455
+ "function",
456
+ "import",
457
+ "cjs-import",
458
+ "return",
459
+ "continue"
460
+ ],
461
+ next: "*"
462
+ },
463
+ {
464
+ blankLine: "always",
465
+ prev: "*",
466
+ next: [
467
+ "block-like",
468
+ "break",
469
+ "class",
470
+ "const",
471
+ "continue",
472
+ "debugger",
473
+ "directive",
474
+ "return",
475
+ "throw",
476
+ "try",
477
+ "export",
478
+ "cjs-export",
479
+ "function",
480
+ "import",
481
+ "cjs-import"
482
+ ]
483
+ },
484
+ {
485
+ blankLine: "always",
486
+ prev: "*",
487
+ next: [
488
+ "multiline-const",
489
+ "multiline-expression",
490
+ "multiline-let",
491
+ "multiline-var"
492
+ ]
493
+ },
494
+ {
495
+ blankLine: "always",
496
+ prev: [
497
+ "multiline-const",
498
+ "multiline-expression",
499
+ "multiline-let",
500
+ "multiline-var"
501
+ ],
502
+ next: "*"
503
+ },
504
+ {
505
+ blankLine: "always",
506
+ prev: "block",
507
+ next: "block"
508
+ },
509
+ {
510
+ blankLine: "never",
511
+ prev: "break",
512
+ next: ["case", "default"]
513
+ },
514
+ {
515
+ blankLine: "never",
516
+ prev: ["case", "default"],
517
+ next: ["case", "default"]
518
+ },
519
+ {
520
+ blankLine: "any",
521
+ prev: "singleline-const",
522
+ next: "singleline-const"
523
+ },
524
+ {
525
+ blankLine: "any",
526
+ prev: "singleline-let",
527
+ next: "singleline-let"
528
+ },
529
+ {
530
+ blankLine: "any",
531
+ prev: "singleline-var",
532
+ next: "singleline-var"
533
+ },
534
+ {
535
+ blankLine: "any",
536
+ prev: "directive",
537
+ next: "directive"
538
+ },
539
+ {
540
+ blankLine: "any",
541
+ prev: "import",
542
+ next: "import"
543
+ },
544
+ {
545
+ blankLine: "any",
546
+ prev: "export",
547
+ next: "export"
548
+ },
549
+ {
550
+ blankLine: "any",
551
+ prev: "cjs-import",
552
+ next: "cjs-import"
553
+ },
554
+ {
555
+ blankLine: "any",
556
+ prev: "cjs-export",
557
+ next: "cjs-export"
558
+ }
559
+ ],
560
+ "style/spaced-comment": "off"
561
+ }
562
+ }];
563
+ }
564
+
565
+ //#endregion
566
+ //#region src/configs/formatters.ts
567
+ function mergePrettierOptions(options, overrides = {}) {
568
+ const config = {
569
+ ...options,
570
+ ...overrides,
571
+ plugins: [...overrides.plugins || [], ...options.plugins || []]
572
+ };
573
+ if (config.parser === "xml") return {
574
+ parser: config.parser,
575
+ plugins: config.plugins,
576
+ bracketSameLine: config.bracketSameLine,
577
+ singleAttributePerLine: config.singleAttributePerLine,
578
+ tabWidth: config.tabWidth,
579
+ xmlQuoteAttributes: config.xmlQuoteAttributes,
580
+ xmlSelfClosingSpace: config.xmlSelfClosingSpace,
581
+ xmlSortAttributesByKey: config.xmlSortAttributesByKey,
582
+ xmlWhitespaceSensitivity: config.xmlWhitespaceSensitivity
583
+ };
584
+ return config;
585
+ }
586
+ async function formatters(stylistic$1 = {}, prettier = {}) {
587
+ const { indent, quotes, semi } = {
588
+ ...StylisticConfigDefaults,
589
+ ...stylistic$1
590
+ };
591
+ const prettierOptions = {
592
+ semi,
593
+ singleQuote: quotes === "single",
594
+ tabWidth: typeof indent === "number" ? indent : 2,
595
+ useTabs: indent === "tab",
596
+ quoteProps: "consistent",
597
+ jsxSingleQuote: false,
598
+ trailingComma: "all",
599
+ bracketSpacing: true,
600
+ bracketSameLine: false,
601
+ arrowParens: "always",
602
+ requirePragma: false,
603
+ insertPragma: false,
604
+ proseWrap: "preserve",
605
+ htmlWhitespaceSensitivity: "css",
606
+ vueIndentScriptAndStyle: true,
607
+ endOfLine: "lf",
608
+ singleAttributePerLine: true,
609
+ ...prettier
610
+ };
611
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
612
+ const tailwindPluginPath = (0, local_pkg.resolveModule)("prettier-plugin-tailwindcss", { paths: [(0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)] });
613
+ const configs$1 = [{
614
+ name: "svifty7/formatter/setup",
615
+ plugins: { format: pluginFormat }
616
+ }];
617
+ configs$1.push({
618
+ files: [GLOB_SRC, GLOB_VUE],
619
+ name: "svifty7/formatter/prettier",
620
+ rules: { "format/prettier": ["error", tailwindPluginPath ? mergePrettierOptions(prettierOptions, { plugins: [tailwindPluginPath] }) : prettierOptions] }
621
+ });
622
+ configs$1.push({
623
+ files: [GLOB_CSS, GLOB_POSTCSS],
624
+ languageOptions: { parser: parserPlain },
625
+ name: "svifty7/formatter/css",
626
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
627
+ }, {
628
+ files: [GLOB_SCSS],
629
+ languageOptions: { parser: parserPlain },
630
+ name: "svifty7/formatter/scss",
631
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
632
+ }, {
633
+ files: [GLOB_LESS],
634
+ languageOptions: { parser: parserPlain },
635
+ name: "svifty7/formatter/less",
636
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
637
+ });
638
+ configs$1.push({
639
+ files: [GLOB_HTML],
640
+ languageOptions: { parser: parserPlain },
641
+ name: "svifty7/formatter/html",
642
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
643
+ parser: "html",
644
+ plugins: tailwindPluginPath ? [tailwindPluginPath] : void 0
645
+ })] }
646
+ });
647
+ configs$1.push({
648
+ files: [GLOB_MARKDOWN],
649
+ languageOptions: { parser: parserPlain },
650
+ name: "svifty7/formatter/markdown",
651
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
652
+ embeddedLanguageFormatting: "off",
653
+ parser: "markdown"
654
+ })] }
655
+ });
656
+ configs$1.push({
657
+ files: [GLOB_GRAPHQL],
658
+ languageOptions: { parser: parserPlain },
659
+ name: "svifty7/formatter/graphql",
660
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
661
+ });
662
+ const prettierXmlOptions = {
663
+ xmlQuoteAttributes: "double",
664
+ xmlSelfClosingSpace: true,
665
+ xmlSortAttributesByKey: false,
666
+ xmlWhitespaceSensitivity: "ignore"
667
+ };
668
+ const xmlPluginPath = (0, local_pkg.resolveModule)("@prettier/plugin-xml", { paths: [(0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)] });
669
+ if (!xmlPluginPath) console.warn("[@svifty7/eslint-config] Failed to resolve @prettier/plugin-xml");
670
+ else {
671
+ configs$1.push({
672
+ files: [GLOB_XML],
673
+ languageOptions: { parser: parserPlain },
674
+ name: "svifty7/formatter/xml",
675
+ rules: { "format/prettier": ["error", mergePrettierOptions({
676
+ ...prettierXmlOptions,
677
+ ...prettierOptions
678
+ }, {
679
+ parser: "xml",
680
+ plugins: [xmlPluginPath]
681
+ })] }
682
+ });
683
+ configs$1.push({
684
+ files: [GLOB_SVG],
685
+ languageOptions: { parser: parserPlain },
686
+ name: "svifty7/formatter/svg",
687
+ rules: { "format/prettier": ["error", mergePrettierOptions({
688
+ ...prettierXmlOptions,
689
+ ...prettierOptions
690
+ }, {
691
+ parser: "xml",
692
+ plugins: [xmlPluginPath]
693
+ })] }
694
+ });
695
+ }
696
+ return configs$1;
697
+ }
698
+
699
+ //#endregion
700
+ //#region src/configs/ignores.ts
701
+ function ignores(userIgnores = []) {
702
+ return [{
703
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
704
+ name: "svifty7/ignores"
705
+ }];
706
+ }
707
+
708
+ //#endregion
709
+ //#region src/configs/imports.ts
710
+ function imports() {
711
+ return [{
712
+ name: "svifty7/imports/rules",
713
+ plugins: {
714
+ antfu: eslint_plugin_antfu.default,
715
+ import: eslint_plugin_import_x
716
+ },
717
+ rules: {
718
+ "antfu/import-dedupe": "error",
719
+ "antfu/no-import-dist": "error",
720
+ "antfu/no-import-node-modules-by-path": "error",
721
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
722
+ "import/first": "error",
723
+ "import/no-duplicates": "error",
724
+ "import/no-mutable-exports": "error",
725
+ "import/no-named-default": "error",
726
+ "import/no-self-import": "error",
727
+ "import/no-webpack-loader-syntax": "error",
728
+ "import/newline-after-import": ["error", { count: 1 }],
729
+ "import/no-named-as-default-member": "off"
730
+ }
731
+ }];
732
+ }
733
+
734
+ //#endregion
735
+ //#region src/configs/javascript.ts
736
+ function javascript(options = {}) {
737
+ const { isInEditor = false } = options;
738
+ return [{
739
+ languageOptions: {
740
+ ecmaVersion: 2022,
741
+ globals: {
742
+ ...globals.default.browser,
743
+ ...globals.default.es2021,
744
+ ...globals.default.node,
745
+ document: "readonly",
746
+ navigator: "readonly",
747
+ window: "readonly"
748
+ },
749
+ parserOptions: {
750
+ ecmaFeatures: { jsx: true },
751
+ ecmaVersion: 2022,
752
+ sourceType: "module"
753
+ },
754
+ sourceType: "module"
755
+ },
756
+ linterOptions: { reportUnusedDisableDirectives: true },
757
+ name: "svifty7/javascript/setup"
758
+ }, {
759
+ name: "svifty7/javascript/rules",
760
+ plugins: {
761
+ "antfu": eslint_plugin_antfu.default,
762
+ "unused-imports": eslint_plugin_unused_imports.default
763
+ },
764
+ rules: {
765
+ "accessor-pairs": ["error", {
766
+ enforceForClassMembers: true,
767
+ setWithoutGet: true
768
+ }],
769
+ "antfu/no-top-level-await": "error",
770
+ "array-callback-return": "error",
771
+ "arrow-body-style": "off",
772
+ "block-scoped-var": "error",
773
+ "camelcase": ["error"],
774
+ "class-methods-use-this": ["error", { enforceForClassFields: false }],
775
+ "consistent-return": "warn",
776
+ "constructor-super": "error",
777
+ "curly": ["error", "all"],
778
+ "default-case-last": "error",
779
+ "default-param-last": ["error"],
780
+ "dot-notation": ["error", { allowKeywords: true }],
781
+ "eqeqeq": ["error", "smart"],
782
+ "guard-for-in": ["error"],
783
+ "lines-between-class-members": [
784
+ "error",
785
+ "always",
786
+ { exceptAfterSingleLine: false }
787
+ ],
788
+ "new-cap": ["error", {
789
+ capIsNew: false,
790
+ newIsCap: true,
791
+ properties: true
792
+ }],
793
+ "no-alert": ["error"],
794
+ "no-array-constructor": "error",
795
+ "no-async-promise-executor": "error",
796
+ "no-await-in-loop": "off",
797
+ "no-bitwise": "off",
798
+ "no-caller": "error",
799
+ "no-case-declarations": "error",
800
+ "no-class-assign": "error",
801
+ "no-compare-neg-zero": "error",
802
+ "no-cond-assign": ["error", "always"],
803
+ "no-console": [isInEditor ? "warn" : "error", { allow: ["warn", "error"] }],
804
+ "no-const-assign": "error",
805
+ "no-continue": "off",
806
+ "no-control-regex": "error",
807
+ "no-debugger": [isInEditor ? "warn" : "error"],
808
+ "no-delete-var": "error",
809
+ "no-dupe-args": "error",
810
+ "no-dupe-class-members": "error",
811
+ "no-dupe-keys": "error",
812
+ "no-duplicate-case": "error",
813
+ "no-empty": ["error", { allowEmptyCatch: true }],
814
+ "no-empty-character-class": "error",
815
+ "no-empty-pattern": "error",
816
+ "no-eval": "error",
817
+ "no-ex-assign": "error",
818
+ "no-extend-native": "error",
819
+ "no-extra-bind": "error",
820
+ "no-extra-boolean-cast": "error",
821
+ "no-fallthrough": "error",
822
+ "no-func-assign": "error",
823
+ "no-global-assign": "error",
824
+ "no-implied-eval": "error",
825
+ "no-import-assign": "error",
826
+ "no-invalid-regexp": "error",
827
+ "no-irregular-whitespace": "error",
828
+ "no-iterator": "error",
829
+ "no-labels": ["error", {
830
+ allowLoop: false,
831
+ allowSwitch: false
832
+ }],
833
+ "no-lone-blocks": "error",
834
+ "no-loss-of-precision": "error",
835
+ "no-misleading-character-class": "error",
836
+ "no-multi-str": "error",
837
+ "no-multiple-empty-lines": ["error", {
838
+ max: 2,
839
+ maxEOF: 1,
840
+ maxBOF: 1
841
+ }],
842
+ "no-nested-ternary": ["warn"],
843
+ "no-new": "error",
844
+ "no-new-func": "error",
845
+ "no-new-native-nonconstructor": "error",
846
+ "no-new-wrappers": "error",
847
+ "no-obj-calls": "error",
848
+ "no-octal": "error",
849
+ "no-octal-escape": "error",
850
+ "no-param-reassign": ["error", { props: false }],
851
+ "no-plusplus": "off",
852
+ "no-proto": "error",
853
+ "no-prototype-builtins": "error",
854
+ "no-redeclare": ["error", { builtinGlobals: false }],
855
+ "no-regex-spaces": "error",
856
+ "no-restricted-globals": [
857
+ "error",
858
+ {
859
+ message: "Use `globalThis` instead.",
860
+ name: "global"
861
+ },
862
+ {
863
+ message: "Use `globalThis` instead.",
864
+ name: "self"
865
+ }
866
+ ],
867
+ "no-restricted-properties": [
868
+ "error",
869
+ {
870
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
871
+ property: "__proto__"
872
+ },
873
+ {
874
+ message: "Use `Object.defineProperty` instead.",
875
+ property: "__defineGetter__"
876
+ },
877
+ {
878
+ message: "Use `Object.defineProperty` instead.",
879
+ property: "__defineSetter__"
880
+ },
881
+ {
882
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
883
+ property: "__lookupGetter__"
884
+ },
885
+ {
886
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
887
+ property: "__lookupSetter__"
888
+ }
889
+ ],
890
+ "no-restricted-syntax": [
891
+ "error",
892
+ "TSExportAssignment",
893
+ "ForInStatement",
894
+ "LabeledStatement",
895
+ "WithStatement"
896
+ ],
897
+ "no-return-assign": ["warn"],
898
+ "no-self-assign": ["error", { props: true }],
899
+ "no-self-compare": "error",
900
+ "no-sequences": "error",
901
+ "no-shadow-restricted-names": "error",
902
+ "no-sparse-arrays": "error",
903
+ "no-template-curly-in-string": "error",
904
+ "no-this-before-super": "error",
905
+ "no-throw-literal": "error",
906
+ "no-undef": "error",
907
+ "no-undef-init": "error",
908
+ "no-underscore-dangle": "off",
909
+ "no-unmodified-loop-condition": "error",
910
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
911
+ "no-unreachable": "error",
912
+ "no-unreachable-loop": "error",
913
+ "no-unsafe-finally": "error",
914
+ "no-unsafe-negation": "error",
915
+ "no-unused-expressions": ["error", {
916
+ allowShortCircuit: true,
917
+ allowTaggedTemplates: true,
918
+ allowTernary: true
919
+ }],
920
+ "no-unused-vars": "off",
921
+ "no-use-before-define": ["error", {
922
+ classes: false,
923
+ functions: false,
924
+ variables: true
925
+ }],
926
+ "no-useless-backreference": "error",
927
+ "no-useless-call": "error",
928
+ "no-useless-catch": "error",
929
+ "no-useless-computed-key": "error",
930
+ "no-useless-constructor": "error",
931
+ "no-useless-rename": "error",
932
+ "no-useless-return": "error",
933
+ "no-var": "error",
934
+ "no-with": "error",
935
+ "object-shorthand": [
936
+ "error",
937
+ "always",
938
+ {
939
+ avoidQuotes: true,
940
+ ignoreConstructors: false
941
+ }
942
+ ],
943
+ "one-var": ["error", { initialized: "never" }],
944
+ "prefer-arrow-callback": ["error", {
945
+ allowNamedFunctions: true,
946
+ allowUnboundThis: true
947
+ }],
948
+ "prefer-const": [isInEditor ? "warn" : "error", {
949
+ destructuring: "all",
950
+ ignoreReadBeforeAssign: true
951
+ }],
952
+ "prefer-exponentiation-operator": "error",
953
+ "prefer-promise-reject-errors": "error",
954
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
955
+ "prefer-rest-params": "error",
956
+ "prefer-spread": "error",
957
+ "prefer-template": "error",
958
+ "require-await": ["error"],
959
+ "spaced-comment": ["error", "always"],
960
+ "symbol-description": "error",
961
+ "unicode-bom": ["error", "never"],
962
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
963
+ "unused-imports/no-unused-vars": ["error", {
964
+ args: "after-used",
965
+ argsIgnorePattern: "^_",
966
+ ignoreRestSiblings: true,
967
+ vars: "all",
968
+ varsIgnorePattern: "^_"
969
+ }],
970
+ "use-isnan": ["error", {
971
+ enforceForIndexOf: true,
972
+ enforceForSwitchCase: true
973
+ }],
974
+ "valid-typeof": ["error", { requireStringLiterals: true }],
975
+ "vars-on-top": "error",
976
+ "yoda": ["error", "never"]
977
+ }
978
+ }];
979
+ }
980
+
981
+ //#endregion
982
+ //#region src/configs/jsdoc.ts
983
+ async function jsdoc() {
984
+ return [{
985
+ name: "svifty7/jsdoc/rules",
986
+ plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
987
+ rules: {
988
+ "jsdoc/check-access": "warn",
989
+ "jsdoc/check-param-names": "warn",
990
+ "jsdoc/check-property-names": "warn",
991
+ "jsdoc/check-types": "warn",
992
+ "jsdoc/empty-tags": "warn",
993
+ "jsdoc/implements-on-classes": "warn",
994
+ "jsdoc/no-defaults": "warn",
995
+ "jsdoc/no-multi-asterisks": "warn",
996
+ "jsdoc/require-param-name": "warn",
997
+ "jsdoc/require-property": "warn",
998
+ "jsdoc/require-property-description": "warn",
999
+ "jsdoc/require-property-name": "warn",
1000
+ "jsdoc/require-returns-check": "warn",
1001
+ "jsdoc/require-returns-description": "warn",
1002
+ "jsdoc/require-yields-check": "warn",
1003
+ "jsdoc/check-alignment": "warn",
1004
+ "jsdoc/multiline-blocks": "warn"
1005
+ }
1006
+ }];
1007
+ }
1008
+
1009
+ //#endregion
1010
+ //#region src/configs/jsonc.ts
1011
+ async function jsonc(options = {}) {
1012
+ const { files = [
1013
+ GLOB_JSON,
1014
+ GLOB_JSON5,
1015
+ GLOB_JSONC
1016
+ ], stylistic: stylistic$1 = true } = options;
1017
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1018
+ const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
1019
+ return [{
1020
+ name: "svifty7/jsonc/setup",
1021
+ plugins: { jsonc: pluginJsonc }
1022
+ }, {
1023
+ files,
1024
+ languageOptions: { parser: parserJsonc },
1025
+ name: "svifty7/jsonc/rules",
1026
+ rules: {
1027
+ "jsonc/no-bigint-literals": "error",
1028
+ "jsonc/no-binary-expression": "error",
1029
+ "jsonc/no-binary-numeric-literals": "error",
1030
+ "jsonc/no-dupe-keys": "error",
1031
+ "jsonc/no-escape-sequence-in-identifier": "error",
1032
+ "jsonc/no-floating-decimal": "error",
1033
+ "jsonc/no-hexadecimal-numeric-literals": "error",
1034
+ "jsonc/no-infinity": "error",
1035
+ "jsonc/no-multi-str": "error",
1036
+ "jsonc/no-nan": "error",
1037
+ "jsonc/no-number-props": "error",
1038
+ "jsonc/no-numeric-separators": "error",
1039
+ "jsonc/no-octal": "error",
1040
+ "jsonc/no-octal-escape": "error",
1041
+ "jsonc/no-octal-numeric-literals": "error",
1042
+ "jsonc/no-parenthesized": "error",
1043
+ "jsonc/no-plus-sign": "error",
1044
+ "jsonc/no-regexp-literals": "error",
1045
+ "jsonc/no-sparse-arrays": "error",
1046
+ "jsonc/no-template-literals": "error",
1047
+ "jsonc/no-undefined-value": "error",
1048
+ "jsonc/no-unicode-codepoint-escapes": "error",
1049
+ "jsonc/no-useless-escape": "error",
1050
+ "jsonc/space-unary-ops": "error",
1051
+ "jsonc/valid-json-number": "error",
1052
+ "jsonc/vue-custom-block/no-parsing-error": "error",
1053
+ "jsonc/array-bracket-spacing": ["error", "never"],
1054
+ "jsonc/comma-dangle": ["error", "never"],
1055
+ "jsonc/comma-style": ["error", "last"],
1056
+ "jsonc/indent": ["error", indent],
1057
+ "jsonc/key-spacing": ["error", {
1058
+ afterColon: true,
1059
+ beforeColon: false
1060
+ }],
1061
+ "jsonc/object-curly-newline": ["error", {
1062
+ consistent: true,
1063
+ multiline: true
1064
+ }],
1065
+ "jsonc/object-curly-spacing": ["error", "always"],
1066
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1067
+ "jsonc/quote-props": "error",
1068
+ "jsonc/quotes": "error"
1069
+ }
1070
+ }];
1071
+ }
1072
+
1073
+ //#endregion
1074
+ //#region src/configs/jsx.ts
1075
+ function jsx() {
1076
+ return [{
1077
+ files: [GLOB_JSX, GLOB_TSX],
1078
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
1079
+ name: "svifty7/jsx/setup"
1080
+ }];
1081
+ }
1082
+
1083
+ //#endregion
1084
+ //#region src/configs/markdown.ts
1085
+ async function markdown(options = {}) {
1086
+ const { componentExts = [], files = [GLOB_MARKDOWN] } = options;
1087
+ const markdownPlugin = await interopDefault(import("@eslint/markdown"));
1088
+ return [
1089
+ {
1090
+ name: "svifty7/markdown/setup",
1091
+ plugins: { markdown: markdownPlugin }
1092
+ },
1093
+ {
1094
+ files,
1095
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1096
+ name: "svifty7/markdown/processor",
1097
+ processor: (0, eslint_merge_processors.mergeProcessors)([markdownPlugin.processors.markdown, eslint_merge_processors.processorPassThrough])
1098
+ },
1099
+ {
1100
+ files,
1101
+ languageOptions: { parser: parserPlain },
1102
+ name: "svifty7/markdown/parser"
1103
+ },
1104
+ {
1105
+ files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
1106
+ languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
1107
+ name: "svifty7/markdown/disables",
1108
+ rules: {
1109
+ "antfu/no-top-level-await": "off",
1110
+ "import/newline-after-import": "off",
1111
+ "no-alert": "off",
1112
+ "no-console": "off",
1113
+ "no-labels": "off",
1114
+ "no-lone-blocks": "off",
1115
+ "no-restricted-syntax": "off",
1116
+ "no-undef": "off",
1117
+ "no-unused-expressions": "off",
1118
+ "no-unused-labels": "off",
1119
+ "no-unused-vars": "off",
1120
+ "node/prefer-global/process": "off",
1121
+ "style/comma-dangle": "off",
1122
+ "style/eol-last": "off",
1123
+ "ts/consistent-type-imports": "off",
1124
+ "ts/explicit-function-return-type": "off",
1125
+ "ts/no-namespace": "off",
1126
+ "ts/no-redeclare": "off",
1127
+ "ts/no-require-imports": "off",
1128
+ "ts/no-unused-expressions": "off",
1129
+ "ts/no-unused-vars": "off",
1130
+ "ts/no-use-before-define": "off",
1131
+ "unicode-bom": "off",
1132
+ "unused-imports/no-unused-imports": "off",
1133
+ "unused-imports/no-unused-vars": "off"
1134
+ }
1135
+ }
1136
+ ];
1137
+ }
1138
+
1139
+ //#endregion
1140
+ //#region src/configs/node.ts
1141
+ function node() {
1142
+ return [{
1143
+ name: "svifty7/node/rules",
1144
+ plugins: { node: eslint_plugin_n.default },
1145
+ rules: {
1146
+ "node/handle-callback-err": ["error", "^(err|error)$"],
1147
+ "node/no-deprecated-api": "error",
1148
+ "node/no-exports-assign": "error",
1149
+ "node/no-new-require": "error",
1150
+ "node/no-path-concat": "error",
1151
+ "node/prefer-global/buffer": ["error", "always"],
1152
+ "node/prefer-global/process": ["error", "always"],
1153
+ "node/process-exit-as-throw": "error"
1154
+ }
1155
+ }];
1156
+ }
1157
+
1158
+ //#endregion
1159
+ //#region src/configs/perfectionist.ts
1160
+ /**
1161
+ * Perfectionist plugin for props and items sorting.
1162
+ *
1163
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
1164
+ */
1165
+ function perfectionist() {
1166
+ return [{
1167
+ name: "svifty7/perfectionist/setup",
1168
+ plugins: { perfectionist: eslint_plugin_perfectionist.default },
1169
+ rules: {
1170
+ "perfectionist/sort-exports": ["error", {
1171
+ order: "asc",
1172
+ type: "natural",
1173
+ newlinesBetween: 1,
1174
+ groups: [
1175
+ "type-export",
1176
+ {
1177
+ group: "multiline-export",
1178
+ newlinesInside: 1
1179
+ },
1180
+ "singleline-export"
1181
+ ]
1182
+ }],
1183
+ "perfectionist/sort-imports": ["error", {
1184
+ groups: [
1185
+ "builtin",
1186
+ "external",
1187
+ "internal",
1188
+ "tsconfig-path",
1189
+ "subpath",
1190
+ "parent",
1191
+ "sibling",
1192
+ "index",
1193
+ "unknown",
1194
+ "type-builtin",
1195
+ "type-external",
1196
+ [
1197
+ "type-internal",
1198
+ "type-tsconfig-path",
1199
+ "type-subpath"
1200
+ ],
1201
+ [
1202
+ "type-parent",
1203
+ "type-sibling",
1204
+ "type-index"
1205
+ ],
1206
+ "side-effect",
1207
+ "side-effect-style",
1208
+ "style"
1209
+ ],
1210
+ internalPattern: ["^~/.+", "^@/.+"],
1211
+ newlinesBetween: 1,
1212
+ order: "asc",
1213
+ type: "natural",
1214
+ tsconfig: { rootDir: process.cwd() },
1215
+ fallbackSort: { type: "unsorted" }
1216
+ }],
1217
+ "perfectionist/sort-named-exports": ["error", {
1218
+ order: "asc",
1219
+ type: "natural"
1220
+ }],
1221
+ "perfectionist/sort-named-imports": ["error", {
1222
+ order: "asc",
1223
+ type: "natural"
1224
+ }]
1225
+ }
1226
+ }];
1227
+ }
1228
+
1229
+ //#endregion
1230
+ //#region src/configs/pnpm.ts
1231
+ async function pnpm() {
1232
+ const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
1233
+ interopDefault(import("eslint-plugin-pnpm")),
1234
+ interopDefault(import("yaml-eslint-parser")),
1235
+ interopDefault(import("jsonc-eslint-parser"))
1236
+ ]);
1237
+ return [{
1238
+ files: ["package.json", "**/package.json"],
1239
+ languageOptions: { parser: jsoncParser },
1240
+ name: "svifty7/pnpm/package-json",
1241
+ plugins: { pnpm: pluginPnpm },
1242
+ rules: {
1243
+ "pnpm/json-enforce-catalog": "off",
1244
+ "pnpm/json-prefer-workspace-settings": "off",
1245
+ "pnpm/json-valid-catalog": "error"
1246
+ }
1247
+ }, {
1248
+ files: ["pnpm-workspace.yaml"],
1249
+ languageOptions: { parser: yamlParser },
1250
+ name: "svifty7/pnpm/pnpm-workspace-yaml",
1251
+ plugins: { pnpm: pluginPnpm },
1252
+ rules: {
1253
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
1254
+ "pnpm/yaml-no-unused-catalog-item": "error"
1255
+ }
1256
+ }];
1257
+ }
1258
+
1259
+ //#endregion
1260
+ //#region src/configs/regexp.ts
1261
+ function regexp(options = {}) {
1262
+ const config = eslint_plugin_regexp.configs["flat/recommended"];
1263
+ if (!config || !config.rules) return [{
1264
+ name: "svifty7/regexp/rules",
1265
+ ...config
1266
+ }];
1267
+ if (options.level === "warn") {
1268
+ for (const key of Object.keys(config.rules)) if (config.rules[key] === "error") config.rules[key] = "warn";
1269
+ }
1270
+ return [{
1271
+ name: "svifty7/regexp/rules",
1272
+ ...config
1273
+ }];
1274
+ }
1275
+
1276
+ //#endregion
1277
+ //#region src/configs/sort.ts
1278
+ /**
1279
+ * Sort package.json
1280
+ *
1281
+ * Requires `jsonc` config
1282
+ */
1283
+ function sortPackageJson() {
1284
+ return [{
1285
+ files: ["**/package.json"],
1286
+ name: "svifty7/sort/package-json",
1287
+ rules: {
1288
+ "jsonc/sort-array-values": ["error", {
1289
+ order: { type: "asc" },
1290
+ pathPattern: "^files$"
1291
+ }],
1292
+ "jsonc/sort-keys": [
1293
+ "error",
1294
+ {
1295
+ order: [
1296
+ "publisher",
1297
+ "name",
1298
+ "displayName",
1299
+ "type",
1300
+ "version",
1301
+ "private",
1302
+ "packageManager",
1303
+ "description",
1304
+ "author",
1305
+ "contributors",
1306
+ "license",
1307
+ "funding",
1308
+ "homepage",
1309
+ "repository",
1310
+ "bugs",
1311
+ "keywords",
1312
+ "categories",
1313
+ "sideEffects",
1314
+ "imports",
1315
+ "exports",
1316
+ "main",
1317
+ "module",
1318
+ "unpkg",
1319
+ "jsdelivr",
1320
+ "types",
1321
+ "typesVersions",
1322
+ "bin",
1323
+ "icon",
1324
+ "files",
1325
+ "engines",
1326
+ "activationEvents",
1327
+ "contributes",
1328
+ "scripts",
1329
+ "peerDependencies",
1330
+ "peerDependenciesMeta",
1331
+ "dependencies",
1332
+ "optionalDependencies",
1333
+ "devDependencies",
1334
+ "pnpm",
1335
+ "overrides",
1336
+ "resolutions",
1337
+ "husky",
1338
+ "simple-git-hooks",
1339
+ "lint-staged",
1340
+ "eslintConfig"
1341
+ ],
1342
+ pathPattern: "^$"
1343
+ },
1344
+ {
1345
+ order: { type: "asc" },
1346
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1347
+ },
1348
+ {
1349
+ order: { type: "asc" },
1350
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1351
+ },
1352
+ {
1353
+ order: [
1354
+ "types",
1355
+ "import",
1356
+ "require",
1357
+ "default"
1358
+ ],
1359
+ pathPattern: "^exports.*$"
1360
+ },
1361
+ {
1362
+ order: [
1363
+ "pre-commit",
1364
+ "prepare-commit-msg",
1365
+ "commit-msg",
1366
+ "post-commit",
1367
+ "pre-rebase",
1368
+ "post-rewrite",
1369
+ "post-checkout",
1370
+ "post-merge",
1371
+ "pre-push",
1372
+ "pre-auto-gc"
1373
+ ],
1374
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1375
+ }
1376
+ ]
1377
+ }
1378
+ }];
1379
+ }
1380
+ /**
1381
+ * Sort tsconfig.json
1382
+ *
1383
+ * Requires `jsonc` config
1384
+ */
1385
+ function sortTsconfig() {
1386
+ return [{
1387
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1388
+ name: "svifty7/sort/tsconfig-json",
1389
+ rules: { "jsonc/sort-keys": [
1390
+ "error",
1391
+ {
1392
+ order: [
1393
+ "extends",
1394
+ "compilerOptions",
1395
+ "references",
1396
+ "files",
1397
+ "include",
1398
+ "exclude"
1399
+ ],
1400
+ pathPattern: "^$"
1401
+ },
1402
+ {
1403
+ order: [
1404
+ "incremental",
1405
+ "composite",
1406
+ "tsBuildInfoFile",
1407
+ "disableSourceOfProjectReferenceRedirect",
1408
+ "disableSolutionSearching",
1409
+ "disableReferencedProjectLoad",
1410
+ "target",
1411
+ "jsx",
1412
+ "jsxFactory",
1413
+ "jsxFragmentFactory",
1414
+ "jsxImportSource",
1415
+ "lib",
1416
+ "moduleDetection",
1417
+ "noLib",
1418
+ "reactNamespace",
1419
+ "useDefineForClassFields",
1420
+ "emitDecoratorMetadata",
1421
+ "experimentalDecorators",
1422
+ "libReplacement",
1423
+ "baseUrl",
1424
+ "rootDir",
1425
+ "rootDirs",
1426
+ "customConditions",
1427
+ "module",
1428
+ "moduleResolution",
1429
+ "moduleSuffixes",
1430
+ "noResolve",
1431
+ "paths",
1432
+ "resolveJsonModule",
1433
+ "resolvePackageJsonExports",
1434
+ "resolvePackageJsonImports",
1435
+ "typeRoots",
1436
+ "types",
1437
+ "allowArbitraryExtensions",
1438
+ "allowImportingTsExtensions",
1439
+ "allowUmdGlobalAccess",
1440
+ "allowJs",
1441
+ "checkJs",
1442
+ "maxNodeModuleJsDepth",
1443
+ "strict",
1444
+ "strictBindCallApply",
1445
+ "strictFunctionTypes",
1446
+ "strictNullChecks",
1447
+ "strictPropertyInitialization",
1448
+ "allowUnreachableCode",
1449
+ "allowUnusedLabels",
1450
+ "alwaysStrict",
1451
+ "exactOptionalPropertyTypes",
1452
+ "noFallthroughCasesInSwitch",
1453
+ "noImplicitAny",
1454
+ "noImplicitOverride",
1455
+ "noImplicitReturns",
1456
+ "noImplicitThis",
1457
+ "noPropertyAccessFromIndexSignature",
1458
+ "noUncheckedIndexedAccess",
1459
+ "noUnusedLocals",
1460
+ "noUnusedParameters",
1461
+ "useUnknownInCatchVariables",
1462
+ "declaration",
1463
+ "declarationDir",
1464
+ "declarationMap",
1465
+ "downlevelIteration",
1466
+ "emitBOM",
1467
+ "emitDeclarationOnly",
1468
+ "importHelpers",
1469
+ "importsNotUsedAsValues",
1470
+ "inlineSourceMap",
1471
+ "inlineSources",
1472
+ "mapRoot",
1473
+ "newLine",
1474
+ "noEmit",
1475
+ "noEmitHelpers",
1476
+ "noEmitOnError",
1477
+ "outDir",
1478
+ "outFile",
1479
+ "preserveConstEnums",
1480
+ "preserveValueImports",
1481
+ "removeComments",
1482
+ "sourceMap",
1483
+ "sourceRoot",
1484
+ "stripInternal",
1485
+ "allowSyntheticDefaultImports",
1486
+ "esModuleInterop",
1487
+ "forceConsistentCasingInFileNames",
1488
+ "isolatedDeclarations",
1489
+ "isolatedModules",
1490
+ "preserveSymlinks",
1491
+ "verbatimModuleSyntax",
1492
+ "erasableSyntaxOnly",
1493
+ "skipDefaultLibCheck",
1494
+ "skipLibCheck"
1495
+ ],
1496
+ pathPattern: "^compilerOptions$"
1497
+ }
1498
+ ] }
1499
+ }];
1500
+ }
1501
+
1502
+ //#endregion
1503
+ //#region src/configs/test.ts
1504
+ let _pluginTest;
1505
+ async function test(options = {}) {
1506
+ const { files = GLOB_TESTS, isInEditor = false } = options;
1507
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
1508
+ _pluginTest = _pluginTest || {
1509
+ ...pluginVitest,
1510
+ rules: {
1511
+ ...pluginVitest.rules,
1512
+ ...pluginNoOnlyTests.rules
1513
+ }
1514
+ };
1515
+ return [{
1516
+ name: "svifty7/test/setup",
1517
+ plugins: { test: _pluginTest }
1518
+ }, {
1519
+ files,
1520
+ name: "svifty7/test/rules",
1521
+ rules: {
1522
+ "test/consistent-test-it": ["error", {
1523
+ fn: "it",
1524
+ withinDescribe: "it"
1525
+ }],
1526
+ "test/no-identical-title": "error",
1527
+ "test/no-import-node-test": "error",
1528
+ "test/no-only-tests": isInEditor ? "warn" : "error",
1529
+ "test/prefer-hooks-in-order": "error",
1530
+ "test/prefer-lowercase-title": "error",
1531
+ "antfu/no-top-level-await": "off",
1532
+ "no-unused-expressions": "off",
1533
+ "node/prefer-global/process": "off",
1534
+ "ts/explicit-function-return-type": "off"
1535
+ }
1536
+ }];
1537
+ }
1538
+
1539
+ //#endregion
1540
+ //#region src/configs/toml.ts
1541
+ async function toml(options = {}) {
1542
+ const { files = [GLOB_TOML], stylistic: stylistic$1 = true } = options;
1543
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1544
+ const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
1545
+ return [{
1546
+ name: "svifty7/toml/setup",
1547
+ plugins: { toml: pluginToml }
1548
+ }, {
1549
+ files,
1550
+ languageOptions: { parser: parserToml },
1551
+ name: "svifty7/toml/rules",
1552
+ rules: {
1553
+ "style/spaced-comment": "off",
1554
+ "toml/comma-style": "error",
1555
+ "toml/keys-order": "error",
1556
+ "toml/no-space-dots": "error",
1557
+ "toml/no-unreadable-number-separator": "error",
1558
+ "toml/precision-of-fractional-seconds": "error",
1559
+ "toml/precision-of-integer": "error",
1560
+ "toml/tables-order": "error",
1561
+ "toml/vue-custom-block/no-parsing-error": "error",
1562
+ "toml/array-bracket-newline": "error",
1563
+ "toml/array-bracket-spacing": "error",
1564
+ "toml/array-element-newline": "error",
1565
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1566
+ "toml/inline-table-curly-spacing": "error",
1567
+ "toml/key-spacing": "error",
1568
+ "toml/padding-line-between-pairs": "error",
1569
+ "toml/padding-line-between-tables": "error",
1570
+ "toml/quoted-keys": "error",
1571
+ "toml/spaced-comment": "error",
1572
+ "toml/table-bracket-spacing": "error"
1573
+ }
1574
+ }];
1575
+ }
1576
+
1577
+ //#endregion
1578
+ //#region src/configs/typescript.ts
1579
+ async function typescript(options = {}) {
1580
+ const { componentExts = [], overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
1581
+ const filePatterns = options.files ?? [
1582
+ GLOB_TS,
1583
+ GLOB_TSX,
1584
+ ...componentExts.map((ext) => `**/*.${ext}`)
1585
+ ];
1586
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1587
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1588
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1589
+ const isTypeAware = !!tsconfigPath;
1590
+ const typeAwareRules = {
1591
+ "dot-notation": "off",
1592
+ "no-implied-eval": "off",
1593
+ "ts/await-thenable": "error",
1594
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1595
+ "ts/no-floating-promises": "error",
1596
+ "ts/no-for-in-array": "error",
1597
+ "ts/no-implied-eval": "error",
1598
+ "ts/no-misused-promises": "error",
1599
+ "ts/no-unnecessary-type-assertion": "error",
1600
+ "ts/no-unsafe-argument": "error",
1601
+ "ts/no-unsafe-assignment": "error",
1602
+ "ts/no-unsafe-call": "error",
1603
+ "ts/no-unsafe-member-access": "error",
1604
+ "ts/no-unsafe-return": "error",
1605
+ "ts/promise-function-async": "error",
1606
+ "ts/restrict-plus-operands": "error",
1607
+ "ts/restrict-template-expressions": "error",
1608
+ "ts/return-await": ["error", "in-try-catch"],
1609
+ "ts/strict-boolean-expressions": ["error", {
1610
+ allowNullableBoolean: true,
1611
+ allowNullableObject: true
1612
+ }],
1613
+ "ts/switch-exhaustiveness-check": "error",
1614
+ "ts/unbound-method": "error"
1615
+ };
1616
+ const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
1617
+ function makeParser(typeAware, files, ignores$1) {
1618
+ return {
1619
+ files,
1620
+ ...ignores$1 ? { ignores: ignores$1 } : {},
1621
+ languageOptions: {
1622
+ parser: parserTs,
1623
+ parserOptions: {
1624
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1625
+ sourceType: "module",
1626
+ ...typeAware ? {
1627
+ projectService: {
1628
+ allowDefaultProject: ["./*.js"],
1629
+ defaultProject: tsconfigPath
1630
+ },
1631
+ tsconfigRootDir: process.cwd()
1632
+ } : {},
1633
+ ...parserOptions
1634
+ }
1635
+ },
1636
+ name: `svifty7/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1637
+ };
1638
+ }
1639
+ return [
1640
+ {
1641
+ name: "svifty7/typescript/setup",
1642
+ plugins: {
1643
+ antfu: eslint_plugin_antfu.default,
1644
+ ts: pluginTs
1645
+ }
1646
+ },
1647
+ ...isTypeAware ? [makeParser(false, filePatterns), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, filePatterns)],
1648
+ {
1649
+ files: filePatterns,
1650
+ name: "svifty7/typescript/rules",
1651
+ rules: {
1652
+ ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
1653
+ ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
1654
+ "constructor-super": "off",
1655
+ "getter-return": "off",
1656
+ "valid-typeof": "off",
1657
+ "no-const-assign": "off",
1658
+ "no-dupe-args": "off",
1659
+ "no-dupe-class-members": "off",
1660
+ "no-dupe-keys": "off",
1661
+ "no-func-assign": "off",
1662
+ "no-import-assign": "off",
1663
+ "no-obj-calls": "off",
1664
+ "no-redeclare": "off",
1665
+ "no-setter-return": "off",
1666
+ "no-this-before-super": "off",
1667
+ "no-undef": "off",
1668
+ "no-unreachable": "off",
1669
+ "no-unsafe-negation": "off",
1670
+ "no-shadow": "off",
1671
+ "no-use-before-define": "off",
1672
+ "no-useless-constructor": "off",
1673
+ "no-var": "error",
1674
+ "prefer-const": "error",
1675
+ "prefer-rest-params": "error",
1676
+ "prefer-spread": "error",
1677
+ "ts/explicit-function-return-type": "off",
1678
+ "ts/no-non-null-assertion": "off",
1679
+ "ts/no-invalid-void-type": "off",
1680
+ "ts/no-useless-constructor": "off",
1681
+ "ts/triple-slash-reference": "off",
1682
+ "ts/ban-ts-comment": ["error", {
1683
+ "ts-ignore": "allow-with-description",
1684
+ "ts-expect-error": "allow-with-description"
1685
+ }],
1686
+ "ts/consistent-type-definitions": ["error", "interface"],
1687
+ "ts/method-signature-style": ["error", "property"],
1688
+ "ts/no-dupe-class-members": "error",
1689
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1690
+ "ts/no-import-type-side-effects": "error",
1691
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1692
+ "ts/no-require-imports": "error",
1693
+ "ts/no-unused-expressions": ["error", {
1694
+ allowShortCircuit: true,
1695
+ allowTaggedTemplates: true,
1696
+ allowTernary: true
1697
+ }],
1698
+ "ts/no-wrapper-object-types": "error",
1699
+ "ts/consistent-type-imports": ["error", {
1700
+ disallowTypeAnnotations: false,
1701
+ prefer: "type-imports"
1702
+ }],
1703
+ "ts/no-unused-vars": ["error", {
1704
+ args: "after-used",
1705
+ argsIgnorePattern: "^_",
1706
+ ignoreRestSiblings: true,
1707
+ vars: "all",
1708
+ varsIgnorePattern: "^_",
1709
+ caughtErrors: "none"
1710
+ }],
1711
+ "ts/no-shadow": "error",
1712
+ "ts/no-explicit-any": "off",
1713
+ "ts/no-use-before-define": ["error", {
1714
+ classes: false,
1715
+ functions: false,
1716
+ enums: false,
1717
+ typedefs: false,
1718
+ ignoreTypeReferences: true
1719
+ }],
1720
+ "ts/consistent-type-assertions": "error",
1721
+ "ts/unified-signatures": "off",
1722
+ "ts/no-extraneous-class": "error",
1723
+ "ts/no-unsafe-function-type": "error",
1724
+ "ts/prefer-literal-enum-member": "error",
1725
+ "ts/no-dynamic-delete": "error",
1726
+ ...type === "lib" ? { "ts/explicit-function-return-type": ["error", {
1727
+ allowExpressions: true,
1728
+ allowHigherOrderFunctions: true,
1729
+ allowIIFEs: true
1730
+ }] } : {}
1731
+ }
1732
+ },
1733
+ ...isTypeAware ? [{
1734
+ files: filesTypeAware,
1735
+ ignores: ignoresTypeAware,
1736
+ name: "svifty7/typescript/rules-type-aware",
1737
+ rules: {
1738
+ ...typeAwareRules,
1739
+ ...overridesTypeAware
1740
+ }
1741
+ }] : []
1742
+ ];
1743
+ }
1744
+
1745
+ //#endregion
1746
+ //#region src/configs/unicorn.ts
1747
+ function unicorn(options = {}) {
1748
+ const { allRecommended = false } = options;
1749
+ return [{
1750
+ name: "svifty7/unicorn/rules",
1751
+ plugins: { unicorn: eslint_plugin_unicorn.default },
1752
+ rules: { ...allRecommended ? eslint_plugin_unicorn.default.configs.recommended.rules : {
1753
+ "unicorn/consistent-empty-array-spread": "error",
1754
+ "unicorn/error-message": "error",
1755
+ "unicorn/escape-case": "error",
1756
+ "unicorn/new-for-builtins": "error",
1757
+ "unicorn/no-instanceof-builtins": "error",
1758
+ "unicorn/no-new-array": "error",
1759
+ "unicorn/no-new-buffer": "error",
1760
+ "unicorn/prefer-dom-node-text-content": "error",
1761
+ "unicorn/prefer-includes": "error",
1762
+ "unicorn/prefer-node-protocol": "error",
1763
+ "unicorn/prefer-number-properties": "error",
1764
+ "unicorn/prefer-string-starts-ends-with": "error",
1765
+ "unicorn/prefer-type-error": "error",
1766
+ "unicorn/throw-new-error": "error"
1767
+ } }
1768
+ }];
1769
+ }
1770
+
1771
+ //#endregion
1772
+ //#region src/configs/vue.ts
1773
+ async function vue(options = {}) {
1774
+ const { files = [GLOB_VUE] } = options;
1775
+ const [pluginVue, parserVue, pluginVueA11y] = await Promise.all([
1776
+ interopDefault(import("eslint-plugin-vue")),
1777
+ interopDefault(import("vue-eslint-parser")),
1778
+ interopDefault(import("eslint-plugin-vuejs-accessibility"))
1779
+ ]);
1780
+ return [{
1781
+ languageOptions: { globals: {
1782
+ computed: "readonly",
1783
+ defineEmits: "readonly",
1784
+ defineExpose: "readonly",
1785
+ defineProps: "readonly",
1786
+ onMounted: "readonly",
1787
+ onUnmounted: "readonly",
1788
+ reactive: "readonly",
1789
+ ref: "readonly",
1790
+ shallowReactive: "readonly",
1791
+ shallowRef: "readonly",
1792
+ toRef: "readonly",
1793
+ toRefs: "readonly",
1794
+ watch: "readonly",
1795
+ watchEffect: "readonly"
1796
+ } },
1797
+ name: "svifty7/vue/setup",
1798
+ plugins: {
1799
+ "vue": pluginVue,
1800
+ "vue-a11y": pluginVueA11y
1801
+ }
1802
+ }, {
1803
+ files,
1804
+ languageOptions: {
1805
+ parser: parserVue,
1806
+ parserOptions: {
1807
+ ecmaFeatures: { jsx: true },
1808
+ extraFileExtensions: [".vue"],
1809
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1810
+ sourceType: "module"
1811
+ }
1812
+ },
1813
+ name: "svifty7/vue/rules",
1814
+ processor: pluginVue.processors[".vue"],
1815
+ rules: {
1816
+ ...pluginVue.configs.base.rules,
1817
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
1818
+ ...acc,
1819
+ ...c
1820
+ }), {}),
1821
+ ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
1822
+ ...acc,
1823
+ ...c
1824
+ }), {}),
1825
+ ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
1826
+ ...acc,
1827
+ ...c
1828
+ }), {}),
1829
+ "antfu/no-top-level-await": "off",
1830
+ "node/prefer-global/process": "off",
1831
+ "ts/explicit-function-return-type": "off",
1832
+ "vue/padding-line-between-tags": ["error", [{
1833
+ blankLine: "always",
1834
+ prev: "*",
1835
+ next: "*"
1836
+ }]],
1837
+ "vue/html-self-closing": "error",
1838
+ "vue/html-closing-bracket-spacing": ["error", {
1839
+ startTag: "never",
1840
+ endTag: "never",
1841
+ selfClosingTag: "always"
1842
+ }],
1843
+ "vue/max-attributes-per-line": ["error", {
1844
+ singleline: 1,
1845
+ multiline: 1
1846
+ }],
1847
+ "vue/first-attribute-linebreak": ["error", {
1848
+ singleline: "ignore",
1849
+ multiline: "below"
1850
+ }],
1851
+ "vue/attribute-hyphenation": ["error", "always"],
1852
+ "vue/block-order": ["error", { order: [
1853
+ "script",
1854
+ "template",
1855
+ "style"
1856
+ ] }],
1857
+ "vue/component-api-style": ["error", ["script-setup"]],
1858
+ "vue/block-lang": ["error", { script: { lang: "ts" } }],
1859
+ "vue/define-props-declaration": ["error", "type-based"],
1860
+ "vue/define-emits-declaration": ["error", "type-based"],
1861
+ "vue/no-ref-object-reactivity-loss": "warn",
1862
+ "vue/match-component-import-name": "error",
1863
+ "vue/no-empty-component-block": "error",
1864
+ "vue/no-multiple-objects-in-class": "error",
1865
+ "vue/no-static-inline-styles": ["error", { allowBinding: true }],
1866
+ "vue/no-use-v-else-with-v-for": "error",
1867
+ "vue/no-useless-mustaches": ["error", {
1868
+ ignoreIncludesComment: true,
1869
+ ignoreStringEscape: true
1870
+ }],
1871
+ "vue/no-v-text": "error",
1872
+ "vue/prefer-define-options": "error",
1873
+ "vue/require-typed-object-prop": "error",
1874
+ "vue/require-typed-ref": "error",
1875
+ "vue/v-for-delimiter-style": ["error", "in"],
1876
+ "vue/component-name-in-template-casing": [
1877
+ "error",
1878
+ "kebab-case",
1879
+ { registeredComponentsOnly: false }
1880
+ ],
1881
+ "vue/array-bracket-spacing": ["error", "never"],
1882
+ "vue/arrow-spacing": ["error", {
1883
+ after: true,
1884
+ before: true
1885
+ }],
1886
+ "vue/block-spacing": ["error", "always"],
1887
+ "vue/block-tag-newline": ["error", {
1888
+ multiline: "always",
1889
+ singleline: "always"
1890
+ }],
1891
+ "vue/brace-style": [
1892
+ "error",
1893
+ "stroustrup",
1894
+ { allowSingleLine: true }
1895
+ ],
1896
+ "vue/html-indent": ["error", 2],
1897
+ "vue/html-quotes": ["error", "double"],
1898
+ "vue/comma-dangle": ["error", "always-multiline"],
1899
+ "vue/comma-spacing": ["error", {
1900
+ after: true,
1901
+ before: false
1902
+ }],
1903
+ "vue/comma-style": ["error", "last"],
1904
+ "vue/html-comment-content-spacing": [
1905
+ "error",
1906
+ "always",
1907
+ { exceptions: ["-"] }
1908
+ ],
1909
+ "vue/key-spacing": ["error", {
1910
+ afterColon: true,
1911
+ beforeColon: false
1912
+ }],
1913
+ "vue/keyword-spacing": ["error", {
1914
+ after: true,
1915
+ before: true
1916
+ }],
1917
+ "vue/object-curly-newline": "off",
1918
+ "vue/object-curly-spacing": ["error", "always"],
1919
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1920
+ "vue/operator-linebreak": ["error", "before"],
1921
+ "vue/padding-line-between-blocks": ["error", "always"],
1922
+ "vue/quote-props": ["error", "consistent-as-needed"],
1923
+ "vue/require-default-prop": "error",
1924
+ "vue/space-in-parens": ["error", "never"],
1925
+ "vue/template-curly-spacing": "error",
1926
+ "vue/no-restricted-v-bind": "off",
1927
+ "vue/one-component-per-file": "off",
1928
+ "vue/prefer-separate-static-class": "off",
1929
+ "vue/valid-v-slot": "off",
1930
+ "vue/require-explicit-emits": "error",
1931
+ "vue/custom-event-name-casing": ["error", "kebab-case"],
1932
+ "vue-a11y/anchor-has-content": "off",
1933
+ "vue-a11y/click-events-have-key-events": "off",
1934
+ "vue-a11y/mouse-events-have-key-events": "off",
1935
+ "vue-a11y/label-has-for": "off",
1936
+ "vue-a11y/no-autofocus": "off",
1937
+ "vue-a11y/form-control-has-label": "off",
1938
+ "vue-a11y/no-static-element-interactions": "off",
1939
+ "vue-a11y/alt-text": "error",
1940
+ "vue-a11y/aria-props": "error",
1941
+ "vue-a11y/aria-role": "error",
1942
+ "vue-a11y/aria-unsupported-elements": "error",
1943
+ "vue-a11y/heading-has-content": "error",
1944
+ "vue-a11y/iframe-has-title": "error",
1945
+ "vue-a11y/interactive-supports-focus": "error",
1946
+ "vue-a11y/media-has-caption": "warn",
1947
+ "vue-a11y/no-access-key": "error",
1948
+ "vue-a11y/no-aria-hidden-on-focusable": "error",
1949
+ "vue-a11y/no-distracting-elements": "error",
1950
+ "vue-a11y/no-redundant-roles": "error",
1951
+ "vue-a11y/no-role-presentation-on-focusable": "error",
1952
+ "vue-a11y/role-has-required-aria-props": "error",
1953
+ "vue-a11y/tabindex-no-positive": "warn"
1954
+ }
1955
+ }];
1956
+ }
1957
+
1958
+ //#endregion
1959
+ //#region src/configs/yaml.ts
1960
+ async function yaml(options = {}) {
1961
+ const { files = [GLOB_YAML], stylistic: stylistic$1 = true } = options;
1962
+ const { indent = 2, quotes = "single" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1963
+ const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
1964
+ return [
1965
+ {
1966
+ name: "svifty7/yaml/setup",
1967
+ plugins: { yaml: pluginYaml }
1968
+ },
1969
+ {
1970
+ files,
1971
+ languageOptions: { parser: parserYaml },
1972
+ name: "svifty7/yaml/rules",
1973
+ rules: {
1974
+ "style/spaced-comment": "off",
1975
+ "yaml/block-mapping": "error",
1976
+ "yaml/block-sequence": "error",
1977
+ "yaml/no-empty-key": "error",
1978
+ "yaml/no-empty-sequence-entry": "error",
1979
+ "yaml/no-irregular-whitespace": "error",
1980
+ "yaml/plain-scalar": "error",
1981
+ "yaml/vue-custom-block/no-parsing-error": "error",
1982
+ "yaml/block-mapping-question-indicator-newline": "error",
1983
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1984
+ "yaml/flow-mapping-curly-newline": "error",
1985
+ "yaml/flow-mapping-curly-spacing": "error",
1986
+ "yaml/flow-sequence-bracket-newline": "error",
1987
+ "yaml/flow-sequence-bracket-spacing": "error",
1988
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1989
+ "yaml/key-spacing": "error",
1990
+ "yaml/no-tab-indent": "error",
1991
+ "yaml/quotes": ["error", {
1992
+ avoidEscape: true,
1993
+ prefer: quotes === "backtick" ? "single" : quotes
1994
+ }],
1995
+ "yaml/spaced-comment": "error"
1996
+ }
1997
+ },
1998
+ {
1999
+ files: ["pnpm-workspace.yaml"],
2000
+ name: "svifty7/yaml/pnpm-workspace",
2001
+ rules: { "yaml/sort-keys": [
2002
+ "error",
2003
+ {
2004
+ order: [
2005
+ "packages",
2006
+ "overrides",
2007
+ "patchedDependencies",
2008
+ "hoistPattern",
2009
+ "catalog",
2010
+ "catalogs",
2011
+ "allowedDeprecatedVersions",
2012
+ "allowNonAppliedPatches",
2013
+ "configDependencies",
2014
+ "ignoredBuiltDependencies",
2015
+ "ignoredOptionalDependencies",
2016
+ "neverBuiltDependencies",
2017
+ "onlyBuiltDependencies",
2018
+ "onlyBuiltDependenciesFile",
2019
+ "packageExtensions",
2020
+ "peerDependencyRules",
2021
+ "supportedArchitectures"
2022
+ ],
2023
+ pathPattern: "^$"
2024
+ },
2025
+ {
2026
+ order: { type: "asc" },
2027
+ pathPattern: ".*"
2028
+ }
2029
+ ] }
2030
+ }
2031
+ ];
2032
+ }
2033
+
2034
+ //#endregion
2035
+ //#region src/factory.ts
2036
+ const flatConfigProps = [
2037
+ "name",
2038
+ "languageOptions",
2039
+ "linterOptions",
2040
+ "processor",
2041
+ "plugins",
2042
+ "rules",
2043
+ "settings"
2044
+ ];
2045
+ const VuePackages = [
2046
+ "vue",
2047
+ "nuxt",
2048
+ "vitepress"
2049
+ ];
2050
+ const defaultPluginRenaming = {
2051
+ "@stylistic": "style",
2052
+ "@typescript-eslint": "ts",
2053
+ "import-x": "import",
2054
+ "node": "node",
2055
+ "vitest": "test",
2056
+ "yml": "yaml"
2057
+ };
2058
+ /**
2059
+ * Construct an array of ESLint flat config items.
2060
+ *
2061
+ * @param {OptionsConfig & TypedFlatConfigItem} options
2062
+ * The options for generating the ESLint configurations.
2063
+ * @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
2064
+ * The user configurations to be merged with the generated configurations.
2065
+ * @returns {Promise<TypedFlatConfigItem[]>}
2066
+ * The merged ESLint configurations.
2067
+ */
2068
+ function configure(options = {}, ...userConfigs) {
2069
+ const defaultConfig = {
2070
+ autoRenamePlugins: true,
2071
+ componentExts: [],
2072
+ gitignore: true,
2073
+ jsx: true,
2074
+ pnpm: true,
2075
+ regexp: true,
2076
+ typescript: (0, local_pkg.isPackageExists)("typescript") ? {} : void 0,
2077
+ unicorn: true,
2078
+ vue: VuePackages.some((i) => (0, local_pkg.isPackageExists)(i)) ? {} : void 0,
2079
+ prettier: true
2080
+ };
2081
+ const { autoRenamePlugins, componentExts = [], gitignore: enableGitignore, jsx: enableJsx, pnpm: enableCatalogs, regexp: enableRegexp, typescript: enableTypeScript, unicorn: enableUnicorn, vue: enableVue } = Object.assign(defaultConfig, options);
2082
+ let isInEditor = options.isInEditor;
2083
+ if (isInEditor == null) {
2084
+ isInEditor = isInEditorEnv();
2085
+ if (isInEditor) console.log("[@svifty7/eslint-config] Detected running in editor, some rules are disabled.");
2086
+ }
2087
+ const stylisticOptions = typeof options.stylistic === "object" ? options.stylistic : {};
2088
+ if (!("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
2089
+ const configs$1 = [];
2090
+ if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2091
+ name: "svifty7/gitignore",
2092
+ ...enableGitignore
2093
+ })]));
2094
+ else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2095
+ name: "svifty7/gitignore",
2096
+ strict: false
2097
+ })]));
2098
+ const typescriptOptions = resolveSubOptions(options, "typescript");
2099
+ configs$1.push(ignores(options.ignores), javascript({ isInEditor }), comments(), node(), jsdoc(), imports(), command(), perfectionist());
2100
+ if (enableUnicorn) configs$1.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2101
+ if (enableVue) componentExts.push("vue");
2102
+ if (enableJsx) configs$1.push(jsx());
2103
+ if (enableTypeScript) configs$1.push(typescript({
2104
+ ...typescriptOptions,
2105
+ componentExts,
2106
+ type: options.type
2107
+ }));
2108
+ configs$1.push(stylistic({ ...stylisticOptions }));
2109
+ if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2110
+ if (options.test ?? true) configs$1.push(test({ isInEditor }));
2111
+ if (enableVue) configs$1.push(vue({
2112
+ ...resolveSubOptions(options, "vue"),
2113
+ typescript: !!enableTypeScript
2114
+ }));
2115
+ if (options.jsonc ?? true) configs$1.push(jsonc({ stylistic: stylisticOptions }), sortPackageJson(), sortTsconfig());
2116
+ if (enableCatalogs) configs$1.push(pnpm());
2117
+ if (options.yaml ?? true) configs$1.push(yaml({ stylistic: stylisticOptions }));
2118
+ if (options.toml ?? true) configs$1.push(toml({ stylistic: stylisticOptions }));
2119
+ if (options.markdown ?? true) configs$1.push(markdown({ componentExts }));
2120
+ if (typeof options.prettier === "object") configs$1.push(formatters(options.stylistic, options.prettier));
2121
+ else if (options.prettier ?? true) configs$1.push(formatters(options.stylistic));
2122
+ configs$1.push(disables());
2123
+ if ("files" in options) throw new Error("[@svifty7/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
2124
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
2125
+ if (key in options) acc[key] = options[key];
2126
+ return acc;
2127
+ }, {});
2128
+ if (Object.keys(fusedConfig).length) configs$1.push([fusedConfig]);
2129
+ let composer = new eslint_flat_config_utils.FlatConfigComposer();
2130
+ composer = composer.append(...configs$1, ...userConfigs);
2131
+ if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
2132
+ if (isInEditor) composer = composer.disableRulesFix([
2133
+ "unused-imports/no-unused-imports",
2134
+ "test/no-only-tests",
2135
+ "prefer-const"
2136
+ ], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
2137
+ return composer;
2138
+ }
2139
+ function resolveSubOptions(options, key) {
2140
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2141
+ }
2142
+
2143
+ //#endregion
2144
+ exports.GLOB_ALL_SRC = GLOB_ALL_SRC;
2145
+ exports.GLOB_CSS = GLOB_CSS;
2146
+ exports.GLOB_EXCLUDE = GLOB_EXCLUDE;
2147
+ exports.GLOB_GRAPHQL = GLOB_GRAPHQL;
2148
+ exports.GLOB_HTML = GLOB_HTML;
2149
+ exports.GLOB_JS = GLOB_JS;
2150
+ exports.GLOB_JSON = GLOB_JSON;
2151
+ exports.GLOB_JSON5 = GLOB_JSON5;
2152
+ exports.GLOB_JSONC = GLOB_JSONC;
2153
+ exports.GLOB_JSX = GLOB_JSX;
2154
+ exports.GLOB_LESS = GLOB_LESS;
2155
+ exports.GLOB_MARKDOWN = GLOB_MARKDOWN;
2156
+ exports.GLOB_MARKDOWN_CODE = GLOB_MARKDOWN_CODE;
2157
+ exports.GLOB_MARKDOWN_IN_MARKDOWN = GLOB_MARKDOWN_IN_MARKDOWN;
2158
+ exports.GLOB_POSTCSS = GLOB_POSTCSS;
2159
+ exports.GLOB_SCSS = GLOB_SCSS;
2160
+ exports.GLOB_SRC = GLOB_SRC;
2161
+ exports.GLOB_SRC_EXT = GLOB_SRC_EXT;
2162
+ exports.GLOB_STYLE = GLOB_STYLE;
2163
+ exports.GLOB_SVG = GLOB_SVG;
2164
+ exports.GLOB_TESTS = GLOB_TESTS;
2165
+ exports.GLOB_TOML = GLOB_TOML;
2166
+ exports.GLOB_TS = GLOB_TS;
2167
+ exports.GLOB_TSX = GLOB_TSX;
2168
+ exports.GLOB_VUE = GLOB_VUE;
2169
+ exports.GLOB_XML = GLOB_XML;
2170
+ exports.GLOB_YAML = GLOB_YAML;
2171
+ exports.StylisticConfigDefaults = StylisticConfigDefaults;
2172
+ exports.combine = combine;
2173
+ exports.command = command;
2174
+ exports.comments = comments;
2175
+ exports.configure = configure;
2176
+ exports.defaultPluginRenaming = defaultPluginRenaming;
2177
+ exports.disables = disables;
2178
+ exports.formatters = formatters;
2179
+ exports.ignores = ignores;
2180
+ exports.imports = imports;
2181
+ exports.interopDefault = interopDefault;
2182
+ exports.isInEditorEnv = isInEditorEnv;
2183
+ exports.isInGitHooksOrLintStaged = isInGitHooksOrLintStaged;
2184
+ exports.javascript = javascript;
2185
+ exports.jsdoc = jsdoc;
2186
+ exports.jsonc = jsonc;
2187
+ exports.jsx = jsx;
2188
+ exports.markdown = markdown;
2189
+ exports.node = node;
2190
+ exports.parserPlain = parserPlain;
2191
+ exports.perfectionist = perfectionist;
2192
+ exports.pnpm = pnpm;
2193
+ exports.regexp = regexp;
2194
+ exports.renameRules = renameRules;
2195
+ exports.resolveSubOptions = resolveSubOptions;
2196
+ exports.sortPackageJson = sortPackageJson;
2197
+ exports.sortTsconfig = sortTsconfig;
2198
+ exports.stylistic = stylistic;
2199
+ exports.test = test;
2200
+ exports.toml = toml;
2201
+ exports.typescript = typescript;
2202
+ exports.unicorn = unicorn;
2203
+ exports.vue = vue;
2204
+ exports.yaml = yaml;