@coderwyd/eslint-config 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -605,7 +605,7 @@ function perfectionist() {
605
605
  "style",
606
606
  "unknown"
607
607
  ],
608
- internalPattern: ["~/**", "@/**", "#**"],
608
+ internalPattern: ["^[~@#]/.*"],
609
609
  newlinesBetween: "ignore",
610
610
  order: "asc",
611
611
  type: "natural"
@@ -627,27 +627,19 @@ function perfectionist() {
627
627
  // src/configs/prettier.ts
628
628
  import prettierRules from "eslint-config-prettier";
629
629
  var { rules: eslintRules } = prettierRules;
630
- async function prettier() {
631
- const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
630
+ function prettier() {
632
631
  return [
633
632
  {
634
633
  name: "coderwyd/prettier/rules",
635
- plugins: {
636
- prettier: pluginPrettier
637
- },
638
634
  rules: {
639
635
  ...eslintRules,
640
636
  "arrow-body-style": "off",
641
- "prefer-arrow-callback": "off",
642
- "prettier/prettier": "warn"
637
+ "prefer-arrow-callback": "off"
643
638
  }
644
639
  }
645
640
  ];
646
641
  }
647
642
 
648
- // src/configs/react.ts
649
- import { isPackageExists as isPackageExists3 } from "local-pkg";
650
-
651
643
  // src/env.ts
652
644
  import process2 from "node:process";
653
645
  import { isPackageExists as isPackageExists2 } from "local-pkg";
@@ -662,31 +654,40 @@ var RemixPackages = [
662
654
  "@remix-run/dev"
663
655
  ];
664
656
  var NextJsPackages = ["next"];
657
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
665
658
  var isUsingRemix = hasPackages(RemixPackages);
666
659
  var isUsingNext = hasPackages(NextJsPackages);
660
+ var isAllowConstantExport = hasPackages(
661
+ ReactRefreshAllowConstantExportPackages
662
+ );
667
663
  function hasPackages(packages) {
668
664
  return packages.some((name) => isPackageExists2(name));
669
665
  }
670
666
 
671
667
  // src/configs/react.ts
672
- var ReactRefreshAllowConstantExportPackages = ["vite"];
673
668
  async function react(options = {}) {
674
- const { files = [GLOB_SRC], overrides = {} } = options;
669
+ const {
670
+ files = [GLOB_SRC],
671
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
672
+ ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS],
673
+ overrides = {},
674
+ tsconfigPath
675
+ } = options;
675
676
  await ensurePackages([
676
677
  "@eslint-react/eslint-plugin",
677
678
  "eslint-plugin-react-hooks",
678
679
  "eslint-plugin-react-refresh"
679
680
  ]);
680
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
681
681
  const isTypeAware = !!tsconfigPath;
682
- const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
683
- interopDefault(import("@eslint-react/eslint-plugin")),
684
- interopDefault(import("eslint-plugin-react-hooks")),
685
- interopDefault(import("eslint-plugin-react-refresh")),
686
- interopDefault(import("@typescript-eslint/parser"))
687
- ]);
688
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
689
- (i) => isPackageExists3(i)
682
+ const typeAwareRules = {
683
+ "react/no-leaked-conditional-rendering": "warn"
684
+ };
685
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
686
+ [
687
+ interopDefault(import("@eslint-react/eslint-plugin")),
688
+ interopDefault(import("eslint-plugin-react-hooks")),
689
+ interopDefault(import("eslint-plugin-react-refresh"))
690
+ ]
690
691
  );
691
692
  const plugins = pluginReact.configs.all.plugins;
