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