eslint-plugin-react-x 1.52.4 → 1.52.5-next.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/dist/index.js CHANGED
@@ -142,7 +142,7 @@ var settings3 = {
142
142
 
143
143
  // package.json
144
144
  var name4 = "eslint-plugin-react-x";
145
- var version = "1.52.4";
145
+ var version = "1.52.5-next.0";
146
146
  var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
147
147
 
148
148
  // src/rules/avoid-shorthand-boolean.ts
@@ -1526,14 +1526,27 @@ function create29(context) {
1526
1526
  return;
1527
1527
  }
1528
1528
  const id = AST8__namespace.getFunctionId(node);
1529
+ const fix = canFix(context, node) ? getFix(context, node) : null;
1529
1530
  context.report({
1530
1531
  messageId: "noForwardRef",
1531
1532
  node: id ?? node,
1532
- fix: getFix(context, node)
1533
+ fix
1533
1534
  });
1534
1535
  }
1535
1536
  };
1536
1537
  }
1538
+ function canFix(context, node) {
1539
+ const { importSource } = shared.getSettingsFromContext(context);
1540
+ const initialScope = context.sourceCode.getScope(node);
1541
+ switch (node.callee.type) {
1542
+ case types.AST_NODE_TYPES.Identifier:
1543
+ return ER25__namespace.isInitializedFromReact(node.callee.name, importSource, initialScope);
1544
+ case types.AST_NODE_TYPES.MemberExpression:
1545
+ return node.callee.object.type === types.AST_NODE_TYPES.Identifier && ER25__namespace.isInitializedFromReact(node.callee.object.name, importSource, initialScope);
1546
+ default:
1547
+ return false;
1548
+ }
1549
+ }
1537
1550
  function getFix(context, node) {
1538
1551
  return (fixer) => {
1539
1552
  const [componentNode] = node.arguments;
@@ -3407,7 +3420,7 @@ function checkNode(context, node, allowExpressions) {
3407
3420
  return;
3408
3421
  }
3409
3422
  function getFix2(context, node) {
3410
- if (!canFix(context, node)) return null;
3423
+ if (!canFix2(context, node)) return null;
3411
3424
  return (fixer) => {
3412
3425
  const opener = node.type === types.AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
3413
3426
  const closer = node.type === types.AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
@@ -3415,7 +3428,7 @@ function getFix2(context, node) {
3415
3428
  return fixer.replaceText(node, trimLikeReact(childrenText));
3416
3429
  };
3417
3430
  }
3418
- function canFix(context, node) {
3431
+ function canFix2(context, node) {
3419
3432
  if (node.parent.type === types.AST_NODE_TYPES.JSXElement || node.parent.type === types.AST_NODE_TYPES.JSXFragment) {
3420
3433
  return ER25__namespace.isHostElement(context, node.parent);
3421
3434
  }
package/dist/index.mjs CHANGED
@@ -115,7 +115,7 @@ var settings3 = {
115
115
 
116
116
  // package.json
117
117
  var name4 = "eslint-plugin-react-x";
118
- var version = "1.52.4";
118
+ var version = "1.52.5-next.0";
119
119
  var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
120
120
 
121
121
  // src/rules/avoid-shorthand-boolean.ts
@@ -1499,14 +1499,27 @@ function create29(context) {
1499
1499
  return;
1500
1500
  }
1501
1501
  const id = AST8.getFunctionId(node);
1502
+ const fix = canFix(context, node) ? getFix(context, node) : null;
1502
1503
  context.report({
1503
1504
  messageId: "noForwardRef",
1504
1505
  node: id ?? node,
1505
- fix: getFix(context, node)
1506
+ fix
1506
1507
  });
1507
1508
  }
1508
1509
  };
1509
1510
  }
1511
+ function canFix(context, node) {
1512
+ const { importSource } = getSettingsFromContext(context);
1513
+ const initialScope = context.sourceCode.getScope(node);
1514
+ switch (node.callee.type) {
1515
+ case AST_NODE_TYPES.Identifier:
1516
+ return ER25.isInitializedFromReact(node.callee.name, importSource, initialScope);
1517
+ case AST_NODE_TYPES.MemberExpression:
1518
+ return node.callee.object.type === AST_NODE_TYPES.Identifier && ER25.isInitializedFromReact(node.callee.object.name, importSource, initialScope);
1519
+ default:
1520
+ return false;
1521
+ }
1522
+ }
1510
1523
  function getFix(context, node) {
1511
1524
  return (fixer) => {
1512
1525
  const [componentNode] = node.arguments;
@@ -3380,7 +3393,7 @@ function checkNode(context, node, allowExpressions) {
3380
3393
  return;
3381
3394
  }
3382
3395
  function getFix2(context, node) {
3383
- if (!canFix(context, node)) return null;
3396
+ if (!canFix2(context, node)) return null;
3384
3397
  return (fixer) => {
3385
3398
  const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
3386
3399
  const closer = node.type === AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
@@ -3388,7 +3401,7 @@ function getFix2(context, node) {
3388
3401
  return fixer.replaceText(node, trimLikeReact(childrenText));
3389
3402
  };
3390
3403
  }
3391
- function canFix(context, node) {
3404
+ function canFix2(context, node) {
3392
3405
  if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) {
3393
3406
  return ER25.isHostElement(context, node.parent);
3394
3407
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.52.4",
3
+ "version": "1.52.5-next.0",
4
4
  "description": "4-7x faster composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -50,12 +50,12 @@
50
50
  "is-immutable-type": "^5.0.1",
51
51
  "string-ts": "^2.2.1",
52
52
  "ts-pattern": "^5.8.0",
53
- "@eslint-react/ast": "1.52.4",
54
- "@eslint-react/core": "1.52.4",
55
- "@eslint-react/eff": "1.52.4",
56
- "@eslint-react/var": "1.52.4",
57
- "@eslint-react/shared": "1.52.4",
58
- "@eslint-react/kit": "1.52.4"
53
+ "@eslint-react/ast": "1.52.5-next.0",
54
+ "@eslint-react/core": "1.52.5-next.0",
55
+ "@eslint-react/kit": "1.52.5-next.0",
56
+ "@eslint-react/shared": "1.52.5-next.0",
57
+ "@eslint-react/eff": "1.52.5-next.0",
58
+ "@eslint-react/var": "1.52.5-next.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^19.1.10",