692
693
  return [
@@ -704,12 +705,10 @@ async function react(options = {}) {
704
705
  {
705
706
  files,
706
707
  languageOptions: {
707
- parser: parserTs,
708
708
  parserOptions: {
709
709
  ecmaFeatures: {
710
710
  jsx: true
711
- },
712
- ...isTypeAware ? { project: tsconfigPath } : {}
711
+ }
713
712
  },
714
713
  sourceType: "module"
715
714
  },
@@ -757,25 +756,30 @@ async function react(options = {}) {
757
756
  ],
758
757
  // recommended rules from @eslint-react
759
758
  "react/ensure-forward-ref-using-ref": "warn",
759
+ "react/jsx-no-duplicate-props": "warn",
760
+ "react/jsx-uses-vars": "warn",
760
761
  "react/no-access-state-in-setstate": "error",
761
762
  "react/no-array-index-key": "warn",
762
763
  "react/no-children-count": "warn",
763
764
  "react/no-children-for-each": "warn",
764
765
  "react/no-children-map": "warn",
765
766
  "react/no-children-only": "warn",
766
- "react/no-children-prop": "warn",
767
767
  "react/no-children-to-array": "warn",
768
768
  "react/no-clone-element": "warn",
769
769
  "react/no-comment-textnodes": "warn",
770
770
  "react/no-component-will-mount": "error",
771
771
  "react/no-component-will-receive-props": "error",
772
772
  "react/no-component-will-update": "error",
773
+ "react/no-context-provider": "warn",
773
774
  "react/no-create-ref": "error",
775
+ "react/no-default-props": "error",
774
776
  "react/no-direct-mutation-state": "error",
775
777
  "react/no-duplicate-key": "error",
776
- "react/no-implicit-key": "error",
778
+ "react/no-forward-ref": "warn",
779
+ "react/no-implicit-key": "warn",
777
780
  "react/no-missing-key": "error",
778
- "react/no-nested-components": "warn",
781
+ "react/no-nested-components": "error",
782
+ "react/no-prop-types": "error",
779
783
  "react/no-redundant-should-component-update": "error",
780
784
  "react/no-set-state-in-component-did-mount": "warn",
781
785
  "react/no-set-state-in-component-did-update": "warn",
@@ -784,21 +788,27 @@ async function react(options = {}) {
784
788
  "react/no-unsafe-component-will-mount": "warn",
785
789
  "react/no-unsafe-component-will-receive-props": "warn",
786
790
  "react/no-unsafe-component-will-update": "warn",
787
- "react/no-unstable-context-value": "error",
788
- "react/no-unstable-default-props": "error",
791
+ "react/no-unstable-context-value": "warn",
792
+ "react/no-unstable-default-props": "warn",
789
793
  "react/no-unused-class-component-members": "warn",
790
794
  "react/no-unused-state": "warn",
791
- "react/no-useless-fragment": "warn",
792
795
  "react/prefer-destructuring-assignment": "warn",
793
796
  "react/prefer-shorthand-boolean": "warn",
794
797
  "react/prefer-shorthand-fragment": "warn",
795
- ...isTypeAware ? {
796
- "react/no-leaked-conditional-rendering": "warn"
797
- } : {},
798
798
  // overrides
799
799
  ...overrides
800
800
  }
801
- }
801
+ },
802
+ ...isTypeAware ? [
803
+ {
804
+ files: filesTypeAware,
805
+ ignores: ignoresTypeAware,
806
+ name: "coderwyd/react/type-aware-rules",
807
+ rules: {
808
+ ...typeAwareRules
809
+ }
810
+ }
811
+ ] : []
802
812
  ];
803
813
  }
804
814
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "3.2.0",
4
+ "version": "3.4.0",
5
5
  "description": "Donny's ESLint config",
6
6
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
7
7
  "license": "MIT",
@@ -68,67 +68,66 @@
68
68
  }
69
69
  },
