eslint-plugin-react-x 3.0.0-next.46 → 3.0.0-next.48

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 +8 -23
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ const rules$7 = {
68
68
  //#endregion
69
69
  //#region package.json
70
70
  var name$6 = "eslint-plugin-react-x";
71
- var version = "3.0.0-next.46";
71
+ var version = "3.0.0-next.48";
72
72
 
73
73
  //#endregion
74
74
  //#region src/utils/create-rule.ts
@@ -1255,19 +1255,6 @@ const MUTATING_ARRAY_METHODS = new Set([
1255
1255
  "splice",
1256
1256
  "unshift"
1257
1257
  ]);
1258
- /**
1259
- * Get the root identifier of a (possibly nested) member expression.
1260
- * For `a.b.c`, returns the `a` Identifier node.
1261
- * @param node The expression to analyze
1262
- * @returns The root Identifier node, or null if it cannot be determined (e.g. non-identifier root)
1263
- */
1264
- function getRootIdentifier(node) {
1265
- switch (node.type) {
1266
- case AST_NODE_TYPES.Identifier: return node;
1267
- case AST_NODE_TYPES.MemberExpression: return getRootIdentifier(node.object);
1268
- default: return null;
1269
- }
1270
- }
1271
1258
  var immutability_default = createRule({
1272
1259
  meta: {
1273
1260
  type: "problem",
@@ -1341,7 +1328,7 @@ function create$60(context) {
1341
1328
  const { object, property } = node.callee;
1342
1329
  if (property.type !== AST_NODE_TYPES.Identifier) return;
1343
1330
  if (!MUTATING_ARRAY_METHODS.has(property.name)) return;
1344
- const rootId = getRootIdentifier(object);
1331
+ const rootId = ast.getRootIdentifier(object);
1345
1332
  if (rootId == null) return;
1346
1333
  if (rootId.name === "draft") return;
1347
1334
  const enclosingFn = ast.findParentNode(node, ast.isFunction);
@@ -1361,7 +1348,7 @@ function create$60(context) {
1361
1348
  },
1362
1349
  AssignmentExpression(node) {
1363
1350
  if (node.left.type !== AST_NODE_TYPES.MemberExpression) return;
1364
- const rootId = getRootIdentifier(node.left);
1351
+ const rootId = ast.getRootIdentifier(node.left);
1365
1352
  if (rootId == null) return;
1366
1353
  if (rootId.name === "draft") return;
1367
1354
  const enclosingFn = ast.findParentNode(node, ast.isFunction);
@@ -2882,9 +2869,8 @@ function create$27(context) {
2882
2869
  }
2883
2870
  for (const { name, node: component } of fComponents) {
2884
2871
  if (name == null) continue;
2885
- if (core.isDirectValueOfRenderPropertyLoose(component)) continue;
2886
2872
  if (isInsideJSXAttributeValue(component)) {
2887
- if (!core.isDeclaredInRenderPropLoose(component)) context.report({
2873
+ context.report({
2888
2874
  messageId: "default",
2889
2875
  node: component,
2890
2876
  data: {
@@ -2905,8 +2891,7 @@ function create$27(context) {
2905
2891
  });
2906
2892
  continue;
2907
2893
  }
2908
- const enclosingComponent = findEnclosingComponent(component);
2909
- if (enclosingComponent != null && !core.isDirectValueOfRenderPropertyLoose(enclosingComponent)) {
2894
+ if (findEnclosingComponent(component) != null) {
2910
2895
  context.report({
2911
2896
  messageId: "default",
2912
2897
  node: component,
@@ -6600,14 +6585,14 @@ function create$4(context) {
6600
6585
  default: return "other";
6601
6586
  }
6602
6587
  }
6603
- function isIdFromUseStateCall(topLevelId, at) {
6604
- const initNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
6588
+ function isIdFromUseStateCall(id, at) {
6589
+ const initNode = getVariableInitializer(findVariable(id, context.sourceCode.getScope(id)), 0);
6605
6590
  if (initNode == null) return false;
6606
6591
  if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6607
6592
  if (!isUseStateCall(initNode)) return false;
6608
6593
  const variableNodeParent = initNode.parent;
6609
6594
  if (!("id" in variableNodeParent) || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6610
- return variableNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === topLevelId.name) === at;
6595
+ return variableNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === id.name) === at;
6611
6596
  }
6612
6597
  function isSetStateCall(node) {
6613
6598
  switch (node.callee.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-next.46",
3
+ "version": "3.0.0-next.48",
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,11 +45,11 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "3.0.0-next.46",
49
- "@eslint-react/core": "3.0.0-next.46",
50
- "@eslint-react/eff": "3.0.0-next.46",
51
- "@eslint-react/var": "3.0.0-next.46",
52
- "@eslint-react/shared": "3.0.0-next.46"
48
+ "@eslint-react/ast": "3.0.0-next.48",
49
+ "@eslint-react/core": "3.0.0-next.48",
50
+ "@eslint-react/eff": "3.0.0-next.48",
51
+ "@eslint-react/shared": "3.0.0-next.48",
52
+ "@eslint-react/var": "3.0.0-next.48"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",