eslint-plugin-react-x 2.0.0-beta.28 → 2.0.0-beta.30

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 +17 -4
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -133,7 +133,7 @@ var settings3 = {
133
133
 
134
134
  // package.json
135
135
  var name4 = "eslint-plugin-react-x";
136
- var version = "2.0.0-beta.28";
136
+ var version = "2.0.0-beta.30";
137
137
  var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
138
138
 
139
139
  // src/rules/jsx-key-before-spread.ts
@@ -1645,14 +1645,27 @@ function create29(context) {
1645
1645
  return;
1646
1646
  }
1647
1647
  const id = AST13.getFunctionId(node);
1648
+ const fix = canFix(context, node) ? getFix(context, node) : null;
1648
1649
  context.report({
1649
1650
  messageId: "noForwardRef",
1650
1651
  node: id ?? node,
1651
- fix: getFix(context, node)
1652
+ fix
1652
1653
  });
1653
1654
  }
1654
1655
  };
1655
1656
  }
1657
+ function canFix(context, node) {
1658
+ const { importSource } = getSettingsFromContext(context);
1659
+ const initialScope = context.sourceCode.getScope(node);
1660
+ switch (node.callee.type) {
1661
+ case AST_NODE_TYPES.Identifier:
1662
+ return ER27.isInitializedFromReact(node.callee.name, importSource, initialScope);
1663
+ case AST_NODE_TYPES.MemberExpression:
1664
+ return node.callee.object.type === AST_NODE_TYPES.Identifier && ER27.isInitializedFromReact(node.callee.object.name, importSource, initialScope);
1665
+ default:
1666
+ return false;
1667
+ }
1668
+ }
1656
1669
  function getFix(context, node) {
1657
1670
  return (fixer) => {
1658
1671
  const [componentNode] = node.arguments;
@@ -3817,7 +3830,7 @@ function checkNode(context, node, allowExpressions) {
3817
3830
  return;
3818
3831
  }
3819
3832
  function getFix2(context, node) {
3820
- if (!canFix(context, node)) return null;
3833
+ if (!canFix2(context, node)) return null;
3821
3834
  return (fixer) => {
3822
3835
  const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
3823
3836
  const closer = node.type === AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
@@ -3825,7 +3838,7 @@ function getFix2(context, node) {
3825
3838
  return fixer.replaceText(node, trimLikeReact(childrenText));
3826
3839
  };
3827
3840
  }
3828
- function canFix(context, node) {
3841
+ function canFix2(context, node) {
3829
3842
  if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) {
3830
3843
  return ER27.isHostElement(context, node.parent);
3831
3844
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.0.0-beta.28",
3
+ "version": "2.0.0-beta.30",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,12 +42,12 @@
42
42
  "is-immutable-type": "^5.0.1",
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-pattern": "^5.8.0",
45
- "@eslint-react/ast": "2.0.0-beta.28",
46
- "@eslint-react/eff": "2.0.0-beta.28",
47
- "@eslint-react/kit": "2.0.0-beta.28",
48
- "@eslint-react/shared": "2.0.0-beta.28",
49
- "@eslint-react/core": "2.0.0-beta.28",
50
- "@eslint-react/var": "2.0.0-beta.28"
45
+ "@eslint-react/ast": "2.0.0-beta.30",
46
+ "@eslint-react/core": "2.0.0-beta.30",
47
+ "@eslint-react/kit": "2.0.0-beta.30",
48
+ "@eslint-react/var": "2.0.0-beta.30",
49
+ "@eslint-react/shared": "2.0.0-beta.30",
50
+ "@eslint-react/eff": "2.0.0-beta.30"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.1.10",