eslint-plugin-react-hooks-extra 2.0.7-beta.2 → 2.0.7-beta.3

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 +4 -7
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ const rules = { "react-hooks-extra/no-direct-set-state-in-use-effect": "warn" };
31
31
  //#endregion
32
32
  //#region package.json
33
33
  var name = "eslint-plugin-react-hooks-extra";
34
- var version = "2.0.7-beta.2";
34
+ var version = "2.0.7-beta.3";
35
35
 
36
36
  //#endregion
37
37
  //#region src/utils/create-rule.ts
@@ -109,8 +109,7 @@ function create(context) {
109
109
  }
110
110
  }
111
111
  function isIdFromUseStateCall(topLevelId, at) {
112
- const variable = findVariable(topLevelId, context.sourceCode.getScope(topLevelId));
113
- const variableNode = getVariableDefinitionNode(variable, 0);
112
+ const variableNode = getVariableDefinitionNode(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
114
113
  if (variableNode == null) return false;
115
114
  if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
116
115
  if (!isUseStateCall(variableNode)) return false;
@@ -127,15 +126,13 @@ function create(context) {
127
126
  const isAt = callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "at";
128
127
  const [index] = node.callee.arguments;
129
128
  if (!isAt || index == null) return false;
130
- const indexScope = context.sourceCode.getScope(node);
131
- return getStaticValue(index, indexScope)?.value === 1 && isIdFromUseStateCall(callee.object);
129
+ return getStaticValue(index, context.sourceCode.getScope(node))?.value === 1 && isIdFromUseStateCall(callee.object);
132
130
  }
133
131
  case AST_NODE_TYPES.Identifier: return isIdFromUseStateCall(node.callee, 1);
134
132
  case AST_NODE_TYPES.MemberExpression: {
135
133
  if (!("name" in node.callee.object)) return false;
136
134
  const property = node.callee.property;
137
- const propertyScope = context.sourceCode.getScope(node);
138
- return getStaticValue(property, propertyScope)?.value === 1 && isIdFromUseStateCall(node.callee.object, 1);
135
+ return getStaticValue(property, context.sourceCode.getScope(node))?.value === 1 && isIdFromUseStateCall(node.callee.object, 1);
139
136
  }
140
137
  default: return false;
141
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "2.0.7-beta.2",
3
+ "version": "2.0.7-beta.3",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,16 +42,16 @@
42
42
  "@typescript-eslint/utils": "^8.46.0",
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-pattern": "^5.8.0",
45
- "@eslint-react/ast": "2.0.7-beta.2",
46
- "@eslint-react/eff": "2.0.7-beta.2",
47
- "@eslint-react/kit": "2.0.7-beta.2",
48
- "@eslint-react/shared": "2.0.7-beta.2",
49
- "@eslint-react/core": "2.0.7-beta.2",
50
- "@eslint-react/var": "2.0.7-beta.2"
45
+ "@eslint-react/ast": "2.0.7-beta.3",
46
+ "@eslint-react/core": "2.0.7-beta.3",
47
+ "@eslint-react/kit": "2.0.7-beta.3",
48
+ "@eslint-react/eff": "2.0.7-beta.3",
49
+ "@eslint-react/var": "2.0.7-beta.3",
50
+ "@eslint-react/shared": "2.0.7-beta.3"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/react": "^19.2.0",
54
- "@types/react-dom": "^19.2.0",
53
+ "@types/react": "^19.2.2",
54
+ "@types/react-dom": "^19.2.1",
55
55
  "tsdown": "^0.15.6",
56
56
  "@local/configs": "0.0.0"
57
57
  },