@ntnyq/eslint-config 3.0.0-beta.2 → 3.0.0-beta.4

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
@@ -43,13 +43,13 @@ function getOverrides(options, key) {
43
43
 
44
44
  // src/globs.ts
45
45
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
46
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
46
+ var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
47
47
  var GLOB_JS = "**/*.?([cm])js";
48
48
  var GLOB_JSX = "**/*.?([cm])jsx";
49
49
  var GLOB_TS = "**/*.?([cm])ts";
50
50
  var GLOB_TSX = "**/*.?([cm])tsx";
51
51
  var GLOB_DTS = "**/*.d.?([cm])ts";
52
- var GLOB_TEST = "**/*.{test,spec}.?([cm])[jt]s?(x)";
52
+ var GLOB_TEST = `**/*.{test,spec,bench,benchmark}.${GLOB_SRC_EXT}`;
53
53
  var GLOB_STYLE = "**/*.{c,le,sc}ss";
54
54
  var GLOB_CSS = "**/*.css";
55
55
  var GLOB_LESS = "**/*.less";
@@ -58,20 +58,22 @@ var GLOB_JSON = "**/*.json";
58
58
  var GLOB_JSON5 = "**/*.json5";
59
59
  var GLOB_JSONC = "**/*.jsonc";
60
60
  var GLOB_VUE = "**/*.vue";
61
- var GLOB_MARKDOWN = "**/*.md";
62
61
  var GLOB_YAML = "**/*.y?(a)ml";
63
62
  var GLOB_TOML = "**/*.toml";
64
63
  var GLOB_HTML = "**/*.htm?(l)";
64
+ var GLOB_MARKDOWN = "**/*.md";
65
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
66
+ var GLOB_MARKDOWN_NESTED = `${GLOB_MARKDOWN}/*.md`;
65
67
  var GLOB_ALL_SRC = [
66
68
  GLOB_SRC,
67
69
  GLOB_STYLE,
68
70
  GLOB_JSON,
69
71
  GLOB_JSON5,
70
- GLOB_MARKDOWN,
71
72
  GLOB_VUE,
72
73
  GLOB_YAML,
73
74
  GLOB_TOML,
74
- GLOB_HTML
75
+ GLOB_HTML,
76
+ GLOB_MARKDOWN
75
77
  ];
76
78
  var GLOB_NODE_MODULES = "**/node_modules/**";
77
79
  var GLOB_DIST = "**/dist/**";
@@ -233,6 +235,8 @@ var imports = (options = {}) => [
233
235
  "import/no-named-as-default-member": "off",
234
236
  "import/first": "error",
235
237
  "import/export": "error",
238
+ // 'import/no-named-default': 'error',
239
+ "import/no-self-import": "error",
236
240
  "import/no-duplicates": "error",
237
241
  "import/no-mutable-exports": "error",
238
242
  "import/newline-after-import": "error",
@@ -384,7 +388,7 @@ var prettier = (options = {}) => [
384
388
  "vue/space-unary-ops": "off",
385
389
  "vue/template-curly-spacing": "off",
386
390
  ...default12.configs.recommended.rules,
387
- "prettier/prettier": "warn",
391
+ "prettier/prettier": options.level || "warn",
388
392
  // Overrides built-in rules
389
393
  ...options.overrides
390
394
  }
@@ -423,320 +427,337 @@ var comments = (options = {}) => [
423
427
  // src/configs/javascript.ts
424
428
  import globals from "globals";
425
429
  import jsConfig from "@eslint/js";
426
- var javascript = (option = {}) => [
427
- {
428
- name: "ntnyq/js/recommended",
429
- ...jsConfig.configs.recommended
430
- },
430
+ var javascript = (options = {}) => {
431
+ const strictRules = {
432
+ complexity: ["error", { max: 30 }],
433
+ "max-params": ["error", { max: 5 }],
434
+ "max-depth": ["error", { max: 5 }],
435
+ "max-nested-callbacks": ["error", { max: 10 }],
436
+ "max-lines": [
437
+ "error",
438
+ {
439
+ max: 1e3,
440
+ skipComments: true,
441
+ skipBlankLines: true
442
+ }
443
+ ],
444
+ "max-lines-per-function": [
445
+ "error",
446
+ {
447
+ max: 200,
448
+ skipComments: true,
449
+ skipBlankLines: true
450
+ }
451
+ ]
452
+ };
453
+ return [
454
+ {
455
+ ...jsConfig.configs.recommended,
456
+ name: "ntnyq/js/recommended"
457
+ },
458
+ {
459
+ name: "ntnyq/js/core",
460
+ languageOptions: {
461
+ globals: {
462
+ ...globals.browser,
463
+ ...globals.es2021,
464
+ ...globals.node
465
+ },
466
+ sourceType: "module"
467
+ },
468
+ rules: {
469
+ // standard v17.0.0
470
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
471
+ camelcase: [
472
+ "error",
473
+ {
474
+ allow: ["^UNSAFE_"],
475
+ properties: "never",
476
+ ignoreGlobals: true
477
+ }
478
+ ],
479
+ "constructor-super": "error",
480
+ curly: ["error", "multi-line"],
481
+ "default-case-last": "error",
482
+ "dot-notation": ["error", { allowKeywords: true }],
483
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
484
+ "no-array-constructor": "error",
485
+ "no-async-promise-executor": "error",
486
+ "no-caller": "error",
487
+ "no-class-assign": "error",
488
+ "no-compare-neg-zero": "error",
489
+ "no-cond-assign": "error",
490
+ "no-const-assign": "error",
491
+ "no-constant-condition": ["error", { checkLoops: false }],
492
+ "no-control-regex": "error",
493
+ "no-debugger": "error",
494
+ "no-delete-var": "error",
495
+ "no-dupe-args": "error",
496
+ "no-dupe-class-members": "error",
497
+ "no-dupe-keys": "error",
498
+ "no-duplicate-case": "error",
499
+ "no-useless-backreference": "error",
500
+ "no-empty": ["error", { allowEmptyCatch: true }],
501
+ "no-empty-character-class": "error",
502
+ "no-empty-pattern": "error",
503
+ "no-eval": "error",
504
+ "no-ex-assign": "error",
505
+ "no-extend-native": "error",
506
+ "no-extra-bind": "error",
507
+ "no-extra-boolean-cast": "error",
508
+ "no-fallthrough": "error",
509
+ "no-func-assign": "error",
510
+ "no-global-assign": "error",
511
+ "no-implied-eval": "error",
512
+ "no-import-assign": "error",
513
+ "no-invalid-regexp": "error",
514
+ "no-irregular-whitespace": "error",
515
+ "no-iterator": "error",
516
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
517
+ "no-lone-blocks": "error",
518
+ "no-loss-of-precision": "error",
519
+ "no-misleading-character-class": "error",
520
+ "no-prototype-builtins": "error",
521
+ "no-useless-catch": "error",
522
+ "no-new": "error",
523
+ "no-new-func": "error",
524
+ "no-new-wrappers": "error",
525
+ "no-obj-calls": "error",
526
+ "no-octal": "error",
527
+ "no-octal-escape": "error",
528
+ "no-proto": "error",
529
+ "no-redeclare": ["error", { builtinGlobals: false }],
530
+ "no-regex-spaces": "error",
531
+ "no-self-assign": ["error", { props: true }],
532
+ "no-self-compare": "error",
533
+ "no-sequences": "error",
534
+ "no-shadow-restricted-names": "error",
535
+ "no-sparse-arrays": "error",
536
+ "no-template-curly-in-string": "error",
537
+ "no-this-before-super": "error",
538
+ "no-throw-literal": "error",
539
+ "no-undef": "error",
540
+ "no-undef-init": "error",
541
+ "no-unexpected-multiline": "error",
542
+ "no-unmodified-loop-condition": "error",
543
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
544
+ "no-unreachable": "error",
545
+ "no-unreachable-loop": "error",
546
+ "no-unsafe-finally": "error",
547
+ "no-unsafe-negation": "error",
548
+ "no-unused-expressions": [
549
+ "error",
550
+ {
551
+ allowShortCircuit: true,
552
+ allowTernary: true,
553
+ allowTaggedTemplates: true
554
+ }
555
+ ],
556
+ "no-unused-vars": [
557
+ "error",
558
+ {
559
+ args: "none",
560
+ caughtErrors: "none",
561
+ ignoreRestSiblings: true,
562
+ vars: "all"
563
+ }
564
+ ],
565
+ "no-useless-call": "error",
566
+ "no-useless-computed-key": "error",
567
+ "no-useless-constructor": "error",
568
+ "no-useless-rename": "error",
569
+ "no-useless-return": "error",
570
+ "prefer-promise-reject-errors": "error",
571
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
572
+ "symbol-description": "error",
573
+ "unicode-bom": ["error", "never"],
574
+ "use-isnan": [
575
+ "error",
576
+ {
577
+ enforceForSwitchCase: true,
578
+ enforceForIndexOf: true
579
+ }
580
+ ],
581
+ "valid-typeof": ["error", { requireStringLiterals: true }],
582
+ yoda: ["error", "never"],
583
+ // es6+
584
+ "no-var": "error",
585
+ "prefer-rest-params": "error",
586
+ "prefer-spread": "error",
587
+ "prefer-template": "error",
588
+ "no-empty-static-block": "error",
589
+ "no-new-native-nonconstructor": "error",
590
+ "prefer-const": [
591
+ "error",
592
+ {
593
+ destructuring: "all",
594
+ ignoreReadBeforeAssign: true
595
+ }
596
+ ],
597
+ "prefer-arrow-callback": [
598
+ "error",
599
+ {
600
+ allowNamedFunctions: false,
601
+ allowUnboundThis: true
602
+ }
603
+ ],
604
+ "object-shorthand": [
605
+ "error",
606
+ "always",
607
+ {
608
+ ignoreConstructors: false,
609
+ avoidQuotes: true
610
+ }
611
+ ],
612
+ // best-practice
613
+ eqeqeq: ["error", "smart"],
614
+ "array-callback-return": "error",
615
+ "block-scoped-var": "error",
616
+ "consistent-return": "off",
617
+ "no-alert": "error",
618
+ "no-case-declarations": "error",
619
+ "no-multi-str": "error",
620
+ "no-with": "error",
621
+ "no-void": "error",
622
+ "no-useless-escape": "off",
623
+ "vars-on-top": "error",
624
+ "require-await": "off",
625
+ "no-return-assign": "off",
626
+ "one-var": ["error", "never"],
627
+ "no-use-before-define": [
628
+ "error",
629
+ {
630
+ functions: false,
631
+ classes: false,
632
+ variables: true
633
+ }
634
+ ],
635
+ "sort-imports": [
636
+ "error",
637
+ {
638
+ ignoreCase: false,
639
+ ignoreDeclarationSort: true,
640
+ ignoreMemberSort: false,
641
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
642
+ allowSeparatedGroups: false
643
+ }
644
+ ],
645
+ // Strict rules
646
+ ...options.strict ? strictRules : {},
647
+ // Overrides built-in rules
648
+ ...options.overrides
649
+ }
650
+ },
651
+ {
652
+ name: "ntnyq/js/scripts",
653
+ files: ["**/scripts/*", "**/cli.*"],
654
+ rules: {
655
+ "no-console": "off"
656
+ }
657
+ },
658
+ {
659
+ name: "ntnyq/js/test",
660
+ files: ["**/*.{test,spec}.js?(x)"],
661
+ rules: {
662
+ "no-unused-expressions": "off",
663
+ "max-lines-per-function": "off"
664
+ }
665
+ }
666
+ ];
667
+ };
668
+ var jsx = () => [
431
669
  {
432
- name: "ntnyq/js/core",
670
+ name: "ntnyq/jsx",
671
+ files: ["**/*.jsx"],
433
672
  languageOptions: {
434
- globals: {
435
- ...globals.browser,
436
- ...globals.es2021,
437
- ...globals.node
438
- },
439
- sourceType: "module"
673
+ parserOptions: {
674
+ ecmaFeatures: {
675
+ jsx: true
676
+ }
677
+ }
678
+ }
679
+ }
680
+ ];
681
+
682
+ // src/configs/typescript.ts
683
+ import process2 from "node:process";
684
+ var typescriptCore = (options = {}) => {
685
+ const isTypeAware = !!options.tsconfigPath;
686
+ const configs = tseslint.config({
687
+ name: "ntnyq/ts/core",
688
+ extends: [...tseslint.configs.recommended],
689
+ files: [GLOB_TS, GLOB_TSX],
690
+ languageOptions: {
691
+ parser: tseslint.parser,
692
+ parserOptions: {
693
+ sourceType: "module",
694
+ ...isTypeAware ? {
695
+ projectService: {
696
+ defaultProject: options.tsconfigPath
697
+ },
698
+ tsconfigRootDir: process2.cwd()
699
+ } : {}
700
+ }
440
701
  },
441
702
  rules: {
442
- // standard v17.0.0
443
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
444
- camelcase: [
703
+ "@typescript-eslint/no-unused-vars": [
445
704
  "error",
446
705
  {
447
- allow: ["^UNSAFE_"],
448
- properties: "never",
449
- ignoreGlobals: true
450
- }
451
- ],
452
- "constructor-super": "error",
453
- curly: ["error", "multi-line"],
454
- "default-case-last": "error",
455
- "dot-notation": ["error", { allowKeywords: true }],
456
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
457
- "no-array-constructor": "error",
458
- "no-async-promise-executor": "error",
459
- "no-caller": "error",
460
- "no-class-assign": "error",
461
- "no-compare-neg-zero": "error",
462
- "no-cond-assign": "error",
463
- "no-const-assign": "error",
464
- "no-constant-condition": ["error", { checkLoops: false }],
465
- "no-control-regex": "error",
466
- "no-debugger": "error",
467
- "no-delete-var": "error",
468
- "no-dupe-args": "error",
469
- "no-dupe-class-members": "error",
470
- "no-dupe-keys": "error",
471
- "no-duplicate-case": "error",
472
- "no-useless-backreference": "error",
473
- "no-empty": ["error", { allowEmptyCatch: true }],
474
- "no-empty-character-class": "error",
475
- "no-empty-pattern": "error",
476
- "no-eval": "error",
477
- "no-ex-assign": "error",
478
- "no-extend-native": "error",
479
- "no-extra-bind": "error",
480
- "no-extra-boolean-cast": "error",
481
- "no-fallthrough": "error",
482
- "no-func-assign": "error",
483
- "no-global-assign": "error",
484
- "no-implied-eval": "error",
485
- "no-import-assign": "error",
486
- "no-invalid-regexp": "error",
487
- "no-irregular-whitespace": "error",
488
- "no-iterator": "error",
489
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
490
- "no-lone-blocks": "error",
491
- "no-loss-of-precision": "error",
492
- "no-misleading-character-class": "error",
493
- "no-prototype-builtins": "error",
494
- "no-useless-catch": "error",
495
- "no-new": "error",
496
- "no-new-func": "error",
497
- "no-new-wrappers": "error",
498
- "no-obj-calls": "error",
499
- "no-octal": "error",
500
- "no-octal-escape": "error",
501
- "no-proto": "error",
502
- "no-redeclare": ["error", { builtinGlobals: false }],
503
- "no-regex-spaces": "error",
504
- "no-self-assign": ["error", { props: true }],
505
- "no-self-compare": "error",
506
- "no-sequences": "error",
507
- "no-shadow-restricted-names": "error",
508
- "no-sparse-arrays": "error",
509
- "no-template-curly-in-string": "error",
510
- "no-this-before-super": "error",
511
- "no-throw-literal": "error",
512
- "no-undef": "error",
513
- "no-undef-init": "error",
514
- "no-unexpected-multiline": "error",
515
- "no-unmodified-loop-condition": "error",
516
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
517
- "no-unreachable": "error",
518
- "no-unreachable-loop": "error",
519
- "no-unsafe-finally": "error",
520
- "no-unsafe-negation": "error",
521
- "no-unused-expressions": [
522
- "error",
523
- {
524
- allowShortCircuit: true,
525
- allowTernary: true,
526
- allowTaggedTemplates: true
527
- }
528
- ],
529
- "no-unused-vars": [
530
- "error",
531
- {
532
- args: "none",
533
- caughtErrors: "none",
534
- ignoreRestSiblings: true,
535
- vars: "all"
536
- }
537
- ],
538
- "no-useless-call": "error",
539
- "no-useless-computed-key": "error",
540
- "no-useless-constructor": "error",
541
- "no-useless-rename": "error",
542
- "no-useless-return": "error",
543
- "prefer-promise-reject-errors": "error",
544
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
545
- "symbol-description": "error",
546
- "unicode-bom": ["error", "never"],
547
- "use-isnan": [
548
- "error",
549
- {
550
- enforceForSwitchCase: true,
551
- enforceForIndexOf: true
552
- }
553
- ],
554
- "valid-typeof": ["error", { requireStringLiterals: true }],
555
- yoda: ["error", "never"],
556
- // es6+
557
- "no-var": "error",
558
- "prefer-rest-params": "error",
559
- "prefer-spread": "error",
560
- "prefer-template": "error",
561
- "no-empty-static-block": "error",
562
- "no-new-native-nonconstructor": "error",
563
- "prefer-const": [
564
- "error",
565
- {
566
- destructuring: "all",
567
- ignoreReadBeforeAssign: true
568
- }
569
- ],
570
- "prefer-arrow-callback": [
571
- "error",
572
- {
573
- allowNamedFunctions: false,
574
- allowUnboundThis: true
575
- }
576
- ],
577
- "object-shorthand": [
578
- "error",
579
- "always",
580
- {
581
- ignoreConstructors: false,
582
- avoidQuotes: true
583
- }
584
- ],
585
- // best-practice
586
- eqeqeq: ["error", "smart"],
587
- complexity: ["error", { max: 30 }],
588
- "array-callback-return": "error",
589
- "block-scoped-var": "error",
590
- "consistent-return": "off",
591
- "no-alert": "error",
592
- "no-case-declarations": "error",
593
- "no-multi-str": "error",
594
- "no-with": "error",
595
- "no-void": "error",
596
- "no-useless-escape": "off",
597
- "vars-on-top": "error",
598
- "require-await": "off",
599
- "no-return-assign": "off",
600
- "one-var": ["error", "never"],
601
- "max-params": ["error", { max: 5 }],
602
- "max-depth": ["error", { max: 5 }],
603
- "max-nested-callbacks": ["error", { max: 10 }],
604
- "max-lines": [
605
- "error",
606
- {
607
- max: 1e3,
608
- skipComments: true,
609
- skipBlankLines: true
706
+ // Args after the last used will be reported
707
+ args: "after-used",
708
+ argsIgnorePattern: "^_",
709
+ caughtErrors: "all",
710
+ caughtErrorsIgnorePattern: "^_",
711
+ destructuredArrayIgnorePattern: "^_",
712
+ varsIgnorePattern: "^_",
713
+ ignoreRestSiblings: true
610
714
  }
611
715
  ],
612
- "max-lines-per-function": [
716
+ "@typescript-eslint/no-redeclare": "error",
717
+ "@typescript-eslint/consistent-type-imports": [
613
718
  "error",
614
719
  {
615
- max: 200,
616
- skipComments: true,
617
- skipBlankLines: true
720
+ prefer: "type-imports",
721
+ fixStyle: "separate-type-imports",
722
+ disallowTypeAnnotations: false
618
723
  }
619
724
  ],
620
- "no-use-before-define": [
725
+ "@typescript-eslint/no-empty-object-type": [
621
726
  "error",
622
727
  {
623
- functions: false,
624
- classes: false,
625
- variables: true
728
+ allowInterfaces: "always",
729
+ allowObjectTypes: "always"
626
730
  }
627
731
  ],
628
- "sort-imports": [
732
+ "@typescript-eslint/consistent-type-assertions": [
629
733
  "error",
630
734
  {
631
- ignoreCase: false,
632
- ignoreDeclarationSort: true,
633
- ignoreMemberSort: false,
634
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
635
- allowSeparatedGroups: false
735
+ assertionStyle: "as",
736
+ objectLiteralTypeAssertions: "allow-as-parameter"
636
737
  }
637
738
  ],
638
- // Overrides built-in rules
639
- ...option.overrides
640
- }
641
- },
642
- {
643
- name: "ntnyq/js/script",
644
- files: ["**/scripts/*", "**/cli.*"],
645
- rules: {
646
- "no-console": "off"
647
- }
648
- },
649
- {
650
- name: "ntnyq/js/test",
651
- files: ["**/*.{test,spec}.js?(x)"],
652
- rules: {
653
- "no-unused-expressions": "off",
654
- "max-lines-per-function": "off"
655
- }
656
- }
657
- ];
658
- var jsx = () => [
659
- {
660
- name: "ntnyq/jsx",
661
- files: ["**/*.jsx"],
662
- languageOptions: {
663
- parserOptions: {
664
- ecmaFeatures: {
665
- jsx: true
666
- }
667
- }
668
- }
669
- }
670
- ];
671
-
672
- // src/configs/typescript.ts
673
- var typescriptCore = (options = {}) => tseslint.config({
674
- name: "ntnyq/ts/core",
675
- extends: [...tseslint.configs.recommended],
676
- files: [GLOB_TS, GLOB_TSX],
677
- languageOptions: {
678
- parser: tseslint.parser,
679
- parserOptions: {
680
- sourceType: "module"
681
- }
682
- },
683
- rules: {
684
- "@typescript-eslint/no-unused-vars": [
685
- "error",
686
- {
687
- // Args after the last used will be reported
688
- args: "after-used",
689
- argsIgnorePattern: "^_",
690
- caughtErrors: "all",
691
- caughtErrorsIgnorePattern: "^_",
692
- destructuredArrayIgnorePattern: "^_",
693
- varsIgnorePattern: "^_",
694
- ignoreRestSiblings: true
695
- }
696
- ],
697
- "@typescript-eslint/no-redeclare": "error",
698
- "@typescript-eslint/consistent-type-imports": [
699
- "error",
700
- {
701
- prefer: "type-imports",
702
- fixStyle: "separate-type-imports",
703
- disallowTypeAnnotations: false
704
- }
705
- ],
706
- "@typescript-eslint/no-empty-object-type": [
707
- "error",
708
- {
709
- allowInterfaces: "always",
710
- allowObjectTypes: "always"
711
- }
712
- ],
713
- "@typescript-eslint/consistent-type-assertions": [
714
- "error",
715
- {
716
- assertionStyle: "as",
717
- objectLiteralTypeAssertions: "allow-as-parameter"
718
- }
719
- ],
720
- "@typescript-eslint/prefer-as-const": "warn",
721
- "@typescript-eslint/ban-types": "off",
722
- "@typescript-eslint/camelcase": "off",
723
- "@typescript-eslint/no-namespace": "off",
724
- "@typescript-eslint/ban-ts-ignore": "off",
725
- "@typescript-eslint/ban-ts-comment": "off",
726
- "@typescript-eslint/no-explicit-any": "off",
727
- "@typescript-eslint/no-empty-function": "off",
728
- "@typescript-eslint/naming-convention": "off",
729
- "@typescript-eslint/no-non-null-assertion": "off",
730
- "@typescript-eslint/triple-slash-reference": "off",
731
- "@typescript-eslint/no-parameter-properties": "off",
732
- "@typescript-eslint/explicit-member-accessibility": "off",
733
- "@typescript-eslint/explicit-function-return-type": "off",
734
- "@typescript-eslint/explicit-module-boundary-types": "off",
735
- "@typescript-eslint/consistent-indexed-object-style": "off"
736
- },
737
- // Overrides built-in rules
738
- ...options.overrides
739
- });
739
+ "@typescript-eslint/prefer-as-const": "warn",
740
+ "@typescript-eslint/ban-types": "off",
741
+ "@typescript-eslint/camelcase": "off",
742
+ "@typescript-eslint/no-namespace": "off",
743
+ "@typescript-eslint/ban-ts-ignore": "off",
744
+ "@typescript-eslint/ban-ts-comment": "off",
745
+ "@typescript-eslint/no-explicit-any": "off",
746
+ "@typescript-eslint/no-empty-function": "off",
747
+ "@typescript-eslint/naming-convention": "off",
748
+ "@typescript-eslint/no-non-null-assertion": "off",
749
+ "@typescript-eslint/triple-slash-reference": "off",
750
+ "@typescript-eslint/no-parameter-properties": "off",
751
+ "@typescript-eslint/explicit-member-accessibility": "off",
752
+ "@typescript-eslint/explicit-function-return-type": "off",
753
+ "@typescript-eslint/explicit-module-boundary-types": "off",
754
+ "@typescript-eslint/consistent-indexed-object-style": "off"
755
+ },
756
+ // Overrides built-in rules
757
+ ...options.overrides
758
+ });
759
+ return configs;
760
+ };
740
761
  var typescript = (options = {}) => [
741
762
  ...typescriptCore(options),
742
763
  {
@@ -870,7 +891,7 @@ var command = () => [
870
891
  // src/configs/vitest.ts
871
892
  var vitest = (options = {}) => [
872
893
  {
873
- name: "ntnyq/test",
894
+ name: "ntnyq/vitest",
874
895
  plugins: {
875
896
  vitest: default9
876
897
  },
@@ -884,16 +905,6 @@ var vitest = (options = {}) => [
884
905
  ];
885
906
 
886
907
  // src/configs/vue.ts
887
- import process2 from "node:process";
888
- import { getPackageInfoSync } from "local-pkg";
889
- function getVueVersion() {
890
- const pkg = getPackageInfoSync("vue", { paths: [process2.cwd()] });
891
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
892
- return +pkg.version[0];
893
- }
894
- return 3;
895
- }
896
- var isVue3 = getVueVersion() === 3;
897
908
  var vue2Rules = {
898
909
  ...default3.configs.base.rules,
899
910
  ...default3.configs.essential.rules,
@@ -906,250 +917,253 @@ var vue3Rules = {
906
917
  ...default3.configs["vue3-strongly-recommended"].rules,
907
918
  ...default3.configs["vue3-recommended"].rules
908
919
  };
909
- var vue = (options = {}) => [
910
- ...tseslint.config({
911
- name: "ntnyq/vue/ts",
912
- files: [GLOB_VUE],
913
- extends: typescriptCore()
914
- }),
915
- {
916
- name: "ntnyq/vue/core",
917
- files: [GLOB_VUE],
918
- plugins: {
919
- vue: default3,
920
- "@typescript-eslint": tseslint.plugin
921
- },
922
- languageOptions: {
923
- parser: parserVue,
924
- parserOptions: {
925
- parser: "@typescript-eslint/parser",
926
- sourceType: "module",
927
- extraFileExtensions: [".vue"],
928
- ecmaFeatures: {
929
- jsx: true
920
+ var vue = (options = {}) => {
921
+ const isVue3 = options.vueVersion !== 2;
922
+ return [
923
+ ...tseslint.config({
924
+ name: "ntnyq/vue/ts",
925
+ files: [GLOB_VUE],
926
+ extends: typescriptCore()
927
+ }),
928
+ {
929
+ name: "ntnyq/vue/core",
930
+ files: [GLOB_VUE],
931
+ plugins: {
932
+ vue: default3,
933
+ "@typescript-eslint": tseslint.plugin
934
+ },
935
+ languageOptions: {
936
+ parser: parserVue,
937
+ parserOptions: {
938
+ parser: "@typescript-eslint/parser",
939
+ sourceType: "module",
940
+ extraFileExtensions: [".vue"],
941
+ ecmaFeatures: {
942
+ jsx: true
943
+ }
930
944
  }
945
+ },
946
+ processor: default3.processors[".vue"],
947
+ rules: {
948
+ ...isVue3 ? vue3Rules : vue2Rules,
949
+ // OFF
950
+ "vue/no-v-html": "off",
951
+ "vue/require-prop-types": "off",
952
+ "vue/require-default-prop": "off",
953
+ "vue/multi-word-component-names": "off",
954
+ "vue/no-setup-props-reactivity-loss": "off",
955
+ "vue/html-self-closing": [
956
+ "error",
957
+ {
958
+ html: {
959
+ void: "always",
960
+ normal: "always",
961
+ component: "always"
962
+ },
963
+ svg: "always",
964
+ math: "always"
965
+ }
966
+ ],
967
+ "vue/block-tag-newline": [
968
+ "error",
969
+ {
970
+ singleline: "always",
971
+ multiline: "always"
972
+ }
973
+ ],
974
+ "vue/component-name-in-template-casing": [
975
+ "error",
976
+ "PascalCase",
977
+ {
978
+ // Force auto-import components to be PascalCase
979
+ registeredComponentsOnly: false,
980
+ ignores: ["slot", "component"]
981
+ }
982
+ ],
983
+ "vue/component-options-name-casing": ["error", "PascalCase"],
984
+ "vue/custom-event-name-casing": ["error", "camelCase"],
985
+ "vue/define-macros-order": [
986
+ "error",
987
+ {
988
+ order: ["defineProps", "defineEmits", "defineOptions", "defineSlots"]
989
+ }
990
+ ],
991
+ "vue/html-comment-content-spacing": [
992
+ "error",
993
+ "always",
994
+ {
995
+ exceptions: ["-"]
996
+ }
997
+ ],
998
+ "vue/array-bracket-spacing": ["error", "never"],
999
+ "vue/arrow-spacing": ["error", { before: true, after: true }],
1000
+ "vue/block-spacing": ["error", "always"],
1001
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1002
+ "vue/comma-dangle": ["error", "always-multiline"],
1003
+ "vue/comma-spacing": ["error", { before: false, after: true }],
1004
+ "vue/comma-style": ["error", "last"],
1005
+ "vue/dot-location": ["error", "property"],
1006
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1007
+ "vue/eqeqeq": ["error", "smart"],
1008
+ "vue/key-spacing": ["error", { beforeColon: false, afterColon: true }],
1009
+ "vue/keyword-spacing": ["error", { before: true, after: true }],
1010
+ "vue/no-empty-pattern": "error",
1011
+ "vue/no-loss-of-precision": "error",
1012
+ "vue/no-irregular-whitespace": "error",
1013
+ "vue/no-use-v-else-with-v-for": "error",
1014
+ "vue/require-typed-object-prop": "error",
1015
+ "vue/no-extra-parens": ["error", "functions"],
1016
+ "vue/no-restricted-syntax": [
1017
+ "error",
1018
+ "DebuggerStatement",
1019
+ "LabeledStatement",
1020
+ "WithStatement"
1021
+ ],
1022
+ "vue/no-sparse-arrays": "error",
1023
+ "vue/no-deprecated-model-definition": [
1024
+ "error",
1025
+ {
1026
+ allowVue3Compat: true
1027
+ }
1028
+ ],
1029
+ "vue/object-curly-newline": [
1030
+ "error",
1031
+ {
1032
+ multiline: true,
1033
+ consistent: true
1034
+ }
1035
+ ],
1036
+ "vue/no-static-inline-styles": [
1037
+ "error",
1038
+ {
1039
+ allowBinding: true
1040
+ }
1041
+ ],
1042
+ "vue/object-curly-spacing": ["error", "always"],
1043
+ "vue/object-property-newline": [
1044
+ "error",
1045
+ {
1046
+ allowMultiplePropertiesPerLine: true
1047
+ }
1048
+ ],
1049
+ "vue/object-shorthand": [
1050
+ "error",
1051
+ "always",
1052
+ {
1053
+ ignoreConstructors: false,
1054
+ avoidQuotes: true
1055
+ }
1056
+ ],
1057
+ "vue/operator-linebreak": ["error", "before"],
1058
+ "vue/prefer-template": "error",
1059
+ "vue/prop-name-casing": ["error", "camelCase"],
1060
+ "vue/quote-props": ["error", "consistent-as-needed"],
1061
+ "vue/space-in-parens": ["error", "never"],
1062
+ "vue/space-infix-ops": "error",
1063
+ "vue/space-unary-ops": [
1064
+ "error",
1065
+ {
1066
+ words: true,
1067
+ nonwords: false
1068
+ }
1069
+ ],
1070
+ "vue/template-curly-spacing": "error",
1071
+ "vue/block-order": [
1072
+ "error",
1073
+ {
1074
+ order: ["script", "template", "style"]
1075
+ }
1076
+ ],
1077
+ "vue/attributes-order": [
1078
+ "error",
1079
+ {
1080
+ order: [
1081
+ "EVENTS",
1082
+ // `@click="functionCall"`, `v-on="event"`
1083
+ "TWO_WAY_BINDING",
1084
+ // `v-model`
1085
+ "OTHER_DIRECTIVES",
1086
+ // `v-custom-directive`
1087
+ "LIST_RENDERING",
1088
+ // `v-for item in items`
1089
+ "CONDITIONALS",
1090
+ // `v-if`, `v-show`, `v-cloak`
1091
+ "CONTENT",
1092
+ // `v-text`, `v-html`
1093
+ "SLOT",
1094
+ // `v-slot`, `slot`
1095
+ "UNIQUE",
1096
+ // `ref`, `key`
1097
+ "DEFINITION",
1098
+ // `is`, `v-is`
1099
+ "ATTR_DYNAMIC",
1100
+ // `v-bind:prop="foo"`, `:prop="foo"`
1101
+ // `OTHER_ATTR`, // `custom-prop="foo"`, `:prop="foo"`, `disabled`
1102
+ "RENDER_MODIFIERS",
1103
+ // `v-once`, `v-pre`
1104
+ "GLOBAL",
1105
+ // `id`
1106
+ "ATTR_STATIC",
1107
+ // `prop="foo", `static attributes
1108
+ "ATTR_SHORTHAND_BOOL"
1109
+ // `disabled`, prop shorthand
1110
+ ],
1111
+ alphabetical: false
1112
+ }
1113
+ ],
1114
+ "vue/order-in-components": [
1115
+ "error",
1116
+ {
1117
+ order: [
1118
+ "el",
1119
+ "name",
1120
+ "key",
1121
+ "parent",
1122
+ "functional",
1123
+ ["provide", "inject"],
1124
+ ["delimiters", "comments"],
1125
+ ["components", "directives", "filters"],
1126
+ "extends",
1127
+ "mixins",
1128
+ "layout",
1129
+ "middleware",
1130
+ "validate",
1131
+ "scrollToTop",
1132
+ "transition",
1133
+ "loading",
1134
+ "inheritAttrs",
1135
+ "model",
1136
+ ["props", "propsData"],
1137
+ "emits",
1138
+ "setup",
1139
+ "asyncData",
1140
+ "computed",
1141
+ "data",
1142
+ "fetch",
1143
+ "head",
1144
+ "methods",
1145
+ ["template", "render"],
1146
+ "watch",
1147
+ "watchQuery",
1148
+ "LIFECYCLE_HOOKS",
1149
+ "renderError",
1150
+ "ROUTER_GUARDS"
1151
+ ]
1152
+ }
1153
+ ],
1154
+ "vue/max-attributes-per-line": [
1155
+ "error",
1156
+ {
1157
+ singleline: 1,
1158
+ multiline: 1
1159
+ }
1160
+ ],
1161
+ // Overrides built-in rules
1162
+ ...options.overrides
931
1163
  }
932
- },
933
- processor: default3.processors[".vue"],
934
- rules: {
935
- ...isVue3 ? vue3Rules : vue2Rules,
936
- // OFF
937
- "vue/no-v-html": "off",
938
- "vue/require-prop-types": "off",
939
- "vue/require-default-prop": "off",
940
- "vue/multi-word-component-names": "off",
941
- "vue/no-setup-props-reactivity-loss": "off",
942
- "vue/html-self-closing": [
943
- "error",
944
- {
945
- html: {
946
- void: "always",
947
- normal: "always",
948
- component: "always"
949
- },
950
- svg: "always",
951
- math: "always"
952
- }
953
- ],
954
- "vue/block-tag-newline": [
955
- "error",
956
- {
957
- singleline: "always",
958
- multiline: "always"
959
- }
960
- ],
961
- "vue/component-name-in-template-casing": [
962
- "error",
963
- "PascalCase",
964
- {
965
- // Force auto-import components to be PascalCase
966
- registeredComponentsOnly: false,
967
- ignores: ["slot", "component"]
968
- }
969
- ],
970
- "vue/component-options-name-casing": ["error", "PascalCase"],
971
- "vue/custom-event-name-casing": ["error", "camelCase"],
972
- "vue/define-macros-order": [
973
- "error",
974
- {
975
- order: ["defineProps", "defineEmits", "defineOptions", "defineSlots"]
976
- }
977
- ],
978
- "vue/html-comment-content-spacing": [
979
- "error",
980
- "always",
981
- {
982
- exceptions: ["-"]
983
- }
984
- ],
985
- "vue/array-bracket-spacing": ["error", "never"],
986
- "vue/arrow-spacing": ["error", { before: true, after: true }],
987
- "vue/block-spacing": ["error", "always"],
988
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
989
- "vue/comma-dangle": ["error", "always-multiline"],
990
- "vue/comma-spacing": ["error", { before: false, after: true }],
991
- "vue/comma-style": ["error", "last"],
992
- "vue/dot-location": ["error", "property"],
993
- "vue/dot-notation": ["error", { allowKeywords: true }],
994
- "vue/eqeqeq": ["error", "smart"],
995
- "vue/key-spacing": ["error", { beforeColon: false, afterColon: true }],
996
- "vue/keyword-spacing": ["error", { before: true, after: true }],
997
- "vue/no-empty-pattern": "error",
998
- "vue/no-loss-of-precision": "error",
999
- "vue/no-irregular-whitespace": "error",
1000
- "vue/no-use-v-else-with-v-for": "error",
1001
- "vue/require-typed-object-prop": "error",
1002
- "vue/no-extra-parens": ["error", "functions"],
1003
- "vue/no-restricted-syntax": [
1004
- "error",
1005
- "DebuggerStatement",
1006
- "LabeledStatement",
1007
- "WithStatement"
1008
- ],
1009
- "vue/no-sparse-arrays": "error",
1010
- "vue/no-deprecated-model-definition": [
1011
- "error",
1012
- {
1013
- allowVue3Compat: true
1014
- }
1015
- ],
1016
- "vue/object-curly-newline": [
1017
- "error",
1018
- {
1019
- multiline: true,
1020
- consistent: true
1021
- }
1022
- ],
1023
- "vue/no-static-inline-styles": [
1024
- "error",
1025
- {
1026
- allowBinding: true
1027
- }
1028
- ],
1029
- "vue/object-curly-spacing": ["error", "always"],
1030
- "vue/object-property-newline": [
1031
- "error",
1032
- {
1033
- allowMultiplePropertiesPerLine: true
1034
- }
1035
- ],
1036
- "vue/object-shorthand": [
1037
- "error",
1038
- "always",
1039
- {
1040
- ignoreConstructors: false,
1041
- avoidQuotes: true
1042
- }
1043
- ],
1044
- "vue/operator-linebreak": ["error", "before"],
1045
- "vue/prefer-template": "error",
1046
- "vue/prop-name-casing": ["error", "camelCase"],
1047
- "vue/quote-props": ["error", "consistent-as-needed"],
1048
- "vue/space-in-parens": ["error", "never"],
1049
- "vue/space-infix-ops": "error",
1050
- "vue/space-unary-ops": [
1051
- "error",
1052
- {
1053
- words: true,
1054
- nonwords: false
1055
- }
1056
- ],
1057
- "vue/template-curly-spacing": "error",
1058
- "vue/block-order": [
1059
- "error",
1060
- {
1061
- order: ["script", "template", "style"]
1062
- }
1063
- ],
1064
- "vue/attributes-order": [
1065
- "error",
1066
- {
1067
- order: [
1068
- "EVENTS",
1069
- // `@click="functionCall"`, `v-on="event"`
1070
- "TWO_WAY_BINDING",
1071
- // `v-model`
1072
- "OTHER_DIRECTIVES",
1073
- // `v-custom-directive`
1074
- "LIST_RENDERING",
1075
- // `v-for item in items`
1076
- "CONDITIONALS",
1077
- // `v-if`, `v-show`, `v-cloak`
1078
- "CONTENT",
1079
- // `v-text`, `v-html`
1080
- "SLOT",
1081
- // `v-slot`, `slot`
1082
- "UNIQUE",
1083
- // `ref`, `key`
1084
- "DEFINITION",
1085
- // `is`, `v-is`
1086
- "ATTR_DYNAMIC",
1087
- // `v-bind:prop="foo"`, `:prop="foo"`
1088
- // `OTHER_ATTR`, // `custom-prop="foo"`, `:prop="foo"`, `disabled`
1089
- "RENDER_MODIFIERS",
1090
- // `v-once`, `v-pre`
1091
- "GLOBAL",
1092
- // `id`
1093
- "ATTR_STATIC",
1094
- // `prop="foo", `static attributes
1095
- "ATTR_SHORTHAND_BOOL"
1096
- // `disabled`, prop shorthand
1097
- ],
1098
- alphabetical: false
1099
- }
1100
- ],
1101
- "vue/order-in-components": [
1102
- "error",
1103
- {
1104
- order: [
1105
- "el",
1106
- "name",
1107
- "key",
1108
- "parent",
1109
- "functional",
1110
- ["provide", "inject"],
1111
- ["delimiters", "comments"],
1112
- ["components", "directives", "filters"],
1113
- "extends",
1114
- "mixins",
1115
- "layout",
1116
- "middleware",
1117
- "validate",
1118
- "scrollToTop",
1119
- "transition",
1120
- "loading",
1121
- "inheritAttrs",
1122
- "model",
1123
- ["props", "propsData"],
1124
- "emits",
1125
- "setup",
1126
- "asyncData",
1127
- "computed",
1128
- "data",
1129
- "fetch",
1130
- "head",
1131
- "methods",
1132
- ["template", "render"],
1133
- "watch",
1134
- "watchQuery",
1135
- "LIFECYCLE_HOOKS",
1136
- "renderError",
1137
- "ROUTER_GUARDS"
1138
- ]
1139
- }
1140
- ],
1141
- "vue/max-attributes-per-line": [
1142
- "error",
1143
- {
1144
- singleline: 1,
1145
- multiline: 1
1146
- }
1147
- ],
1148
- // Overrides built-in rules
1149
- ...options.overrides
1150
1164
  }
1151
- }
1152
- ];
1165
+ ];
1166
+ };
1153
1167
 
1154
1168
  // src/configs/yml.ts
1155
1169
  var yml = (options = {}) => [
@@ -1426,6 +1440,20 @@ var sortTsConfig = () => [
1426
1440
  }
1427
1441
  }
1428
1442
  ];
1443
+ var sortI18nLocale = () => [
1444
+ {
1445
+ files: ["**/{locales,i18n}/*.json", "**/{locales,i18n}/*.y?(a)ml"],
1446
+ rules: {
1447
+ "jsonc/sort-keys": [
1448
+ "error",
1449
+ {
1450
+ pathPattern: ".*",
1451
+ order: { type: "asc" }
1452
+ }
1453
+ ]
1454
+ }
1455
+ }
1456
+ ];
1429
1457
 
1430
1458
  // src/configs/jsonc.ts
1431
1459
  var jsonc = (options = {}) => [
@@ -1517,6 +1545,7 @@ function ntnyq(options = {}, customConfig = []) {
1517
1545
  overrides: getOverrides(options, "imports")
1518
1546
  }),
1519
1547
  ...javascript({
1548
+ ...resolveSubOptions(options, "javascript"),
1520
1549
  overrides: getOverrides(options, "javascript")
1521
1550
  })
1522
1551
  ];
@@ -1551,10 +1580,14 @@ function ntnyq(options = {}, customConfig = []) {
1551
1580
  if (options.typescript ?? hasTypeScript) {
1552
1581
  configs.push(
1553
1582
  ...typescript({
1583
+ ...resolveSubOptions(options, "typescript"),
1554
1584
  overrides: getOverrides(options, "typescript")
1555
1585
  })
1556
1586
  );
1557
1587
  }
1588
+ if (options.sortI18nLocale ?? true) {
1589
+ configs.push(...sortI18nLocale());
1590
+ }
1558
1591
  if (options.sortTsConfig ?? true) {
1559
1592
  configs.push(...sortTsConfig());
1560
1593
  }
@@ -1585,6 +1618,7 @@ function ntnyq(options = {}, customConfig = []) {
1585
1618
  if (options.vue ?? hasVue) {
1586
1619
  configs.push(
1587
1620
  ...vue({
1621
+ ...resolveSubOptions(options, "vue"),
1588
1622
  overrides: getOverrides(options, "vue")
1589
1623
  })
1590
1624
  );
@@ -1617,6 +1651,7 @@ function ntnyq(options = {}, customConfig = []) {
1617
1651
  if (options.prettier ?? true) {
1618
1652
  configs.push(
1619
1653
  ...prettier({
1654
+ ...resolveSubOptions(options, "prettier"),
1620
1655
  overrides: getOverrides(options, "prettier")
1621
1656
  })
1622
1657
  );
@@ -1638,6 +1673,8 @@ export {
1638
1673
  GLOB_LESS,
1639
1674
  GLOB_LOCKFILE,
1640
1675
  GLOB_MARKDOWN,
1676
+ GLOB_MARKDOWN_CODE,
1677
+ GLOB_MARKDOWN_NESTED,
1641
1678
  GLOB_NODE_MODULES,
1642
1679
  GLOB_SCSS,
1643
1680
  GLOB_SRC,
@@ -1652,7 +1689,6 @@ export {
1652
1689
  command,
1653
1690
  comments,
1654
1691
  getOverrides,
1655
- getVueVersion,
1656
1692
  hasTypeScript,
1657
1693
  hasUnoCSS,
1658
1694
  hasVitest,
@@ -1692,6 +1728,7 @@ export {
1692
1728
  prettier,
1693
1729
  regexp,
1694
1730
  resolveSubOptions,
1731
+ sortI18nLocale,
1695
1732
  sortPackageJson,
1696
1733
  sortTsConfig,
1697
1734
  toArray,