@dhzh/eslint-config 0.2.2 → 0.3.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
@@ -982,52 +982,69 @@ var ReactRefreshAllowConstantExportPackages = [
982
982
  ];
983
983
  async function react(options = {}) {
984
984
  const {
985
- files = [GLOB_JSX, GLOB_TSX],
986
- overrides = {},
987
- typescript: typescript2 = true
985
+ files = [GLOB_TS, GLOB_TSX],
986
+ overrides = {}
988
987
  } = options;
989
988
  await ensurePackages([
990
- "eslint-plugin-react",
989
+ "@eslint-react/eslint-plugin",
991
990
  "eslint-plugin-react-hooks",
992
991
  "eslint-plugin-react-refresh"
993
992
  ]);
993
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
994
+ const isTypeAware = !!tsconfigPath;
994
995
  const [
995
996
  pluginReact,
996
997
  pluginReactHooks,
997
- pluginReactRefresh
998
+ pluginReactRefresh,
999
+ parserTs
998
1000
  ] = await Promise.all([
999
- interopDefault(import("eslint-plugin-react")),
1001
+ interopDefault(import("@eslint-react/eslint-plugin")),
1000
1002
  interopDefault(import("eslint-plugin-react-hooks")),
1001
- interopDefault(import("eslint-plugin-react-refresh"))
1003
+ interopDefault(import("eslint-plugin-react-refresh")),
1004
+ interopDefault(import("@typescript-eslint/parser"))
1002
1005
  ]);
1003
1006
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1004
1007
  (i) => isPackageExists3(i)
1005
1008
  );
1009
+ const plugins = pluginReact.configs.all.plugins;
1006
1010
  return [
1007
1011
  {
1008
1012
  name: "antfu/react/setup",
1009
1013
  plugins: {
1010
- "react": pluginReact,
1014
+ "react": plugins["@eslint-react"],
1015
+ "react-dom": plugins["@eslint-react/dom"],
1011
1016
  "react-hooks": pluginReactHooks,
1017
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1018
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1012
1019
  "react-refresh": pluginReactRefresh
1013
- },
1014
- settings: {
1015
- react: {
1016
- version: "detect"
1017
- }
1018
1020
  }
1019
1021
  },
1020
1022
  {
1021
1023
  files,
1022
1024
  languageOptions: {
1025
+ parser: parserTs,
1023
1026
  parserOptions: {
1024
1027
  ecmaFeatures: {
1025
1028
  jsx: true
1026
- }
1027
- }
1029
+ },
1030
+ ...isTypeAware ? { project: tsconfigPath } : {}
1031
+ },
1032
+ sourceType: "module"
1028
1033
  },
1029
1034
  name: "antfu/react/rules",
1030
1035
  rules: {
1036
+ // recommended rules from @eslint-react/dom
1037
+ "react-dom/no-children-in-void-dom-elements": "warn",
1038
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1039
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1040
+ "react-dom/no-find-dom-node": "error",
1041
+ "react-dom/no-missing-button-type": "warn",
1042
+ "react-dom/no-missing-iframe-sandbox": "warn",
1043
+ "react-dom/no-namespace": "error",
1044
+ "react-dom/no-render-return-value": "error",
1045
+ "react-dom/no-script-url": "warn",
1046
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1047
+ "react-dom/no-unsafe-target-blank": "warn",
1031
1048
  // recommended rules react-hooks
1032
1049
  "react-hooks/exhaustive-deps": "warn",
1033
1050
  "react-hooks/rules-of-hooks": "error",
@@ -1036,32 +1053,45 @@ async function react(options = {}) {
1036
1053
  "warn",
1037
1054
  { allowConstantExport: isAllowConstantExport }
1038
1055
  ],
1039
- // recommended rules react
1040
- "react/display-name": "error",
1041
- "react/jsx-key": "error",
1042
- "react/jsx-no-comment-textnodes": "error",
1043
- "react/jsx-no-duplicate-props": "error",
1044
- "react/jsx-no-target-blank": "error",
1045
- "react/jsx-no-undef": "error",
1046
- "react/jsx-uses-react": "error",
1047
- "react/jsx-uses-vars": "error",
1048
- "react/no-children-prop": "error",
1049
- "react/no-danger-with-children": "error",
1050
- "react/no-deprecated": "error",
1056
+ // recommended rules from @eslint-react
1057
+ "react/ensure-forward-ref-using-ref": "warn",
1058
+ "react/no-access-state-in-setstate": "error",
1059
+ "react/no-array-index-key": "warn",
1060
+ "react/no-children-count": "warn",
1061
+ "react/no-children-for-each": "warn",
1062
+ "react/no-children-map": "warn",
1063
+ "react/no-children-only": "warn",
1064
+ "react/no-children-prop": "warn",
1065
+ "react/no-children-to-array": "warn",
1066
+ "react/no-clone-element": "warn",
1067
+ "react/no-comment-textnodes": "warn",
1068
+ "react/no-component-will-mount": "error",
1069
+ "react/no-component-will-receive-props": "error",
1070
+ "react/no-component-will-update": "error",
1071
+ "react/no-create-ref": "error",
1051
1072
  "react/no-direct-mutation-state": "error",
1052
- "react/no-find-dom-node": "error",
1053
- "react/no-is-mounted": "error",
1054
- "react/no-render-return-value": "error",
1073
+ "react/no-duplicate-key": "error",
1074
+ "react/no-implicit-key": "error",
1075
+ "react/no-missing-key": "error",
1076
+ "react/no-nested-components": "warn",
1077
+ "react/no-redundant-should-component-update": "error",
1078
+ "react/no-set-state-in-component-did-mount": "warn",
1079
+ "react/no-set-state-in-component-did-update": "warn",
1080
+ "react/no-set-state-in-component-will-update": "warn",
1055
1081
  "react/no-string-refs": "error",
1056
- "react/no-unescaped-entities": "error",
1057
- "react/no-unknown-property": "error",
1058
- "react/no-unsafe": "off",
1059
- "react/prop-types": "error",
1060
- "react/react-in-jsx-scope": "off",
1061
- "react/require-render-return": "error",
1062
- ...typescript2 ? {
1063
- "react/jsx-no-undef": "off",
1064
- "react/prop-type": "off"
1082
+ "react/no-unsafe-component-will-mount": "warn",
1083
+ "react/no-unsafe-component-will-receive-props": "warn",
1084
+ "react/no-unsafe-component-will-update": "warn",
1085
+ "react/no-unstable-context-value": "error",
1086
+ "react/no-unstable-default-props": "error",
1087
+ "react/no-unused-class-component-members": "warn",
1088
+ "react/no-unused-state": "warn",
1089
+ "react/no-useless-fragment": "warn",
1090
+ "react/prefer-destructuring-assignment": "warn",
1091
+ "react/prefer-shorthand-boolean": "warn",
1092
+ "react/prefer-shorthand-fragment": "warn",
1093
+ ...isTypeAware ? {
1094
+ "react/no-leaked-conditional-rendering": "warn"
1065
1095
  } : {},
1066
1096
  // overrides
1067
1097
  ...overrides
@@ -2097,6 +2127,10 @@ var VuePackages = [
2097
2127
  "@slidev/cli"
2098
2128
  ];
2099
2129
  var defaultPluginRenaming = {
2130
+ "@eslint-react": "react",
2131
+ "@eslint-react/dom": "react-dom",
2132
+ "@eslint-react/hooks-extra": "react-hooks-extra",
2133
+ "@eslint-react/naming-convention": "react-naming-convention",
2100
2134
  "@stylistic": "style",
2101
2135
  "@typescript-eslint": "ts",
2102
2136
  "import-x": "import",
@@ -2184,7 +2218,7 @@ function dhzh(options = {}, ...userConfigs) {
2184
2218
  if (enableReact) {
2185
2219
  configs.push(react({
2186
2220
  overrides: getOverrides(options, "react"),
2187
- typescript: !!enableTypeScript
2221
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath
2188
2222
  }));
2189
2223
  }
2190
2224
  if (enableSolid) {
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/eslint-config",
3
3
  "type": "module",
4
- "version": "0.2.2",
5
- "packageManager": "pnpm@8.15.7",
4
+ "version": "0.3.0",
6
5
  "description": "Easton's ESLint config",
7
6
  "author": "Easton Zheng <dhzhme@gmail.com>",
8
7
  "license": "MIT",
@@ -68,9 +67,10 @@
68
67
  "dependencies": {
69
68
  "@antfu/install-pkg": "^0.3.2",
70
69
  "@clack/prompts": "^0.7.0",
71
- "@stylistic/eslint-plugin": "^1.7.0",
72
- "@typescript-eslint/eslint-plugin": "^7.6.0",
73
- "@typescript-eslint/parser": "^7.6.0",
70
+ "@eslint-react/eslint-plugin": "^1.5.8",
71
+ "@stylistic/eslint-plugin": "^1.7.2",
72
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
73
+ "@typescript-eslint/parser": "^7.7.0",
74
74
  "eslint-config-flat-gitignore": "^0.1.5",
75
75
  "eslint-flat-config-utils": "^0.2.3",
76
76
  "eslint-merge-processors": "^0.1.0",
@@ -83,7 +83,6 @@
83
83
  "eslint-plugin-n": "^17.2.1",
84
84
  "eslint-plugin-no-only-tests": "^3.1.0",
85
85
  "eslint-plugin-perfectionist": "^2.9.0",
86
- "eslint-plugin-react": "^7.34.1",
87
86
  "eslint-plugin-react-hooks": "^4.6.0",
88
87
  "eslint-plugin-react-refresh": "^0.4.6",
89
88
  "eslint-plugin-toml": "^0.11.0",
@@ -92,7 +91,7 @@
92
91
  "eslint-plugin-vitest": "^0.5.3",
93
92
  "eslint-plugin-vue": "^9.25.0",
94
93
  "eslint-plugin-yml": "^1.14.0",
95
- "eslint-processor-vue-blocks": "^0.1.1",
94
+ "eslint-processor-vue-blocks": "^0.1.2",
96
95
  "globals": "^15.0.0",
97
96
  "jsonc-eslint-parser": "^2.4.0",
98
97
  "local-pkg": "^0.5.0",
@@ -107,19 +106,19 @@
107
106
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
108
107
  "@antfu/ni": "^0.21.12",
109
108
  "@eslint/config-inspector": "^0.4.6",
110
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
109
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
111
110
  "@types/eslint": "^8.56.9",
112
111
  "@types/fs-extra": "^11.0.4",
113
112
  "@types/node": "^20.12.7",
114
113
  "@types/prompts": "^2.4.9",
115
114
  "@types/yargs": "^17.0.32",
116
- "@unocss/eslint-plugin": "^0.59.2",
115
+ "@unocss/eslint-plugin": "^0.59.3",
117
116
  "astro-eslint-parser": "^0.17.0",
118
117
  "bumpp": "^9.4.0",
119
118
  "bundle-require": "^4.0.2",
120
119
  "eslint": "^9.0.0",
121
120
  "eslint-plugin-astro": "^0.34.0",
122
- "eslint-plugin-format": "^0.1.0",
121
+ "eslint-plugin-format": "^0.1.1",
123
122
  "eslint-plugin-solid": "^0.13.2",
124
123
  "eslint-plugin-svelte": "2.36.0-next.13",
125
124
  "eslint-typegen": "^0.2.3",
@@ -132,13 +131,13 @@
132
131
  "prettier-plugin-slidev": "^1.0.5",
133
132
  "rimraf": "^5.0.5",
134
133
  "simple-git-hooks": "^2.11.1",
135
- "svelte": "^4.2.14",
134
+ "svelte": "^4.2.15",
136
135
  "svelte-eslint-parser": "^0.34.1",
137
136
  "tsup": "^8.0.2",
138
137
  "typescript": "^5.4.5",
139
138
  "vitest": "^1.5.0",
140
- "vue": "^3.4.21",
141
- "@dhzh/eslint-config": "0.2.2"
139
+ "vue": "^3.4.23",
140
+ "@dhzh/eslint-config": "0.3.0"
142
141
  },
143
142
  "simple-git-hooks": {
144
143
  "pre-commit": "pnpm lint-staged"