eslint-plugin-react-x 5.24.5 → 5.24.6

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 -7
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -135,7 +135,7 @@ const rules$6 = {
135
135
  //#endregion
136
136
  //#region package.json
137
137
  var name$6 = "eslint-plugin-react-x";
138
- var version = "5.24.5";
138
+ var version = "5.24.6";
139
139
  //#endregion
140
140
  //#region src/utils/create-rule.ts
141
141
  function getDocsUrl(ruleName) {
@@ -3463,7 +3463,7 @@ function collectUsedPropKeysOfParameter(context, usedPropKeys, parameter) {
3463
3463
  function collectUsedPropKeysOfObjectPattern(context, usedPropKeys, objectPattern) {
3464
3464
  for (const property of objectPattern.properties) switch (property.type) {
3465
3465
  case AST_NODE_TYPES.Property: {
3466
- const key = getKeyOfExpression(property.key);
3466
+ const key = getKeyOfExpression(property.key, property.computed);
3467
3467
  if (key == null) return false;
3468
3468
  usedPropKeys.add(key);
3469
3469
  break;
@@ -3494,7 +3494,7 @@ function collectUsedPropKeysOfReference(context, usedPropKeys, ref) {
3494
3494
  switch (parent.type) {
3495
3495
  case AST_NODE_TYPES.MemberExpression:
3496
3496
  if (parent.object === valueNode) {
3497
- const key = getKeyOfExpression(parent.property);
3497
+ const key = getKeyOfExpression(parent.property, parent.computed);
3498
3498
  if (key == null) return false;
3499
3499
  usedPropKeys.add(key);
3500
3500
  return true;
@@ -3504,9 +3504,9 @@ function collectUsedPropKeysOfReference(context, usedPropKeys, ref) {
3504
3504
  }
3505
3505
  return false;
3506
3506
  }
3507
- function getKeyOfExpression(expr) {
3507
+ function getKeyOfExpression(expr, computed = false) {
3508
3508
  switch (expr.type) {
3509
- case AST_NODE_TYPES.Identifier: return expr.name;
3509
+ case AST_NODE_TYPES.Identifier: return computed ? null : expr.name;
3510
3510
  case AST_NODE_TYPES.Literal: if (isString(expr.value)) return expr.value;
3511
3511
  }
3512
3512
  return null;
@@ -6509,7 +6509,9 @@ function createSetStateResolver$1(context) {
6509
6509
  if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6510
6510
  if (!isUseStateCall(initNode)) return false;
6511
6511
  const variableNodeParent = initNode.parent;
6512
- if (!hasProperty(variableNodeParent, "id") || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6512
+ if (!hasProperty(variableNodeParent, "id")) return true;
6513
+ if (variableNodeParent.id?.type === AST_NODE_TYPES.ObjectPattern) return variableNodeParent.id.properties.some((p) => p.type === AST_NODE_TYPES.Property && p.key.type === AST_NODE_TYPES.Literal && p.key.value === (at ?? 1) && Check.isIdentifier(p.value, id.name));
6514
+ if (variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6513
6515
  return variableNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === at;
6514
6516
  }
6515
6517
  function isSetStateCall(node) {
@@ -6862,7 +6864,9 @@ function createSetStateResolver(context) {
6862
6864
  if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6863
6865
  if (!isUseStateCall(initNode)) return false;
6864
6866
  const variableNodeParent = initNode.parent;
6865
- if (!hasProperty(variableNodeParent, "id") || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6867
+ if (!hasProperty(variableNodeParent, "id")) return true;
6868
+ if (variableNodeParent.id?.type === AST_NODE_TYPES.ObjectPattern) return variableNodeParent.id.properties.some((p) => p.type === AST_NODE_TYPES.Property && p.key.type === AST_NODE_TYPES.Literal && p.key.value === (at ?? 1) && Check.isIdentifier(p.value, id.name));
6869
+ if (variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6866
6870
  return variableNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === at;
6867
6871
  }
6868
6872
  function isSetStateCall(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.24.5",
3
+ "version": "5.24.6",
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",
@@ -36,12 +36,12 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@eslint-react/ast": "5.24.5",
40
- "@eslint-react/core": "5.24.5",
41
- "@eslint-react/eslint": "5.24.5",
42
- "@eslint-react/jsx": "5.24.5",
43
- "@eslint-react/shared": "5.24.5",
44
- "@eslint-react/var": "5.24.5",
39
+ "@eslint-react/ast": "5.24.6",
40
+ "@eslint-react/core": "5.24.6",
41
+ "@eslint-react/eslint": "5.24.6",
42
+ "@eslint-react/jsx": "5.24.6",
43
+ "@eslint-react/shared": "5.24.6",
44
+ "@eslint-react/var": "5.24.6",
45
45
  "@typescript-eslint/scope-manager": "^8.71.0",
46
46
  "@typescript-eslint/types": "^8.71.0",
47
47
  "@typescript-eslint/typescript-estree": "^8.71.0",