eslint-plugin-react-x 3.0.0-next.13 → 3.0.0-next.14

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -2
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ const rules$7 = {
68
68
  //#endregion
69
69
  //#region package.json
70
70
  var name$6 = "eslint-plugin-react-x";
71
- var version = "3.0.0-next.13";
71
+ var version = "3.0.0-next.14";
72
72
 
73
73
  //#endregion
74
74
  //#region src/utils/create-rule.ts
@@ -4231,13 +4231,17 @@ function create$2(context) {
4231
4231
  case entry.kind === "deferred":
4232
4232
  case entry.node.async: break;
4233
4233
  case entry.node === setupFunction:
4234
- case entry.kind === "immediate" && ast.findParentNode(entry.node, ast.isFunction) === setupFunction:
4234
+ case entry.kind === "immediate" && ast.findParentNode(entry.node, ast.isFunction) === setupFunction: {
4235
+ const args0 = node.arguments.at(0);
4236
+ if (args0 == null) return;
4237
+ if (isSetterUsingRefValue(context, args0)) return;
4235
4238
  context.report({
4236
4239
  messageId: "default",
4237
4240
  node,
4238
4241
  data: { name: context.sourceCode.getText(node.callee) }
4239
4242
  });
4240
4243
  return;
4244
+ }
4241
4245
  default: {
4242
4246
  const init = ast.findParentNode(node, isVariableDeclaratorFromHookCall)?.init;
4243
4247
  if (init == null) getOrElseUpdate(setStateCallsByFn, entry.node, () => []).push(node);
@@ -4311,6 +4315,18 @@ function create$2(context) {
4311
4315
  }
4312
4316
  });
4313
4317
  }
4318
+ function isSetterUsingRefValue(context, node) {
4319
+ const isUsingRefValue = (n) => {
4320
+ switch (n.type) {
4321
+ case AST_NODE_TYPES.Identifier: return core.isInitializedFromRef(n.name, context.sourceCode.getScope(n));
4322
+ case AST_NODE_TYPES.MemberExpression: return isUsingRefValue(n.object);
4323
+ case AST_NODE_TYPES.CallExpression: return isUsingRefValue(n.callee) || ast.getNestedIdentifiers(n).some(isUsingRefValue);
4324
+ default: return false;
4325
+ }
4326
+ };
4327
+ if (isUsingRefValue(node)) return true;
4328
+ return ast.isFunction(node) && context.sourceCode.getScope(node.body).references.some((r) => isUsingRefValue(r.identifier));
4329
+ }
4314
4330
  function isInitFromHookCall(init) {
4315
4331
  if (init?.type !== AST_NODE_TYPES.CallExpression) return false;
4316
4332
  switch (init.callee.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-next.13",
3
+ "version": "3.0.0-next.14",
4
4
  "description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "is-immutable-type": "^5.0.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "3.0.0-next.13",
49
- "@eslint-react/eff": "3.0.0-next.13",
50
- "@eslint-react/shared": "3.0.0-next.13",
51
- "@eslint-react/var": "3.0.0-next.13",
52
- "@eslint-react/core": "3.0.0-next.13"
48
+ "@eslint-react/ast": "3.0.0-next.14",
49
+ "@eslint-react/core": "3.0.0-next.14",
50
+ "@eslint-react/eff": "3.0.0-next.14",
51
+ "@eslint-react/shared": "3.0.0-next.14",
52
+ "@eslint-react/var": "3.0.0-next.14"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",