70
70
  "dependencies": {
71
- "@antfu/install-pkg": "^0.4.1",
71
+ "@antfu/install-pkg": "^0.5.0",
72
72
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
73
73
  "@toml-tools/parser": "^1.0.0",
74
- "@typescript-eslint/eslint-plugin": "^8.13.0",
75
- "@typescript-eslint/parser": "^8.13.0",
76
- "@vitest/eslint-plugin": "^1.1.8",
74
+ "@typescript-eslint/eslint-plugin": "^8.18.0",
75
+ "@typescript-eslint/parser": "^8.18.0",
76
+ "@vitest/eslint-plugin": "^1.1.16",
77
77
  "eslint-config-flat-gitignore": "^0.3.0",
78
78
  "eslint-config-prettier": "^9.1.0",
79
79
  "eslint-plugin-antfu": "^2.7.0",
80
80
  "eslint-plugin-command": "^0.2.6",
81
81
  "eslint-plugin-eslint-comments": "^3.2.0",
82
- "eslint-plugin-import-x": "^4.4.0",
83
- "eslint-plugin-jsdoc": "^50.4.3",
84
- "eslint-plugin-jsonc": "^2.18.1",
85
- "eslint-plugin-n": "^17.13.1",
82
+ "eslint-plugin-import-x": "^4.5.0",
83
+ "eslint-plugin-jsdoc": "^50.6.1",
84
+ "eslint-plugin-jsonc": "^2.18.2",
85
+ "eslint-plugin-n": "^17.15.0",
86
86
  "eslint-plugin-no-only-tests": "^3.3.0",
87
- "eslint-plugin-perfectionist": "^3.9.1",
88
- "eslint-plugin-prettier": "^5.2.1",
89
- "eslint-plugin-regexp": "^2.6.0",
90
- "eslint-plugin-unicorn": "^56.0.0",
87
+ "eslint-plugin-perfectionist": "^4.3.0",
88
+ "eslint-plugin-regexp": "^2.7.0",
89
+ "eslint-plugin-unicorn": "^56.0.1",
91
90
  "eslint-plugin-unused-imports": "^4.1.4",
92
- "eslint-plugin-vue": "^9.30.0",
91
+ "eslint-plugin-vue": "^9.32.0",
93
92
  "eslint-typegen": "^0.3.2",
94
- "globals": "^15.12.0",
93
+ "globals": "^15.13.0",
95
94
  "jsonc-eslint-parser": "^2.4.0",
96
- "local-pkg": "^0.5.0",
95
+ "local-pkg": "^0.5.1",
97
96
  "parse-gitignore": "^2.0.0",
98
97
  "picocolors": "^1.1.1",
99
- "prettier": "^3.3.3",
98
+ "prettier": "^3.4.2",
100
99
  "prompts": "^2.4.2",
101
100
  "vue-eslint-parser": "^9.4.3",
102
101
  "yargs": "^17.7.2"
103
102
  },
104
103
  "devDependencies": {
105
- "@antfu/ni": "^0.23.0",
106
- "@eslint-react/eslint-plugin": "^1.16.1",
107
- "@eslint/config-inspector": "^0.5.6",
104
+ "@antfu/ni": "^0.23.1",
105
+ "@eslint-react/eslint-plugin": "^1.19.0",
106
+ "@eslint/config-inspector": "^0.6.0",
108
107
  "@types/eslint-config-prettier": "^6.11.3",
109
108
  "@types/fs-extra": "^11.0.4",
110
- "@types/node": "^22.9.0",
109
+ "@types/node": "^22.10.2",
111
110
  "@types/prompts": "^2.4.9",
112
111
  "@types/yargs": "^17.0.33",
113
- "@unocss/eslint-plugin": "^0.64.0",
114
- "bumpp": "^9.8.1",
115
- "eslint": "^9.14.0",
116
- "eslint-plugin-react-hooks": "^5.0.0",
117
- "eslint-plugin-react-refresh": "^0.4.14",
118
- "eslint-plugin-svelte": "^2.46.0",
112
+ "@unocss/eslint-plugin": "^0.65.1",
113
+ "bumpp": "^9.9.1",
114
+ "eslint": "^9.17.0",
115
+ "eslint-plugin-react-hooks": "^5.1.0",
116
+ "eslint-plugin-react-refresh": "^0.4.16",
117
+ "eslint-plugin-svelte": "^2.46.1",
119
118
  "eslint-plugin-tailwindcss": "^3.17.5",
120
- "execa": "^9.5.1",
119
+ "execa": "^9.5.2",
121
120
  "fast-glob": "^3.3.2",
122
121
  "fs-extra": "^11.2.0",
123
- "jiti": "^2.4.0",
124
- "lint-staged": "^15.2.10",
122
+ "jiti": "^2.4.1",
123
+ "lint-staged": "^15.2.11",
125
124
  "rimraf": "^6.0.1",
126
125
  "simple-git-hooks": "^2.11.1",
127
- "svelte": "^5.1.13",
126
+ "svelte": "^5.14.0",
128
127
  "svelte-eslint-parser": "^0.43.0",
129
128
  "tsup": "^8.3.5",
130
129
  "tsx": "^4.19.2",
131
- "typescript": "^5.6.3"
130
+ "typescript": "^5.7.2"
132
131
  },
133
132
  "simple-git-hooks": {
134
133
  "pre-commit": "pnpx nano-staged"