@unshared/eslint-config 0.2.3 → 0.3.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.
@@ -0,0 +1,1148 @@
1
+ import pluginAntfu from "eslint-plugin-antfu";
2
+ import eslintCommentsPlugin from "eslint-plugin-eslint-comments";
3
+ import pluginJsdoc from "eslint-plugin-jsdoc";
4
+ import pluginJsonc from "eslint-plugin-jsonc";
5
+ import nodePlugin from "eslint-plugin-n";
6
+ import pluginSonarjs from "eslint-plugin-sonarjs";
7
+ import javascript from "@eslint/js";
8
+ import stylistic from "@stylistic/eslint-plugin";
9
+ import { toArray } from "@unshared/collection/toArray";
10
+ import perfectionist from "eslint-plugin-perfectionist";
11
+ import tslint from "typescript-eslint";
12
+ import { getConfigRules } from "./utils.js";
13
+ import unicornPlugin from "eslint-plugin-unicorn";
14
+ import vitestPlugin from "@vitest/eslint-plugin";
15
+ import { mergeProcessors } from "eslint-merge-processors";
16
+ import vuePlugin from "eslint-plugin-vue";
17
+ import vueProcessorBlocks from "eslint-processor-vue-blocks";
18
+ import vueParser from "vue-eslint-parser";
19
+ import pluginYml from "eslint-plugin-yml";
20
+ function antfu() {
21
+ return [
22
+ {
23
+ plugins: {
24
+ antfu: pluginAntfu
25
+ },
26
+ rules: {
27
+ // --- Enforce consistent line breaks for chaining member access.
28
+ "antfu/consistent-chaining": "error",
29
+ // --- Enforce consistent line breaks inside braces of object/array/named imports/exports and function parameters.
30
+ "antfu/consistent-list-newline": "error",
31
+ // --- Deduplicate imports.
32
+ "antfu/import-dedupe": "error",
33
+ // --- Avoid importing from 'dist' directories.
34
+ "antfu/no-import-dist": "error",
35
+ // --- Enforce `export default` insteand of `export = {}`.
36
+ "antfu/no-ts-export-equal": "error",
37
+ // --- Enforce `function()` instead of `() => {}` for top-level functions.
38
+ "antfu/top-level-function": "error"
39
+ }
40
+ }
41
+ ];
42
+ }
43
+ function eslintComments() {
44
+ return [
45
+ {
46
+ plugins: {
47
+ "eslint-comments": eslintCommentsPlugin
48
+ },
49
+ rules: {
50
+ // --- Allow disable without having to enable again.
51
+ "eslint-comments/disable-enable-pair": "off",
52
+ // --- Disallow eslint-disable comments without rule names. This ensures that we cannot
53
+ "eslint-comments/no-aggregating-enable": "error",
54
+ // --- Disable must specify rule names.
55
+ "eslint-comments/no-unlimited-disable": "error",
56
+ // --- Prevent superfluous eslint comments.
57
+ "eslint-comments/no-duplicate-disable": "error",
58
+ "eslint-comments/no-unused-disable": "error",
59
+ "eslint-comments/no-unused-enable": "error"
60
+ }
61
+ }
62
+ ];
63
+ }
64
+ function jsdoc() {
65
+ return [
66
+ pluginJsdoc.configs["flat/recommended-typescript-error"],
67
+ {
68
+ files: [
69
+ "**/*.{ts,mts,cts,tsx,d.ts}",
70
+ "**/*.{js,mjs,cjs,jsx}",
71
+ "**/*.vue"
72
+ ],
73
+ plugins: {
74
+ jsdoc: pluginJsdoc
75
+ },
76
+ rules: {
77
+ // --- Redudant with TypeScript.
78
+ "jsdoc/require-jsdoc": "off",
79
+ "jsdoc/require-param-type": "off",
80
+ "jsdoc/require-returns-type": "off",
81
+ // --- Reports malformed JSDoc comments.
82
+ "jsdoc/no-bad-blocks": "error",
83
+ "jsdoc/check-alignment": "error",
84
+ "jsdoc/check-indentation": "error",
85
+ // --- Reports invalid block tag names.
86
+ "jsdoc/check-tag-names": ["error", { definedTags: ["category"] }],
87
+ // --- Do not use hyphens before param descriptions.
88
+ "jsdoc/require-hyphen-before-param-description": ["error", "never"],
89
+ // --- Newline after description.
90
+ "jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
91
+ }
92
+ }
93
+ ];
94
+ }
95
+ function json() {
96
+ return [
97
+ ...pluginJsonc.configs["flat/recommended-with-json"],
98
+ {
99
+ rules: {
100
+ // --- Automatically apply jsonc rules similar to your configured ESLint core rules to JSON.
101
+ "jsonc/auto": "error"
102
+ }
103
+ }
104
+ ];
105
+ }
106
+ function jsonPackage() {
107
+ return [
108
+ {
109
+ files: [
110
+ "**/package.json"
111
+ ],
112
+ rules: {
113
+ "jsonc/sort-keys": [
114
+ "error",
115
+ {
116
+ order: [
117
+ "name",
118
+ "type",
119
+ "version",
120
+ "license",
121
+ "private",
122
+ "sideEffects",
123
+ // --- Publishing
124
+ "description",
125
+ "author",
126
+ "keywords",
127
+ "bugs",
128
+ "funding",
129
+ "homepage",
130
+ "repository",
131
+ // --- Distribution
132
+ "bin",
133
+ "main",
134
+ "module",
135
+ "types",
136
+ "typings",
137
+ "browser",
138
+ "exports",
139
+ "files",
140
+ // --- Package Manager
141
+ "packageManager",
142
+ "pnpm",
143
+ // --- Scripts
144
+ "scripts",
145
+ // --- Dependencies
146
+ "peerDependencies",
147
+ "peerDependenciesMeta",
148
+ "optionalDependencies",
149
+ "dependencies",
150
+ "devDependencies",
151
+ "bundledDependencies",
152
+ "bundleDependencies",
153
+ // --- Config
154
+ "tsup",
155
+ "husky",
156
+ "lint-staged",
157
+ "eslintConfig"
158
+ ],
159
+ pathPattern: "^$"
160
+ },
161
+ {
162
+ order: { type: "asc" },
163
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
164
+ }
165
+ ]
166
+ }
167
+ }
168
+ ];
169
+ }
170
+ function jsonTsconfig() {
171
+ return [
172
+ {
173
+ files: [
174
+ "**/tsconfig.json",
175
+ "**/tsconfig.*.json"
176
+ ],
177
+ rules: {
178
+ "jsonc/sort-array-values": [
179
+ "error",
180
+ {
181
+ order: { type: "asc" },
182
+ pathPattern: "^(includes|excludes)$"
183
+ }
184
+ ],
185
+ "jsonc/sort-keys": [
186
+ "error",
187
+ {
188
+ order: [
189
+ "extends",
190
+ "compilerOptions",
191
+ "references",
192
+ "files",
193
+ "include",
194
+ "exclude"
195
+ ],
196
+ pathPattern: "^$"
197
+ },
198
+ {
199
+ order: [
200
+ // --- Project Structure
201
+ "incremental",
202
+ "composite",
203
+ "tsBuildInfoFile",
204
+ "disableSourceOfProjectReferenceRedirect",
205
+ "disableSolutionSearching",
206
+ "disableReferencedProjectLoad",
207
+ // --- Language and Environment
208
+ "target",
209
+ "jsx",
210
+ "jsxFactory",
211
+ "jsxFragmentFactory",
212
+ "jsxImportSource",
213
+ "lib",
214
+ "moduleDetection",
215
+ "noLib",
216
+ "reactNamespace",
217
+ "useDefineForClassFields",
218
+ "emitDecoratorMetadata",
219
+ "experimentalDecorators",
220
+ // --- Module Resolution
221
+ "baseUrl",
222
+ "rootDir",
223
+ "rootDirs",
224
+ "customConditions",
225
+ "module",
226
+ "moduleResolution",
227
+ "moduleSuffixes",
228
+ "noResolve",
229
+ "paths",
230
+ "resolveJsonModule",
231
+ "resolvePackageJsonExports",
232
+ "resolvePackageJsonImports",
233
+ "typeRoots",
234
+ "types",
235
+ "allowArbitraryExtensions",
236
+ "allowImportingTsExtensions",
237
+ "allowUmdGlobalAccess",
238
+ // --- JavaScript Support
239
+ "allowJs",
240
+ "checkJs",
241
+ "maxNodeModuleJsDepth",
242
+ // --- Type Checking
243
+ "strict",
244
+ "strictBindCallApply",
245
+ "strictFunctionTypes",
246
+ "strictNullChecks",
247
+ "strictPropertyInitialization",
248
+ "allowUnreachableCode",
249
+ "allowUnusedLabels",
250
+ "alwaysStrict",
251
+ "exactOptionalPropertyTypes",
252
+ "noFallthroughCasesInSwitch",
253
+ "noImplicitAny",
254
+ "noImplicitOverride",
255
+ "noImplicitReturns",
256
+ "noImplicitThis",
257
+ "noPropertyAccessFromIndexSignature",
258
+ "noUncheckedIndexedAccess",
259
+ "noUnusedLocals",
260
+ "noUnusedParameters",
261
+ "useUnknownInCatchVariables",
262
+ // --- Emitting
263
+ "declaration",
264
+ "declarationDir",
265
+ "declarationMap",
266
+ "downlevelIteration",
267
+ "emitBOM",
268
+ "emitDeclarationOnly",
269
+ "importHelpers",
270
+ "importsNotUsedAsValues",
271
+ "inlineSourceMap",
272
+ "inlineSources",
273
+ "mapRoot",
274
+ "newLine",
275
+ "noEmit",
276
+ "noEmitHelpers",
277
+ "noEmitOnError",
278
+ "outDir",
279
+ "outFile",
280
+ "preserveConstEnums",
281
+ "preserveValueImports",
282
+ "removeComments",
283
+ "sourceMap",
284
+ "sourceRoot",
285
+ "stripInternal",
286
+ // --- Interop Constraints
287
+ "allowSyntheticDefaultImports",
288
+ "esModuleInterop",
289
+ "forceConsistentCasingInFileNames",
290
+ "isolatedModules",
291
+ "preserveSymlinks",
292
+ "verbatimModuleSyntax",
293
+ // --- Completeness
294
+ "skipDefaultLibCheck",
295
+ "skipLibCheck"
296
+ ],
297
+ pathPattern: "^compilerOptions$"
298
+ },
299
+ {
300
+ order: { type: "asc" },
301
+ pathPattern: String.raw`^compilerOptions\.paths$`
302
+ }
303
+ ]
304
+ }
305
+ }
306
+ ];
307
+ }
308
+ function node() {
309
+ return [
310
+ nodePlugin.configs["flat/recommended"],
311
+ {
312
+ settings: {
313
+ node: {
314
+ version: ">=20.0.0"
315
+ }
316
+ },
317
+ rules: {
318
+ // --- Redundant with TypeScript module resolution.
319
+ "n/no-missing-import": "off",
320
+ "n/no-missing-require": "off",
321
+ "n/no-unpublished-import": "off",
322
+ // --- Enforce async functions over synchronous functions.
323
+ "n/no-sync": ["error", { allowAtRootLevel: !0 }],
324
+ // --- Enforce the use of ECMAScript features.
325
+ "n/no-unsupported-features/es-syntax": "error",
326
+ "n/no-unsupported-features/es-builtins": "error",
327
+ // --- Ignore experimental warnings.
328
+ "n/no-unsupported-features/node-builtins": "off",
329
+ // --- Prefer the use of global objects over built-in modules.
330
+ "n/prefer-global/buffer": "error",
331
+ "n/prefer-global/console": "error",
332
+ "n/prefer-global/process": "error",
333
+ "n/prefer-global/text-decoder": "error",
334
+ "n/prefer-global/text-encoder": "error",
335
+ "n/prefer-global/url": "error",
336
+ "n/prefer-global/url-search-params": "error",
337
+ // --- Prefer the use of the `node:` protocol for built-in modules.
338
+ "n/prefer-node-protocol": "error",
339
+ // --- Prefer the use of promises over callbacks.
340
+ "n/prefer-promises/fs": "error",
341
+ "n/prefer-promises/dns": "error"
342
+ }
343
+ },
344
+ {
345
+ files: [
346
+ "**/*.test.ts",
347
+ "**/*.spec.ts"
348
+ ],
349
+ rules: {
350
+ // --- Disable the no-sync rule for tests.
351
+ "n/no-sync": "off"
352
+ }
353
+ }
354
+ ];
355
+ }
356
+ function sonarjs() {
357
+ return [
358
+ pluginSonarjs.configs.recommended,
359
+ {
360
+ rules: {
361
+ // --- Increase the default threshold to 30.
362
+ "sonarjs/cognitive-complexity": ["error", 30],
363
+ // --- Increase the default threshold to 10.
364
+ "sonarjs/no-duplicate-string": ["error", { threshold: 10 }],
365
+ // --- Disable unnecessary rules.
366
+ "sonarjs/use-type-alias": "off",
367
+ "sonarjs/no-use-of-empty-return-value": "off",
368
+ "sonarjs/no-nested-functions": "off",
369
+ // --- Disable rules that are already covered by TypeScript.
370
+ "sonarjs/no-extra-arguments": "off",
371
+ "sonarjs/function-return-type": "off",
372
+ "sonarjs/no-misused-promises": "off",
373
+ "sonarjs/no-invariant-returns": "off",
374
+ "sonarjs/no-unused-expressions": "off",
375
+ "sonarjs/different-types-comparison": "off",
376
+ // --- Allow control characters in regex.
377
+ "sonarjs/sonar-no-control-regex": "off"
378
+ }
379
+ },
380
+ {
381
+ files: [
382
+ "**/*.test.ts",
383
+ "**/*.spec.ts"
384
+ ],
385
+ rules: {
386
+ // --- Disable unnecessary rules for test files.
387
+ "sonarjs/cognitive-complexity": "off",
388
+ "sonarjs/no-duplicate-string": "off",
389
+ "sonarjs/no-useless-constructor": "off",
390
+ "sonarjs/public-static-readonly": "off"
391
+ }
392
+ }
393
+ ];
394
+ }
395
+ function typescript(options) {
396
+ return [
397
+ javascript.configs.recommended,
398
+ // stylistic.configs['recommended-flat'],
399
+ {
400
+ languageOptions: {
401
+ // @ts-expect-error: ignore
402
+ parser: tslint.parser,
403
+ parserOptions: {
404
+ ecmaVersion: "latest",
405
+ sourceType: "module",
406
+ project: toArray(options.tsConfigPath ?? "./tsconfig.json"),
407
+ tsconfigRootDir: process.cwd()
408
+ }
409
+ },
410
+ plugins: {
411
+ "@typescript-eslint": tslint.plugin,
412
+ "@stylistic": stylistic,
413
+ perfectionist
414
+ },
415
+ files: [
416
+ "**/*.{ts,tsx,cts,mts}",
417
+ "**/*.{js,jsx,cjs,mjs}",
418
+ "**/*.vue"
419
+ ],
420
+ rules: {
421
+ /**
422
+ * Inherit all recommended rules from the `@eslint/js` plugin. This is the base
423
+ * configuration for JavaScript files.
424
+ */
425
+ ...getConfigRules(tslint.configs.recommendedTypeChecked),
426
+ ...getConfigRules(tslint.configs.stylisticTypeChecked),
427
+ // --- Enforce stroustrup brace style.
428
+ "brace-style": "off",
429
+ "@typescript-eslint/brace-style": "off",
430
+ "@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
431
+ // --- Enforce 2 spaces for indentation and disallow tabs.
432
+ "no-tabs": "off",
433
+ indent: "off",
434
+ "indent-binary-ops": "off",
435
+ "@typescript-eslint/no-tabs": "off",
436
+ "@typescript-eslint/indent": "off",
437
+ "@typescript-eslint/indent-binary-ops": "off",
438
+ "@stylistic/no-tabs": "error",
439
+ "@stylistic/indent": ["error", 2],
440
+ "@stylistic/indent-binary-ops": ["error", 2],
441
+ // --- No semicolons.
442
+ semi: "off",
443
+ "@typescript-eslint/semi": "off",
444
+ "@stylistic/semi": ["error", "never"],
445
+ // --- Consistent line breaks.
446
+ "eol-last": "off",
447
+ "no-multiple-empty-lines": "off",
448
+ "@stylistic/eol-last": ["error", "always"],
449
+ "@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
450
+ // --- Enforce dangling commas in multiline object literals.
451
+ "comma-dangle": "off",
452
+ "@typescript-eslint/comma-dangle": "off",
453
+ "@stylistic/comma-dangle": ["error", "always-multiline"],
454
+ // --- Enforce type interfaces over type aliases.
455
+ "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
456
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
457
+ "@typescript-eslint/array-type": ["error", { default: "array-simple", readonly: "array-simple" }],
458
+ // --- Enforce declaration and usage from top to bottom.
459
+ "no-use-before-define": "off",
460
+ "@typescript-eslint/no-use-before-define": ["error", {
461
+ enums: !0,
462
+ classes: !1,
463
+ typedefs: !0,
464
+ variables: !0,
465
+ functions: !1,
466
+ ignoreTypeReferences: !0
467
+ }],
468
+ // --- Consistent spacing and line breaks between tokens.
469
+ "key-spacing": "off",
470
+ "comma-spacing": "off",
471
+ "block-spacing": "off",
472
+ "arrow-spacing": "off",
473
+ "spaced-comment": "off",
474
+ "no-multi-spaces": "off",
475
+ "space-before-blocks": "off",
476
+ "lines-around-comment": "off",
477
+ "object-curly-spacing": "off",
478
+ "array-bracket-spacing": "off",
479
+ "array-bracket-newline": "off",
480
+ "function-call-spacing": "off",
481
+ "generator-star-spacing": "off",
482
+ "template-curly-spacing": "off",
483
+ "object-property-newline ": "off",
484
+ "newline-per-chained-call": "off",
485
+ "computed-property-spacing": "off",
486
+ "lines-between-class-members": "off",
487
+ "@typescript-eslint/comma-spacing": "off",
488
+ "@typescript-eslint/object-curly-spacing": "off",
489
+ "@typescript-eslint/type-annotation-spacing": "off",
490
+ "@typescript-eslint/lines-around-comment": "off",
491
+ "@stylistic/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
492
+ "@stylistic/comma-spacing": ["error", { after: !0, before: !1 }],
493
+ "@stylistic/arrow-spacing": ["error", { before: !0, after: !0 }],
494
+ "@stylistic/type-generic-spacing": "error",
495
+ "@stylistic/type-named-tuple-spacing": "error",
496
+ "@stylistic/block-spacing": ["error", "always"],
497
+ "@stylistic/no-multi-spaces": "error",
498
+ "@stylistic/keyword-spacing": ["error", { before: !0, after: !0 }],
499
+ "@stylistic/space-before-blocks": ["error", "always"],
500
+ "@stylistic/object-curly-spacing": ["error", "always"],
501
+ "@stylistic/array-bracket-spacing": ["error", "never"],
502
+ "@stylistic/array-bracket-newline": ["error", "consistent"],
503
+ "@stylistic/function-call-spacing": ["error", "never"],
504
+ "@stylistic/template-curly-spacing": ["error", "never"],
505
+ "@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
506
+ "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: !0 }],
507
+ "@stylistic/generator-star-spacing": ["error", { before: !0, after: !0 }],
508
+ "@stylistic/computed-property-spacing": ["error", "never"],
509
+ "@stylistic/multiline-ternary": ["error", "always-multiline"],
510
+ "@stylistic/lines-around-comment": ["error", {
511
+ beforeBlockComment: !0,
512
+ beforeLineComment: !0,
513
+ ignorePattern: String.raw`^(?! ?---|\*)`,
514
+ applyDefaultIgnorePatterns: !0,
515
+ afterHashbangComment: !0
516
+ }],
517
+ "@stylistic/spaced-comment": ["error", "always", {
518
+ block: { markers: ["!"], exceptions: ["*"], balanced: !0 },
519
+ line: { markers: ["/"], exceptions: ["/", "#"] }
520
+ }],
521
+ "@stylistic/lines-between-class-members": ["error", {
522
+ enforce: [{ blankLine: "always", prev: "method", next: "*" }]
523
+ }, {
524
+ exceptAfterSingleLine: !0
525
+ }],
526
+ "@stylistic/type-annotation-spacing": ["error", {
527
+ before: !0,
528
+ after: !0,
529
+ overrides: {
530
+ arrow: { before: !0, after: !0 },
531
+ colon: { before: !1, after: !0 },
532
+ variable: { before: !1, after: !0 },
533
+ property: { before: !1, after: !0 },
534
+ parameter: { before: !1, after: !0 },
535
+ returnType: { before: !1, after: !0 }
536
+ }
537
+ }],
538
+ // --- Enforce `@ts-expect-error` over `@ts-ignore`.
539
+ "@typescript-eslint/prefer-ts-expect-error": "error",
540
+ "@typescript-eslint/ban-ts-comment": ["error", {
541
+ "ts-check": !1,
542
+ "ts-expect-error": "allow-with-description",
543
+ "ts-ignore": !1,
544
+ "ts-nocheck": !1
545
+ }],
546
+ /**
547
+ * Disallow dangling expressions and promises. This rule aims to prevent
548
+ * dangling promises and expressions that are not assigned to a variable.
549
+ * This can lead to bugs and unexpected behavior in the codebase.
550
+ *
551
+ * @see https://eslint.org/docs/rules/no-void
552
+ * @see https://typescript-eslint.io/rules/no-floating-promises
553
+ */
554
+ "no-void": "off",
555
+ "no-unused-expressions": "off",
556
+ "@typescript-eslint/no-unused-expressions": "error",
557
+ "@typescript-eslint/no-floating-promises": ["error", {
558
+ ignoreVoid: !0,
559
+ ignoreIIFE: !0
560
+ }],
561
+ /**
562
+ * Sort imports alphabetically and group them without newlines. This rule
563
+ * aims to maintain consistency around the order of imports in JavaScript
564
+ * files. Helps reduce the visual noise in the codebase.
565
+ *
566
+ * @see https://typescript-eslint.io/rules/consistent-type-imports
567
+ * @see https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
568
+ */
569
+ "sort-imports": "off",
570
+ "@typescript-eslint/consistent-type-imports": ["error", {
571
+ disallowTypeAnnotations: !1,
572
+ prefer: "type-imports",
573
+ fixStyle: "separate-type-imports"
574
+ }],
575
+ "perfectionist/sort-exports": ["error", {
576
+ type: "alphabetical",
577
+ ignoreCase: !0
578
+ }],
579
+ "perfectionist/sort-named-imports": ["error", {
580
+ type: "alphabetical",
581
+ ignoreCase: !0
582
+ }],
583
+ "perfectionist/sort-imports": ["error", {
584
+ newlinesBetween: "never",
585
+ order: "asc",
586
+ ignoreCase: !0,
587
+ groups: [
588
+ "type",
589
+ "internal-type",
590
+ ["parent-type", "sibling-type", "index-type"],
591
+ ["builtin", "external"],
592
+ "internal",
593
+ ["parent", "sibling", "index"],
594
+ "object",
595
+ "unknown"
596
+ ]
597
+ }],
598
+ /**
599
+ * Sort types and union types alphabetically. This rule aims to maintain
600
+ * consistency around the order of types in TypeScript files. Helps reduce
601
+ * the visual noise in the codebase.
602
+ *
603
+ * @see https://perfectionist.dev/rules/sort-union-types
604
+ */
605
+ "@typescript-eslint/sort-type-constituents": "off",
606
+ "perfectionist/sort-intersection-types": ["error", {
607
+ type: "natural"
608
+ }],
609
+ "perfectionist/sort-union-types": ["error", {
610
+ type: "natural",
611
+ ignoreCase: !1
612
+ }],
613
+ /**
614
+ * Enforce no unused variables. Helps keep the codebase clean and reduces
615
+ * the chance of bugs from side-effects.
616
+ *
617
+ * @see https://typescript-eslint.io/rules/@typescript-eslint/no-unused-vars
618
+ */
619
+ "no-redeclare": "off",
620
+ "no-unused-vars": "off",
621
+ "@typescript-eslint/no-redeclare": "error",
622
+ "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
623
+ //////////////////////////////////////////////////////////////////////////////////////////
624
+ "no-useless-constructor": "off",
625
+ "@typescript-eslint/ban-types": "off",
626
+ "@typescript-eslint/camelcase": "off",
627
+ "@typescript-eslint/explicit-function-return-type": "off",
628
+ "@typescript-eslint/explicit-member-accessibility": "off",
629
+ "@typescript-eslint/explicit-module-boundary-types": "off",
630
+ "@typescript-eslint/no-empty-function": "off",
631
+ "@typescript-eslint/no-empty-interface": "off",
632
+ "@typescript-eslint/no-explicit-any": "off",
633
+ "@typescript-eslint/no-namespace": "off",
634
+ "@typescript-eslint/no-non-null-assertion": "off",
635
+ "@typescript-eslint/no-parameter-properties": "off",
636
+ "array-callback-return": "error",
637
+ "arrow-body-style": ["error", "as-needed"],
638
+ "arrow-parens": ["error", "as-needed", { requireForBlockBody: !0 }],
639
+ "block-scoped-var": "error",
640
+ camelcase: "off",
641
+ "comma-style": ["error", "last"],
642
+ complexity: ["off", 11],
643
+ "consistent-return": "off",
644
+ curly: ["error", "multi-or-nest", "consistent"],
645
+ eqeqeq: ["error", "smart"],
646
+ "no-alert": "error",
647
+ "no-case-declarations": "error",
648
+ "no-cond-assign": ["error", "always"],
649
+ "no-confusing-arrow": "error",
650
+ "no-console": ["warn", { allow: ["warn", "error"] }],
651
+ "no-constant-condition": "error",
652
+ "no-debugger": "error",
653
+ "no-eval": "error",
654
+ "no-implied-eval": "error",
655
+ "no-multi-str": "error",
656
+ "no-param-reassign": "off",
657
+ "no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
658
+ "no-return-assign": "off",
659
+ "no-return-await": "off",
660
+ "no-trailing-spaces": "error",
661
+ "no-useless-escape": "off",
662
+ "no-var": "error",
663
+ "no-with": "error",
664
+ "object-shorthand": ["error", "always", { avoidQuotes: !0, ignoreConstructors: !1 }],
665
+ "one-var-declaration-per-line": "error",
666
+ "operator-linebreak": ["error", "before"],
667
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: !1, allowUnboundThis: !0 }],
668
+ "prefer-const": ["error", { destructuring: "any", ignoreReadBeforeAssign: !0 }],
669
+ "prefer-rest-params": "error",
670
+ "prefer-spread": "error",
671
+ "prefer-template": "error",
672
+ "quote-props": ["error", "consistent-as-needed"],
673
+ quotes: ["error", "single"],
674
+ "require-await": "off",
675
+ "space-before-function-paren": ["error", "never"],
676
+ "vars-on-top": "error"
677
+ }
678
+ },
679
+ /**
680
+ * Ignore duplicate imports in declaration files as they are often used to re-export
681
+ * types from other packages into multiple namespaces. This is a common pattern
682
+ * in TypeScript declaration files.
683
+ */
684
+ {
685
+ files: ["*.d.ts"],
686
+ rules: {
687
+ "@typescript-eslint/no-use-before-define": "off",
688
+ "import/no-duplicates": "off"
689
+ }
690
+ },
691
+ /**
692
+ * Allow console statements in scripts and CLI files since they are not part of the
693
+ * library / production code and are useful for debugging, logging, and testing.
694
+ */
695
+ {
696
+ files: ["**/scripts/**/*", "cli.*"],
697
+ rules: {
698
+ "no-console": "off"
699
+ }
700
+ }
701
+ ];
702
+ }
703
+ function unicorn() {
704
+ return [
705
+ unicornPlugin.configs["flat/recommended"],
706
+ {
707
+ rules: {
708
+ // --- Allow any kind of import style.
709
+ "unicorn/import-style": "off",
710
+ // --- Improve regexes by making them shorter, consistent, and safer.
711
+ "unicorn/better-regex": "error",
712
+ // --- Use destructured variables over properties.
713
+ "unicorn/consistent-destructuring": "error",
714
+ // --- Enforce consistent function scoping except for arrow functions.
715
+ "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: !1 }],
716
+ // --- Disable switch-case fallthrough.
717
+ "unicorn/prefer-switch": "off",
718
+ // --- Enforce camelCase & PascalCase in filenames. Exepct non TS/JS files.
719
+ "unicorn/filename-case": ["error", {
720
+ multipleFileExtensions: !1,
721
+ cases: { camelCase: !0, pascalCase: !0 },
722
+ ignore: [/\.json$/, /\.md$/, /\.yml$/, /\.yaml$/]
723
+ }],
724
+ // --- Improve readability by using numeric separators.
725
+ "unicorn/numeric-separators-style": ["error", {
726
+ onlyIfContainsSeparator: !0
727
+ }],
728
+ // --- Enforce long variable names when they are meaningful.
729
+ "unicorn/prevent-abbreviations": ["error", {
730
+ allowList: {
731
+ args: !0,
732
+ dir: !0,
733
+ fn: !0,
734
+ i: !0,
735
+ j: !0,
736
+ k: !0,
737
+ ref: !0,
738
+ Ref: !0,
739
+ props: !0,
740
+ Props: !0,
741
+ v: !0,
742
+ x: !0,
743
+ y: !0,
744
+ z: !0
745
+ }
746
+ }]
747
+ }
748
+ },
749
+ {
750
+ files: [
751
+ "**/*.test.ts",
752
+ "**/*.spec.ts"
753
+ ],
754
+ rules: {
755
+ // --- Disable unnecessary rules for test files.
756
+ "unicorn/no-null": "off",
757
+ "unicorn/no-useless-undefined": "off",
758
+ "unicorn/no-static-only-class": "off"
759
+ }
760
+ }
761
+ ];
762
+ }
763
+ function vitest() {
764
+ return [
765
+ vitestPlugin.configs.recommended,
766
+ {
767
+ rules: {
768
+ // --- Add the `expectTypeOf` function to the list of assert functions.
769
+ "vitest/expect-expect": ["error", {
770
+ assertFunctionNames: ["expect", "expectTypeOf"]
771
+ }],
772
+ // --- Enforce a single top-level describe block.
773
+ "vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 1 }],
774
+ // --- Enforce 'should' as the prefix for test titles.
775
+ "vitest/valid-title": ["error", {
776
+ ignoreTypeOfDescribeName: !0,
777
+ mustMatch: { test: ["^should"] }
778
+ }],
779
+ // --- Prefer strict equality checks.
780
+ "vitest/prefer-to-be-truthy": "off",
781
+ "vitest/prefer-to-be-falsy": "off",
782
+ /// --- Loosen the rules for test files.
783
+ "vitest/no-hooks": "off",
784
+ "vitest/require-hook": "off",
785
+ "vitest/no-conditional-in-test": "off",
786
+ "vitest/no-conditional-tests": "off",
787
+ "vitest/prefer-expect-assertions": "off",
788
+ "vitest/padding-around-all": "off",
789
+ "vitest/padding-around-expect-groups": "off"
790
+ }
791
+ }
792
+ ];
793
+ }
794
+ function vue(options) {
795
+ const TYPESCRIPT_CONFIG = typescript(options).at(1);
796
+ return [
797
+ ...vuePlugin.configs["flat/recommended"],
798
+ {
799
+ plugins: {
800
+ vue: vuePlugin,
801
+ ...TYPESCRIPT_CONFIG.plugins
802
+ },
803
+ languageOptions: {
804
+ globals: {
805
+ computed: "readonly",
806
+ defineEmits: "readonly",
807
+ defineExpose: "readonly",
808
+ defineProps: "readonly",
809
+ onMounted: "readonly",
810
+ onUnmounted: "readonly",
811
+ reactive: "readonly",
812
+ ref: "readonly",
813
+ shallowReactive: "readonly",
814
+ shallowRef: "readonly",
815
+ toRef: "readonly",
816
+ toRefs: "readonly",
817
+ watch: "readonly",
818
+ watchEffect: "readonly"
819
+ },
820
+ parser: vueParser,
821
+ parserOptions: {
822
+ parser: tslint.parser,
823
+ extraFileExtensions: [".vue"],
824
+ ...TYPESCRIPT_CONFIG.languageOptions.parserOptions
825
+ }
826
+ },
827
+ processor: mergeProcessors([
828
+ vuePlugin.processors.vue,
829
+ vueProcessorBlocks()
830
+ ]),
831
+ files: [
832
+ "**/*.vue",
833
+ "**/*.ts"
834
+ ],
835
+ rules: {
836
+ "vue/return-in-computed-property": "off",
837
+ // --- Allow multiple component definitions in a single file.
838
+ "vue/one-component-per-file": "off",
839
+ // --- Enforce Component API style.
840
+ "vue/prefer-define-options": "error",
841
+ "vue/component-api-style": ["error", ["script-setup", "composition"]],
842
+ // --- Enforce PascalCase components and allow reserved and single-word names.
843
+ "vue/multi-word-component-names": "off",
844
+ "vue/no-reserved-component-names": "off",
845
+ "vue/component-name-in-template-casing": ["error", "PascalCase", {
846
+ ignores: [String.raw`/\./`],
847
+ registeredComponentsOnly: !1
848
+ }],
849
+ // --- Consistent spacing around HTML comments.
850
+ "vue/html-comment-indent": ["error", 2],
851
+ "vue/multiline-html-element-content-newline": ["error", {
852
+ allowEmptyLines: !0,
853
+ ignores: [],
854
+ ignoreWhenEmpty: !0
855
+ }],
856
+ "vue/html-comment-content-spacing": ["error", "always"],
857
+ "vue/html-comment-content-newline": ["error", {
858
+ multiline: "always",
859
+ singleline: "never"
860
+ }],
861
+ // --- Consistent block order in Vue components.
862
+ "vue/block-order": ["error", { order: ["script", "template", "style", "i18n"] }],
863
+ // --- Consistent spacing in and around the block.
864
+ "vue/block-spacing": ["error", "always"],
865
+ "vue/padding-line-between-blocks": ["error", "always"],
866
+ "vue/padding-line-between-tags": ["error", [
867
+ { blankLine: "consistent", next: "*", prev: "*" },
868
+ { blankLine: "always", next: "*", prev: "comment" }
869
+ ]],
870
+ /**
871
+ * Enforce consistent spacing and newlines in the template. This rule helps
872
+ * to maintain consistency and readability by enforcing a predictable
873
+ *
874
+ * @see https://eslint.vuejs.org/rules/html-indent.html
875
+ * @see https://eslint.vuejs.org/rules/max-attributes-per-line.html
876
+ * @see https://eslint.vuejs.org/rules/html-closing-bracket-newline.html
877
+ */
878
+ "vue/html-indent": ["error", 2, {
879
+ alignAttributesVertically: !0,
880
+ attribute: 1,
881
+ baseIndent: 1,
882
+ closeBracket: 0,
883
+ ignores: []
884
+ }],
885
+ // 'vue/func-call-spacing': ['off', 'never'],
886
+ "vue/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
887
+ "vue/keyword-spacing": ["error", { after: !0, before: !0 }],
888
+ "vue/max-attributes-per-line": ["error", {
889
+ multiline: { max: 1 },
890
+ singleline: { max: 5 }
891
+ }],
892
+ /**
893
+ * Allow single-word component names. This rule is disabled because we use
894
+ * pascal-casing to distinguish between components and HTML elements.
895
+ *
896
+ * @see https://eslint.vuejs.org/rules/multi-word-component-names.html
897
+ */
898
+ /**
899
+ * Reports the destructuring or member expression of props passed to setup
900
+ * causing the value to lose reactivity. This rule helps to avoid common
901
+ * pitfalls when using the Composition API.
902
+ *
903
+ * @see https://eslint.vuejs.org/rules/no-setup-props-reactivity-loss.html
904
+ */
905
+ "vue/no-setup-props-reactivity-loss": "error",
906
+ /**
907
+ * Disallow v-if in v-for. This rule helps to avoid common pitfalls when
908
+ * using v-if and v-for together in the same element.
909
+ *
910
+ * @see https://eslint.vuejs.org/rules/no-use-v-if-with-v-for.html
911
+ */
912
+ "vue/no-use-v-if-with-v-for": "error",
913
+ /**
914
+ * Enforce the declaration of emits in the setup function and warn on unused
915
+ * emits declarations. This rule helps reduce the risk stale code.
916
+ *
917
+ * @see https://eslint.vuejs.org/rules/require-explicit-emits.html
918
+ * @see https://eslint.vuejs.org/rules/no-unused-emit-declarations.html
919
+ */
920
+ "vue/require-explicit-emits": "error",
921
+ /**
922
+ * Enforce the `@` shorthand over `v-on:` and only allow inline callbacks.
923
+ * This rule helps to maintain consistency and readability by enforcing a
924
+ * predictable order of the event handlers in the component.
925
+ *
926
+ * @see https://eslint.vuejs.org/rules/v-on-style.html
927
+ * @see https://eslint.vuejs.org/rules/v-on-handler-style.html
928
+ */
929
+ "vue/v-on-style": ["error", "shorthand"],
930
+ "vue/v-on-handler-style": ["error", "inline-function"],
931
+ /**
932
+ * Sort the vue attributes in a consistent order. This rule helps to maintain
933
+ * consistency and readability by enforcing a predictable order of the
934
+ * attributes in the component.
935
+ *
936
+ * @see https://eslint.vuejs.org/rules/attributes-order.html
937
+ */
938
+ "vue/attributes-order": ["error", {
939
+ order: [
940
+ "DEFINITION",
941
+ "LIST_RENDERING",
942
+ "CONDITIONALS",
943
+ "RENDER_MODIFIERS",
944
+ "GLOBAL",
945
+ ["UNIQUE", "SLOT"],
946
+ "TWO_WAY_BINDING",
947
+ "OTHER_DIRECTIVES",
948
+ "OTHER_ATTR",
949
+ "EVENTS",
950
+ "CONTENT"
951
+ ],
952
+ alphabetical: !1
953
+ }],
954
+ /**
955
+ * Enforce consistent spacing around attribute assignments. This ensures that
956
+ * the code is easier to read and maintain.
957
+ *
958
+ * @see https://eslint.vuejs.org/rules/no-spaces-around-equal-signs-in-attribute.html
959
+ */
960
+ "vue/no-spaces-around-equal-signs-in-attribute": "error",
961
+ "vue/no-multi-spaces": "error",
962
+ /**
963
+ * Enforce the use of the `ts` lang attribute in the script block. This rule
964
+ * explicitly dissallows the use of the `js` lang attribute in the script.
965
+ */
966
+ "vue/block-lang": ["error", {
967
+ script: { lang: "ts" }
968
+ }],
969
+ "vue/no-sparse-arrays": "error",
970
+ "vue/no-unused-emit-declarations": "error",
971
+ "vue/no-use-v-else-with-v-for": "error",
972
+ "vue/no-useless-v-bind": "error",
973
+ "vue/no-v-html": "off",
974
+ "vue/no-v-text-v-html-on-component": "error",
975
+ "vue/object-curly-newline": ["error", { consistent: !0, multiline: !0 }],
976
+ "vue/object-curly-spacing": ["error", "always"],
977
+ "vue/object-shorthand": [
978
+ "error",
979
+ "always",
980
+ {
981
+ avoidQuotes: !0,
982
+ ignoreConstructors: !1
983
+ }
984
+ ],
985
+ "vue/operator-linebreak": ["error", "before"],
986
+ "vue/prefer-import-from-vue": "off",
987
+ "vue/prefer-separate-static-class": "error",
988
+ "vue/prefer-template": "error",
989
+ "vue/quote-props": ["error", "consistent-as-needed"],
990
+ "vue/require-default-prop": "off",
991
+ // reactivity transform
992
+ "vue/block-tag-newline": ["error", {
993
+ multiline: "always",
994
+ singleline: "always"
995
+ }],
996
+ // extensions
997
+ "vue/array-bracket-spacing": ["error", "never"],
998
+ "vue/arrow-spacing": ["error", { after: !0, before: !0 }],
999
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
1000
+ "vue/comma-dangle": ["error", "always-multiline"],
1001
+ "vue/comma-spacing": ["error", { after: !0, before: !1 }],
1002
+ "vue/comma-style": ["error", "last"],
1003
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1004
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1005
+ "vue/define-macros-order": ["error", {
1006
+ order: ["defineProps", "defineEmits"]
1007
+ }],
1008
+ "vue/dot-location": ["error", "property"],
1009
+ "vue/dot-notation": ["error", { allowKeywords: !0 }],
1010
+ "vue/eqeqeq": ["error", "smart"],
1011
+ "vue/first-attribute-linebreak": ["error", {
1012
+ multiline: "below",
1013
+ singleline: "beside"
1014
+ }],
1015
+ "vue/html-closing-bracket-newline": ["error", {
1016
+ multiline: "never",
1017
+ selfClosingTag: {
1018
+ multiline: "always",
1019
+ singleline: "never"
1020
+ },
1021
+ singleline: "never"
1022
+ }],
1023
+ "vue/no-constant-condition": "warn",
1024
+ "vue/no-empty-pattern": "error",
1025
+ "vue/no-extra-parens": ["error", "functions"],
1026
+ "vue/no-irregular-whitespace": "error",
1027
+ "vue/no-loss-of-precision": "error",
1028
+ "vue/no-restricted-syntax": [
1029
+ "error",
1030
+ "DebuggerStatement",
1031
+ "LabeledStatement",
1032
+ "WithStatement"
1033
+ ],
1034
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1035
+ "vue/require-prop-types": "off",
1036
+ "vue/space-in-parens": ["error", "never"],
1037
+ "vue/space-infix-ops": "error",
1038
+ "vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
1039
+ "vue/template-curly-spacing": "error"
1040
+ }
1041
+ },
1042
+ // --- Disable some TypeScript rules that may conflict with the Vue SFC parser.
1043
+ {
1044
+ files: [
1045
+ "**/*.vue"
1046
+ ],
1047
+ rules: {
1048
+ "@typescript-eslint/no-unsafe-call": "off",
1049
+ "@typescript-eslint/no-unsafe-return": "off",
1050
+ "@typescript-eslint/no-unsafe-argument": "off",
1051
+ "@typescript-eslint/no-unsafe-assignment": "off",
1052
+ "@typescript-eslint/no-unsafe-member-access": "off",
1053
+ "@typescript-eslint/no-misused-promises": "off"
1054
+ }
1055
+ },
1056
+ // --- Disable in test files.
1057
+ {
1058
+ files: [
1059
+ "**/*.test.ts",
1060
+ "**/*.spec.ts"
1061
+ ],
1062
+ rules: {
1063
+ "vue/one-component-per-file": "off"
1064
+ }
1065
+ }
1066
+ ];
1067
+ }
1068
+ function yml() {
1069
+ return [
1070
+ ...pluginYml.configs["flat/standard"],
1071
+ ...pluginYml.configs["flat/recommended"],
1072
+ {
1073
+ rules: {
1074
+ // --- Force single quotes.
1075
+ "yml/quotes": ["error", {
1076
+ avoidEscape: !0,
1077
+ prefer: "single"
1078
+ }],
1079
+ // --- Remove trailing zeros in numbers.
1080
+ "yml/no-trailing-zeros": "error",
1081
+ // --- Prevent empty keys.
1082
+ "yml/require-string-key": "error",
1083
+ // --- Prevent empty values or weird newlines in mappings.
1084
+ "yml/block-mapping-colon-indicator-newline": "error",
1085
+ // --- No more than one empty line.
1086
+ "yml/no-multiple-empty-lines": ["error", {
1087
+ max: 1,
1088
+ maxBOF: 0,
1089
+ maxEOF: 0
1090
+ }],
1091
+ // --- Sort environemnt variables alphabetically.
1092
+ "yml/sort-sequence-values": ["error", {
1093
+ pathPattern: "^env$",
1094
+ order: { type: "asc" }
1095
+ }]
1096
+ }
1097
+ }
1098
+ ];
1099
+ }
1100
+ function all(options = {}) {
1101
+ return [
1102
+ ...antfu(),
1103
+ ...eslintComments(),
1104
+ ...jsdoc(),
1105
+ ...json(),
1106
+ ...jsonPackage(),
1107
+ ...jsonTsconfig(),
1108
+ ...node(),
1109
+ ...sonarjs(),
1110
+ ...typescript(options),
1111
+ ...unicorn(),
1112
+ ...vitest(),
1113
+ ...vue(options),
1114
+ ...yml(),
1115
+ {
1116
+ ignores: [
1117
+ "**/dist",
1118
+ "**/bin",
1119
+ "**/node_modules",
1120
+ "**/.nuxt",
1121
+ "**/.output",
1122
+ "**/coverage",
1123
+ "**/public",
1124
+ "**/__wip__",
1125
+ "**/__snapshots__",
1126
+ "**/LICENSE*",
1127
+ "**/CHANGELOG*",
1128
+ "packages-lock.json",
1129
+ "pnpm-lock.yaml",
1130
+ "yarn.lock"
1131
+ ]
1132
+ }
1133
+ ];
1134
+ }
1135
+ export {
1136
+ all,
1137
+ antfu,
1138
+ eslintComments,
1139
+ jsdoc,
1140
+ json,
1141
+ jsonPackage,
1142
+ jsonTsconfig,
1143
+ typescript,
1144
+ unicorn,
1145
+ vitest,
1146
+ vue
1147
+ };
1148
+ //# sourceMappingURL=configs.js.map