eslint-plugin-react-x 5.6.1-next.1 → 5.6.2-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +11 -4
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -142,7 +142,7 @@ const rules$6 = {
142
142
  //#endregion
143
143
  //#region package.json
144
144
  var name$6 = "eslint-plugin-react-x";
145
- var version = "5.6.1-next.1";
145
+ var version = "5.6.2-beta.0";
146
146
 
147
147
  //#endregion
148
148
  //#region src/utils/create-rule.ts
@@ -7253,6 +7253,14 @@ function isInsideNestedFunction(node, boundary) {
7253
7253
  }
7254
7254
  return false;
7255
7255
  }
7256
+ function isDeclaredInsideCallback(variable, callback) {
7257
+ let scope = variable.scope;
7258
+ while (scope != null) {
7259
+ if (scope.block === callback) return true;
7260
+ scope = scope.upper;
7261
+ }
7262
+ return false;
7263
+ }
7256
7264
  /**
7257
7265
  * Gets the nested return statements in the node that are within the same function
7258
7266
  * @param node The AST node
@@ -7293,15 +7301,14 @@ function create$1(context) {
7293
7301
  if (!context.sourceCode.text.includes("useMemo")) return {};
7294
7302
  function validateNoOuterVariableReassignment(callback) {
7295
7303
  const violations = [];
7296
- const callbackScope = context.sourceCode.getScope(callback);
7297
- const localVars = new Set(callbackScope.variables.map((v) => v.name));
7298
7304
  if (callback.body == null) return violations;
7299
7305
  simpleTraverse(callback.body, { enter(node) {
7300
7306
  if (node.type !== AST_NODE_TYPES.AssignmentExpression) return;
7301
7307
  const left = Extract.unwrap(node.left);
7302
7308
  if (left.type !== AST_NODE_TYPES.Identifier) return;
7303
- if (localVars.has(left.name)) return;
7304
7309
  if (isInsideNestedFunction(node, callback)) return;
7310
+ const variable = findVariable(context.sourceCode.getScope(left), left);
7311
+ if (variable != null && variable.defs.length > 0 && isDeclaredInsideCallback(variable, callback)) return;
7305
7312
  violations.push({
7306
7313
  messageId: "noReassigningOuterVariables",
7307
7314
  node: left
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.6.1-next.1",
3
+ "version": "5.6.2-beta.0",
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,12 +45,12 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.5.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "5.6.1-next.1",
49
- "@eslint-react/core": "5.6.1-next.1",
50
- "@eslint-react/jsx": "5.6.1-next.1",
51
- "@eslint-react/eslint": "5.6.1-next.1",
52
- "@eslint-react/shared": "5.6.1-next.1",
53
- "@eslint-react/var": "5.6.1-next.1"
48
+ "@eslint-react/ast": "5.6.2-beta.0",
49
+ "@eslint-react/jsx": "5.6.2-beta.0",
50
+ "@eslint-react/core": "5.6.2-beta.0",
51
+ "@eslint-react/eslint": "5.6.2-beta.0",
52
+ "@eslint-react/shared": "5.6.2-beta.0",
53
+ "@eslint-react/var": "5.6.2-beta.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.14",