@coderwyd/eslint-config 1.1.0-beta.1 → 1.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29,32 +29,40 @@ import { default as default22 } from "jsonc-eslint-parser";
29
29
  import { default as default23 } from "astro-eslint-parser";
30
30
 
31
31
  // src/configs/comments.ts
32
- var comments = [
33
- {
34
- plugins: {
35
- "eslint-comments": default3
36
- },
37
- rules: {
38
- "eslint-comments/no-aggregating-enable": "error",
39
- "eslint-comments/no-duplicate-disable": "error",
40
- "eslint-comments/no-unlimited-disable": "error",
41
- "eslint-comments/no-unused-enable": "error"
32
+ function comments() {
33
+ return [
34
+ {
35
+ plugins: {
36
+ "eslint-comments": default3
37
+ },
38
+ rules: {
39
+ "eslint-comments/no-aggregating-enable": "error",
40
+ "eslint-comments/no-duplicate-disable": "error",
41
+ "eslint-comments/no-unlimited-disable": "error",
42
+ "eslint-comments/no-unused-enable": "error"
43
+ }
42
44
  }
43
- }
44
- ];
45
+ ];
46
+ }
45
47
 
46
48
  // src/globs.ts
47
49
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
48
50
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
51
+ var GLOB_JS = "**/*.?([cm])js";
49
52
  var GLOB_JSX = "**/*.?([cm])jsx";
50
53
  var GLOB_TS = "**/*.?([cm])ts";
51
54
  var GLOB_TSX = "**/*.?([cm])tsx";
55
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
56
+ var GLOB_CSS = "**/*.css";
57
+ var GLOB_LESS = "**/*.less";
58
+ var GLOB_SCSS = "**/*.scss";
52
59
  var GLOB_JSON = "**/*.json";
53
60
  var GLOB_JSON5 = "**/*.json5";
54
61
  var GLOB_JSONC = "**/*.jsonc";
55
62
  var GLOB_MARKDOWN = "**/*.md";
56
63
  var GLOB_VUE = "**/*.vue";
57
64
  var GLOB_YAML = "**/*.y?(a)ml";
65
+ var GLOB_HTML = "**/*.htm?(l)";
58
66
  var GLOB_ASTRO = "**/*.astro";
59
67
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
60
68
  var GLOB_TESTS = [
@@ -62,6 +70,16 @@ var GLOB_TESTS = [
62
70
  `**/*.spec.${GLOB_SRC_EXT}`,
63
71
  `**/*.test.${GLOB_SRC_EXT}`
64
72
  ];
73
+ var GLOB_ALL_SRC = [
74
+ GLOB_SRC,
75
+ GLOB_STYLE,
76
+ GLOB_JSON,
77
+ GLOB_JSON5,
78
+ GLOB_MARKDOWN,
79
+ GLOB_VUE,
80
+ GLOB_YAML,
81
+ GLOB_HTML
82
+ ];
65
83
  var GLOB_EXCLUDE = [
66
84
  "**/node_modules",
67
85
  "**/dist",
@@ -87,29 +105,41 @@ var GLOB_EXCLUDE = [
87
105
  ];
88
106
 
89
107
  // src/configs/ignores.ts
90
- var ignores = [
91
- { ignores: GLOB_EXCLUDE }
92
- ];
108
+ function ignores() {
109
+ return [
110
+ { ignores: GLOB_EXCLUDE }
111
+ ];
112
+ }
93
113
 
94
114
  // src/configs/imports.ts
95
- var imports = [
96
- {
97
- plugins: {
98
- import: default4
99
- },
100
- rules: {
101
- "import/export": "error",
102
- "import/first": "error",
103
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
104
- "import/no-duplicates": "error",
105
- "import/no-mutable-exports": "error",
106
- "import/no-named-default": "error",
107
- "import/no-self-import": "error",
108
- "import/no-webpack-loader-syntax": "error",
109
- "import/order": "error"
115
+ function imports(options = {}) {
116
+ const {
117
+ stylistic: stylistic2 = true
118
+ } = options;
119
+ return [
120
+ {
121
+ plugins: {
122
+ antfu: default2,
123
+ import: default4
124
+ },
125
+ rules: {
126
+ "antfu/import-dedupe": "error",
127
+ "antfu/no-import-node-modules-by-path": "error",
128
+ "import/export": "error",
129
+ "import/first": "error",
130
+ "import/no-duplicates": "error",
131
+ "import/no-mutable-exports": "error",
132
+ "import/no-named-default": "error",
133
+ "import/no-self-import": "error",
134
+ "import/no-webpack-loader-syntax": "error",
135
+ "import/order": "error",
136
+ ...stylistic2 ? {
137
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
138
+ } : {}
139
+ }
110
140
  }
111
- }
112
- ];
141
+ ];
142
+ }
113
143
 
114
144
  // src/configs/javascript.ts
115
145
  import globals from "globals";
@@ -119,7 +149,17 @@ var OFF = 0;
119
149
 
120
150
  // src/configs/javascript.ts
121
151
  function javascript(options = {}) {
152
+ const {
153
+ isInEditor = false,
154
+ overrides = {}
155
+ } = options;
122
156
  return [
157
+ {
158
+ plugins: {
159
+ "antfu": default2,
160
+ "unused-imports": default12
161
+ }
162
+ },
123
163
  {
124
164
  languageOptions: {
125
165
  ecmaVersion: 2022,
@@ -140,14 +180,8 @@ function javascript(options = {}) {
140
180
  },
141
181
  sourceType: "module"
142
182
  },
143
- plugins: {
144
- "antfu": default2,
145
- "unused-imports": default12
146
- },
147
183
  rules: {
148
184
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
149
- "antfu/import-dedupe": "error",
150
- "antfu/no-import-node-modules-by-path": "error",
151
185
  "antfu/top-level-function": "error",
152
186
  "array-callback-return": "error",
153
187
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
@@ -322,7 +356,7 @@ function javascript(options = {}) {
322
356
  ],
323
357
  "symbol-description": "error",
324
358
  "unicode-bom": ["error", "never"],
325
- "unused-imports/no-unused-imports": options.isInEditor ? OFF : "error",
359
+ "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
326
360
  "unused-imports/no-unused-vars": [
327
361
  "error",
328
362
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
@@ -331,7 +365,8 @@ function javascript(options = {}) {
331
365
  "valid-typeof": ["error", { requireStringLiterals: true }],
332
366
  "vars-on-top": "error",
333
367
  "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
334
- "yoda": ["error", "never"]
368
+ "yoda": ["error", "never"],
369
+ ...overrides
335
370
  }
336
371
  },
337
372
  {
@@ -344,97 +379,119 @@ function javascript(options = {}) {
344
379
  }
345
380
 
346
381
  // src/configs/jsdoc.ts
347
- var jsdoc = [
348
- {
349
- plugins: {
350
- jsdoc: default5
382
+ function jsdoc(options = {}) {
383
+ const {
384
+ stylistic: stylistic2 = true
385
+ } = options;
386
+ return [
387
+ {
388
+ plugins: {
389
+ jsdoc: default5
390
+ }
351
391
  },
352
- rules: {
353
- "jsdoc/check-access": "warn",
354
- "jsdoc/check-alignment": "warn",
355
- "jsdoc/check-param-names": "warn",
356
- "jsdoc/check-property-names": "warn",
357
- "jsdoc/check-types": "warn",
358
- "jsdoc/empty-tags": "warn",
359
- "jsdoc/implements-on-classes": "warn",
360
- "jsdoc/multiline-blocks": "warn",
361
- "jsdoc/no-defaults": "warn",
362
- "jsdoc/no-multi-asterisks": "warn",
363
- "jsdoc/no-types": "warn",
364
- "jsdoc/require-param-name": "warn",
365
- "jsdoc/require-property": "warn",
366
- "jsdoc/require-property-description": "warn",
367
- "jsdoc/require-property-name": "warn",
368
- "jsdoc/require-returns-check": "warn",
369
- "jsdoc/require-returns-description": "warn",
370
- "jsdoc/require-yields-check": "warn",
371
- "jsdoc/valid-types": "warn"
392
+ {
393
+ rules: {
394
+ "jsdoc/check-access": "warn",
395
+ "jsdoc/check-param-names": "warn",
396
+ "jsdoc/check-property-names": "warn",
397
+ "jsdoc/check-types": "warn",
398
+ "jsdoc/empty-tags": "warn",
399
+ "jsdoc/implements-on-classes": "warn",
400
+ "jsdoc/no-defaults": "warn",
401
+ "jsdoc/no-multi-asterisks": "warn",
402
+ "jsdoc/require-param-name": "warn",
403
+ "jsdoc/require-property": "warn",
404
+ "jsdoc/require-property-description": "warn",
405
+ "jsdoc/require-property-name": "warn",
406
+ "jsdoc/require-returns-check": "warn",
407
+ "jsdoc/require-returns-description": "warn",
408
+ "jsdoc/require-yields-check": "warn",
409
+ "jsdoc/valid-types": "warn",
410
+ ...stylistic2 ? {
411
+ "jsdoc/check-alignment": "warn",
412
+ "jsdoc/multiline-blocks": "warn"
413
+ } : {}
414
+ }
372
415
  }
373
- }
374
- ];
416
+ ];
417
+ }
375
418
 
376
419
  // src/configs/jsonc.ts
377
- var jsonc = [
378
- {
379
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
380
- languageOptions: {
381
- parser: default22
382
- },
383
- plugins: {
384
- jsonc: default6
420
+ function jsonc(options = {}) {
421
+ const {
422
+ stylistic: stylistic2 = true,
423
+ overrides = {}
424
+ } = options;
425
+ return [
426
+ {
427
+ plugins: {
428
+ jsonc: default6
429
+ }
385
430
  },
386
- rules: {
387
- "jsonc/array-bracket-spacing": ["error", "never"],
388
- "jsonc/comma-dangle": ["error", "never"],
389
- "jsonc/comma-style": ["error", "last"],
390
- "jsonc/indent": ["error", 2],
391
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
392
- "jsonc/no-bigint-literals": "error",
393
- "jsonc/no-binary-expression": "error",
394
- "jsonc/no-binary-numeric-literals": "error",
395
- "jsonc/no-dupe-keys": "error",
396
- "jsonc/no-escape-sequence-in-identifier": "error",
397
- "jsonc/no-floating-decimal": "error",
398
- "jsonc/no-hexadecimal-numeric-literals": "error",
399
- "jsonc/no-infinity": "error",
400
- "jsonc/no-multi-str": "error",
401
- "jsonc/no-nan": "error",
402
- "jsonc/no-number-props": "error",
403
- "jsonc/no-numeric-separators": "error",
404
- "jsonc/no-octal": "error",
405
- "jsonc/no-octal-escape": "error",
406
- "jsonc/no-octal-numeric-literals": "error",
407
- "jsonc/no-parenthesized": "error",
408
- "jsonc/no-plus-sign": "error",
409
- "jsonc/no-regexp-literals": "error",
410
- "jsonc/no-sparse-arrays": "error",
411
- "jsonc/no-template-literals": "error",
412
- "jsonc/no-undefined-value": "error",
413
- "jsonc/no-unicode-codepoint-escapes": "error",
414
- "jsonc/no-useless-escape": "error",
415
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
416
- "jsonc/object-curly-spacing": ["error", "always"],
417
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
418
- "jsonc/quote-props": "error",
419
- "jsonc/quotes": "error",
420
- "jsonc/space-unary-ops": "error",
421
- "jsonc/valid-json-number": "error",
422
- "jsonc/vue-custom-block/no-parsing-error": "error"
431
+ {
432
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
433
+ languageOptions: {
434
+ parser: default22
435
+ },
436
+ rules: {
437
+ "jsonc/no-bigint-literals": "error",
438
+ "jsonc/no-binary-expression": "error",
439
+ "jsonc/no-binary-numeric-literals": "error",
440
+ "jsonc/no-dupe-keys": "error",
441
+ "jsonc/no-escape-sequence-in-identifier": "error",
442
+ "jsonc/no-floating-decimal": "error",
443
+ "jsonc/no-hexadecimal-numeric-literals": "error",
444
+ "jsonc/no-infinity": "error",
445
+ "jsonc/no-multi-str": "error",
446
+ "jsonc/no-nan": "error",
447
+ "jsonc/no-number-props": "error",
448
+ "jsonc/no-numeric-separators": "error",
449
+ "jsonc/no-octal": "error",
450
+ "jsonc/no-octal-escape": "error",
451
+ "jsonc/no-octal-numeric-literals": "error",
452
+ "jsonc/no-parenthesized": "error",
453
+ "jsonc/no-plus-sign": "error",
454
+ "jsonc/no-regexp-literals": "error",
455
+ "jsonc/no-sparse-arrays": "error",
456
+ "jsonc/no-template-literals": "error",
457
+ "jsonc/no-undefined-value": "error",
458
+ "jsonc/no-unicode-codepoint-escapes": "error",
459
+ "jsonc/no-useless-escape": "error",
460
+ "jsonc/space-unary-ops": "error",
461
+ "jsonc/valid-json-number": "error",
462
+ "jsonc/vue-custom-block/no-parsing-error": "error",
463
+ ...stylistic2 ? {
464
+ "jsonc/array-bracket-spacing": ["error", "never"],
465
+ "jsonc/comma-dangle": ["error", "never"],
466
+ "jsonc/comma-style": ["error", "last"],
467
+ "jsonc/indent": ["error", 2],
468
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
469
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
470
+ "jsonc/object-curly-spacing": ["error", "always"],
471
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
472
+ "jsonc/quote-props": "error",
473
+ "jsonc/quotes": "error"
474
+ } : {},
475
+ ...overrides
476
+ }
423
477
  }
424
- }
425
- ];
478
+ ];
479
+ }
426
480
 
427
481
  // src/configs/markdown.ts
428
482
  function markdown(options = {}) {
429
483
  const {
430
- componentExts = []
484
+ componentExts = [],
485
+ overrides = {}
431
486
  } = options;
432
487
  return [
433
488
  {
434
- files: [GLOB_MARKDOWN],
435
489
  plugins: {
436
490
  markdown: default7
437
- },
491
+ }
492
+ },
493
+ {
494
+ files: [GLOB_MARKDOWN],
438
495
  processor: "markdown/markdown"
439
496
  },
440
497
  {
@@ -449,9 +506,6 @@ function markdown(options = {}) {
449
506
  }
450
507
  }
451
508
  },
452
- plugins: {
453
- ts: default10
454
- },
455
509
  rules: {
456
510
  "antfu/no-cjs-exports": OFF,
457
511
  "antfu/no-ts-export-equal": OFF,
@@ -472,340 +526,370 @@ function markdown(options = {}) {
472
526
  "ts/no-var-requires": OFF,
473
527
  "unicode-bom": "off",
474
528
  "unused-imports/no-unused-imports": OFF,
475
- "unused-imports/no-unused-vars": OFF
529
+ "unused-imports/no-unused-vars": OFF,
530
+ // Type aware rules
531
+ ...{
532
+ "ts/await-thenable": OFF,
533
+ "ts/dot-notation": OFF,
534
+ "ts/no-floating-promises": OFF,
535
+ "ts/no-for-in-array": OFF,
536
+ "ts/no-implied-eval": OFF,
537
+ "ts/no-misused-promises": OFF,
538
+ "ts/no-throw-literal": OFF,
539
+ "ts/no-unnecessary-type-assertion": OFF,
540
+ "ts/no-unsafe-argument": OFF,
541
+ "ts/no-unsafe-assignment": OFF,
542
+ "ts/no-unsafe-call": OFF,
543
+ "ts/no-unsafe-member-access": OFF,
544
+ "ts/no-unsafe-return": OFF,
545
+ "ts/restrict-plus-operands": OFF,
546
+ "ts/restrict-template-expressions": OFF,
547
+ "ts/unbound-method": OFF
548
+ },
549
+ ...overrides
476
550
  }
477
551
  }
478
552
  ];
479
553
  }
480
554
 
481
555
  // src/configs/node.ts
482
- var node = [
483
- {
484
- plugins: {
485
- node: default8
486
- },
487
- rules: {
488
- "node/handle-callback-err": ["error", "^(err|error)$"],
489
- "node/no-deprecated-api": "error",
490
- "node/no-exports-assign": "error",
491
- "node/no-new-require": "error",
492
- "node/no-path-concat": "error",
493
- "node/prefer-global/buffer": ["error", "never"],
494
- "node/prefer-global/process": ["error", "never"],
495
- "node/process-exit-as-throw": "error"
556
+ function node() {
557
+ return [
558
+ {
559
+ plugins: {
560
+ node: default8
561
+ },
562
+ rules: {
563
+ "node/handle-callback-err": ["error", "^(err|error)$"],
564
+ "node/no-deprecated-api": "error",
565
+ "node/no-exports-assign": "error",
566
+ "node/no-new-require": "error",
567
+ "node/no-path-concat": "error",
568
+ "node/prefer-global/buffer": ["error", "never"],
569
+ "node/prefer-global/process": ["error", "never"],
570
+ "node/process-exit-as-throw": "error"
571
+ }
496
572
  }
497
- }
498
- ];
573
+ ];
574
+ }
499
575
 
500
576
  // src/configs/sort.ts
501
- var sortPackageJson = [
502
- {
503
- files: ["**/package.json"],
504
- rules: {
505
- "jsonc/sort-array-values": [
506
- "error",
507
- {
508
- order: { type: "asc" },
509
- pathPattern: "^files$"
510
- }
511
- ],
512
- "jsonc/sort-keys": [
513
- "error",
514
- {
515
- order: [
516
- "publisher",
517
- "name",
518
- "displayName",
519
- "type",
520
- "version",
521
- "private",
522
- "packageManager",
523
- "description",
524
- "author",
525
- "license",
526
- "funding",
527
- "homepage",
528
- "repository",
529
- "bugs",
530
- "keywords",
531
- "categories",
532
- "sideEffects",
533
- "exports",
534
- "main",
535
- "module",
536
- "unpkg",
537
- "jsdelivr",
538
- "types",
539
- "typesVersions",
540
- "bin",
541
- "icon",
542
- "files",
543
- "engines",
544
- "activationEvents",
545
- "contributes",
546
- "scripts",
547
- "peerDependencies",
548
- "peerDependenciesMeta",
549
- "dependencies",
550
- "optionalDependencies",
551
- "devDependencies",
552
- "pnpm",
553
- "overrides",
554
- "resolutions",
555
- "husky",
556
- "simple-git-hooks",
557
- "lint-staged",
558
- "eslintConfig"
559
- ],
560
- pathPattern: "^$"
561
- },
562
- {
563
- order: { type: "asc" },
564
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
565
- },
566
- {
567
- order: { type: "asc" },
568
- pathPattern: "^resolutions$"
569
- },
570
- {
571
- order: { type: "asc" },
572
- pathPattern: "^pnpm.overrides$"
573
- },
574
- {
575
- order: [
576
- "types",
577
- "import",
578
- "require",
579
- "default"
580
- ],
581
- pathPattern: "^exports.*$"
582
- }
583
- ]
577
+ function sortPackageJson() {
578
+ return [
579
+ {
580
+ files: ["**/package.json"],
581
+ rules: {
582
+ "jsonc/sort-array-values": [
583
+ "error",
584
+ {
585
+ order: { type: "asc" },
586
+ pathPattern: "^files$"
587
+ }
588
+ ],
589
+ "jsonc/sort-keys": [
590
+ "error",
591
+ {
592
+ order: [
593
+ "publisher",
594
+ "name",
595
+ "displayName",
596
+ "type",
597
+ "version",
598
+ "private",
599
+ "packageManager",
600
+ "description",
601
+ "author",
602
+ "license",
603
+ "funding",
604
+ "homepage",
605
+ "repository",
606
+ "bugs",
607
+ "keywords",
608
+ "categories",
609
+ "sideEffects",
610
+ "exports",
611
+ "main",
612
+ "module",
613
+ "unpkg",
614
+ "jsdelivr",
615
+ "types",
616
+ "typesVersions",
617
+ "bin",
618
+ "icon",
619
+ "files",
620
+ "engines",
621
+ "activationEvents",
622
+ "contributes",
623
+ "scripts",
624
+ "peerDependencies",
625
+ "peerDependenciesMeta",
626
+ "dependencies",
627
+ "optionalDependencies",
628
+ "devDependencies",
629
+ "pnpm",
630
+ "overrides",
631
+ "resolutions",
632
+ "husky",
633
+ "simple-git-hooks",
634
+ "lint-staged",
635
+ "nano-staged",
636
+ "eslintConfig"
637
+ ],
638
+ pathPattern: "^$"
639
+ },
640
+ {
641
+ order: { type: "asc" },
642
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
643
+ },
644
+ {
645
+ order: { type: "asc" },
646
+ pathPattern: "^resolutions$"
647
+ },
648
+ {
649
+ order: { type: "asc" },
650
+ pathPattern: "^pnpm.overrides$"
651
+ },
652
+ {
653
+ order: [
654
+ "types",
655
+ "import",
656
+ "require",
657
+ "default"
658
+ ],
659
+ pathPattern: "^exports.*$"
660
+ }
661
+ ]
662
+ }
584
663
  }
585
- }
586
- ];
587
- var sortTsconfig = [
588
- {
589
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
590
- rules: {
591
- "jsonc/sort-keys": [
592
- "error",
593
- {
594
- order: [
595
- "extends",
596
- "compilerOptions",
597
- "references",
598
- "files",
599
- "include",
600
- "exclude"
601
- ],
602
- pathPattern: "^$"
603
- },
604
- {
605
- order: [
606
- /* Projects */
607
- "incremental",
608
- "composite",
609
- "tsBuildInfoFile",
610
- "disableSourceOfProjectReferenceRedirect",
611
- "disableSolutionSearching",
612
- "disableReferencedProjectLoad",
613
- /* Language and Environment */
614
- "target",
615
- "lib",
616
- "jsx",
617
- "experimentalDecorators",
618
- "emitDecoratorMetadata",
619
- "jsxFactory",
620
- "jsxFragmentFactory",
621
- "jsxImportSource",
622
- "reactNamespace",
623
- "noLib",
624
- "useDefineForClassFields",
625
- "moduleDetection",
626
- /* Modules */
627
- "module",
628
- "rootDir",
629
- "moduleResolution",
630
- "baseUrl",
631
- "paths",
632
- "rootDirs",
633
- "typeRoots",
634
- "types",
635
- "allowUmdGlobalAccess",
636
- "moduleSuffixes",
637
- "allowImportingTsExtensions",
638
- "resolvePackageJsonExports",
639
- "resolvePackageJsonImports",
640
- "customConditions",
641
- "resolveJsonModule",
642
- "allowArbitraryExtensions",
643
- "noResolve",
644
- /* JavaScript Support */
645
- "allowJs",
646
- "checkJs",
647
- "maxNodeModuleJsDepth",
648
- /* Emit */
649
- "declaration",
650
- "declarationMap",
651
- "emitDeclarationOnly",
652
- "sourceMap",
653
- "inlineSourceMap",
654
- "outFile",
655
- "outDir",
656
- "removeComments",
657
- "noEmit",
658
- "importHelpers",
659
- "importsNotUsedAsValues",
660
- "downlevelIteration",
661
- "sourceRoot",
662
- "mapRoot",
663
- "inlineSources",
664
- "emitBOM",
665
- "newLine",
666
- "stripInternal",
667
- "noEmitHelpers",
668
- "noEmitOnError",
669
- "preserveConstEnums",
670
- "declarationDir",
671
- "preserveValueImports",
672
- /* Interop Constraints */
673
- "isolatedModules",
674
- "verbatimModuleSyntax",
675
- "allowSyntheticDefaultImports",
676
- "esModuleInterop",
677
- "preserveSymlinks",
678
- "forceConsistentCasingInFileNames",
679
- /* Type Checking */
680
- "strict",
681
- "strictBindCallApply",
682
- "strictFunctionTypes",
683
- "strictNullChecks",
684
- "strictPropertyInitialization",
685
- "allowUnreachableCode",
686
- "allowUnusedLabels",
687
- "alwaysStrict",
688
- "exactOptionalPropertyTypes",
689
- "noFallthroughCasesInSwitch",
690
- "noImplicitAny",
691
- "noImplicitOverride",
692
- "noImplicitReturns",
693
- "noImplicitThis",
694
- "noPropertyAccessFromIndexSignature",
695
- "noUncheckedIndexedAccess",
696
- "noUnusedLocals",
697
- "noUnusedParameters",
698
- "useUnknownInCatchVariables",
699
- /* Completeness */
700
- "skipDefaultLibCheck",
701
- "skipLibCheck"
702
- ],
703
- pathPattern: "^compilerOptions$"
704
- }
705
- ]
664
+ ];
665
+ }
666
+ function sortTsconfig() {
667
+ return [
668
+ {
669
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
670
+ rules: {
671
+ "jsonc/sort-keys": [
672
+ "error",
673
+ {
674
+ order: [
675
+ "extends",
676
+ "compilerOptions",
677
+ "references",
678
+ "files",
679
+ "include",
680
+ "exclude"
681
+ ],
682
+ pathPattern: "^$"
683
+ },
684
+ {
685
+ order: [
686
+ /* Projects */
687
+ "incremental",
688
+ "composite",
689
+ "tsBuildInfoFile",
690
+ "disableSourceOfProjectReferenceRedirect",
691
+ "disableSolutionSearching",
692
+ "disableReferencedProjectLoad",
693
+ /* Language and Environment */
694
+ "target",
695
+ "lib",
696
+ "jsx",
697
+ "experimentalDecorators",
698
+ "emitDecoratorMetadata",
699
+ "jsxFactory",
700
+ "jsxFragmentFactory",
701
+ "jsxImportSource",
702
+ "reactNamespace",
703
+ "noLib",
704
+ "useDefineForClassFields",
705
+ "moduleDetection",
706
+ /* Modules */
707
+ "module",
708
+ "rootDir",
709
+ "moduleResolution",
710
+ "baseUrl",
711
+ "paths",
712
+ "rootDirs",
713
+ "typeRoots",
714
+ "types",
715
+ "allowUmdGlobalAccess",
716
+ "moduleSuffixes",
717
+ "allowImportingTsExtensions",
718
+ "resolvePackageJsonExports",
719
+ "resolvePackageJsonImports",
720
+ "customConditions",
721
+ "resolveJsonModule",
722
+ "allowArbitraryExtensions",
723
+ "noResolve",
724
+ /* JavaScript Support */
725
+ "allowJs",
726
+ "checkJs",
727
+ "maxNodeModuleJsDepth",
728
+ /* Emit */
729
+ "declaration",
730
+ "declarationMap",
731
+ "emitDeclarationOnly",
732
+ "sourceMap",
733
+ "inlineSourceMap",
734
+ "outFile",
735
+ "outDir",
736
+ "removeComments",
737
+ "noEmit",
738
+ "importHelpers",
739
+ "importsNotUsedAsValues",
740
+ "downlevelIteration",
741
+ "sourceRoot",
742
+ "mapRoot",
743
+ "inlineSources",
744
+ "emitBOM",
745
+ "newLine",
746
+ "stripInternal",
747
+ "noEmitHelpers",
748
+ "noEmitOnError",
749
+ "preserveConstEnums",
750
+ "declarationDir",
751
+ "preserveValueImports",
752
+ /* Interop Constraints */
753
+ "isolatedModules",
754
+ "verbatimModuleSyntax",
755
+ "allowSyntheticDefaultImports",
756
+ "esModuleInterop",
757
+ "preserveSymlinks",
758
+ "forceConsistentCasingInFileNames",
759
+ /* Type Checking */
760
+ "strict",
761
+ "strictBindCallApply",
762
+ "strictFunctionTypes",
763
+ "strictNullChecks",
764
+ "strictPropertyInitialization",
765
+ "allowUnreachableCode",
766
+ "allowUnusedLabels",
767
+ "alwaysStrict",
768
+ "exactOptionalPropertyTypes",
769
+ "noFallthroughCasesInSwitch",
770
+ "noImplicitAny",
771
+ "noImplicitOverride",
772
+ "noImplicitReturns",
773
+ "noImplicitThis",
774
+ "noPropertyAccessFromIndexSignature",
775
+ "noUncheckedIndexedAccess",
776
+ "noUnusedLocals",
777
+ "noUnusedParameters",
778
+ "useUnknownInCatchVariables",
779
+ /* Completeness */
780
+ "skipDefaultLibCheck",
781
+ "skipLibCheck"
782
+ ],
783
+ pathPattern: "^compilerOptions$"
784
+ }
785
+ ]
786
+ }
706
787
  }
707
- }
708
- ];
788
+ ];
789
+ }
709
790
 
710
791
  // src/configs/stylistic.ts
711
- var stylistic = [
712
- {
713
- plugins: {
714
- style: default9
715
- },
716
- rules: {
717
- "antfu/consistent-list-newline": "error",
718
- "antfu/if-newline": "error",
719
- "curly": ["error", "multi-or-nest", "consistent"],
720
- "style/array-bracket-spacing": ["error", "never"],
721
- "style/arrow-spacing": ["error", { after: true, before: true }],
722
- "style/block-spacing": ["error", "always"],
723
- "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
724
- "style/comma-dangle": ["error", "always-multiline"],
725
- "style/comma-spacing": ["error", { after: true, before: false }],
726
- "style/comma-style": ["error", "last"],
727
- "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
728
- "style/dot-location": ["error", "property"],
729
- "style/indent": ["error", 2, {
730
- ArrayExpression: 1,
731
- CallExpression: { arguments: 1 },
732
- FunctionDeclaration: { body: 1, parameters: 1 },
733
- FunctionExpression: { body: 1, parameters: 1 },
734
- ImportDeclaration: 1,
735
- MemberExpression: 1,
736
- ObjectExpression: 1,
737
- SwitchCase: 1,
738
- VariableDeclarator: 1,
739
- flatTernaryExpressions: false,
740
- ignoreComments: false,
741
- ignoredNodes: [
742
- "TemplateLiteral *",
743
- "JSXElement",
744
- "JSXElement > *",
745
- "JSXAttribute",
746
- "JSXIdentifier",
747
- "JSXNamespacedName",
748
- "JSXMemberExpression",
749
- "JSXSpreadAttribute",
750
- "JSXExpressionContainer",
751
- "JSXOpeningElement",
752
- "JSXClosingElement",
753
- "JSXFragment",
754
- "JSXOpeningFragment",
755
- "JSXClosingFragment",
756
- "JSXText",
757
- "JSXEmptyExpression",
758
- "JSXSpreadChild",
759
- "TSTypeParameterInstantiation",
760
- "FunctionExpression > .params[decorators.length > 0]",
761
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
762
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
763
- ],
764
- offsetTernaryExpressions: true,
765
- outerIIFEBody: 1
766
- }],
767
- "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
768
- "style/keyword-spacing": ["error", { after: true, before: true }],
769
- "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
770
- "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
771
- "style/multiline-ternary": ["error", "always-multiline"],
772
- "style/no-mixed-spaces-and-tabs": "error",
773
- "style/no-multi-spaces": "error",
774
- "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
775
- "style/no-tabs": "error",
776
- "style/no-trailing-spaces": "error",
777
- "style/no-whitespace-before-property": "error",
778
- "style/object-curly-spacing": ["error", "always"],
779
- "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
780
- "style/operator-linebreak": ["error", "before"],
781
- "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
782
- "style/quotes": ["error", "single"],
783
- "style/rest-spread-spacing": ["error", "never"],
784
- "style/semi": ["error", "never"],
785
- "style/semi-spacing": ["error", { after: true, before: false }],
786
- "style/space-before-blocks": ["error", "always"],
787
- "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
788
- "style/space-in-parens": ["error", "never"],
789
- "style/space-infix-ops": "error",
790
- "style/space-unary-ops": ["error", { nonwords: false, words: true }],
791
- "style/spaced-comment": ["error", "always", {
792
- block: {
793
- balanced: true,
794
- exceptions: ["*"],
795
- markers: ["!"]
796
- },
797
- line: {
798
- exceptions: ["/", "#"],
799
- markers: ["/"]
800
- }
801
- }],
802
- "style/template-curly-spacing": "error",
803
- "style/template-tag-spacing": ["error", "never"],
804
- "style/type-annotation-spacing": ["error", {}],
805
- "style/yield-star-spacing": ["error", "both"]
792
+ function stylistic() {
793
+ return [
794
+ {
795
+ plugins: {
796
+ antfu: default2,
797
+ style: default9
798
+ },
799
+ rules: {
800
+ "antfu/consistent-list-newline": "error",
801
+ "antfu/if-newline": "error",
802
+ "curly": ["error", "multi-or-nest", "consistent"],
803
+ "style/array-bracket-spacing": ["error", "never"],
804
+ "style/arrow-spacing": ["error", { after: true, before: true }],
805
+ "style/block-spacing": ["error", "always"],
806
+ "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
807
+ "style/comma-dangle": ["error", "always-multiline"],
808
+ "style/comma-spacing": ["error", { after: true, before: false }],
809
+ "style/comma-style": ["error", "last"],
810
+ "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
811
+ "style/dot-location": ["error", "property"],
812
+ "style/indent": ["error", 2, {
813
+ ArrayExpression: 1,
814
+ CallExpression: { arguments: 1 },
815
+ FunctionDeclaration: { body: 1, parameters: 1 },
816
+ FunctionExpression: { body: 1, parameters: 1 },
817
+ ImportDeclaration: 1,
818
+ MemberExpression: 1,
819
+ ObjectExpression: 1,
820
+ SwitchCase: 1,
821
+ VariableDeclarator: 1,
822
+ flatTernaryExpressions: false,
823
+ ignoreComments: false,
824
+ ignoredNodes: [
825
+ "TemplateLiteral *",
826
+ "JSXElement",
827
+ "JSXElement > *",
828
+ "JSXAttribute",
829
+ "JSXIdentifier",
830
+ "JSXNamespacedName",
831
+ "JSXMemberExpression",
832
+ "JSXSpreadAttribute",
833
+ "JSXExpressionContainer",
834
+ "JSXOpeningElement",
835
+ "JSXClosingElement",
836
+ "JSXFragment",
837
+ "JSXOpeningFragment",
838
+ "JSXClosingFragment",
839
+ "JSXText",
840
+ "JSXEmptyExpression",
841
+ "JSXSpreadChild",
842
+ "TSTypeParameterInstantiation",
843
+ "FunctionExpression > .params[decorators.length > 0]",
844
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
845
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
846
+ ],
847
+ offsetTernaryExpressions: true,
848
+ outerIIFEBody: 1
849
+ }],
850
+ "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
851
+ "style/keyword-spacing": ["error", { after: true, before: true }],
852
+ "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
853
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
854
+ "style/multiline-ternary": ["error", "always-multiline"],
855
+ "style/no-mixed-spaces-and-tabs": "error",
856
+ "style/no-multi-spaces": "error",
857
+ "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
858
+ "style/no-tabs": "error",
859
+ "style/no-trailing-spaces": "error",
860
+ "style/no-whitespace-before-property": "error",
861
+ "style/object-curly-spacing": ["error", "always"],
862
+ "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
863
+ "style/operator-linebreak": ["error", "before"],
864
+ "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
865
+ "style/quotes": ["error", "single"],
866
+ "style/rest-spread-spacing": ["error", "never"],
867
+ "style/semi": ["error", "never"],
868
+ "style/semi-spacing": ["error", { after: true, before: false }],
869
+ "style/space-before-blocks": ["error", "always"],
870
+ "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
871
+ "style/space-in-parens": ["error", "never"],
872
+ "style/space-infix-ops": "error",
873
+ "style/space-unary-ops": ["error", { nonwords: false, words: true }],
874
+ "style/spaced-comment": ["error", "always", {
875
+ block: {
876
+ balanced: true,
877
+ exceptions: ["*"],
878
+ markers: ["!"]
879
+ },
880
+ line: {
881
+ exceptions: ["/", "#"],
882
+ markers: ["/"]
883
+ }
884
+ }],
885
+ "style/template-curly-spacing": "error",
886
+ "style/template-tag-spacing": ["error", "never"],
887
+ "style/type-annotation-spacing": ["error", {}],
888
+ "style/yield-star-spacing": ["error", "both"]
889
+ }
806
890
  }
807
- }
808
- ];
891
+ ];
892
+ }
809
893
 
810
894
  // src/configs/typescript.ts
811
895
  import process from "process";
@@ -827,9 +911,40 @@ function renameRules(rules, from, to) {
827
911
  // src/configs/typescript.ts
828
912
  function typescript(options) {
829
913
  const {
830
- componentExts = []
914
+ componentExts = [],
915
+ overrides = {},
916
+ parserOptions = {},
917
+ tsconfigPath
831
918
  } = options ?? {};
919
+ const typeAwareRules = {
920
+ "dot-notation": OFF,
921
+ "no-implied-eval": OFF,
922
+ "no-throw-literal": OFF,
923
+ "ts/await-thenable": "error",
924
+ "ts/dot-notation": ["error", { allowKeywords: true }],
925
+ "ts/no-floating-promises": "error",
926
+ "ts/no-for-in-array": "error",
927
+ "ts/no-implied-eval": "error",
928
+ "ts/no-misused-promises": "error",
929
+ "ts/no-throw-literal": "error",
930
+ "ts/no-unnecessary-type-assertion": "error",
931
+ "ts/no-unsafe-argument": "error",
932
+ "ts/no-unsafe-assignment": "error",
933
+ "ts/no-unsafe-call": "error",
934
+ "ts/no-unsafe-member-access": "error",
935
+ "ts/no-unsafe-return": "error",
936
+ "ts/restrict-plus-operands": "error",
937
+ "ts/restrict-template-expressions": "error",
938
+ "ts/unbound-method": "error"
939
+ };
832
940
  return [
941
+ {
942
+ plugins: {
943
+ antfu: default2,
944
+ import: default4,
945
+ ts: default10
946
+ }
947
+ },
833
948
  {
834
949
  files: [
835
950
  GLOB_TS,
@@ -839,14 +954,14 @@ function typescript(options) {
839
954
  languageOptions: {
840
955
  parser: default19,
841
956
  parserOptions: {
842
- sourceType: "module"
957
+ sourceType: "module",
958
+ ...tsconfigPath ? {
959
+ project: [tsconfigPath],
960
+ tsconfigRootDir: process.cwd()
961
+ } : {},
962
+ ...parserOptions
843
963
  }
844
964
  },
845
- plugins: {
846
- antfu: default2,
847
- import: default4,
848
- ts: default10
849
- },
850
965
  rules: {
851
966
  ...renameRules(
852
967
  default10.configs["eslint-recommended"].overrides[0].rules,
@@ -887,7 +1002,9 @@ function typescript(options) {
887
1002
  "ts/no-unused-vars": OFF,
888
1003
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
889
1004
  "ts/prefer-ts-expect-error": "error",
890
- "ts/triple-slash-reference": OFF
1005
+ "ts/triple-slash-reference": OFF,
1006
+ ...tsconfigPath ? typeAwareRules : {},
1007
+ ...overrides
891
1008
  }
892
1009
  },
893
1010
  {
@@ -913,94 +1030,50 @@ function typescript(options) {
913
1030
  }
914
1031
  ];
915
1032
  }
916
- function typescriptWithLanguageServer(options) {
917
- const {
918
- componentExts = [],
919
- tsconfigPath,
920
- tsconfigRootDir = process.cwd()
921
- } = options;
1033
+
1034
+ // src/configs/unicorn.ts
1035
+ function unicorn() {
922
1036
  return [
923
1037
  {
924
- files: [
925
- GLOB_TS,
926
- GLOB_TSX,
927
- ...componentExts.map((ext) => `**/*.${ext}`)
928
- ],
929
- ignores: ["**/*.md/*.*"],
930
- languageOptions: {
931
- parser: default19,
932
- parserOptions: {
933
- project: [tsconfigPath],
934
- tsconfigRootDir
935
- }
936
- },
937
1038
  plugins: {
938
- ts: default10
939
- },
1039
+ unicorn: default11
1040
+ }
1041
+ },
1042
+ {
940
1043
  rules: {
941
- "dot-notation": OFF,
942
- "no-implied-eval": OFF,
943
- "no-throw-literal": OFF,
944
- "ts/await-thenable": "error",
945
- "ts/dot-notation": ["error", { allowKeywords: true }],
946
- "ts/no-floating-promises": "error",
947
- "ts/no-for-in-array": "error",
948
- "ts/no-implied-eval": "error",
949
- "ts/no-misused-promises": "error",
950
- "ts/no-throw-literal": "error",
951
- "ts/no-unnecessary-type-assertion": "error",
952
- "ts/no-unsafe-argument": "error",
953
- "ts/no-unsafe-assignment": "error",
954
- "ts/no-unsafe-call": "error",
955
- "ts/no-unsafe-member-access": "error",
956
- "ts/no-unsafe-return": "error",
957
- "ts/restrict-plus-operands": "error",
958
- "ts/restrict-template-expressions": "error",
959
- "ts/unbound-method": "error"
1044
+ // Pass error message when throwing errors
1045
+ "unicorn/error-message": "error",
1046
+ // Uppercase regex escapes
1047
+ "unicorn/escape-case": "error",
1048
+ // Array.isArray instead of instanceof
1049
+ "unicorn/no-instanceof-array": "error",
1050
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1051
+ "unicorn/no-new-array": "error",
1052
+ // Prevent deprecated `new Buffer()`
1053
+ "unicorn/no-new-buffer": "error",
1054
+ // Keep regex literals safe!
1055
+ "unicorn/no-unsafe-regex": "error",
1056
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1057
+ "unicorn/number-literal-case": "error",
1058
+ // includes over indexOf when checking for existence
1059
+ "unicorn/prefer-includes": "error",
1060
+ // Prefer using the node: protocol
1061
+ "unicorn/prefer-node-protocol": "error",
1062
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1063
+ "unicorn/prefer-number-properties": "error",
1064
+ // String methods startsWith/endsWith instead of more complicated stuff
1065
+ "unicorn/prefer-string-starts-ends-with": "error",
1066
+ // textContent instead of innerText
1067
+ "unicorn/prefer-text-content": "error",
1068
+ // Enforce throwing type error when throwing error while checking typeof
1069
+ "unicorn/prefer-type-error": "error",
1070
+ // Use new when throwing error
1071
+ "unicorn/throw-new-error": "error"
960
1072
  }
961
1073
  }
962
1074
  ];
963
1075
  }
964
1076
 
965
- // src/configs/unicorn.ts
966
- var unicorn = [
967
- {
968
- plugins: {
969
- unicorn: default11
970
- },
971
- rules: {
972
- // Pass error message when throwing errors
973
- "unicorn/error-message": "error",
974
- // Uppercase regex escapes
975
- "unicorn/escape-case": "error",
976
- // Array.isArray instead of instanceof
977
- "unicorn/no-instanceof-array": "error",
978
- // Ban `new Array` as `Array` constructor's params are ambiguous
979
- "unicorn/no-new-array": "error",
980
- // Prevent deprecated `new Buffer()`
981
- "unicorn/no-new-buffer": "error",
982
- // Keep regex literals safe!
983
- "unicorn/no-unsafe-regex": "error",
984
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
985
- "unicorn/number-literal-case": "error",
986
- // includes over indexOf when checking for existence
987
- "unicorn/prefer-includes": "error",
988
- // Prefer using the node: protocol
989
- "unicorn/prefer-node-protocol": "error",
990
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
991
- "unicorn/prefer-number-properties": "error",
992
- // String methods startsWith/endsWith instead of more complicated stuff
993
- "unicorn/prefer-string-starts-ends-with": "error",
994
- // textContent instead of innerText
995
- "unicorn/prefer-text-content": "error",
996
- // Enforce throwing type error when throwing error while checking typeof
997
- "unicorn/prefer-type-error": "error",
998
- // Use new when throwing error
999
- "unicorn/throw-new-error": "error"
1000
- }
1001
- }
1002
- ];
1003
-
1004
1077
  // src/configs/vue.ts
1005
1078
  import process2 from "process";
1006
1079
  import { getPackageInfoSync } from "local-pkg";
@@ -1024,7 +1097,16 @@ var vue2Rules = {
1024
1097
  ...default13.configs.recommended.rules
1025
1098
  };
1026
1099
  function vue(options = {}) {
1100
+ const {
1101
+ overrides = {},
1102
+ stylistic: stylistic2 = true
1103
+ } = options;
1027
1104
  return [
1105
+ {
1106
+ plugins: {
1107
+ vue: default13
1108
+ }
1109
+ },
1028
1110
  {
1029
1111
  files: [GLOB_VUE],
1030
1112
  languageOptions: {
@@ -1038,27 +1120,13 @@ function vue(options = {}) {
1038
1120
  sourceType: "module"
1039
1121
  }
1040
1122
  },
1041
- plugins: {
1042
- vue: default13
1043
- },
1044
1123
  processor: default13.processors[".vue"],
1045
1124
  rules: {
1046
1125
  ...isVue3 ? vue3Rules : vue2Rules,
1047
1126
  "node/prefer-global/process": OFF,
1048
- "vue/array-bracket-spacing": ["error", "never"],
1049
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1050
1127
  "vue/block-order": ["error", {
1051
1128
  order: ["script", "template", "style"]
1052
1129
  }],
1053
- "vue/block-spacing": ["error", "always"],
1054
- "vue/block-tag-newline": ["error", {
1055
- multiline: "always",
1056
- singleline: "always"
1057
- }],
1058
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1059
- "vue/comma-dangle": ["error", "always-multiline"],
1060
- "vue/comma-spacing": ["error", { after: true, before: false }],
1061
- "vue/comma-style": ["error", "last"],
1062
1130
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1063
1131
  "vue/component-options-name-casing": ["error", "PascalCase"],
1064
1132
  "vue/custom-event-name-casing": ["error", "camelCase"],
@@ -1068,11 +1136,6 @@ function vue(options = {}) {
1068
1136
  "vue/dot-location": ["error", "property"],
1069
1137
  "vue/dot-notation": ["error", { allowKeywords: true }],
1070
1138
  "vue/eqeqeq": ["error", "smart"],
1071
- "vue/html-comment-content-spacing": ["error", "always", {
1072
- exceptions: ["-"]
1073
- }],
1074
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1075
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1076
1139
  "vue/max-attributes-per-line": OFF,
1077
1140
  "vue/multi-word-component-names": OFF,
1078
1141
  "vue/no-dupe-keys": OFF,
@@ -1092,10 +1155,6 @@ function vue(options = {}) {
1092
1155
  "vue/no-unused-refs": "error",
1093
1156
  "vue/no-useless-v-bind": "error",
1094
1157
  "vue/no-v-html": OFF,
1095
- "vue/no-v-text-v-html-on-component": OFF,
1096
- "vue/object-curly-newline": OFF,
1097
- "vue/object-curly-spacing": ["error", "always"],
1098
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1099
1158
  "vue/object-shorthand": [
1100
1159
  "error",
1101
1160
  "always",
@@ -1104,74 +1163,120 @@ function vue(options = {}) {
1104
1163
  ignoreConstructors: false
1105
1164
  }
1106
1165
  ],
1107
- "vue/operator-linebreak": ["error", "before"],
1108
- "vue/padding-line-between-blocks": ["error", "always"],
1109
1166
  "vue/prefer-separate-static-class": "error",
1110
1167
  "vue/prefer-template": "error",
1111
- "vue/quote-props": ["error", "consistent-as-needed"],
1112
1168
  "vue/require-default-prop": OFF,
1113
1169
  "vue/require-prop-types": OFF,
1114
- "vue/space-in-parens": ["error", "never"],
1115
1170
  "vue/space-infix-ops": "error",
1116
1171
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1117
- "vue/template-curly-spacing": "error"
1172
+ ...stylistic2 ? {
1173
+ "vue/array-bracket-spacing": ["error", "never"],
1174
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1175
+ "vue/block-spacing": ["error", "always"],
1176
+ "vue/block-tag-newline": ["error", {
1177
+ multiline: "always",
1178
+ singleline: "always"
1179
+ }],
1180
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1181
+ "vue/comma-dangle": ["error", "always-multiline"],
1182
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1183
+ "vue/comma-style": ["error", "last"],
1184
+ "vue/html-comment-content-spacing": ["error", "always", {
1185
+ exceptions: ["-"]
1186
+ }],
1187
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1188
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1189
+ "vue/object-curly-newline": OFF,
1190
+ "vue/object-curly-spacing": ["error", "always"],
1191
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1192
+ "vue/operator-linebreak": ["error", "before"],
1193
+ "vue/padding-line-between-blocks": ["error", "always"],
1194
+ "vue/quote-props": ["error", "consistent-as-needed"],
1195
+ "vue/space-in-parens": ["error", "never"],
1196
+ "vue/template-curly-spacing": "error"
1197
+ } : {},
1198
+ ...overrides
1118
1199
  }
1119
1200
  }
1120
1201
  ];
1121
1202
  }
1122
1203
 
1123
- // src/configs/yml.ts
1124
- var yml = [
1125
- {
1126
- files: [GLOB_YAML],
1127
- languageOptions: {
1128
- parser: default21
1129
- },
1130
- plugins: {
1131
- yml: default14
1132
- },
1133
- rules: {
1134
- "style/spaced-comment": OFF,
1135
- "yml/block-mapping": "error",
1136
- "yml/block-mapping-question-indicator-newline": "error",
1137
- "yml/block-sequence": "error",
1138
- "yml/block-sequence-hyphen-indicator-newline": "error",
1139
- "yml/flow-mapping-curly-newline": "error",
1140
- "yml/flow-mapping-curly-spacing": "error",
1141
- "yml/flow-sequence-bracket-newline": "error",
1142
- "yml/flow-sequence-bracket-spacing": "error",
1143
- "yml/indent": ["error", 2],
1144
- "yml/key-spacing": "error",
1145
- "yml/no-empty-key": "error",
1146
- "yml/no-empty-sequence-entry": "error",
1147
- "yml/no-irregular-whitespace": "error",
1148
- "yml/no-tab-indent": "error",
1149
- "yml/plain-scalar": "error",
1150
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1151
- "yml/spaced-comment": "error",
1152
- "yml/vue-custom-block/no-parsing-error": "error"
1153
- }
1154
- }
1155
- ];
1156
-
1157
- // src/configs/test.ts
1158
- function test(options = {}) {
1204
+ // src/configs/yaml.ts
1205
+ function yaml(options = {}) {
1206
+ const {
1207
+ overrides = {},
1208
+ stylistic: stylistic2 = true
1209
+ } = options;
1159
1210
  return [
1160
1211
  {
1161
- files: GLOB_TESTS,
1162
1212
  plugins: {
1163
- "no-only-tests": default15
1213
+ yaml: default14
1214
+ }
1215
+ },
1216
+ {
1217
+ files: [GLOB_YAML],
1218
+ languageOptions: {
1219
+ parser: default21
1164
1220
  },
1165
1221
  rules: {
1166
- "no-only-tests/no-only-tests": options.isInEditor ? OFF : "error"
1222
+ "style/spaced-comment": OFF,
1223
+ "yaml/block-mapping": "error",
1224
+ "yaml/block-sequence": "error",
1225
+ "yaml/no-empty-key": "error",
1226
+ "yaml/no-empty-sequence-entry": "error",
1227
+ "yaml/no-irregular-whitespace": "error",
1228
+ "yaml/plain-scalar": "error",
1229
+ "yaml/vue-custom-block/no-parsing-error": "error",
1230
+ ...stylistic2 ? {
1231
+ "yaml/block-mapping-question-indicator-newline": "error",
1232
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1233
+ "yaml/flow-mapping-curly-newline": "error",
1234
+ "yaml/flow-mapping-curly-spacing": "error",
1235
+ "yaml/flow-sequence-bracket-newline": "error",
1236
+ "yaml/flow-sequence-bracket-spacing": "error",
1237
+ "yaml/indent": ["error", 2],
1238
+ "yaml/key-spacing": "error",
1239
+ "yaml/no-tab-indent": "error",
1240
+ "yaml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1241
+ "yaml/spaced-comment": "error"
1242
+ } : {},
1243
+ ...overrides
1167
1244
  }
1168
1245
  }
1169
1246
  ];
1170
1247
  }
1171
1248
 
1249
+ // src/configs/test.ts
1250
+ function test(options = {}) {
1251
+ const {
1252
+ isInEditor = false,
1253
+ overrides = {}
1254
+ } = options;
1255
+ return [{
1256
+ plugins: {
1257
+ "no-only-tests": default15
1258
+ }
1259
+ }, {
1260
+ files: GLOB_TESTS,
1261
+ rules: {
1262
+ "no-only-tests/no-only-tests": isInEditor ? OFF : "error",
1263
+ ...overrides
1264
+ }
1265
+ }];
1266
+ }
1267
+
1172
1268
  // src/configs/react.ts
1173
1269
  function react(options = {}) {
1270
+ const {
1271
+ overrides = {}
1272
+ } = options;
1174
1273
  return [
1274
+ {
1275
+ plugins: {
1276
+ "react": default16,
1277
+ "react-hooks": default17
1278
+ }
1279
+ },
1175
1280
  {
1176
1281
  files: [GLOB_JSX, GLOB_TSX],
1177
1282
  languageOptions: {
@@ -1183,15 +1288,12 @@ function react(options = {}) {
1183
1288
  sourceType: "module"
1184
1289
  }
1185
1290
  },
1186
- plugins: {
1187
- "react": default16,
1188
- "react-hooks": default17
1189
- },
1190
1291
  rules: {
1191
1292
  "jsx-quotes": ["error", "prefer-double"],
1192
1293
  ...default16.configs.recommended.rules,
1193
1294
  "react/react-in-jsx-scope": OFF,
1194
- ...default17.configs.recommended.rules
1295
+ ...default17.configs.recommended.rules,
1296
+ ...overrides
1195
1297
  },
1196
1298
  settings: {
1197
1299
  react: {
@@ -1204,7 +1306,13 @@ function react(options = {}) {
1204
1306
 
1205
1307
  // src/configs/astro.ts
1206
1308
  function astro(options = {}) {
1309
+ const { overrides = {} } = options;
1207
1310
  return [
1311
+ {
1312
+ plugins: {
1313
+ astro: default18
1314
+ }
1315
+ },
1208
1316
  {
1209
1317
  files: [GLOB_ASTRO],
1210
1318
  languageOptions: {
@@ -1214,11 +1322,9 @@ function astro(options = {}) {
1214
1322
  parser: options.typescript ? default19 : null
1215
1323
  }
1216
1324
  },
1217
- plugins: {
1218
- astro: default18
1219
- },
1220
1325
  rules: {
1221
- ...default18.configs.recommended.rules
1326
+ ...default18.configs.recommended.rules,
1327
+ ...overrides
1222
1328
  }
1223
1329
  }
1224
1330
  ];
@@ -1235,14 +1341,31 @@ var flatConfigProps = [
1235
1341
  "rules",
1236
1342
  "settings"
1237
1343
  ];
1344
+ var VuePackages = [
1345
+ "vue",
1346
+ "nuxt",
1347
+ "vitepress",
1348
+ "@slidev/cli"
1349
+ ];
1350
+ var ReactPackages = [
1351
+ "react",
1352
+ "next"
1353
+ ];
1354
+ var AstroPackages = [
1355
+ "astro"
1356
+ ];
1238
1357
  function coderwyd(options = {}, ...userConfigs) {
1239
- const isInEditor = options.isInEditor ?? !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI);
1240
- const enableVue = options.vue ?? (isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli"));
1241
- const enableReact = options.react ?? (isPackageExists("react") || isPackageExists("next") || isPackageExists("react-dom"));
1242
- const enableAstro = options.astro ?? isPackageExists("astro");
1243
- const enableTypeScript = options.typescript ?? isPackageExists("typescript");
1244
- const enableStylistic = options.stylistic ?? true;
1245
- const enableGitignore = options.gitignore ?? true;
1358
+ const {
1359
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
1360
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1361
+ react: enableReact = ReactPackages.some((i) => isPackageExists(i)),
1362
+ astro: enableAstro = AstroPackages.some((i) => isPackageExists(i)),
1363
+ typescript: enableTypeScript = isPackageExists("typescript"),
1364
+ stylistic: enableStylistic = true,
1365
+ gitignore: enableGitignore = true,
1366
+ overrides = {},
1367
+ componentExts = []
1368
+ } = options;
1246
1369
  const configs = [];
1247
1370
  if (enableGitignore) {
1248
1371
  if (typeof enableGitignore !== "boolean") {
@@ -1253,47 +1376,65 @@ function coderwyd(options = {}, ...userConfigs) {
1253
1376
  }
1254
1377
  }
1255
1378
  configs.push(
1256
- ignores,
1379
+ ignores(),
1257
1380
  javascript({ isInEditor }),
1258
- comments,
1259
- node,
1260
- jsdoc,
1261
- imports,
1262
- unicorn
1381
+ comments(),
1382
+ node(),
1383
+ jsdoc({
1384
+ stylistic: enableStylistic
1385
+ }),
1386
+ imports({
1387
+ stylistic: enableStylistic
1388
+ }),
1389
+ unicorn()
1263
1390
  );
1264
- const componentExts = [];
1265
1391
  if (enableVue)
1266
1392
  componentExts.push("vue");
1267
1393
  if (enableTypeScript) {
1268
- configs.push(typescript({ componentExts }));
1269
- if (typeof enableTypeScript !== "boolean") {
1270
- configs.push(typescriptWithLanguageServer({
1271
- ...enableTypeScript,
1272
- componentExts
1273
- }));
1274
- }
1394
+ configs.push(typescript({
1395
+ ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1396
+ componentExts,
1397
+ overrides: overrides.typescript
1398
+ }));
1275
1399
  }
1276
1400
  if (enableStylistic)
1277
- configs.push(stylistic);
1401
+ configs.push(stylistic());
1278
1402
  if (options.test ?? true)
1279
- configs.push(test({ isInEditor }));
1280
- if (enableVue)
1281
- configs.push(vue({ typescript: !!enableTypeScript }));
1282
- if (enableReact)
1283
- configs.push(react({ typescript: !!enableTypeScript }));
1284
- if (enableAstro)
1285
- configs.push(astro({ typescript: !!enableTypeScript }));
1403
+ configs.push(test({ isInEditor, overrides: overrides.test }));
1404
+ if (enableVue) {
1405
+ configs.push(vue({
1406
+ overrides: overrides.vue,
1407
+ stylistic: enableStylistic,
1408
+ typescript: !!enableTypeScript
1409
+ }));
1410
+ }
1411
+ if (enableReact) {
1412
+ configs.push(react({
1413
+ overrides: overrides.react,
1414
+ typescript: !!enableTypeScript
1415
+ }));
1416
+ }
1417
+ if (enableAstro) {
1418
+ configs.push(astro({
1419
+ overrides: overrides.astro,
1420
+ typescript: !!enableTypeScript
1421
+ }));
1422
+ }
1286
1423
  if (options.jsonc ?? true) {
1287
1424
  configs.push(
1288
- jsonc,
1289
- sortPackageJson,
1290
- sortTsconfig
1425
+ jsonc(),
1426
+ sortPackageJson(),
1427
+ sortTsconfig()
1291
1428
  );
1292
1429
  }
1293
- if (options.yaml ?? true)
1294
- configs.push(yml);
1430
+ if (options.yaml ?? true) {
1431
+ configs.push(yaml({
1432
+ overrides: overrides.yaml,
1433
+ stylistic: enableStylistic
1434
+ }));
1435
+ }
1295
1436
  if (options.markdown ?? true)
1296
- configs.push(markdown({ componentExts }));
1437
+ configs.push(markdown({ componentExts, overrides: overrides.markdown }));
1297
1438
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1298
1439
  if (key in options)
1299
1440
  acc[key] = options[key];
@@ -1311,6 +1452,28 @@ function coderwyd(options = {}, ...userConfigs) {
1311
1452
  // src/index.ts
1312
1453
  var src_default = coderwyd;
1313
1454
  export {
1455
+ GLOB_ALL_SRC,
1456
+ GLOB_ASTRO,
1457
+ GLOB_CSS,
1458
+ GLOB_EXCLUDE,
1459
+ GLOB_HTML,
1460
+ GLOB_JS,
1461
+ GLOB_JSON,
1462
+ GLOB_JSON5,
1463
+ GLOB_JSONC,
1464
+ GLOB_JSX,
1465
+ GLOB_LESS,
1466
+ GLOB_MARKDOWN,
1467
+ GLOB_MARKDOWN_CODE,
1468
+ GLOB_SCSS,
1469
+ GLOB_SRC,
1470
+ GLOB_SRC_EXT,
1471
+ GLOB_STYLE,
1472
+ GLOB_TESTS,
1473
+ GLOB_TS,
1474
+ GLOB_TSX,
1475
+ GLOB_VUE,
1476
+ GLOB_YAML,
1314
1477
  astro,
1315
1478
  coderwyd,
1316
1479
  combine,
@@ -1328,7 +1491,7 @@ export {
1328
1491
  default22 as parserJsonc,
1329
1492
  default19 as parserTs,
1330
1493
  default20 as parserVue,
1331
- default21 as parserYml,
1494
+ default21 as parserYaml,
1332
1495
  default2 as pluginAntfu,
1333
1496
  default18 as pluginAstro,
1334
1497
  default3 as pluginComments,
@@ -1345,7 +1508,7 @@ export {
1345
1508
  default11 as pluginUnicorn,
1346
1509
  default12 as pluginUnusedImports,
1347
1510
  default13 as pluginVue,
1348
- default14 as pluginYml,
1511
+ default14 as pluginYaml,
1349
1512
  react,
1350
1513
  renameRules,
1351
1514
  sortPackageJson,
@@ -1353,8 +1516,7 @@ export {
1353
1516
  stylistic,
1354
1517
  test,
1355
1518
  typescript,
1356
- typescriptWithLanguageServer,
1357
1519
  unicorn,
1358
1520
  vue,
1359
- yml
1521
+ yaml
1360
1522
  };