@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.cjs CHANGED
@@ -1,1123 +1,23 @@
1
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"), 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
- }
362
- },
363
- {
364
- files: [
365
- "**/*.test.ts",
366
- "**/*.spec.ts"
367
- ],
368
- rules: {
369
- // --- Disable unnecessary rules for test files.
370
- "sonarjs/cognitive-complexity": "off",
371
- "sonarjs/no-duplicate-string": "off",
372
- "sonarjs/no-useless-constructor": "off",
373
- "sonarjs/public-static-readonly": "off"
374
- }
375
- }
376
- ];
377
- }
378
- function getConfigRules(config) {
379
- const rules = toArray.toArray(config).flat().map((x) => x.rules);
380
- return Object.assign({}, ...rules);
381
- }
382
- function typescript(options) {
383
- return [
384
- javascript.configs.recommended,
385
- // stylistic.configs['recommended-flat'],
386
- {
387
- languageOptions: {
388
- // @ts-expect-error: ignore
389
- parser: tslint.parser,
390
- parserOptions: {
391
- ecmaVersion: "latest",
392
- sourceType: "module",
393
- project: toArray.toArray(options.tsConfigPath ?? "./tsconfig.json"),
394
- tsconfigRootDir: process.cwd()
395
- }
396
- },
397
- plugins: {
398
- "@typescript-eslint": tslint.plugin,
399
- "@stylistic": stylistic,
400
- perfectionist
401
- },
402
- files: [
403
- "**/*.{ts,tsx,cts,mts}",
404
- "**/*.{js,jsx,cjs,mjs}",
405
- "**/*.vue"
406
- ],
407
- rules: {
408
- /**
409
- * Inherit all recommended rules from the `@eslint/js` plugin. This is the base
410
- * configuration for JavaScript files.
411
- */
412
- ...getConfigRules(tslint.configs.recommendedTypeChecked),
413
- ...getConfigRules(tslint.configs.stylisticTypeChecked),
414
- // --- Enforce stroustrup brace style.
415
- "brace-style": "off",
416
- "@typescript-eslint/brace-style": "off",
417
- "@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
418
- // --- Enforce 2 spaces for indentation and disallow tabs.
419
- "no-tabs": "off",
420
- indent: "off",
421
- "indent-binary-ops": "off",
422
- "@typescript-eslint/no-tabs": "off",
423
- "@typescript-eslint/indent": "off",
424
- "@typescript-eslint/indent-binary-ops": "off",
425
- "@stylistic/no-tabs": "error",
426
- "@stylistic/indent": ["error", 2],
427
- "@stylistic/indent-binary-ops": ["error", 2],
428
- // --- No semicolons.
429
- semi: "off",
430
- "@typescript-eslint/semi": "off",
431
- "@stylistic/semi": ["error", "never"],
432
- // --- Consistent line breaks.
433
- "eol-last": "off",
434
- "no-multiple-empty-lines": "off",
435
- "@stylistic/eol-last": ["error", "always"],
436
- "@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
437
- // --- Enforce dangling commas in multiline object literals.
438
- "comma-dangle": "off",
439
- "@typescript-eslint/comma-dangle": "off",
440
- "@stylistic/comma-dangle": ["error", "always-multiline"],
441
- // --- Enforce type interfaces over type aliases.
442
- "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
443
- "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
444
- "@typescript-eslint/array-type": ["error", { default: "array-simple", readonly: "array-simple" }],
445
- // --- Enforce declaration and usage from top to bottom.
446
- "no-use-before-define": "off",
447
- "@typescript-eslint/no-use-before-define": ["error", {
448
- enums: !0,
449
- classes: !1,
450
- typedefs: !0,
451
- variables: !0,
452
- functions: !1,
453
- ignoreTypeReferences: !0
454
- }],
455
- // --- Consistent spacing and line breaks between tokens.
456
- "key-spacing": "off",
457
- "comma-spacing": "off",
458
- "block-spacing": "off",
459
- "arrow-spacing": "off",
460
- "spaced-comment": "off",
461
- "no-multi-spaces": "off",
462
- "space-before-blocks": "off",
463
- "lines-around-comment": "off",
464
- "object-curly-spacing": "off",
465
- "array-bracket-spacing": "off",
466
- "array-bracket-newline": "off",
467
- "function-call-spacing": "off",
468
- "generator-star-spacing": "off",
469
- "template-curly-spacing": "off",
470
- "object-property-newline ": "off",
471
- "newline-per-chained-call": "off",
472
- "computed-property-spacing": "off",
473
- "lines-between-class-members": "off",
474
- "@typescript-eslint/comma-spacing": "off",
475
- "@typescript-eslint/object-curly-spacing": "off",
476
- "@typescript-eslint/type-annotation-spacing": "off",
477
- "@typescript-eslint/lines-around-comment": "off",
478
- "@stylistic/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
479
- "@stylistic/comma-spacing": ["error", { after: !0, before: !1 }],
480
- "@stylistic/arrow-spacing": ["error", { before: !0, after: !0 }],
481
- "@stylistic/type-generic-spacing": "error",
482
- "@stylistic/type-named-tuple-spacing": "error",
483
- "@stylistic/block-spacing": ["error", "always"],
484
- "@stylistic/no-multi-spaces": "error",
485
- "@stylistic/keyword-spacing": ["error", { before: !0, after: !0 }],
486
- "@stylistic/space-before-blocks": ["error", "always"],
487
- "@stylistic/object-curly-spacing": ["error", "always"],
488
- "@stylistic/array-bracket-spacing": ["error", "never"],
489
- "@stylistic/array-bracket-newline": ["error", "consistent"],
490
- "@stylistic/function-call-spacing": ["error", "never"],
491
- "@stylistic/template-curly-spacing": ["error", "never"],
492
- "@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
493
- "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: !0 }],
494
- "@stylistic/generator-star-spacing": ["error", { before: !0, after: !0 }],
495
- "@stylistic/computed-property-spacing": ["error", "never"],
496
- "@stylistic/multiline-ternary": ["error", "always-multiline"],
497
- "@stylistic/lines-around-comment": ["error", {
498
- beforeBlockComment: !0,
499
- beforeLineComment: !0,
500
- ignorePattern: String.raw`^(?! ?---|\*)`,
501
- applyDefaultIgnorePatterns: !0,
502
- afterHashbangComment: !0
503
- }],
504
- "@stylistic/spaced-comment": ["error", "always", {
505
- block: { markers: ["!"], exceptions: ["*"], balanced: !0 },
506
- line: { markers: ["/"], exceptions: ["/", "#"] }
507
- }],
508
- "@stylistic/lines-between-class-members": ["error", {
509
- enforce: [{ blankLine: "always", prev: "method", next: "*" }]
510
- }, {
511
- exceptAfterSingleLine: !0
512
- }],
513
- "@stylistic/type-annotation-spacing": ["error", {
514
- before: !0,
515
- after: !0,
516
- overrides: {
517
- arrow: { before: !0, after: !0 },
518
- colon: { before: !1, after: !0 },
519
- variable: { before: !1, after: !0 },
520
- property: { before: !1, after: !0 },
521
- parameter: { before: !1, after: !0 },
522
- returnType: { before: !1, after: !0 }
523
- }
524
- }],
525
- // --- Enforce `@ts-expect-error` over `@ts-ignore`.
526
- "@typescript-eslint/prefer-ts-expect-error": "error",
527
- "@typescript-eslint/ban-ts-comment": ["error", {
528
- "ts-check": !1,
529
- "ts-expect-error": "allow-with-description",
530
- "ts-ignore": !1,
531
- "ts-nocheck": !1
532
- }],
533
- /**
534
- * Disallow dangling expressions and promises. This rule aims to prevent
535
- * dangling promises and expressions that are not assigned to a variable.
536
- * This can lead to bugs and unexpected behavior in the codebase.
537
- *
538
- * @see https://eslint.org/docs/rules/no-void
539
- * @see https://typescript-eslint.io/rules/no-floating-promises
540
- */
541
- "no-void": "off",
542
- "no-unused-expressions": "off",
543
- "@typescript-eslint/no-unused-expressions": "error",
544
- "@typescript-eslint/no-floating-promises": ["error", {
545
- ignoreVoid: !0,
546
- ignoreIIFE: !0
547
- }],
548
- /**
549
- * Sort imports alphabetically and group them without newlines. This rule
550
- * aims to maintain consistency around the order of imports in JavaScript
551
- * files. Helps reduce the visual noise in the codebase.
552
- *
553
- * @see https://typescript-eslint.io/rules/consistent-type-imports
554
- * @see https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
555
- */
556
- "sort-imports": "off",
557
- "@typescript-eslint/consistent-type-imports": ["error", {
558
- disallowTypeAnnotations: !1,
559
- prefer: "type-imports",
560
- fixStyle: "separate-type-imports"
561
- }],
562
- "perfectionist/sort-exports": ["error", {
563
- type: "alphabetical",
564
- ignoreCase: !0
565
- }],
566
- "perfectionist/sort-named-imports": ["error", {
567
- type: "alphabetical",
568
- ignoreCase: !0
569
- }],
570
- "perfectionist/sort-imports": ["error", {
571
- newlinesBetween: "never",
572
- order: "asc",
573
- ignoreCase: !0,
574
- groups: [
575
- "type",
576
- "internal-type",
577
- ["parent-type", "sibling-type", "index-type"],
578
- ["builtin", "external"],
579
- "internal",
580
- ["parent", "sibling", "index"],
581
- "object",
582
- "unknown"
583
- ]
584
- }],
585
- /**
586
- * Sort types and union types alphabetically. This rule aims to maintain
587
- * consistency around the order of types in TypeScript files. Helps reduce
588
- * the visual noise in the codebase.
589
- *
590
- * @see https://perfectionist.dev/rules/sort-union-types
591
- */
592
- "@typescript-eslint/sort-type-constituents": "off",
593
- "perfectionist/sort-intersection-types": ["error", {
594
- type: "natural"
595
- }],
596
- "perfectionist/sort-union-types": ["error", {
597
- type: "natural",
598
- ignoreCase: !1
599
- }],
600
- /**
601
- * Enforce no unused variables. Helps keep the codebase clean and reduces
602
- * the chance of bugs from side-effects.
603
- *
604
- * @see https://typescript-eslint.io/rules/@typescript-eslint/no-unused-vars
605
- */
606
- "no-redeclare": "off",
607
- "no-unused-vars": "off",
608
- "@typescript-eslint/no-redeclare": "error",
609
- "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
610
- //////////////////////////////////////////////////////////////////////////////////////////
611
- "no-useless-constructor": "off",
612
- "@typescript-eslint/ban-types": "off",
613
- "@typescript-eslint/camelcase": "off",
614
- "@typescript-eslint/explicit-function-return-type": "off",
615
- "@typescript-eslint/explicit-member-accessibility": "off",
616
- "@typescript-eslint/explicit-module-boundary-types": "off",
617
- "@typescript-eslint/no-empty-function": "off",
618
- "@typescript-eslint/no-empty-interface": "off",
619
- "@typescript-eslint/no-explicit-any": "off",
620
- "@typescript-eslint/no-namespace": "off",
621
- "@typescript-eslint/no-non-null-assertion": "off",
622
- "@typescript-eslint/no-parameter-properties": "off",
623
- "array-callback-return": "error",
624
- "arrow-body-style": ["error", "as-needed"],
625
- "arrow-parens": ["error", "as-needed", { requireForBlockBody: !0 }],
626
- "block-scoped-var": "error",
627
- camelcase: "off",
628
- "comma-style": ["error", "last"],
629
- complexity: ["off", 11],
630
- "consistent-return": "off",
631
- curly: ["error", "multi-or-nest", "consistent"],
632
- eqeqeq: ["error", "smart"],
633
- "no-alert": "error",
634
- "no-case-declarations": "error",
635
- "no-cond-assign": ["error", "always"],
636
- "no-confusing-arrow": "error",
637
- "no-console": ["warn", { allow: ["warn", "error"] }],
638
- "no-constant-condition": "error",
639
- "no-debugger": "error",
640
- "no-eval": "error",
641
- "no-implied-eval": "error",
642
- "no-multi-str": "error",
643
- "no-param-reassign": "off",
644
- "no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
645
- "no-return-assign": "off",
646
- "no-return-await": "off",
647
- "no-trailing-spaces": "error",
648
- "no-useless-escape": "off",
649
- "no-var": "error",
650
- "no-with": "error",
651
- "object-shorthand": ["error", "always", { avoidQuotes: !0, ignoreConstructors: !1 }],
652
- "one-var-declaration-per-line": "error",
653
- "operator-linebreak": ["error", "before"],
654
- "prefer-arrow-callback": ["error", { allowNamedFunctions: !1, allowUnboundThis: !0 }],
655
- "prefer-const": ["error", { destructuring: "any", ignoreReadBeforeAssign: !0 }],
656
- "prefer-rest-params": "error",
657
- "prefer-spread": "error",
658
- "prefer-template": "error",
659
- "quote-props": ["error", "consistent-as-needed"],
660
- quotes: ["error", "single"],
661
- "require-await": "off",
662
- "space-before-function-paren": ["error", "never"],
663
- "vars-on-top": "error"
664
- }
665
- },
666
- /**
667
- * Ignore duplicate imports in declaration files as they are often used to re-export
668
- * types from other packages into multiple namespaces. This is a common pattern
669
- * in TypeScript declaration files.
670
- */
671
- {
672
- files: ["*.d.ts"],
673
- rules: {
674
- "@typescript-eslint/no-use-before-define": "off",
675
- "import/no-duplicates": "off"
676
- }
677
- },
678
- /**
679
- * Allow console statements in scripts and CLI files since they are not part of the
680
- * library / production code and are useful for debugging, logging, and testing.
681
- */
682
- {
683
- files: ["**/scripts/**/*", "cli.*"],
684
- rules: {
685
- "no-console": "off"
686
- }
687
- }
688
- ];
689
- }
690
- function unicorn() {
691
- return [
692
- unicornPlugin.configs["flat/recommended"],
693
- {
694
- rules: {
695
- // --- Allow any kind of import style.
696
- "unicorn/import-style": "off",
697
- // --- Improve regexes by making them shorter, consistent, and safer.
698
- "unicorn/better-regex": "error",
699
- // --- Use destructured variables over properties.
700
- "unicorn/consistent-destructuring": "error",
701
- // --- Enforce consistent function scoping except for arrow functions.
702
- "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: !1 }],
703
- // --- Disable switch-case fallthrough.
704
- "unicorn/prefer-switch": "off",
705
- // --- Enforce camelCase & PascalCase in filenames. Exepct non TS/JS files.
706
- "unicorn/filename-case": ["error", {
707
- multipleFileExtensions: !1,
708
- cases: { camelCase: !0, pascalCase: !0 },
709
- ignore: [/\.json$/, /\.md$/, /\.yml$/, /\.yaml$/]
710
- }],
711
- // --- Improve readability by using numeric separators.
712
- "unicorn/numeric-separators-style": ["error", {
713
- onlyIfContainsSeparator: !0
714
- }],
715
- // --- Enforce long variable names when they are meaningful.
716
- "unicorn/prevent-abbreviations": ["error", {
717
- allowList: {
718
- args: !0,
719
- dir: !0,
720
- fn: !0,
721
- i: !0,
722
- j: !0,
723
- k: !0,
724
- ref: !0,
725
- Ref: !0,
726
- props: !0,
727
- Props: !0,
728
- v: !0,
729
- x: !0,
730
- y: !0,
731
- z: !0
732
- }
733
- }]
734
- }
735
- },
736
- {
737
- files: [
738
- "**/*.test.ts",
739
- "**/*.spec.ts"
740
- ],
741
- rules: {
742
- // --- Disable unnecessary rules for test files.
743
- "unicorn/no-null": "off",
744
- "unicorn/no-useless-undefined": "off",
745
- "unicorn/no-static-only-class": "off"
746
- }
747
- }
748
- ];
749
- }
750
- function vitest() {
751
- return [
752
- vitestPlugin.configs.recommended,
753
- {
754
- rules: {
755
- // --- Add the `expectTypeOf` function to the list of assert functions.
756
- "vitest/expect-expect": ["error", {
757
- assertFunctionNames: ["expect", "expectTypeOf"]
758
- }],
759
- // --- Enforce a single top-level describe block.
760
- "vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 1 }],
761
- // --- Enforce 'should' as the prefix for test titles.
762
- "vitest/valid-title": ["error", {
763
- ignoreTypeOfDescribeName: !0,
764
- mustMatch: { test: ["^should"] }
765
- }],
766
- // --- Prefer strict equality checks.
767
- "vitest/prefer-to-be-truthy": "off",
768
- "vitest/prefer-to-be-falsy": "off",
769
- /// --- Loosen the rules for test files.
770
- "vitest/no-hooks": "off",
771
- "vitest/require-hook": "off",
772
- "vitest/no-conditional-in-test": "off",
773
- "vitest/no-conditional-tests": "off",
774
- "vitest/prefer-expect-assertions": "off",
775
- "vitest/padding-around-all": "off",
776
- "vitest/padding-around-expect-groups": "off"
777
- }
778
- }
779
- ];
780
- }
781
- function vue(options) {
782
- const TYPESCRIPT_CONFIG = typescript(options).at(1);
783
- return [
784
- ...vuePlugin.configs["flat/recommended"],
785
- {
786
- plugins: {
787
- vue: vuePlugin,
788
- ...TYPESCRIPT_CONFIG.plugins
789
- },
790
- languageOptions: {
791
- globals: {
792
- computed: "readonly",
793
- defineEmits: "readonly",
794
- defineExpose: "readonly",
795
- defineProps: "readonly",
796
- onMounted: "readonly",
797
- onUnmounted: "readonly",
798
- reactive: "readonly",
799
- ref: "readonly",
800
- shallowReactive: "readonly",
801
- shallowRef: "readonly",
802
- toRef: "readonly",
803
- toRefs: "readonly",
804
- watch: "readonly",
805
- watchEffect: "readonly"
806
- },
807
- parser: vueParser,
808
- parserOptions: {
809
- parser: tslint.parser,
810
- extraFileExtensions: [".vue"],
811
- ...TYPESCRIPT_CONFIG.languageOptions.parserOptions
812
- }
813
- },
814
- processor: eslintMergeProcessors.mergeProcessors([
815
- vuePlugin.processors.vue,
816
- vueProcessorBlocks()
817
- ]),
818
- files: [
819
- "**/*.vue",
820
- "**/*.ts"
821
- ],
822
- rules: {
823
- "vue/return-in-computed-property": "off",
824
- // --- Allow multiple component definitions in a single file.
825
- "vue/one-component-per-file": "off",
826
- // --- Enforce Component API style.
827
- "vue/prefer-define-options": "error",
828
- "vue/component-api-style": ["error", ["script-setup", "composition"]],
829
- // --- Enforce PascalCase components and allow reserved and single-word names.
830
- "vue/multi-word-component-names": "off",
831
- "vue/no-reserved-component-names": "off",
832
- "vue/component-name-in-template-casing": ["error", "PascalCase", {
833
- ignores: [String.raw`/\./`],
834
- registeredComponentsOnly: !1
835
- }],
836
- // --- Consistent spacing around HTML comments.
837
- "vue/html-comment-indent": ["error", 2],
838
- "vue/multiline-html-element-content-newline": ["error", {
839
- allowEmptyLines: !0,
840
- ignores: [],
841
- ignoreWhenEmpty: !0
842
- }],
843
- "vue/html-comment-content-spacing": ["error", "always"],
844
- "vue/html-comment-content-newline": ["error", {
845
- multiline: "always",
846
- singleline: "never"
847
- }],
848
- // --- Consistent block order in Vue components.
849
- "vue/block-order": ["error", { order: ["script", "template", "style", "i18n"] }],
850
- // --- Consistent spacing in and around the block.
851
- "vue/block-spacing": ["error", "always"],
852
- "vue/padding-line-between-blocks": ["error", "always"],
853
- "vue/padding-line-between-tags": ["error", [
854
- { blankLine: "consistent", next: "*", prev: "*" },
855
- { blankLine: "always", next: "*", prev: "comment" }
856
- ]],
857
- /**
858
- * Enforce consistent spacing and newlines in the template. This rule helps
859
- * to maintain consistency and readability by enforcing a predictable
860
- *
861
- * @see https://eslint.vuejs.org/rules/html-indent.html
862
- * @see https://eslint.vuejs.org/rules/max-attributes-per-line.html
863
- * @see https://eslint.vuejs.org/rules/html-closing-bracket-newline.html
864
- */
865
- "vue/html-indent": ["error", 2, {
866
- alignAttributesVertically: !0,
867
- attribute: 1,
868
- baseIndent: 1,
869
- closeBracket: 0,
870
- ignores: []
871
- }],
872
- // 'vue/func-call-spacing': ['off', 'never'],
873
- "vue/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
874
- "vue/keyword-spacing": ["error", { after: !0, before: !0 }],
875
- "vue/max-attributes-per-line": ["error", {
876
- multiline: { max: 1 },
877
- singleline: { max: 5 }
878
- }],
879
- /**
880
- * Allow single-word component names. This rule is disabled because we use
881
- * pascal-casing to distinguish between components and HTML elements.
882
- *
883
- * @see https://eslint.vuejs.org/rules/multi-word-component-names.html
884
- */
885
- /**
886
- * Reports the destructuring or member expression of props passed to setup
887
- * causing the value to lose reactivity. This rule helps to avoid common
888
- * pitfalls when using the Composition API.
889
- *
890
- * @see https://eslint.vuejs.org/rules/no-setup-props-reactivity-loss.html
891
- */
892
- "vue/no-setup-props-reactivity-loss": "error",
893
- /**
894
- * Disallow v-if in v-for. This rule helps to avoid common pitfalls when
895
- * using v-if and v-for together in the same element.
896
- *
897
- * @see https://eslint.vuejs.org/rules/no-use-v-if-with-v-for.html
898
- */
899
- "vue/no-use-v-if-with-v-for": "error",
900
- /**
901
- * Enforce the declaration of emits in the setup function and warn on unused
902
- * emits declarations. This rule helps reduce the risk stale code.
903
- *
904
- * @see https://eslint.vuejs.org/rules/require-explicit-emits.html
905
- * @see https://eslint.vuejs.org/rules/no-unused-emit-declarations.html
906
- */
907
- "vue/require-explicit-emits": "error",
908
- /**
909
- * Enforce the `@` shorthand over `v-on:` and only allow inline callbacks.
910
- * This rule helps to maintain consistency and readability by enforcing a
911
- * predictable order of the event handlers in the component.
912
- *
913
- * @see https://eslint.vuejs.org/rules/v-on-style.html
914
- * @see https://eslint.vuejs.org/rules/v-on-handler-style.html
915
- */
916
- "vue/v-on-style": ["error", "shorthand"],
917
- "vue/v-on-handler-style": ["error", "inline-function"],
918
- /**
919
- * Sort the vue attributes in a consistent order. This rule helps to maintain
920
- * consistency and readability by enforcing a predictable order of the
921
- * attributes in the component.
922
- *
923
- * @see https://eslint.vuejs.org/rules/attributes-order.html
924
- */
925
- "vue/attributes-order": ["error", {
926
- order: [
927
- "DEFINITION",
928
- "LIST_RENDERING",
929
- "CONDITIONALS",
930
- "RENDER_MODIFIERS",
931
- "GLOBAL",
932
- ["UNIQUE", "SLOT"],
933
- "TWO_WAY_BINDING",
934
- "OTHER_DIRECTIVES",
935
- "OTHER_ATTR",
936
- "EVENTS",
937
- "CONTENT"
938
- ],
939
- alphabetical: !1
940
- }],
941
- /**
942
- * Enforce consistent spacing around attribute assignments. This ensures that
943
- * the code is easier to read and maintain.
944
- *
945
- * @see https://eslint.vuejs.org/rules/no-spaces-around-equal-signs-in-attribute.html
946
- */
947
- "vue/no-spaces-around-equal-signs-in-attribute": "error",
948
- "vue/no-multi-spaces": "error",
949
- /**
950
- * Enforce the use of the `ts` lang attribute in the script block. This rule
951
- * explicitly dissallows the use of the `js` lang attribute in the script.
952
- */
953
- "vue/block-lang": ["error", {
954
- script: { lang: "ts" }
955
- }],
956
- "vue/no-sparse-arrays": "error",
957
- "vue/no-unused-emit-declarations": "error",
958
- "vue/no-use-v-else-with-v-for": "error",
959
- "vue/no-useless-v-bind": "error",
960
- "vue/no-v-html": "off",
961
- "vue/no-v-text-v-html-on-component": "error",
962
- "vue/object-curly-newline": ["error", { consistent: !0, multiline: !0 }],
963
- "vue/object-curly-spacing": ["error", "always"],
964
- "vue/object-shorthand": [
965
- "error",
966
- "always",
967
- {
968
- avoidQuotes: !0,
969
- ignoreConstructors: !1
970
- }
971
- ],
972
- "vue/operator-linebreak": ["error", "before"],
973
- "vue/prefer-import-from-vue": "off",
974
- "vue/prefer-separate-static-class": "error",
975
- "vue/prefer-template": "error",
976
- "vue/quote-props": ["error", "consistent-as-needed"],
977
- "vue/require-default-prop": "off",
978
- // reactivity transform
979
- "vue/block-tag-newline": ["error", {
980
- multiline: "always",
981
- singleline: "always"
982
- }],
983
- // extensions
984
- "vue/array-bracket-spacing": ["error", "never"],
985
- "vue/arrow-spacing": ["error", { after: !0, before: !0 }],
986
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
987
- "vue/comma-dangle": ["error", "always-multiline"],
988
- "vue/comma-spacing": ["error", { after: !0, before: !1 }],
989
- "vue/comma-style": ["error", "last"],
990
- "vue/component-options-name-casing": ["error", "PascalCase"],
991
- "vue/custom-event-name-casing": ["error", "camelCase"],
992
- "vue/define-macros-order": ["error", {
993
- order: ["defineProps", "defineEmits"]
994
- }],
995
- "vue/dot-location": ["error", "property"],
996
- "vue/dot-notation": ["error", { allowKeywords: !0 }],
997
- "vue/eqeqeq": ["error", "smart"],
998
- "vue/first-attribute-linebreak": ["error", {
999
- multiline: "below",
1000
- singleline: "beside"
1001
- }],
1002
- "vue/html-closing-bracket-newline": ["error", {
1003
- multiline: "never",
1004
- selfClosingTag: {
1005
- multiline: "always",
1006
- singleline: "never"
1007
- },
1008
- singleline: "never"
1009
- }],
1010
- "vue/no-constant-condition": "warn",
1011
- "vue/no-empty-pattern": "error",
1012
- "vue/no-extra-parens": ["error", "functions"],
1013
- "vue/no-irregular-whitespace": "error",
1014
- "vue/no-loss-of-precision": "error",
1015
- "vue/no-restricted-syntax": [
1016
- "error",
1017
- "DebuggerStatement",
1018
- "LabeledStatement",
1019
- "WithStatement"
1020
- ],
1021
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1022
- "vue/require-prop-types": "off",
1023
- "vue/space-in-parens": ["error", "never"],
1024
- "vue/space-infix-ops": "error",
1025
- "vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
1026
- "vue/template-curly-spacing": "error"
1027
- }
1028
- },
1029
- // --- Disable some TypeScript rules that may conflict with the Vue SFC parser.
1030
- {
1031
- files: [
1032
- "**/*.vue"
1033
- ],
1034
- rules: {
1035
- "@typescript-eslint/no-unsafe-call": "off",
1036
- "@typescript-eslint/no-unsafe-return": "off",
1037
- "@typescript-eslint/no-unsafe-argument": "off",
1038
- "@typescript-eslint/no-unsafe-assignment": "off",
1039
- "@typescript-eslint/no-unsafe-member-access": "off",
1040
- "@typescript-eslint/no-misused-promises": "off"
1041
- }
1042
- },
1043
- // --- Disable in test files.
1044
- {
1045
- files: [
1046
- "**/*.test.ts",
1047
- "**/*.spec.ts"
1048
- ],
1049
- rules: {
1050
- "vue/one-component-per-file": "off"
1051
- }
1052
- }
1053
- ];
1054
- }
1055
- function yml() {
1056
- return [
1057
- ...pluginYml.configs["flat/standard"],
1058
- ...pluginYml.configs["flat/recommended"],
1059
- {
1060
- rules: {
1061
- // --- Force single quotes.
1062
- "yml/quotes": ["error", {
1063
- avoidEscape: !0,
1064
- prefer: "single"
1065
- }],
1066
- // --- Remove trailing zeros in numbers.
1067
- "yml/no-trailing-zeros": "error",
1068
- // --- Prevent empty keys.
1069
- "yml/require-string-key": "error",
1070
- // --- Prevent empty values or weird newlines in mappings.
1071
- "yml/block-mapping-colon-indicator-newline": "error",
1072
- // --- No more than one empty line.
1073
- "yml/no-multiple-empty-lines": ["error", {
1074
- max: 1,
1075
- maxBOF: 0,
1076
- maxEOF: 0
1077
- }],
1078
- // --- Sort environemnt variables alphabetically.
1079
- "yml/sort-sequence-values": ["error", {
1080
- pathPattern: "^env$",
1081
- order: { type: "asc" }
1082
- }]
1083
- }
1084
- }
1085
- ];
1086
- }
1087
- function all(options = {}) {
1088
- return [
1089
- ...antfu(),
1090
- ...eslintComments(),
1091
- ...jsdoc(),
1092
- ...json(),
1093
- ...jsonPackage(),
1094
- ...jsonTsconfig(),
1095
- ...node(),
1096
- ...sonarjs(),
1097
- ...typescript(options),
1098
- ...unicorn(),
1099
- ...vitest(),
1100
- ...vue(options),
1101
- ...yml(),
1102
- {
1103
- ignores: [
1104
- "**/dist",
1105
- "**/bin",
1106
- "**/node_modules",
1107
- "**/.nuxt",
1108
- "**/.output",
1109
- "**/coverage",
1110
- "**/public",
1111
- "**/__wip__",
1112
- "**/__snapshots__",
1113
- "**/LICENSE*",
1114
- "**/CHANGELOG*",
1115
- "packages-lock.json",
1116
- "pnpm-lock.yaml",
1117
- "yarn.lock"
1118
- ]
1119
- }
1120
- ];
1121
- }
1122
- module.exports = all;
2
+ var configs = require("./configs.cjs");
3
+ require("eslint-plugin-antfu");
4
+ require("eslint-plugin-eslint-comments");
5
+ require("eslint-plugin-jsdoc");
6
+ require("eslint-plugin-jsonc");
7
+ require("eslint-plugin-n");
8
+ require("eslint-plugin-sonarjs");
9
+ require("@eslint/js");
10
+ require("@stylistic/eslint-plugin");
11
+ require("@unshared/collection/toArray");
12
+ require("eslint-plugin-perfectionist");
13
+ require("typescript-eslint");
14
+ require("./utils.cjs");
15
+ require("eslint-plugin-unicorn");
16
+ require("@vitest/eslint-plugin");
17
+ require("eslint-merge-processors");
18
+ require("eslint-plugin-vue");
19
+ require("eslint-processor-vue-blocks");
20
+ require("vue-eslint-parser");
21
+ require("eslint-plugin-yml");
22
+ module.exports = configs.all;
1123
23
  //# sourceMappingURL=index.cjs.map