@so1ve/eslint-config 2.0.0 → 3.0.0

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.mjs DELETED
@@ -1,1633 +0,0 @@
1
- import pluginComments from '@eslint-community/eslint-plugin-eslint-comments';
2
- export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
3
- import pluginHtml from '@html-eslint/eslint-plugin';
4
- export { default as pluginHtml } from '@html-eslint/eslint-plugin';
5
- import parserHtml from '@html-eslint/parser';
6
- export { default as parserHtml } from '@html-eslint/parser';
7
- import pluginSo1ve from '@so1ve/eslint-plugin';
8
- export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
9
- import pluginSortImports from '@so1ve/eslint-plugin-sort-imports';
10
- export { default as pluginSortImports } from '@so1ve/eslint-plugin-sort-imports';
11
- import pluginStylistic from '@stylistic/eslint-plugin';
12
- export { default as pluginStylistic } from '@stylistic/eslint-plugin';
13
- export { default as parserMdx } from 'eslint-mdx';
14
- import pluginArrayFunc from 'eslint-plugin-array-func';
15
- export { default as pluginArrayFunc } from 'eslint-plugin-array-func';
16
- import pluginEtc from 'eslint-plugin-etc';
17
- export { default as pluginEtc } from 'eslint-plugin-etc';
18
- import pluginHtmlJsSupport from 'eslint-plugin-html';
19
- export { default as pluginHtmlJsSupport } from 'eslint-plugin-html';
20
- import pluginImport from 'eslint-plugin-i';
21
- export { default as pluginImport } from 'eslint-plugin-i';
22
- import pluginJestFormatting from 'eslint-plugin-jest-formatting';
23
- export { default as pluginJestFormatting } from 'eslint-plugin-jest-formatting';
24
- import pluginJsonSchemaValidator from 'eslint-plugin-json-schema-validator';
25
- export { default as pluginJsonSchemaValidator } from 'eslint-plugin-json-schema-validator';
26
- import pluginJsonc from 'eslint-plugin-jsonc';
27
- export { default as pluginJsonc } from 'eslint-plugin-jsonc';
28
- import pluginMdx from 'eslint-plugin-mdx';
29
- export { default as pluginMdx } from 'eslint-plugin-mdx';
30
- import pluginNode from 'eslint-plugin-n';
31
- export { default as pluginNode } from 'eslint-plugin-n';
32
- import * as pluginNoAwaitInPromise from 'eslint-plugin-no-await-in-promise';
33
- export { pluginNoAwaitInPromise };
34
- import pluginNoOnlyTests from 'eslint-plugin-no-only-tests';
35
- export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
36
- import pluginOnlyError from 'eslint-plugin-only-error';
37
- export { default as pluginOnlyError } from 'eslint-plugin-only-error';
38
- import pluginPromise from 'eslint-plugin-promise';
39
- export { default as pluginPromise } from 'eslint-plugin-promise';
40
- import pluginRegexp from 'eslint-plugin-regexp';
41
- export { default as pluginRegexp } from 'eslint-plugin-regexp';
42
- import pluginSolid from 'eslint-plugin-solid';
43
- export { default as pluginSolid } from 'eslint-plugin-solid';
44
- import pluginToml from 'eslint-plugin-toml';
45
- export { default as pluginToml } from 'eslint-plugin-toml';
46
- import pluginUnicorn from 'eslint-plugin-unicorn';
47
- export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
48
- import pluginUnusedImports from 'eslint-plugin-unused-imports';
49
- export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
50
- import pluginVitest from 'eslint-plugin-vitest';
51
- export { default as pluginVitest } from 'eslint-plugin-vitest';
52
- import pluginVue from 'eslint-plugin-vue';
53
- export { default as pluginVue } from 'eslint-plugin-vue';
54
- import pluginYaml from 'eslint-plugin-yml';
55
- export { default as pluginYaml } from 'eslint-plugin-yml';
56
- import parserJsonc from 'jsonc-eslint-parser';
57
- export { default as parserJsonc } from 'jsonc-eslint-parser';
58
- import parserToml from 'toml-eslint-parser';
59
- export { default as parserToml } from 'toml-eslint-parser';
60
- import parserVue from 'vue-eslint-parser';
61
- export { default as parserVue } from 'vue-eslint-parser';
62
- import parserYaml from 'yaml-eslint-parser';
63
- export { default as parserYaml } from 'yaml-eslint-parser';
64
- import globals from 'globals';
65
- import tseslint from 'typescript-eslint';
66
- import fs from 'node:fs';
67
- import gitignore from 'eslint-config-flat-gitignore';
68
- import { isPackageExists } from 'local-pkg';
69
-
70
- const comments = () => [
71
- {
72
- plugins: {
73
- "eslint-comments": pluginComments
74
- }
75
- },
76
- {
77
- rules: {
78
- "eslint-comments/no-aggregating-enable": "error",
79
- "eslint-comments/no-duplicate-disable": "error",
80
- "eslint-comments/no-unused-enable": "error",
81
- "eslint-comments/disable-enable-pair": "off",
82
- "eslint-comments/no-unlimited-disable": "off"
83
- }
84
- }
85
- ];
86
-
87
- const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
88
- const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
89
- const GLOB_JS = "**/*.?([cm])js";
90
- const GLOB_JSX = "**/*.?([cm])jsx";
91
- const GLOB_TS = "**/*.?([cm])ts";
92
- const GLOB_TSX = "**/*.?([cm])tsx";
93
- const GLOB_DTS = "**/*.d.?([cm])tsx";
94
- const GLOB_STYLE = "**/*.{c,le,sc}ss";
95
- const GLOB_CSS = "**/*.css";
96
- const GLOB_LESS = "**/*.less";
97
- const GLOB_SCSS = "**/*.scss";
98
- const GLOB_JSON = "**/*.json";
99
- const GLOB_JSON5 = "**/*.json5";
100
- const GLOB_JSONC = "**/*.jsonc";
101
- const GLOB_ESLINTRC = "**/.eslintrc";
102
- const GLOB_MARKDOWN = "**/*.md?(x)";
103
- const GLOB_VUE = "**/*.vue";
104
- const GLOB_YAML = "**/*.y?(a)ml";
105
- const GLOB_TOML = "**/*.toml";
106
- const GLOB_HTML = "**/*.htm?(l)";
107
- const GLOB_PACKAGEJSON = "**/package.json";
108
- const GLOB_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
109
- const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
110
- const GLOB_TESTS = [
111
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
112
- `**/*.spec.${GLOB_SRC_EXT}`,
113
- `**/*.test.${GLOB_SRC_EXT}`,
114
- `**/*.bench.${GLOB_SRC_EXT}`,
115
- `**/*.benchmark.${GLOB_SRC_EXT}`
116
- ];
117
- const GLOB_ALL_SRC = [
118
- GLOB_SRC,
119
- GLOB_STYLE,
120
- GLOB_JSON,
121
- GLOB_JSON5,
122
- GLOB_ESLINTRC,
123
- GLOB_MARKDOWN,
124
- GLOB_VUE,
125
- GLOB_YAML,
126
- GLOB_HTML
127
- ];
128
- const GLOB_EXCLUDE = [
129
- "**/node_modules",
130
- "**/dist",
131
- "**/out",
132
- "**/output",
133
- "**/package-lock.json",
134
- "**/yarn.lock",
135
- "**/pnpm-lock.yaml",
136
- "**/bun.lockb",
137
- "**/coverage",
138
- "**/temp",
139
- "**/.vitepress/cache",
140
- "**/.nuxt",
141
- "**/.nitro",
142
- "**/.vercel",
143
- "**/.netlify",
144
- "**/.output",
145
- "**/.vercel",
146
- "**/.changeset",
147
- "**/.idea",
148
- "**/.vite-inspect",
149
- "**/.yarn",
150
- "**/CHANGELOG*.md",
151
- "**/*.min.*",
152
- "**/LICENSE*",
153
- "**/__snapshots__",
154
- "**/auto-import?(s).d.ts",
155
- "**/components.d.ts",
156
- // Volar
157
- "**/*.vue.js",
158
- "**/*.vue.jsx",
159
- "**/*.vue.ts",
160
- "**/*.vue.tsx"
161
- ];
162
-
163
- const formatting = (options) => {
164
- var _a, _b;
165
- return [
166
- {
167
- plugins: {
168
- style: pluginStylistic
169
- }
170
- },
171
- {
172
- rules: {
173
- "curly": ["error", "all"],
174
- "so1ve/no-useless-template-string": "error",
175
- "so1ve/no-negated-comparison": "error",
176
- "so1ve/no-import-promises-as": "error",
177
- "so1ve/pad-after-last-import": "error",
178
- "so1ve/function-style": "error",
179
- "style/quote-props": ["error", "consistent-as-needed"],
180
- "style/padding-line-between-statements": [
181
- "error",
182
- { blankLine: "always", prev: "*", next: "return" }
183
- ]
184
- }
185
- },
186
- ((_a = options.jsonc) != null ? _a : true) && [
187
- {
188
- files: [GLOB_PACKAGEJSON],
189
- rules: {
190
- "jsonc/sort-keys": [
191
- "error",
192
- {
193
- pathPattern: "^exports$",
194
- order: { type: "asc" }
195
- },
196
- {
197
- pathPattern: "^exports.*$",
198
- order: ["types", "require", "import", "default"]
199
- }
200
- ]
201
- }
202
- },
203
- {
204
- files: GLOB_TSCONFIG,
205
- rules: {
206
- "jsonc/sort-keys": [
207
- "error",
208
- {
209
- order: [
210
- "extends",
211
- "compilerOptions",
212
- "references",
213
- "files",
214
- "include",
215
- "exclude"
216
- ],
217
- pathPattern: "^$"
218
- },
219
- {
220
- order: [
221
- /* Projects */
222
- "incremental",
223
- "composite",
224
- "tsBuildInfoFile",
225
- "disableSourceOfProjectReferenceRedirect",
226
- "disableSolutionSearching",
227
- "disableReferencedProjectLoad",
228
- /* Language and Environment */
229
- "target",
230
- "jsx",
231
- "jsxFactory",
232
- "jsxFragmentFactory",
233
- "jsxImportSource",
234
- "lib",
235
- "moduleDetection",
236
- "noLib",
237
- "reactNamespace",
238
- "useDefineForClassFields",
239
- "emitDecoratorMetadata",
240
- "experimentalDecorators",
241
- /* Modules */
242
- "baseUrl",
243
- "rootDir",
244
- "rootDirs",
245
- "customConditions",
246
- "module",
247
- "moduleResolution",
248
- "moduleSuffixes",
249
- "noResolve",
250
- "resolveJsonModule",
251
- "resolvePackageJsonExports",
252
- "resolvePackageJsonImports",
253
- "typeRoots",
254
- "types",
255
- "allowArbitraryExtensions",
256
- "allowImportingTsExtensions",
257
- "allowUmdGlobalAccess",
258
- /* JavaScript Support */
259
- "allowJs",
260
- "checkJs",
261
- "maxNodeModuleJsDepth",
262
- /* Type Checking */
263
- "strict",
264
- "strictBindCallApply",
265
- "strictFunctionTypes",
266
- "strictNullChecks",
267
- "strictPropertyInitialization",
268
- "allowUnreachableCode",
269
- "allowUnusedLabels",
270
- "alwaysStrict",
271
- "exactOptionalPropertyTypes",
272
- "noFallthroughCasesInSwitch",
273
- "noImplicitAny",
274
- "noImplicitOverride",
275
- "noImplicitReturns",
276
- "noImplicitThis",
277
- "noPropertyAccessFromIndexSignature",
278
- "noUncheckedIndexedAccess",
279
- "noUnusedLocals",
280
- "noUnusedParameters",
281
- "useUnknownInCatchVariables",
282
- /* Emit */
283
- "declaration",
284
- "declarationDir",
285
- "declarationMap",
286
- "downlevelIteration",
287
- "emitBOM",
288
- "emitDeclarationOnly",
289
- "importHelpers",
290
- "importsNotUsedAsValues",
291
- "inlineSourceMap",
292
- "inlineSources",
293
- "mapRoot",
294
- "newLine",
295
- "noEmit",
296
- "noEmitHelpers",
297
- "noEmitOnError",
298
- "outDir",
299
- "outFile",
300
- "preserveConstEnums",
301
- "preserveValueImports",
302
- "removeComments",
303
- "sourceMap",
304
- "sourceRoot",
305
- "stripInternal",
306
- /* Interop Constraints */
307
- "allowSyntheticDefaultImports",
308
- "esModuleInterop",
309
- "forceConsistentCasingInFileNames",
310
- "isolatedModules",
311
- "preserveSymlinks",
312
- "verbatimModuleSyntax",
313
- /* Completeness */
314
- "skipDefaultLibCheck",
315
- "skipLibCheck",
316
- /* Alias */
317
- "paths"
318
- ],
319
- pathPattern: "^compilerOptions$"
320
- }
321
- ]
322
- }
323
- }
324
- ],
325
- ((_b = options.test) != null ? _b : true) && {
326
- files: GLOB_TESTS,
327
- rules: {
328
- "jest-formatting/padding-around-all": "error"
329
- }
330
- }
331
- ].flat().filter(Boolean);
332
- };
333
-
334
- const renameRules = (rules, from, to) => Object.fromEntries(
335
- Object.entries(rules).map(([key, value]) => {
336
- if (key.startsWith(from)) {
337
- return [to + key.slice(from.length), value];
338
- }
339
- return [key, value];
340
- })
341
- );
342
- const rulesOn = /* @__PURE__ */ new Set();
343
- const rulesOff = /* @__PURE__ */ new Set();
344
- function recordRulesStateConfigs(configs) {
345
- var _a;
346
- for (const config of configs) {
347
- recordRulesState((_a = config.rules) != null ? _a : {});
348
- }
349
- return configs;
350
- }
351
- function recordRulesState(rules) {
352
- for (const [key, value] of Object.entries(rules != null ? rules : {})) {
353
- const firstValue = Array.isArray(value) ? value[0] : value;
354
- if (firstValue == null) {
355
- continue;
356
- }
357
- if (firstValue === "off" || firstValue === 0) {
358
- rulesOff.add(key);
359
- } else {
360
- rulesOn.add(key);
361
- }
362
- }
363
- return rules;
364
- }
365
- function warnUnnecessaryOffRules() {
366
- const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
367
- for (const off of unnecessaryOffRules) {
368
- console.warn(
369
- `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
370
- );
371
- }
372
- }
373
-
374
- const html = () => [
375
- {
376
- plugins: {
377
- "html": pluginHtml,
378
- "html-js-support": pluginHtmlJsSupport
379
- }
380
- },
381
- {
382
- languageOptions: {
383
- parser: parserHtml
384
- },
385
- settings: {
386
- "html/report-bad-indent": "off"
387
- },
388
- files: [GLOB_HTML],
389
- rules: {
390
- ...renameRules(
391
- pluginHtml.configs.recommended.rules,
392
- "@html-eslint/",
393
- "html/"
394
- ),
395
- "html/indent": "off",
396
- "html/no-trailing-spaces": "off",
397
- "html/require-closing-tags": "off",
398
- "html/no-extra-spacing-attrs": "off",
399
- "html/quotes": "off"
400
- }
401
- }
402
- ];
403
-
404
- const ignores = () => [{ ignores: GLOB_EXCLUDE }];
405
-
406
- const imports = (options = {}) => [
407
- {
408
- plugins: {
409
- import: pluginImport
410
- }
411
- },
412
- {
413
- settings: {
414
- "import/parsers": {
415
- espree: [".js", ".cjs", ".mjs", ".jsx"]
416
- },
417
- "import/resolver": {
418
- ...options.typescript ? {
419
- node: {
420
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
421
- },
422
- typescript: {
423
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
424
- }
425
- } : {
426
- node: { extensions: [".js", ".mjs"] }
427
- }
428
- }
429
- },
430
- rules: {
431
- ...pluginImport.configs.recommended.rules,
432
- "import/first": "error",
433
- "import/no-mutable-exports": "error",
434
- "import/no-useless-path-segments": ["error", { noUselessIndex: true }],
435
- "import/no-unresolved": "off",
436
- "import/no-absolute-path": "off",
437
- "import/namespace": "off",
438
- // Disable this for better performance
439
- "import/export": "error",
440
- "import/no-duplicates": "error",
441
- "import/no-named-default": "error",
442
- "import/no-webpack-loader-syntax": "error",
443
- "import/no-named-as-default-member": "off"
444
- }
445
- },
446
- {
447
- files: [GLOB_DTS],
448
- rules: {
449
- "import/no-duplicates": "off"
450
- }
451
- }
452
- ];
453
-
454
- const javascript = ({
455
- overrides
456
- } = {}) => [
457
- {
458
- plugins: {
459
- "so1ve": pluginSo1ve,
460
- "unused-imports": pluginUnusedImports,
461
- "sort-imports": pluginSortImports,
462
- "array-func": pluginArrayFunc,
463
- "json-schema-validator": pluginJsonSchemaValidator,
464
- "regexp": pluginRegexp,
465
- "no-await-in-promise": pluginNoAwaitInPromise
466
- }
467
- },
468
- {
469
- languageOptions: {
470
- ecmaVersion: 2022,
471
- globals: {
472
- ...globals.browser,
473
- ...globals.es2021,
474
- ...globals.node,
475
- document: "readonly",
476
- navigator: "readonly",
477
- window: "readonly"
478
- },
479
- parserOptions: {
480
- ecmaFeatures: {
481
- jsx: true
482
- },
483
- ecmaVersion: 2022,
484
- sourceType: "module"
485
- },
486
- sourceType: "module"
487
- },
488
- linterOptions: {
489
- reportUnusedDisableDirectives: true
490
- },
491
- rules: {
492
- // Common
493
- "array-bracket-newline": "off",
494
- "array-element-newline": "off",
495
- "arrow-body-style": "off",
496
- "arrow-parens": "off",
497
- "dot-notation": ["error", { allowKeywords: true }],
498
- "function-call-argument-newline": "off",
499
- "function-paren-newline": "off",
500
- "generator-star": "off",
501
- "implicit-arrow-linebreak": "off",
502
- "indent": "off",
503
- "indent-legacy": "off",
504
- "jsx-quotes": "off",
505
- "linebreak-style": "off",
506
- "newline-per-chained-call": "off",
507
- "no-arrow-condition": "off",
508
- "no-comma-dangle": "off",
509
- "no-confusing-arrow": "off",
510
- "no-extra-semi": "off",
511
- "no-reserved-keys": "off",
512
- "no-spaced-func": "off",
513
- "no-space-before-semi": "off",
514
- "no-wrap-func": "off",
515
- "nonblock-statement-body-position": "off",
516
- "one-var-declaration-per-line": "off",
517
- "switch-colon-spacing": "off",
518
- "symbol-description": "off",
519
- "wrap-regex": "off",
520
- "unused-imports/no-unused-imports": "error",
521
- "unused-imports/no-unused-vars": [
522
- "error",
523
- {
524
- vars: "all",
525
- varsIgnorePattern: "^_",
526
- args: "after-used",
527
- argsIgnorePattern: "^_"
528
- }
529
- ],
530
- "accessor-pairs": [
531
- "error",
532
- { setWithoutGet: true, enforceForClassMembers: true }
533
- ],
534
- "constructor-super": "error",
535
- "default-case-last": "error",
536
- "lines-between-class-members": [
537
- "error",
538
- "always",
539
- { exceptAfterSingleLine: true }
540
- ],
541
- "new-cap": [
542
- "error",
543
- { newIsCap: true, capIsNew: false, properties: true }
544
- ],
545
- "no-array-constructor": "error",
546
- "no-async-promise-executor": "error",
547
- "no-caller": "error",
548
- "no-class-assign": "error",
549
- "no-compare-neg-zero": "error",
550
- "no-const-assign": "error",
551
- "no-control-regex": "error",
552
- "no-delete-var": "error",
553
- "no-dupe-args": "error",
554
- "no-dupe-class-members": "error",
555
- "no-dupe-keys": "error",
556
- "no-duplicate-case": "error",
557
- "no-useless-backreference": "error",
558
- "no-useless-call": "error",
559
- "no-useless-computed-key": "error",
560
- "no-useless-constructor": "error",
561
- "no-useless-rename": "error",
562
- "no-useless-return": "error",
563
- "no-void": "error",
564
- "no-empty": ["error", { allowEmptyCatch: true }],
565
- "no-empty-character-class": "error",
566
- "no-empty-pattern": "error",
567
- "no-eval": "error",
568
- "no-ex-assign": "error",
569
- "no-extend-native": "error",
570
- "no-extra-bind": "error",
571
- "no-extra-boolean-cast": "error",
572
- "no-extra-parens": ["error", "functions"],
573
- "no-fallthrough": "error",
574
- "no-func-assign": "error",
575
- "no-global-assign": "error",
576
- "no-implied-eval": "error",
577
- "no-import-assign": "error",
578
- "no-invalid-regexp": "error",
579
- "no-irregular-whitespace": "error",
580
- "no-iterator": "error",
581
- "no-labels": ["error", { allowLoop: true, allowSwitch: false }],
582
- "no-lone-blocks": "error",
583
- "no-loss-of-precision": "error",
584
- "no-misleading-character-class": "error",
585
- "no-new-func": "error",
586
- "no-new-object": "error",
587
- "no-new-symbol": "error",
588
- "no-new-wrappers": "error",
589
- "no-prototype-builtins": "error",
590
- "no-useless-catch": "error",
591
- "no-param-reassign": "off",
592
- "no-constant-condition": "error",
593
- "no-debugger": "error",
594
- "no-console": ["error", { allow: ["error", "warn", "table", "time"] }],
595
- "no-cond-assign": ["error", "always"],
596
- "no-restricted-syntax": [
597
- "error",
598
- "DebuggerStatement",
599
- "LabeledStatement",
600
- "WithStatement"
601
- ],
602
- "no-restricted-globals": [
603
- "error",
604
- { name: "global", message: "Use `globalThis` instead." },
605
- { name: "self", message: "Use `globalThis` instead." },
606
- { name: "isNaN", message: "Use `Number.isNaN` instead" },
607
- { name: "isFinite", message: "Use `Number.isFinite` instead" },
608
- { name: "parseFloat", message: "Use `Number.parseFloat` instead" },
609
- { name: "parseInt", message: "Use `Number.parseInt` instead" }
610
- ],
611
- "no-restricted-properties": [
612
- "error",
613
- {
614
- object: "globalThis",
615
- property: "isNaN",
616
- message: "Use `Number.isNaN` instead"
617
- },
618
- {
619
- object: "globalThis",
620
- property: "isFinite",
621
- message: "Use `Number.isFinite` instead"
622
- },
623
- {
624
- object: "globalThis",
625
- property: "parseFloat",
626
- message: "Use `Number.parseFloat` instead"
627
- },
628
- {
629
- object: "globalThis",
630
- property: "parseInt",
631
- message: "Use `Number.parseInt` instead"
632
- },
633
- {
634
- object: "window",
635
- property: "isNaN",
636
- message: "Use `Number.isNaN` instead"
637
- },
638
- {
639
- object: "window",
640
- property: "isFinite",
641
- message: "Use `Number.isFinite` instead"
642
- },
643
- {
644
- object: "window",
645
- property: "parseFloat",
646
- message: "Use `Number.parseFloat` instead"
647
- },
648
- {
649
- object: "window",
650
- property: "parseInt",
651
- message: "Use `Number.parseInt` instead"
652
- }
653
- ],
654
- "no-obj-calls": "error",
655
- "no-octal": "error",
656
- "no-octal-escape": "error",
657
- "no-proto": "error",
658
- "no-redeclare": ["error", { builtinGlobals: false }],
659
- "no-regex-spaces": "error",
660
- "no-self-assign": ["error", { props: true }],
661
- "no-self-compare": "error",
662
- "no-sequences": "error",
663
- "no-shadow-restricted-names": "error",
664
- "no-template-curly-in-string": "error",
665
- "no-this-before-super": "error",
666
- "no-throw-literal": "error",
667
- "no-undef": "error",
668
- "no-undef-init": "error",
669
- "no-unexpected-multiline": "error",
670
- "no-unmodified-loop-condition": "error",
671
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
672
- "no-unreachable": "error",
673
- "no-unreachable-loop": "error",
674
- "no-unsafe-finally": "error",
675
- "no-unsafe-negation": "error",
676
- "no-return-await": "off",
677
- // es6
678
- "no-var": "error",
679
- "prefer-const": [
680
- "error",
681
- {
682
- destructuring: "all",
683
- ignoreReadBeforeAssign: true
684
- }
685
- ],
686
- "prefer-arrow-callback": [
687
- "error",
688
- {
689
- allowNamedFunctions: false,
690
- allowUnboundThis: true
691
- }
692
- ],
693
- "one-var": ["error", "never"],
694
- "object-shorthand": [
695
- "error",
696
- "always",
697
- {
698
- ignoreConstructors: false
699
- }
700
- ],
701
- "prefer-exponentiation-operator": "error",
702
- "prefer-rest-params": "error",
703
- "prefer-spread": "error",
704
- "prefer-template": "error",
705
- "prefer-promise-reject-errors": "error",
706
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
707
- "yoda": ["error", "never"],
708
- "spaced-comment": [
709
- "error",
710
- "always",
711
- {
712
- line: {
713
- markers: ["/"],
714
- exceptions: ["/", "#"]
715
- },
716
- block: {
717
- markers: ["!"],
718
- exceptions: ["*"],
719
- balanced: true
720
- }
721
- }
722
- ],
723
- // best-practice
724
- "array-callback-return": "error",
725
- "block-scoped-var": "error",
726
- "no-unused-expressions": [
727
- "error",
728
- {
729
- allowShortCircuit: true,
730
- allowTernary: true,
731
- allowTaggedTemplates: true
732
- }
733
- ],
734
- "no-unused-vars": [
735
- "error",
736
- {
737
- args: "none",
738
- caughtErrors: "none",
739
- ignoreRestSiblings: true,
740
- vars: "all"
741
- }
742
- ],
743
- "no-use-before-define": [
744
- "error",
745
- { functions: false, classes: false, variables: true }
746
- ],
747
- "consistent-return": "off",
748
- "complexity": ["off", 11],
749
- "eqeqeq": ["error", "smart"],
750
- "no-alert": "error",
751
- "no-case-declarations": "error",
752
- "no-multi-str": "error",
753
- "no-with": "error",
754
- "no-invalid-this": "error",
755
- "vars-on-top": "error",
756
- "require-await": "off",
757
- "use-isnan": [
758
- "error",
759
- {
760
- enforceForSwitchCase: true,
761
- enforceForIndexOf: true
762
- }
763
- ],
764
- "valid-typeof": ["error", { requireStringLiterals: true }],
765
- // so1ve
766
- "so1ve/import-dedupe": "error",
767
- "so1ve/require-async-with-await": "error",
768
- // Sort Imports
769
- "sort-imports/imports": ["error"],
770
- "sort-imports/exports": "error",
771
- // array-func
772
- "array-func/prefer-array-from": "off",
773
- "array-func/prefer-flat": "off",
774
- // Handled by unicorn
775
- "array-func/from-map": "off",
776
- // Conflicts with unicorn/prefer-spread
777
- "array-func/no-unnecessary-this-arg": "error",
778
- "array-func/avoid-reverse": "error",
779
- "array-func/prefer-flat-map": "error",
780
- // json-schema-validator
781
- "json-schema-validator/no-invalid": "warn",
782
- // regexp
783
- "regexp/no-unused-capturing-group": "warn",
784
- // no-await-in-promise
785
- "no-await-in-promise/no-await-in-promise": "error",
786
- ...overrides
787
- }
788
- },
789
- {
790
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
791
- rules: {
792
- "no-console": "off"
793
- }
794
- }
795
- ];
796
-
797
- const jsonc = () => [
798
- {
799
- plugins: {
800
- jsonc: pluginJsonc
801
- }
802
- },
803
- {
804
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_ESLINTRC],
805
- languageOptions: {
806
- parser: parserJsonc
807
- },
808
- rules: {
809
- ...pluginJsonc.configs.base.overrides[0].rules,
810
- ...pluginJsonc.configs["recommended-with-jsonc"].rules,
811
- "jsonc/no-octal-escape": "error",
812
- "jsonc/quotes": "off",
813
- "jsonc/quotes-props": "off"
814
- }
815
- }
816
- ];
817
-
818
- const mdx = ({
819
- componentExts = [],
820
- overrides
821
- } = {}) => [
822
- {
823
- ...pluginMdx.flat,
824
- processor: pluginMdx.createRemarkProcessor({
825
- lintCodeBlocks: true,
826
- languageMapper: {}
827
- })
828
- },
829
- {
830
- ...pluginMdx.flatCodeBlocks,
831
- files: [
832
- ...pluginMdx.flatCodeBlocks.files,
833
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/*.${ext}`)
834
- ],
835
- rules: {
836
- ...pluginMdx.flatCodeBlocks.rules,
837
- "html/require-doctype": "off",
838
- "ts/no-redeclare": "off",
839
- "ts/no-unused-vars": "off",
840
- "ts/no-use-before-define": "off",
841
- "ts/no-var-requires": "off",
842
- "ts/consistent-type-imports": "off",
843
- "ts/no-namespace": "off",
844
- "ts/no-require-imports": "off",
845
- "import/no-unresolved": "off",
846
- "unused-imports/no-unused-imports": "off",
847
- "unused-imports/no-unused-vars": "off",
848
- "no-alert": "off",
849
- "no-console": "off",
850
- "no-restricted-imports": "off",
851
- "no-undef": "off",
852
- "no-unused-expressions": "off",
853
- ...overrides
854
- }
855
- }
856
- ];
857
-
858
- const node = () => [
859
- {
860
- plugins: {
861
- node: pluginNode
862
- }
863
- },
864
- {
865
- rules: {
866
- "node/no-callback-literal": "off",
867
- "node/handle-callback-err": ["error", "^(err|error)$"],
868
- "node/no-deprecated-api": "error",
869
- "node/no-exports-assign": "error",
870
- "node/no-new-require": "error",
871
- "node/no-path-concat": "error",
872
- "node/process-exit-as-throw": "error"
873
- }
874
- }
875
- ];
876
-
877
- const onlyError = () => [
878
- {
879
- plugins: {
880
- "only-error": pluginOnlyError
881
- }
882
- }
883
- ];
884
-
885
- const promise = () => [
886
- {
887
- plugins: {
888
- promise: pluginPromise
889
- }
890
- },
891
- {
892
- rules: {
893
- "promise/param-names": "error"
894
- }
895
- }
896
- ];
897
-
898
- const solid = ({
899
- overrides,
900
- typescript
901
- } = {}) => [
902
- {
903
- plugins: {
904
- solid: pluginSolid
905
- }
906
- },
907
- {
908
- languageOptions: {
909
- sourceType: "module",
910
- parserOptions: {
911
- ecmaFeatures: {
912
- jsx: true
913
- }
914
- }
915
- },
916
- rules: {
917
- ...pluginSolid.configs.recommended.rules,
918
- ...typescript ? pluginSolid.configs.typescript.rules : {},
919
- ...overrides
920
- }
921
- }
922
- ];
923
-
924
- const sortImports = () => [
925
- {
926
- plugins: {
927
- "sort-imports": pluginSortImports
928
- }
929
- },
930
- {
931
- rules: {
932
- "sort-imports/imports": "error",
933
- "sort-imports/exports": "error"
934
- }
935
- }
936
- ];
937
-
938
- const test = ({ overrides } = {}) => [
939
- {
940
- plugins: {
941
- "no-only-tests": pluginNoOnlyTests,
942
- "vitest": pluginVitest,
943
- "jest-formatting": pluginJestFormatting
944
- }
945
- },
946
- {
947
- files: GLOB_TESTS,
948
- rules: {
949
- ...pluginVitest.configs.recommended.rules,
950
- "no-only-tests/no-only-tests": "error",
951
- "vitest/expect-expect": "off",
952
- "vitest/valid-title": "off",
953
- "vitest/valid-describe-callback": "off",
954
- "vitest/no-alias-methods": "error",
955
- "vitest/no-interpolation-in-snapshots": "error",
956
- "vitest/no-test-prefixes": "error",
957
- "vitest/prefer-expect-resolves": "error",
958
- "vitest/prefer-comparison-matcher": "error",
959
- "vitest/prefer-mock-promise-shorthand": "error",
960
- "vitest/prefer-spy-on": "error",
961
- "vitest/prefer-to-be-falsy": "error",
962
- "vitest/prefer-to-be-object": "error",
963
- "vitest/prefer-to-be-truthy": "error",
964
- "vitest/prefer-to-contain": "error",
965
- "vitest/prefer-to-have-length": "error",
966
- "vitest/prefer-todo": "error",
967
- ...overrides
968
- }
969
- }
970
- ];
971
-
972
- const toml = ({ overrides } = {}) => [
973
- {
974
- plugins: {
975
- toml: pluginToml
976
- }
977
- },
978
- {
979
- languageOptions: {
980
- parser: parserToml
981
- },
982
- files: [GLOB_TOML],
983
- rules: {
984
- ...pluginToml.configs.recommended.rules,
985
- "no-irregular-whitespace": "off",
986
- "spaced-comment": "off",
987
- ...overrides
988
- }
989
- }
990
- ];
991
-
992
- function typescript({
993
- componentExts = [],
994
- parserOptions,
995
- overrides
996
- } = {}) {
997
- const typeAwareRules = {
998
- "etc/no-assign-mutated-array": "error",
999
- "etc/no-deprecated": "warn",
1000
- "etc/no-internal": "error",
1001
- "no-throw-literal": "off",
1002
- "ts/no-throw-literal": "error",
1003
- "no-implied-eval": "off",
1004
- "ts/no-implied-eval": "error",
1005
- "dot-notation": "off",
1006
- "ts/dot-notation": ["error", { allowKeywords: true }],
1007
- "no-void": ["error", { allowAsStatement: true }],
1008
- "ts/await-thenable": "error",
1009
- "ts/no-for-in-array": "error",
1010
- "ts/no-unnecessary-type-assertion": "error",
1011
- "ts/restrict-template-expressions": [
1012
- "error",
1013
- {
1014
- allowAny: true,
1015
- allowNumber: true,
1016
- allowBoolean: true
1017
- }
1018
- ],
1019
- "ts/array-type": ["error", { default: "array", readonly: "array" }],
1020
- "ts/consistent-generic-constructors": "error",
1021
- "ts/consistent-type-exports": "error",
1022
- "ts/consistent-type-assertions": [
1023
- "error",
1024
- { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
1025
- ],
1026
- "ts/prefer-nullish-coalescing": "error",
1027
- "ts/prefer-optional-chain": "error",
1028
- "ts/prefer-return-this-type": "error",
1029
- "ts/no-unnecessary-type-arguments": "error",
1030
- "ts/non-nullable-type-assertion-style": "error"
1031
- };
1032
- return [
1033
- {
1034
- // Install the plugins without globs, so they can be configured separately.
1035
- plugins: {
1036
- import: pluginImport,
1037
- ts: tseslint.plugin,
1038
- etc: pluginEtc
1039
- }
1040
- },
1041
- {
1042
- files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1043
- languageOptions: {
1044
- parser: tseslint.parser,
1045
- parserOptions: {
1046
- sourceType: "module",
1047
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1048
- ...parserOptions
1049
- }
1050
- },
1051
- settings: {
1052
- "import/resolver": {
1053
- node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
1054
- typescript: {
1055
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1056
- }
1057
- }
1058
- },
1059
- rules: {
1060
- ...renameRules(
1061
- tseslint.configs.eslintRecommended.rules,
1062
- "@typescript-eslint/",
1063
- "ts/"
1064
- ),
1065
- ...renameRules(
1066
- tseslint.configs.recommended.map((config) => config.rules).filter(Boolean).reduce((a, b) => ({ ...a, ...b }), {}),
1067
- "@typescript-eslint/",
1068
- "ts/"
1069
- ),
1070
- "import/named": "off",
1071
- // TS
1072
- "ts/comma-dangle": "off",
1073
- "ts/brace-style": "off",
1074
- "ts/comma-spacing": "off",
1075
- "ts/func-call-spacing": "off",
1076
- "ts/indent": "off",
1077
- "ts/keyword-spacing": "off",
1078
- "ts/member-delimiter-style": "off",
1079
- "ts/no-extra-parens": "off",
1080
- "ts/no-extra-semi": "off",
1081
- "ts/quotes": "off",
1082
- "ts/semi": "off",
1083
- "ts/space-before-function-paren": "off",
1084
- "ts/type-annotation-spacing": "off",
1085
- "ts/ban-ts-comment": [
1086
- "error",
1087
- {
1088
- minimumDescriptionLength: 0
1089
- }
1090
- ],
1091
- "ts/ban-types": [
1092
- "error",
1093
- {
1094
- extendDefaults: false,
1095
- types: {
1096
- String: {
1097
- message: "Use `string` instead.",
1098
- fixWith: "string"
1099
- },
1100
- Number: {
1101
- message: "Use `number` instead.",
1102
- fixWith: "number"
1103
- },
1104
- Boolean: {
1105
- message: "Use `boolean` instead.",
1106
- fixWith: "boolean"
1107
- },
1108
- Symbol: {
1109
- message: "Use `symbol` instead.",
1110
- fixWith: "symbol"
1111
- },
1112
- BigInt: {
1113
- message: "Use `bigint` instead.",
1114
- fixWith: "bigint"
1115
- },
1116
- Object: {
1117
- message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
1118
- fixWith: "Record<PropertyKey, unknown>"
1119
- },
1120
- object: {
1121
- message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
1122
- fixWith: "Record<PropertyKey, unknown>"
1123
- },
1124
- Function: {
1125
- message: "Use `(...args: any[]) => any` instead.",
1126
- fixWith: "(...args: any[]) => any"
1127
- }
1128
- }
1129
- }
1130
- ],
1131
- "ts/consistent-type-imports": [
1132
- "error",
1133
- { prefer: "type-imports", disallowTypeAnnotations: false }
1134
- ],
1135
- "ts/consistent-type-definitions": ["error", "interface"],
1136
- "ts/consistent-indexed-object-style": ["error", "record"],
1137
- "ts/prefer-ts-expect-error": "error",
1138
- "ts/prefer-for-of": "error",
1139
- "ts/no-duplicate-enum-values": "error",
1140
- "ts/no-non-null-asserted-nullish-coalescing": "error",
1141
- "ts/no-require-imports": "error",
1142
- "ts/method-signature-style": ["error", "property"],
1143
- "ts/explicit-member-accessibility": [
1144
- "error",
1145
- {
1146
- accessibility: "explicit",
1147
- overrides: {
1148
- constructors: "no-public"
1149
- }
1150
- }
1151
- ],
1152
- // Override JS
1153
- "no-useless-constructor": "off",
1154
- "no-invalid-this": "off",
1155
- "ts/no-invalid-this": "error",
1156
- "no-redeclare": "off",
1157
- "ts/no-redeclare": "error",
1158
- "no-use-before-define": "off",
1159
- "ts/no-use-before-define": [
1160
- "error",
1161
- { functions: false, classes: false, variables: true }
1162
- ],
1163
- "object-curly-spacing": "off",
1164
- "space-before-blocks": "off",
1165
- "ts/space-before-blocks": "off",
1166
- "space-before-function-paren": "off",
1167
- "no-dupe-class-members": "off",
1168
- "ts/no-dupe-class-members": "error",
1169
- "no-loss-of-precision": "off",
1170
- "ts/no-loss-of-precision": "error",
1171
- "lines-between-class-members": "off",
1172
- "ts/lines-between-class-members": [
1173
- "error",
1174
- "always",
1175
- { exceptAfterSingleLine: true }
1176
- ],
1177
- // so1ve
1178
- "so1ve/no-inline-type-import": "error",
1179
- // off
1180
- "ts/camelcase": "off",
1181
- "ts/explicit-function-return-type": "off",
1182
- "ts/no-explicit-any": "off",
1183
- "ts/no-parameter-properties": "off",
1184
- "ts/no-empty-interface": "off",
1185
- "ts/ban-ts-ignore": "off",
1186
- "ts/no-empty-function": "off",
1187
- "ts/no-non-null-assertion": "off",
1188
- "ts/explicit-module-boundary-types": "off",
1189
- "ts/triple-slash-reference": "off",
1190
- // handled by unused-imports/no-unused-imports
1191
- "ts/no-unused-vars": "off",
1192
- ...overrides
1193
- }
1194
- },
1195
- {
1196
- files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1197
- ignores: [GLOB_MARKDOWN_CODE],
1198
- languageOptions: {
1199
- parser: tseslint.parser,
1200
- parserOptions: {
1201
- sourceType: "module",
1202
- // EXPERIMENTAL_useProjectService: true,
1203
- project: true,
1204
- tsconfigRootDir: process.cwd()
1205
- }
1206
- },
1207
- settings: {
1208
- "import/resolver": {
1209
- node: {
1210
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1211
- },
1212
- typescript: {
1213
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1214
- }
1215
- }
1216
- },
1217
- rules: {
1218
- ...typeAwareRules
1219
- }
1220
- },
1221
- {
1222
- files: ["**/*.d.ts"],
1223
- rules: {
1224
- "eslint-comments/no-unlimited-disable": "off",
1225
- "import/no-duplicates": "off",
1226
- "unused-imports/no-unused-vars": "off"
1227
- }
1228
- },
1229
- {
1230
- files: ["**/*.js", "**/*.cjs"],
1231
- rules: {
1232
- "ts/no-require-imports": "off",
1233
- "ts/no-var-requires": "off"
1234
- }
1235
- }
1236
- ];
1237
- }
1238
-
1239
- const unicorn = () => [
1240
- {
1241
- plugins: {
1242
- unicorn: pluginUnicorn
1243
- },
1244
- rules: {
1245
- "unicorn/throw-new-error": "error",
1246
- "unicorn/relative-url-style": ["error", "always"],
1247
- "unicorn/switch-case-braces": "error",
1248
- "unicorn/number-literal-case": "error",
1249
- "unicorn/numeric-separators-style": "error",
1250
- "unicorn/new-for-builtins": "error",
1251
- "unicorn/error-message": "error",
1252
- "unicorn/escape-case": "error",
1253
- "unicorn/explicit-length-check": "error",
1254
- "unicorn/no-instanceof-array": "error",
1255
- "unicorn/no-new-buffer": "error",
1256
- "unicorn/no-new-array": "error",
1257
- "unicorn/no-array-for-each": "error",
1258
- "unicorn/no-array-method-this-argument": "error",
1259
- "unicorn/no-for-loop": "error",
1260
- "unicorn/no-lonely-if": "error",
1261
- "unicorn/no-negated-condition": "error",
1262
- "unicorn/no-useless-spread": "error",
1263
- "unicorn/prefer-ternary": "error",
1264
- "unicorn/prefer-query-selector": "error",
1265
- "unicorn/prefer-modern-dom-apis": "error",
1266
- "unicorn/prefer-modern-math-apis": "error",
1267
- "unicorn/prefer-json-parse-buffer": "error",
1268
- "unicorn/prefer-date-now": "error",
1269
- "unicorn/prefer-array-some": "error",
1270
- "unicorn/prefer-array-index-of": "error",
1271
- "unicorn/prefer-array-flat": "error",
1272
- "unicorn/prefer-array-find": "error",
1273
- "unicorn/prefer-spread": "error",
1274
- "unicorn/prefer-set-size": "error",
1275
- "unicorn/prefer-string-slice": "error",
1276
- "unicorn/prefer-includes": "error",
1277
- "unicorn/prefer-string-starts-ends-with": "error",
1278
- "unicorn/prefer-text-content": "error",
1279
- "unicorn/prefer-type-error": "error",
1280
- "unicorn/prefer-node-protocol": "error",
1281
- "unicorn/prefer-negative-index": "error",
1282
- "unicorn/prefer-regexp-test": "error",
1283
- "unicorn/prefer-optional-catch-binding": "error",
1284
- "unicorn/prefer-object-from-entries": "error",
1285
- "unicorn/prefer-prototype-methods": "error"
1286
- }
1287
- }
1288
- ];
1289
-
1290
- const vue = ({
1291
- overrides,
1292
- typescript
1293
- } = {}) => [
1294
- {
1295
- plugins: {
1296
- vue: pluginVue
1297
- }
1298
- },
1299
- {
1300
- files: [GLOB_VUE],
1301
- languageOptions: {
1302
- parser: parserVue,
1303
- parserOptions: {
1304
- ecmaFeatures: {
1305
- jsx: true
1306
- },
1307
- extraFileExtensions: [".vue"],
1308
- parser: typescript ? tseslint.parser : null,
1309
- sourceType: "module"
1310
- }
1311
- },
1312
- processor: pluginVue.processors[".vue"],
1313
- rules: {
1314
- ...pluginVue.configs.base.rules,
1315
- ...pluginVue.configs["vue3-essential"].rules,
1316
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
1317
- ...pluginVue.configs["vue3-recommended"].rules,
1318
- "no-unused-vars": "off",
1319
- "no-undef": "off",
1320
- "ts/no-unused-vars": "off",
1321
- "vue/no-v-html": "off",
1322
- "vue/require-prop-types": "off",
1323
- "vue/require-default-prop": "off",
1324
- "vue/multi-word-component-names": "off",
1325
- "vue/no-ref-object-reactivity-loss": "error",
1326
- "vue/no-setup-props-reactivity-loss": "error",
1327
- "vue/block-order": [
1328
- "error",
1329
- {
1330
- order: ["script:not([setup])", "script[setup]", "template", "style"]
1331
- }
1332
- ],
1333
- "vue/component-api-style": ["error", ["script-setup", "composition"]],
1334
- "vue/component-name-in-template-casing": [
1335
- "error",
1336
- "PascalCase",
1337
- { registeredComponentsOnly: false }
1338
- ],
1339
- "vue/component-options-name-casing": ["error", "PascalCase"],
1340
- "vue/custom-event-name-casing": ["error", "camelCase"],
1341
- "vue/define-macros-order": [
1342
- "error",
1343
- {
1344
- order: ["defineOptions", "defineEmits", "defineProps", "defineSlots"]
1345
- }
1346
- ],
1347
- "vue/html-comment-content-spacing": [
1348
- "error",
1349
- "always",
1350
- { exceptions: ["-"] }
1351
- ],
1352
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1353
- "vue/no-useless-v-bind": ["error", { ignoreIncludesComment: true }],
1354
- "vue/no-unused-refs": "error",
1355
- "vue/no-v-text-v-html-on-component": "error",
1356
- "vue/padding-line-between-blocks": ["error", "always"],
1357
- "vue/prefer-separate-static-class": "error",
1358
- // extensions
1359
- "vue/dot-location": ["error", "property"],
1360
- "vue/dot-notation": ["error", { allowKeywords: true }],
1361
- "vue/eqeqeq": ["error", "smart"],
1362
- "vue/no-constant-condition": "error",
1363
- "vue/no-empty-pattern": "error",
1364
- "vue/no-irregular-whitespace": "error",
1365
- "vue/no-loss-of-precision": "error",
1366
- "vue/no-restricted-syntax": [
1367
- "error",
1368
- "DebuggerStatement",
1369
- "LabeledStatement",
1370
- "WithStatement"
1371
- ],
1372
- "vue/no-sparse-arrays": "error",
1373
- "vue/object-curly-newline": [
1374
- "error",
1375
- { multiline: true, consistent: true }
1376
- ],
1377
- "vue/object-property-newline": [
1378
- "error",
1379
- { allowMultiplePropertiesPerLine: true }
1380
- ],
1381
- "vue/object-shorthand": [
1382
- "error",
1383
- "always",
1384
- { ignoreConstructors: false, avoidQuotes: true }
1385
- ],
1386
- "vue/prefer-template": "error",
1387
- "vue/quote-props": ["error", "consistent-as-needed"],
1388
- "vue/block-lang": [
1389
- "error",
1390
- {
1391
- script: {
1392
- lang: ["js", "ts"]
1393
- },
1394
- template: {
1395
- lang: ["html", "jade", "pug", "ejs"]
1396
- },
1397
- style: {
1398
- lang: ["css", "sass", "scss", "less", "stylus", "postcss"]
1399
- }
1400
- }
1401
- ],
1402
- "vue/require-macro-variable-name": [
1403
- "error",
1404
- {
1405
- defineProps: "props",
1406
- defineEmits: "emit",
1407
- defineSlots: "slots",
1408
- useSlots: "slots",
1409
- useAttrs: "attrs"
1410
- }
1411
- ],
1412
- "vue/require-typed-ref": "error",
1413
- "vue/no-static-inline-styles": ["error", { allowBinding: true }],
1414
- "vue/no-console": [
1415
- "error",
1416
- { allow: ["error", "warn", "table", "time"] }
1417
- ],
1418
- "vue/camelcase": "error",
1419
- "vue/v-for-delimiter-style": ["error", "in"],
1420
- "vue/attributes-order": [
1421
- "error",
1422
- {
1423
- order: [
1424
- "DEFINITION",
1425
- "LIST_RENDERING",
1426
- "CONDITIONALS",
1427
- "RENDER_MODIFIERS",
1428
- "TWO_WAY_BINDING",
1429
- "OTHER_DIRECTIVES",
1430
- ["UNIQUE", "SLOT"],
1431
- "GLOBAL",
1432
- "OTHER_ATTR",
1433
- "EVENTS",
1434
- "CONTENT"
1435
- ],
1436
- alphabetical: true
1437
- }
1438
- ],
1439
- "vue/prefer-true-attribute-shorthand": "error",
1440
- "vue/prefer-define-options": "error",
1441
- "vue/html-comment-content-newline": [
1442
- "error",
1443
- { singleline: "ignore", multiline: "always" }
1444
- ],
1445
- "vue/html-comment-indent": ["error", "tab"],
1446
- "vue/html-self-closing": [
1447
- "error",
1448
- {
1449
- html: {
1450
- void: "always",
1451
- normal: "always",
1452
- component: "always"
1453
- },
1454
- svg: "always",
1455
- math: "always"
1456
- }
1457
- ],
1458
- "vue/no-useless-concat": "error",
1459
- // off
1460
- "vue/no-multiple-template-root": "off",
1461
- "vue/multiline-html-element-content-newline": "off",
1462
- "vue/singleline-html-element-content-newline": "off",
1463
- "vue/no-extra-parens": "off",
1464
- "vue/array-bracket-spacing": "off",
1465
- "vue/arrow-spacing": "off",
1466
- "vue/block-spacing": "off",
1467
- "vue/brace-style": "off",
1468
- "vue/comma-dangle": "off",
1469
- "vue/comma-spacing": "off",
1470
- "vue/comma-style": "off",
1471
- "vue/operator-linebreak": "off",
1472
- "vue/template-curly-spacing": "off",
1473
- "vue/key-spacing": "off",
1474
- "vue/keyword-spacing": "off",
1475
- "vue/html-quotes": "off",
1476
- "vue/html-indent": "off",
1477
- "vue/no-multi-spaces": "off",
1478
- "vue/max-attributes-per-line": "off",
1479
- "vue/html-closing-bracket-spacing": "off",
1480
- ...overrides
1481
- }
1482
- }
1483
- ];
1484
-
1485
- const yaml = ({ overrides } = {}) => [
1486
- {
1487
- plugins: {
1488
- yaml: pluginYaml
1489
- },
1490
- languageOptions: {
1491
- parser: parserYaml
1492
- },
1493
- files: [GLOB_YAML],
1494
- rules: {
1495
- ...renameRules(pluginYaml.configs.prettier.rules, "yml/", "yaml/"),
1496
- ...renameRules(pluginYaml.configs.recommended.rules, "yml/", "yaml/"),
1497
- "yaml/no-empty-document": "off",
1498
- "spaced-comment": "off",
1499
- ...overrides
1500
- }
1501
- }
1502
- ];
1503
-
1504
- const flatConfigProps = [
1505
- "files",
1506
- "ignores",
1507
- "languageOptions",
1508
- "linterOptions",
1509
- "processor",
1510
- "plugins",
1511
- "rules",
1512
- "settings"
1513
- ];
1514
- const VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1515
- function so1ve(options = {}, ...userConfigs) {
1516
- var _a, _b, _c, _d, _e, _f;
1517
- const {
1518
- vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1519
- solid: enableSolid = isPackageExists("solid-js"),
1520
- typescript: enableTypeScript = isPackageExists("typescript"),
1521
- gitignore: enableGitignore = true,
1522
- componentExts = []
1523
- } = options;
1524
- const configs = [];
1525
- if (enableGitignore) {
1526
- if (typeof enableGitignore === "boolean") {
1527
- if (fs.existsSync(".gitignore")) {
1528
- configs.push([gitignore()]);
1529
- }
1530
- } else {
1531
- configs.push([gitignore(enableGitignore)]);
1532
- }
1533
- }
1534
- configs.push(
1535
- ignores(),
1536
- javascript({
1537
- overrides: getOverrides(options, "javascript")
1538
- }),
1539
- comments(),
1540
- node(),
1541
- onlyError(),
1542
- promise(),
1543
- sortImports(),
1544
- imports(),
1545
- unicorn(),
1546
- html()
1547
- );
1548
- if (enableVue) {
1549
- componentExts.push("vue");
1550
- }
1551
- if (enableTypeScript) {
1552
- configs.push(
1553
- typescript({
1554
- componentExts,
1555
- overrides: getOverrides(options, "typescript")
1556
- })
1557
- );
1558
- }
1559
- if ((_a = options.test) != null ? _a : true) {
1560
- configs.push(
1561
- test({
1562
- overrides: getOverrides(options, "test")
1563
- })
1564
- );
1565
- }
1566
- if (enableVue) {
1567
- configs.push(
1568
- vue({
1569
- overrides: getOverrides(options, "vue"),
1570
- typescript: !!enableTypeScript
1571
- })
1572
- );
1573
- }
1574
- if (enableSolid) {
1575
- configs.push(
1576
- solid({
1577
- overrides: getOverrides(options, "solid"),
1578
- typescript: !!enableTypeScript
1579
- })
1580
- );
1581
- }
1582
- if ((_b = options.jsonc) != null ? _b : true) {
1583
- configs.push(jsonc());
1584
- }
1585
- if ((_c = options.toml) != null ? _c : true) {
1586
- configs.push(
1587
- toml({
1588
- overrides: getOverrides(options, "toml")
1589
- })
1590
- );
1591
- }
1592
- if ((_d = options.yaml) != null ? _d : true) {
1593
- configs.push(
1594
- yaml({
1595
- overrides: getOverrides(options, "yaml")
1596
- })
1597
- );
1598
- }
1599
- if ((_e = options.mdx) != null ? _e : true) {
1600
- configs.push(
1601
- mdx({
1602
- componentExts,
1603
- overrides: getOverrides(options, "mdx")
1604
- })
1605
- );
1606
- }
1607
- if ((_f = options.formatting) != null ? _f : true) {
1608
- configs.push(formatting(options));
1609
- }
1610
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
1611
- if (key in options) {
1612
- acc[key] = options[key];
1613
- }
1614
- return acc;
1615
- }, {});
1616
- if (Object.keys(fusedConfig).length > 0) {
1617
- configs.push([fusedConfig]);
1618
- }
1619
- const merged = [...configs, ...userConfigs].flat();
1620
- return merged;
1621
- }
1622
- const resolveSubOptions = (options, key) => typeof options[key] === "boolean" ? {} : options[key] || {};
1623
- function getOverrides(options, key) {
1624
- var _a;
1625
- const sub = resolveSubOptions(options, key);
1626
- return {
1627
- // eslint-disable-next-line etc/no-deprecated
1628
- ...(_a = options.overrides) == null ? void 0 : _a[key],
1629
- ..."overrides" in sub ? sub.overrides : {}
1630
- };
1631
- }
1632
-
1633
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, comments, formatting, getOverrides, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };