@antfu/eslint-config 2.14.0 → 2.15.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/README.md CHANGED
@@ -471,7 +471,7 @@ export default antfu({
471
471
  Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
472
472
 
473
473
  ```bash
474
- npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
474
+ npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
475
475
  ```
476
476
 
477
477
  #### Svelte
package/dist/cli.cjs CHANGED
@@ -48,8 +48,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
48
48
  var package_default = {
49
49
  name: "@antfu/eslint-config",
50
50
  type: "module",
51
- version: "2.14.0",
52
- packageManager: "pnpm@8.15.7",
51
+ version: "2.15.0",
52
+ packageManager: "pnpm@9.0.2",
53
53
  description: "Anthony's ESLint config",
54
54
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
55
55
  license: "MIT",
@@ -86,12 +86,12 @@ var package_default = {
86
86
  prepare: "simple-git-hooks"
87
87
  },
88
88
  peerDependencies: {
89
+ "@eslint-react/eslint-plugin": "^1.5.8",
89
90
  "@unocss/eslint-plugin": ">=0.50.0",
90
91
  "astro-eslint-parser": "^0.16.3",
91
92
  eslint: ">=8.40.0",
92
93
  "eslint-plugin-astro": "^0.31.4",
93
94
  "eslint-plugin-format": ">=0.1.0",
94
- "eslint-plugin-react": "^7.33.2",
95
95
  "eslint-plugin-react-hooks": "^4.6.0",
96
96
  "eslint-plugin-react-refresh": "^0.4.4",
97
97
  "eslint-plugin-solid": "^0.13.2",
@@ -101,6 +101,9 @@ var package_default = {
101
101
  "svelte-eslint-parser": "^0.33.1"
102
102
  },
103
103
  peerDependenciesMeta: {
104
+ "@eslint-react/eslint-plugin": {
105
+ optional: true
106
+ },
104
107
  "@unocss/eslint-plugin": {
105
108
  optional: true
106
109
  },
@@ -113,9 +116,6 @@ var package_default = {
113
116
  "eslint-plugin-format": {
114
117
  optional: true
115
118
  },
116
- "eslint-plugin-react": {
117
- optional: true
118
- },
119
119
  "eslint-plugin-react-hooks": {
120
120
  optional: true
121
121
  },
@@ -141,9 +141,9 @@ var package_default = {
141
141
  dependencies: {
142
142
  "@antfu/install-pkg": "^0.3.2",
143
143
  "@clack/prompts": "^0.7.0",
144
- "@stylistic/eslint-plugin": "^1.7.0",
145
- "@typescript-eslint/eslint-plugin": "^7.6.0",
146
- "@typescript-eslint/parser": "^7.6.0",
144
+ "@stylistic/eslint-plugin": "^1.7.2",
145
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
146
+ "@typescript-eslint/parser": "^7.7.0",
147
147
  "eslint-config-flat-gitignore": "^0.1.5",
148
148
  "eslint-flat-config-utils": "^0.2.3",
149
149
  "eslint-merge-processors": "^0.1.0",
@@ -162,7 +162,7 @@ var package_default = {
162
162
  "eslint-plugin-vitest": "^0.5.3",
163
163
  "eslint-plugin-vue": "^9.25.0",
164
164
  "eslint-plugin-yml": "^1.14.0",
165
- "eslint-processor-vue-blocks": "^0.1.1",
165
+ "eslint-processor-vue-blocks": "^0.1.2",
166
166
  globals: "^15.0.0",
167
167
  "jsonc-eslint-parser": "^2.4.0",
168
168
  "local-pkg": "^0.5.0",
@@ -177,21 +177,21 @@ var package_default = {
177
177
  "@antfu/eslint-config": "workspace:*",
178
178
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
179
179
  "@antfu/ni": "^0.21.12",
180
+ "@eslint-react/eslint-plugin": "^1.5.8",
180
181
  "@eslint/config-inspector": "^0.4.6",
181
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
182
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
182
183
  "@types/eslint": "^8.56.9",
183
184
  "@types/fs-extra": "^11.0.4",
184
185
  "@types/node": "^20.12.7",
185
186
  "@types/prompts": "^2.4.9",
186
187
  "@types/yargs": "^17.0.32",
187
- "@unocss/eslint-plugin": "^0.59.2",
188
+ "@unocss/eslint-plugin": "^0.59.3",
188
189
  "astro-eslint-parser": "^0.17.0",
189
190
  bumpp: "^9.4.0",
190
191
  "bundle-require": "^4.0.2",
191
192
  eslint: "^9.0.0",
192
193
  "eslint-plugin-astro": "^0.34.0",
193
- "eslint-plugin-format": "^0.1.0",
194
- "eslint-plugin-react": "^7.34.1",
194
+ "eslint-plugin-format": "^0.1.1",
195
195
  "eslint-plugin-react-hooks": "^4.6.0",
196
196
  "eslint-plugin-react-refresh": "^0.4.6",
197
197
  "eslint-plugin-solid": "^0.13.2",
@@ -206,12 +206,12 @@ var package_default = {
206
206
  "prettier-plugin-slidev": "^1.0.5",
207
207
  rimraf: "^5.0.5",
208
208
  "simple-git-hooks": "^2.11.1",
209
- svelte: "^4.2.14",
209
+ svelte: "^4.2.15",
210
210
  "svelte-eslint-parser": "^0.34.1",
211
211
  tsup: "^8.0.2",
212
212
  typescript: "^5.4.5",
213
213
  vitest: "^1.5.0",
214
- vue: "^3.4.21"
214
+ vue: "^3.4.23"
215
215
  },
216
216
  "simple-git-hooks": {
217
217
  "pre-commit": "pnpm lint-staged"
@@ -311,7 +311,7 @@ var dependenciesMap = {
311
311
  "astro-eslint-parser"
312
312
  ],
313
313
  react: [
314
- "eslint-plugin-react",
314
+ "@eslint-react/eslint-plugin",
315
315
  "eslint-plugin-react-hooks",
316
316
  "eslint-plugin-react-refresh"
317
317
  ],
package/dist/cli.js CHANGED
@@ -19,8 +19,8 @@ import c from "picocolors";
19
19
  var package_default = {
20
20
  name: "@antfu/eslint-config",
21
21
  type: "module",
22
- version: "2.14.0",
23
- packageManager: "pnpm@8.15.7",
22
+ version: "2.15.0",
23
+ packageManager: "pnpm@9.0.2",
24
24
  description: "Anthony's ESLint config",
25
25
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
26
26
  license: "MIT",
@@ -57,12 +57,12 @@ var package_default = {
57
57
  prepare: "simple-git-hooks"
58
58
  },
59
59
  peerDependencies: {
60
+ "@eslint-react/eslint-plugin": "^1.5.8",
60
61
  "@unocss/eslint-plugin": ">=0.50.0",
61
62
  "astro-eslint-parser": "^0.16.3",
62
63
  eslint: ">=8.40.0",
63
64
  "eslint-plugin-astro": "^0.31.4",
64
65
  "eslint-plugin-format": ">=0.1.0",
65
- "eslint-plugin-react": "^7.33.2",
66
66
  "eslint-plugin-react-hooks": "^4.6.0",
67
67
  "eslint-plugin-react-refresh": "^0.4.4",
68
68
  "eslint-plugin-solid": "^0.13.2",
@@ -72,6 +72,9 @@ var package_default = {
72
72
  "svelte-eslint-parser": "^0.33.1"
73
73
  },
74
74
  peerDependenciesMeta: {
75
+ "@eslint-react/eslint-plugin": {
76
+ optional: true
77
+ },
75
78
  "@unocss/eslint-plugin": {
76
79
  optional: true
77
80
  },
@@ -84,9 +87,6 @@ var package_default = {
84
87
  "eslint-plugin-format": {
85
88
  optional: true
86
89
  },
87
- "eslint-plugin-react": {
88
- optional: true
89
- },
90
90
  "eslint-plugin-react-hooks": {
91
91
  optional: true
92
92
  },
@@ -112,9 +112,9 @@ var package_default = {
112
112
  dependencies: {
113
113
  "@antfu/install-pkg": "^0.3.2",
114
114
  "@clack/prompts": "^0.7.0",
115
- "@stylistic/eslint-plugin": "^1.7.0",
116
- "@typescript-eslint/eslint-plugin": "^7.6.0",
117
- "@typescript-eslint/parser": "^7.6.0",
115
+ "@stylistic/eslint-plugin": "^1.7.2",
116
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
117
+ "@typescript-eslint/parser": "^7.7.0",
118
118
  "eslint-config-flat-gitignore": "^0.1.5",
119
119
  "eslint-flat-config-utils": "^0.2.3",
120
120
  "eslint-merge-processors": "^0.1.0",
@@ -133,7 +133,7 @@ var package_default = {
133
133
  "eslint-plugin-vitest": "^0.5.3",
134
134
  "eslint-plugin-vue": "^9.25.0",
135
135
  "eslint-plugin-yml": "^1.14.0",
136
- "eslint-processor-vue-blocks": "^0.1.1",
136
+ "eslint-processor-vue-blocks": "^0.1.2",
137
137
  globals: "^15.0.0",
138
138
  "jsonc-eslint-parser": "^2.4.0",
139
139
  "local-pkg": "^0.5.0",
@@ -148,21 +148,21 @@ var package_default = {
148
148
  "@antfu/eslint-config": "workspace:*",
149
149
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
150
150
  "@antfu/ni": "^0.21.12",
151
+ "@eslint-react/eslint-plugin": "^1.5.8",
151
152
  "@eslint/config-inspector": "^0.4.6",
152
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
153
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
153
154
  "@types/eslint": "^8.56.9",
154
155
  "@types/fs-extra": "^11.0.4",
155
156
  "@types/node": "^20.12.7",
156
157
  "@types/prompts": "^2.4.9",
157
158
  "@types/yargs": "^17.0.32",
158
- "@unocss/eslint-plugin": "^0.59.2",
159
+ "@unocss/eslint-plugin": "^0.59.3",
159
160
  "astro-eslint-parser": "^0.17.0",
160
161
  bumpp: "^9.4.0",
161
162
  "bundle-require": "^4.0.2",
162
163
  eslint: "^9.0.0",
163
164
  "eslint-plugin-astro": "^0.34.0",
164
- "eslint-plugin-format": "^0.1.0",
165
- "eslint-plugin-react": "^7.34.1",
165
+ "eslint-plugin-format": "^0.1.1",
166
166
  "eslint-plugin-react-hooks": "^4.6.0",
167
167
  "eslint-plugin-react-refresh": "^0.4.6",
168
168
  "eslint-plugin-solid": "^0.13.2",
@@ -177,12 +177,12 @@ var package_default = {
177
177
  "prettier-plugin-slidev": "^1.0.5",
178
178
  rimraf: "^5.0.5",
179
179
  "simple-git-hooks": "^2.11.1",
180
- svelte: "^4.2.14",
180
+ svelte: "^4.2.15",
181
181
  "svelte-eslint-parser": "^0.34.1",
182
182
  tsup: "^8.0.2",
183
183
  typescript: "^5.4.5",
184
184
  vitest: "^1.5.0",
185
- vue: "^3.4.21"
185
+ vue: "^3.4.23"
186
186
  },
187
187
  "simple-git-hooks": {
188
188
  "pre-commit": "pnpm lint-staged"
@@ -282,7 +282,7 @@ var dependenciesMap = {
282
282
  "astro-eslint-parser"
283
283
  ],
284
284
  react: [
285
- "eslint-plugin-react",
285
+ "@eslint-react/eslint-plugin",
286
286
  "eslint-plugin-react-hooks",
287
287
  "eslint-plugin-react-refresh"
288
288
  ],
package/dist/index.cjs CHANGED
@@ -1072,52 +1072,69 @@ var ReactRefreshAllowConstantExportPackages = [
1072
1072
  ];
1073
1073
  async function react(options = {}) {
1074
1074
  const {
1075
- files = [GLOB_JSX, GLOB_TSX],
1076
- overrides = {},
1077
- typescript: typescript2 = true
1075
+ files = [GLOB_TS, GLOB_TSX],
1076
+ overrides = {}
1078
1077
  } = options;
1079
1078
  await ensurePackages([
1080
- "eslint-plugin-react",
1079
+ "@eslint-react/eslint-plugin",
1081
1080
  "eslint-plugin-react-hooks",
1082
1081
  "eslint-plugin-react-refresh"
1083
1082
  ]);
1083
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1084
+ const isTypeAware = !!tsconfigPath;
1084
1085
  const [
1085
1086
  pluginReact,
1086
1087
  pluginReactHooks,
1087
- pluginReactRefresh
1088
+ pluginReactRefresh,
1089
+ parserTs
1088
1090
  ] = await Promise.all([
1089
- interopDefault(import("eslint-plugin-react")),
1091
+ interopDefault(import("@eslint-react/eslint-plugin")),
1090
1092
  interopDefault(import("eslint-plugin-react-hooks")),
1091
- interopDefault(import("eslint-plugin-react-refresh"))
1093
+ interopDefault(import("eslint-plugin-react-refresh")),
1094
+ interopDefault(import("@typescript-eslint/parser"))
1092
1095
  ]);
1093
1096
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1094
1097
  (i) => (0, import_local_pkg3.isPackageExists)(i)
1095
1098
  );
1099
+ const plugins = pluginReact.configs.all.plugins;
1096
1100
  return [
1097
1101
  {
1098
1102
  name: "antfu/react/setup",
1099
1103
  plugins: {
1100
- "react": pluginReact,
1104
+ "react": plugins["@eslint-react"],
1105
+ "react-dom": plugins["@eslint-react/dom"],
1101
1106
  "react-hooks": pluginReactHooks,
1107
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1108
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1102
1109
  "react-refresh": pluginReactRefresh
1103
- },
1104
- settings: {
1105
- react: {
1106
- version: "detect"
1107
- }
1108
1110
  }
1109
1111
  },
1110
1112
  {
1111
1113
  files,
1112
1114
  languageOptions: {
1115
+ parser: parserTs,
1113
1116
  parserOptions: {
1114
1117
  ecmaFeatures: {
1115
1118
  jsx: true
1116
- }
1117
- }
1119
+ },
1120
+ ...isTypeAware ? { project: tsconfigPath } : {}
1121
+ },
1122
+ sourceType: "module"
1118
1123
  },
1119
1124
  name: "antfu/react/rules",
1120
1125
  rules: {
1126
+ // recommended rules from @eslint-react/dom
1127
+ "react-dom/no-children-in-void-dom-elements": "warn",
1128
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1129
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1130
+ "react-dom/no-find-dom-node": "error",
1131
+ "react-dom/no-missing-button-type": "warn",
1132
+ "react-dom/no-missing-iframe-sandbox": "warn",
1133
+ "react-dom/no-namespace": "error",
1134
+ "react-dom/no-render-return-value": "error",
1135
+ "react-dom/no-script-url": "warn",
1136
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1137
+ "react-dom/no-unsafe-target-blank": "warn",
1121
1138
  // recommended rules react-hooks
1122
1139
  "react-hooks/exhaustive-deps": "warn",
1123
1140
  "react-hooks/rules-of-hooks": "error",
@@ -1126,32 +1143,45 @@ async function react(options = {}) {
1126
1143
  "warn",
1127
1144
  { allowConstantExport: isAllowConstantExport }
1128
1145
  ],
1129
- // recommended rules react
1130
- "react/display-name": "error",
1131
- "react/jsx-key": "error",
1132
- "react/jsx-no-comment-textnodes": "error",
1133
- "react/jsx-no-duplicate-props": "error",
1134
- "react/jsx-no-target-blank": "error",
1135
- "react/jsx-no-undef": "error",
1136
- "react/jsx-uses-react": "error",
1137
- "react/jsx-uses-vars": "error",
1138
- "react/no-children-prop": "error",
1139
- "react/no-danger-with-children": "error",
1140
- "react/no-deprecated": "error",
1146
+ // recommended rules from @eslint-react
1147
+ "react/ensure-forward-ref-using-ref": "warn",
1148
+ "react/no-access-state-in-setstate": "error",
1149
+ "react/no-array-index-key": "warn",
1150
+ "react/no-children-count": "warn",
1151
+ "react/no-children-for-each": "warn",
1152
+ "react/no-children-map": "warn",
1153
+ "react/no-children-only": "warn",
1154
+ "react/no-children-prop": "warn",
1155
+ "react/no-children-to-array": "warn",
1156
+ "react/no-clone-element": "warn",
1157
+ "react/no-comment-textnodes": "warn",
1158
+ "react/no-component-will-mount": "error",
1159
+ "react/no-component-will-receive-props": "error",
1160
+ "react/no-component-will-update": "error",
1161
+ "react/no-create-ref": "error",
1141
1162
  "react/no-direct-mutation-state": "error",
1142
- "react/no-find-dom-node": "error",
1143
- "react/no-is-mounted": "error",
1144
- "react/no-render-return-value": "error",
1163
+ "react/no-duplicate-key": "error",
1164
+ "react/no-implicit-key": "error",
1165
+ "react/no-missing-key": "error",
1166
+ "react/no-nested-components": "warn",
1167
+ "react/no-redundant-should-component-update": "error",
1168
+ "react/no-set-state-in-component-did-mount": "warn",
1169
+ "react/no-set-state-in-component-did-update": "warn",
1170
+ "react/no-set-state-in-component-will-update": "warn",
1145
1171
  "react/no-string-refs": "error",
1146
- "react/no-unescaped-entities": "error",
1147
- "react/no-unknown-property": "error",
1148
- "react/no-unsafe": "off",
1149
- "react/prop-types": "error",
1150
- "react/react-in-jsx-scope": "off",
1151
- "react/require-render-return": "error",
1152
- ...typescript2 ? {
1153
- "react/jsx-no-undef": "off",
1154
- "react/prop-type": "off"
1172
+ "react/no-unsafe-component-will-mount": "warn",
1173
+ "react/no-unsafe-component-will-receive-props": "warn",
1174
+ "react/no-unsafe-component-will-update": "warn",
1175
+ "react/no-unstable-context-value": "error",
1176
+ "react/no-unstable-default-props": "error",
1177
+ "react/no-unused-class-component-members": "warn",
1178
+ "react/no-unused-state": "warn",
1179
+ "react/no-useless-fragment": "warn",
1180
+ "react/prefer-destructuring-assignment": "warn",
1181
+ "react/prefer-shorthand-boolean": "warn",
1182
+ "react/prefer-shorthand-fragment": "warn",
1183
+ ...isTypeAware ? {
1184
+ "react/no-leaked-conditional-rendering": "warn"
1155
1185
  } : {},
1156
1186
  // overrides
1157
1187
  ...overrides
@@ -2187,6 +2217,10 @@ var VuePackages = [
2187
2217
  "@slidev/cli"
2188
2218
  ];
2189
2219
  var defaultPluginRenaming = {
2220
+ "@eslint-react": "react",
2221
+ "@eslint-react/dom": "react-dom",
2222
+ "@eslint-react/hooks-extra": "react-hooks-extra",
2223
+ "@eslint-react/naming-convention": "react-naming-convention",
2190
2224
  "@stylistic": "style",
2191
2225
  "@typescript-eslint": "ts",
2192
2226
  "import-x": "import",
@@ -2271,7 +2305,7 @@ function antfu(options = {}, ...userConfigs) {
2271
2305
  if (enableReact) {
2272
2306
  configs.push(react({
2273
2307
  overrides: getOverrides(options, "react"),
2274
- typescript: !!enableTypeScript
2308
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath
2275
2309
  }));
2276
2310
  }
2277
2311
  if (enableSolid) {