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

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 +6 -19
  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.47";
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);
@@ -6600,14 +6587,14 @@ function create$4(context) {
6600
6587
  default: return "other";
6601
6588
  }
6602
6589
  }
6603
- function isIdFromUseStateCall(topLevelId, at) {
6604
- const initNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
6590
+ function isIdFromUseStateCall(id, at) {
6591
+ const initNode = getVariableInitializer(findVariable(id, context.sourceCode.getScope(id)), 0);
6605
6592
  if (initNode == null) return false;
6606
6593
  if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6607
6594
  if (!isUseStateCall(initNode)) return false;
6608
6595
  const variableNodeParent = initNode.parent;
6609
6596
  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;
6597
+ return variableNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === id.name) === at;
6611
6598
  }
6612
6599
  function isSetStateCall(node) {
6613
6600
  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.47",
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.47",
49
+ "@eslint-react/core": "3.0.0-next.47",
50
+ "@eslint-react/eff": "3.0.0-next.47",
51
+ "@eslint-react/shared": "3.0.0-next.47",
52
+ "@eslint-react/var": "3.0.0-next.47"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",