@unshared/eslint-config 0.3.0 → 0.3.2

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