eslint-plugin-react-x 5.14.8 → 5.14.10

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 +196 -243
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
8
8
  import { computeObjectType, isAssignmentTargetEqual, isInitializedFromReact, resolve, resolveEnclosingAssignmentTarget } from "@eslint-react/var";
9
9
  import { DefinitionType, ScopeType } from "@typescript-eslint/scope-manager";
10
10
  import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
11
- import { P, isMatching, match } from "ts-pattern";
12
11
  import { compare } from "compare-versions";
12
+ import { P, isMatching, match } from "ts-pattern";
13
13
  import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
14
14
  import { unionConstituents } from "ts-api-utils";
15
15
  import { simpleTraverse } from "@typescript-eslint/typescript-estree";
@@ -144,7 +144,7 @@ const rules$6 = {
144
144
  //#endregion
145
145
  //#region package.json
146
146
  var name$6 = "eslint-plugin-react-x";
147
- var version = "5.14.8";
147
+ var version = "5.14.10";
148
148
 
149
149
  //#endregion
150
150
  //#region src/utils/create-rule.ts
@@ -1282,7 +1282,7 @@ function create$49(context) {
1282
1282
  recordCallEdge(node);
1283
1283
  const callee = Extract.unwrap(node.callee);
1284
1284
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return;
1285
- const method = Extract.getPropertyName(callee.property);
1285
+ const method = Extract.getCalleeName(node);
1286
1286
  if (method == null || !MUTATING_ARRAY_METHODS.has(method)) return;
1287
1287
  const origin = resolveGlobalOrigin(context, callee.object);
1288
1288
  if (origin == null) return;
@@ -1376,8 +1376,7 @@ function isRefLikeName$1(name) {
1376
1376
  function hasRefLikeNameInChain(node) {
1377
1377
  if (node.type === AST_NODE_TYPES.Identifier) return isRefLikeName$1(node.name);
1378
1378
  if (node.type !== AST_NODE_TYPES.MemberExpression) return false;
1379
- const propertyName = Extract.getPropertyName(node.property);
1380
- return propertyName != null ? isRefLikeName$1(propertyName) || hasRefLikeNameInChain(node.object) : hasRefLikeNameInChain(node.object);
1379
+ return node.property.type === AST_NODE_TYPES.Identifier ? isRefLikeName$1(node.property.name) || hasRefLikeNameInChain(node.object) : hasRefLikeNameInChain(node.object);
1381
1380
  }
1382
1381
  function isInitializedFromCall(context, node, isCall) {
1383
1382
  const root = node.type === AST_NODE_TYPES.Identifier ? node : Extract.getRootIdentifier(node);
@@ -1440,8 +1439,8 @@ function createImmutabilityCollector() {
1440
1439
  CallExpression(node) {
1441
1440
  const callee = Extract.unwrap(node.callee);
1442
1441
  if (callee.type === AST_NODE_TYPES.MemberExpression) {
1443
- const property = Extract.getPropertyName(callee.property);
1444
- if (property != null && MUTATING_METHODS.has(property)) {
1442
+ const method = Extract.getCalleeName(node);
1443
+ if (method != null && MUTATING_METHODS.has(method)) {
1445
1444
  const root = Extract.getRootIdentifier(callee.object);
1446
1445
  if (root != null) pushMutation("value", node, callee.object, root);
1447
1446
  }
@@ -1570,191 +1569,9 @@ function create$48(context) {
1570
1569
  } });
1571
1570
  }
1572
1571
 
1573
- //#endregion
1574
- //#region ../../.pkgs/eff/dist/index.js
1575
- function not(predicate) {
1576
- return (data) => !predicate(data);
1577
- }
1578
- /**
1579
- * Creates a function that can be used in a data-last (aka `pipe`able) or
1580
- * data-first style.
1581
- *
1582
- * The first parameter to `dual` is either the arity of the uncurried function
1583
- * or a predicate that determines if the function is being used in a data-first
1584
- * or data-last style.
1585
- *
1586
- * Using the arity is the most common use case, but there are some cases where
1587
- * you may want to use a predicate. For example, if you have a function that
1588
- * takes an optional argument, you can use a predicate to determine if the
1589
- * function is being used in a data-first or data-last style.
1590
- *
1591
- * You can pass either the arity of the uncurried function or a predicate
1592
- * which determines if the function is being used in a data-first or
1593
- * data-last style.
1594
- *
1595
- * **Example** (Using arity to determine data-first or data-last style)
1596
- *
1597
- * ```ts
1598
- * import { dual, pipe } from "effect/Function"
1599
- *
1600
- * const sum = dual<
1601
- * (that: number) => (self: number) => number,
1602
- * (self: number, that: number) => number
1603
- * >(2, (self, that) => self + that)
1604
- *
1605
- * console.log(sum(2, 3)) // 5
1606
- * console.log(pipe(2, sum(3))) // 5
1607
- * ```
1608
- *
1609
- * **Example** (Using call signatures to define the overloads)
1610
- *
1611
- * ```ts
1612
- * import { dual, pipe } from "effect/Function"
1613
- *
1614
- * const sum: {
1615
- * (that: number): (self: number) => number
1616
- * (self: number, that: number): number
1617
- * } = dual(2, (self: number, that: number): number => self + that)
1618
- *
1619
- * console.log(sum(2, 3)) // 5
1620
- * console.log(pipe(2, sum(3))) // 5
1621
- * ```
1622
- *
1623
- * **Example** (Using a predicate to determine data-first or data-last style)
1624
- *
1625
- * ```ts
1626
- * import { dual, pipe } from "effect/Function"
1627
- *
1628
- * const sum = dual<
1629
- * (that: number) => (self: number) => number,
1630
- * (self: number, that: number) => number
1631
- * >(
1632
- * (args) => args.length === 2,
1633
- * (self, that) => self + that
1634
- * )
1635
- *
1636
- * console.log(sum(2, 3)) // 5
1637
- * console.log(pipe(2, sum(3))) // 5
1638
- * ```
1639
- *
1640
- * @param arity - The arity of the uncurried function or a predicate that determines if the function is being used in a data-first or data-last style.
1641
- * @param body - The function to be curried.
1642
- * @since 1.0.0
1643
- */
1644
- const dual = function(arity, body) {
1645
- if (typeof arity === "function") return function() {
1646
- return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
1647
- };
1648
- switch (arity) {
1649
- case 0:
1650
- case 1: throw new RangeError(`Invalid arity ${arity}`);
1651
- case 2: return function(a, b) {
1652
- if (arguments.length >= 2) return body(a, b);
1653
- return function(self) {
1654
- return body(self, a);
1655
- };
1656
- };
1657
- case 3: return function(a, b, c) {
1658
- if (arguments.length >= 3) return body(a, b, c);
1659
- return function(self) {
1660
- return body(self, a, b);
1661
- };
1662
- };
1663
- default: return function() {
1664
- if (arguments.length >= arity) return body.apply(this, arguments);
1665
- const args = arguments;
1666
- return function(self) {
1667
- return body(self, ...args);
1668
- };
1669
- };
1670
- }
1671
- };
1672
- /**
1673
- * Do nothing and return `void`.
1674
- */
1675
- function constVoid() {}
1676
- /**
1677
- * Do nothing and return `true`.
1678
- *
1679
- * @returns true
1680
- */
1681
- function constTrue() {
1682
- return true;
1683
- }
1684
- /**
1685
- * Do nothing and return `false`.
1686
- *
1687
- * @returns false
1688
- */
1689
- function constFalse() {
1690
- return false;
1691
- }
1692
- /**
1693
- * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
1694
- * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
1695
- *
1696
- * @param self - The first function to apply (or the composed function in data-last style).
1697
- * @param bc - The second function to apply.
1698
- * @returns A composed function that applies both functions in sequence.
1699
- * @example
1700
- * ```ts
1701
- * import * as assert from "node:assert"
1702
- * import { compose } from "effect/Function"
1703
- *
1704
- * const increment = (n: number) => n + 1;
1705
- * const square = (n: number) => n * n;
1706
- *
1707
- * assert.strictEqual(compose(increment, square)(2), 9);
1708
- * ```
1709
- *
1710
- * @since 1.0.0
1711
- */
1712
- const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
1713
- function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
1714
- switch (arguments.length) {
1715
- case 1: return ab;
1716
- case 2: return function() {
1717
- return bc(ab.apply(this, arguments));
1718
- };
1719
- case 3: return function() {
1720
- return cd(bc(ab.apply(this, arguments)));
1721
- };
1722
- case 4: return function() {
1723
- return de(cd(bc(ab.apply(this, arguments))));
1724
- };
1725
- case 5: return function() {
1726
- return ef(de(cd(bc(ab.apply(this, arguments)))));
1727
- };
1728
- case 6: return function() {
1729
- return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
1730
- };
1731
- case 7: return function() {
1732
- return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
1733
- };
1734
- case 8: return function() {
1735
- return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
1736
- };
1737
- case 9: return function() {
1738
- return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
1739
- };
1740
- }
1741
- }
1742
- function getOrInsertComputed(map, key, callback) {
1743
- if (map.has(key)) return map.get(key);
1744
- const value = callback(key);
1745
- map.set(key, value);
1746
- return value;
1747
- }
1748
-
1749
1572
  //#endregion
1750
1573
  //#region src/rules/no-access-state-in-setstate/no-access-state-in-setstate.ts
1751
1574
  const RULE_NAME$47 = "no-access-state-in-setstate";
1752
- function isKeyLiteral$1(node, key) {
1753
- return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
1754
- type: AST_NODE_TYPES.TemplateLiteral,
1755
- expressions: []
1756
- }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
1757
- }
1758
1575
  var no_access_state_in_setstate_default = createRule({
1759
1576
  meta: {
1760
1577
  type: "problem",
@@ -1800,7 +1617,7 @@ function create$47(context) {
1800
1617
  if (currMethod == null || isStatic) return;
1801
1618
  const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
1802
1619
  if (setState == null || hasThisState) return;
1803
- if (Extract.getPropertyName(node.property) !== "state") return;
1620
+ if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== "state") return;
1804
1621
  context.report({
1805
1622
  messageId: "default",
1806
1623
  node
@@ -1826,7 +1643,7 @@ function create$47(context) {
1826
1643
  const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
1827
1644
  if (setState == null || hasThisState) return;
1828
1645
  if (node.init == null || node.init.type !== AST_NODE_TYPES.ThisExpression || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
1829
- if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$1(prop, prop.key) && Extract.getPropertyName(prop.key) === "state")) return;
1646
+ if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && !prop.computed && prop.key.type === AST_NODE_TYPES.Identifier && prop.key.name === "state")) return;
1830
1647
  context.report({
1831
1648
  messageId: "default",
1832
1649
  node
@@ -1952,7 +1769,7 @@ function create$46(context) {
1952
1769
  case AST_NODE_TYPES.LogicalExpression: return [...visitKeyExpression(node.left), ...visitKeyExpression(node.right)];
1953
1770
  case AST_NODE_TYPES.CallExpression: {
1954
1771
  const callee = Extract.unwrap(node.callee);
1955
- if (callee.type === AST_NODE_TYPES.MemberExpression && Extract.getPropertyName(callee.property) === "toString" && isArrayIndex(callee.object)) return [{
1772
+ if (callee.type === AST_NODE_TYPES.MemberExpression && Extract.getCalleeName(node) === "toString" && isArrayIndex(callee.object)) return [{
1956
1773
  messageId: "default",
1957
1774
  node: callee.object
1958
1775
  }];
@@ -2408,7 +2225,7 @@ function create$32(context) {
2408
2225
  const call = Traverse.findParent(jsxElement, (n) => {
2409
2226
  if (n.type !== AST_NODE_TYPES.CallExpression) return false;
2410
2227
  const callee = Extract.unwrap(n.callee);
2411
- return callee.type === AST_NODE_TYPES.MemberExpression && Extract.getPropertyName(callee.property) === "map";
2228
+ return callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "map";
2412
2229
  });
2413
2230
  const iter = Traverse.findParent(jsxElement, Check.isFunction, (n) => n === call);
2414
2231
  if (!Check.isFunction(iter)) return;
@@ -2668,6 +2485,166 @@ function create$28(context) {
2668
2485
  } };
2669
2486
  }
2670
2487
 
2488
+ //#endregion
2489
+ //#region ../../.pkgs/eff/dist/index.js
2490
+ function not(predicate) {
2491
+ return (data) => !predicate(data);
2492
+ }
2493
+ /**
2494
+ * Creates a function that can be used in a data-last (aka `pipe`able) or
2495
+ * data-first style.
2496
+ *
2497
+ * The first parameter to `dual` is either the arity of the uncurried function
2498
+ * or a predicate that determines if the function is being used in a data-first
2499
+ * or data-last style.
2500
+ *
2501
+ * Using the arity is the most common use case, but there are some cases where
2502
+ * you may want to use a predicate. For example, if you have a function that
2503
+ * takes an optional argument, you can use a predicate to determine if the
2504
+ * function is being used in a data-first or data-last style.
2505
+ *
2506
+ * You can pass either the arity of the uncurried function or a predicate
2507
+ * which determines if the function is being used in a data-first or
2508
+ * data-last style.
2509
+ *
2510
+ * **Example** (Using arity to determine data-first or data-last style)
2511
+ *
2512
+ * ```ts
2513
+ * import { dual, pipe } from "effect/Function"
2514
+ *
2515
+ * const sum = dual<
2516
+ * (that: number) => (self: number) => number,
2517
+ * (self: number, that: number) => number
2518
+ * >(2, (self, that) => self + that)
2519
+ *
2520
+ * console.log(sum(2, 3)) // 5
2521
+ * console.log(pipe(2, sum(3))) // 5
2522
+ * ```
2523
+ *
2524
+ * **Example** (Using call signatures to define the overloads)
2525
+ *
2526
+ * ```ts
2527
+ * import { dual, pipe } from "effect/Function"
2528
+ *
2529
+ * const sum: {
2530
+ * (that: number): (self: number) => number
2531
+ * (self: number, that: number): number
2532
+ * } = dual(2, (self: number, that: number): number => self + that)
2533
+ *
2534
+ * console.log(sum(2, 3)) // 5
2535
+ * console.log(pipe(2, sum(3))) // 5
2536
+ * ```
2537
+ *
2538
+ * **Example** (Using a predicate to determine data-first or data-last style)
2539
+ *
2540
+ * ```ts
2541
+ * import { dual, pipe } from "effect/Function"
2542
+ *
2543
+ * const sum = dual<
2544
+ * (that: number) => (self: number) => number,
2545
+ * (self: number, that: number) => number
2546
+ * >(
2547
+ * (args) => args.length === 2,
2548
+ * (self, that) => self + that
2549
+ * )
2550
+ *
2551
+ * console.log(sum(2, 3)) // 5
2552
+ * console.log(pipe(2, sum(3))) // 5
2553
+ * ```
2554
+ *
2555
+ * @param arity - The arity of the uncurried function or a predicate that determines if the function is being used in a data-first or data-last style.
2556
+ * @param body - The function to be curried.
2557
+ * @since 1.0.0
2558
+ */
2559
+ const dual = function(arity, body) {
2560
+ if (typeof arity === "function") return function() {
2561
+ return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
2562
+ };
2563
+ switch (arity) {
2564
+ case 0:
2565
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
2566
+ case 2: return function(a, b) {
2567
+ if (arguments.length >= 2) return body(a, b);
2568
+ return function(self) {
2569
+ return body(self, a);
2570
+ };
2571
+ };
2572
+ case 3: return function(a, b, c) {
2573
+ if (arguments.length >= 3) return body(a, b, c);
2574
+ return function(self) {
2575
+ return body(self, a, b);
2576
+ };
2577
+ };
2578
+ default: return function() {
2579
+ if (arguments.length >= arity) return body.apply(this, arguments);
2580
+ const args = arguments;
2581
+ return function(self) {
2582
+ return body(self, ...args);
2583
+ };
2584
+ };
2585
+ }
2586
+ };
2587
+ /**
2588
+ * Do nothing and return `void`.
2589
+ */
2590
+ function constVoid() {}
2591
+ /**
2592
+ * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
2593
+ * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
2594
+ *
2595
+ * @param self - The first function to apply (or the composed function in data-last style).
2596
+ * @param bc - The second function to apply.
2597
+ * @returns A composed function that applies both functions in sequence.
2598
+ * @example
2599
+ * ```ts
2600
+ * import * as assert from "node:assert"
2601
+ * import { compose } from "effect/Function"
2602
+ *
2603
+ * const increment = (n: number) => n + 1;
2604
+ * const square = (n: number) => n * n;
2605
+ *
2606
+ * assert.strictEqual(compose(increment, square)(2), 9);
2607
+ * ```
2608
+ *
2609
+ * @since 1.0.0
2610
+ */
2611
+ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
2612
+ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
2613
+ switch (arguments.length) {
2614
+ case 1: return ab;
2615
+ case 2: return function() {
2616
+ return bc(ab.apply(this, arguments));
2617
+ };
2618
+ case 3: return function() {
2619
+ return cd(bc(ab.apply(this, arguments)));
2620
+ };
2621
+ case 4: return function() {
2622
+ return de(cd(bc(ab.apply(this, arguments))));
2623
+ };
2624
+ case 5: return function() {
2625
+ return ef(de(cd(bc(ab.apply(this, arguments)))));
2626
+ };
2627
+ case 6: return function() {
2628
+ return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
2629
+ };
2630
+ case 7: return function() {
2631
+ return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
2632
+ };
2633
+ case 8: return function() {
2634
+ return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
2635
+ };
2636
+ case 9: return function() {
2637
+ return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
2638
+ };
2639
+ }
2640
+ }
2641
+ function getOrInsertComputed(map, key, callback) {
2642
+ if (map.has(key)) return map.get(key);
2643
+ const value = callback(key);
2644
+ map.set(key, value);
2645
+ return value;
2646
+ }
2647
+
2671
2648
  //#endregion
2672
2649
  //#region src/rules/no-leaked-conditional-rendering/lib.ts
2673
2650
  /**
@@ -3303,7 +3280,7 @@ function containsUseComments(context, node) {
3303
3280
  return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
3304
3281
  }
3305
3282
  function isTestMock(node) {
3306
- return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && Extract.getPropertyName(node.property) === "mock";
3283
+ return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "mock";
3307
3284
  }
3308
3285
  function isTestMockCallback(node) {
3309
3286
  return node != null && Check.isFunction(node) && node.parent.type === AST_NODE_TYPES.CallExpression && isTestMock(node.parent.callee) && node.parent.arguments[1] === node;
@@ -3618,12 +3595,6 @@ const LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
3618
3595
  "UNSAFE_componentWillReceiveProps",
3619
3596
  "UNSAFE_componentWillUpdate"
3620
3597
  ]);
3621
- function isKeyLiteral(node, key) {
3622
- return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
3623
- type: AST_NODE_TYPES.TemplateLiteral,
3624
- expressions: []
3625
- }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
3626
- }
3627
3598
 
3628
3599
  //#endregion
3629
3600
  //#region src/rules/no-unused-class-component-members/no-unused-class-component-members.ts
@@ -3658,8 +3629,7 @@ function create$11(context) {
3658
3629
  const usages = propertyUsages.get(currentClass);
3659
3630
  if (defs == null) return;
3660
3631
  for (const def of defs) {
3661
- const methodName = Extract.getPropertyName(def);
3662
- if (methodName == null) continue;
3632
+ const methodName = def.name;
3663
3633
  if (usages?.has(methodName) ?? false) continue;
3664
3634
  if (LIFECYCLE_METHODS.has(methodName)) if (methodName === "shouldComponentUpdate" && core.isPureComponent(currentClass)) {} else continue;
3665
3635
  context.report({
@@ -3677,7 +3647,7 @@ function create$11(context) {
3677
3647
  const currentClass = classStack.at(-1);
3678
3648
  if (currentClass == null || !core.isClassComponent(currentClass)) return;
3679
3649
  if (node.static) return;
3680
- if (isKeyLiteral(node, node.key)) propertyDefs.get(currentClass)?.add(node.key);
3650
+ if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) propertyDefs.get(currentClass)?.add(node.key);
3681
3651
  }
3682
3652
  function methodExit() {
3683
3653
  methodStack.pop();
@@ -3692,13 +3662,12 @@ function create$11(context) {
3692
3662
  const currentMethod = methodStack.at(-1);
3693
3663
  if (currentClass == null || currentMethod == null) return;
3694
3664
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3695
- if (node.object.type !== AST_NODE_TYPES.ThisExpression || !isKeyLiteral(node, node.property)) return;
3665
+ if (node.object.type !== AST_NODE_TYPES.ThisExpression || node.computed || node.property.type !== AST_NODE_TYPES.Identifier) return;
3696
3666
  if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
3697
3667
  propertyDefs.get(currentClass)?.add(node.property);
3698
3668
  return;
3699
3669
  }
3700
- const propertyName = Extract.getPropertyName(node.property);
3701
- if (propertyName != null) propertyUsages.get(currentClass)?.add(propertyName);
3670
+ propertyUsages.get(currentClass)?.add(node.property.name);
3702
3671
  },
3703
3672
  MethodDefinition: methodEnter,
3704
3673
  "MethodDefinition:exit": methodExit,
@@ -3710,10 +3679,7 @@ function create$11(context) {
3710
3679
  if (currentClass == null || currentMethod == null) return;
3711
3680
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3712
3681
  if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) {
3713
- for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) {
3714
- const keyName = Extract.getPropertyName(prop.key);
3715
- if (keyName != null) propertyUsages.get(currentClass)?.add(keyName);
3716
- }
3682
+ for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && !prop.computed && prop.key.type === AST_NODE_TYPES.Identifier) propertyUsages.get(currentClass)?.add(prop.key.name);
3717
3683
  }
3718
3684
  }
3719
3685
  };
@@ -4362,9 +4328,8 @@ function createBindingResolver(context) {
4362
4328
  node: value
4363
4329
  };
4364
4330
  if (value.type === AST_NODE_TYPES.CallExpression && (core.isUseRefCall(context, value) || core.isCreateRefCall(context, value))) return { kind: "ref" };
4365
- if (value.type === AST_NODE_TYPES.MemberExpression) {
4366
- const property = Extract.getPropertyName(value.property);
4367
- if (property != null && isRefLikeName(property)) return { kind: "ref" };
4331
+ if (value.type === AST_NODE_TYPES.MemberExpression && value.property.type === AST_NODE_TYPES.Identifier) {
4332
+ if (isRefLikeName(value.property.name)) return { kind: "ref" };
4368
4333
  }
4369
4334
  return { kind: "unknown" };
4370
4335
  }
@@ -4435,10 +4400,10 @@ function createBindingResolver(context) {
4435
4400
  const variable = getVariable(callee);
4436
4401
  return variable == null ? null : resolveFunction(variable, position);
4437
4402
  }
4438
- if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
4403
+ if (callee.type !== AST_NODE_TYPES.MemberExpression || callee.property.type !== AST_NODE_TYPES.Identifier) return null;
4439
4404
  const object = Extract.unwrap(callee.object);
4440
- const property = Extract.getPropertyName(callee.property);
4441
- if (object.type !== AST_NODE_TYPES.Identifier || property == null) return null;
4405
+ const property = callee.property.name;
4406
+ if (object.type !== AST_NODE_TYPES.Identifier) return null;
4442
4407
  const variable = getVariable(object);
4443
4408
  if (variable == null) return null;
4444
4409
  const event = getLatestValue(memberBindings.get(variable)?.get(property), position);
@@ -4455,15 +4420,15 @@ function createBindingResolver(context) {
4455
4420
  const identity = resolveRef(variable, node.range[0]);
4456
4421
  return identity == null ? null : { identity };
4457
4422
  }
4458
- if (object.type === AST_NODE_TYPES.MemberExpression) {
4459
- const property = Extract.getPropertyName(object.property);
4460
- if (property != null && isRefLikeName(property)) return { identity: null };
4423
+ if (object.type === AST_NODE_TYPES.MemberExpression && object.property.type === AST_NODE_TYPES.Identifier) {
4424
+ if (isRefLikeName(object.property.name)) return { identity: null };
4461
4425
  }
4462
4426
  return null;
4463
4427
  }
4464
4428
  function getNullBranch(test, identity) {
4465
4429
  return getNullCheckBranch(test, (candidate) => {
4466
- if (candidate.type !== AST_NODE_TYPES.MemberExpression || Extract.getPropertyName(candidate.property) !== "current") return false;
4430
+ if (candidate.type !== AST_NODE_TYPES.MemberExpression) return false;
4431
+ if (candidate.property.type !== AST_NODE_TYPES.Identifier || candidate.property.name !== "current") return false;
4467
4432
  return getRefTarget(candidate)?.identity === identity;
4468
4433
  }, (candidate) => {
4469
4434
  if (candidate.type === AST_NODE_TYPES.Literal) return candidate.value == null;
@@ -4499,15 +4464,9 @@ function isFunctionExpressionLike(node) {
4499
4464
  function isRefLikeName(name) {
4500
4465
  return name === "ref" || name.endsWith("Ref");
4501
4466
  }
4502
- function getCalleeName(node) {
4503
- const callee = Extract.unwrap(node.callee);
4504
- if (callee.type === AST_NODE_TYPES.Identifier) return callee.name;
4505
- if (callee.type === AST_NODE_TYPES.MemberExpression) return Extract.getPropertyName(callee.property);
4506
- return null;
4507
- }
4508
4467
  function getSynchronousCallbackIndexes(node) {
4509
4468
  const callee = Extract.unwrap(node.callee);
4510
- const name = getCalleeName(node);
4469
+ const name = Extract.getCalleeName(node);
4511
4470
  if (name == null) return [];
4512
4471
  if (callee.type === AST_NODE_TYPES.MemberExpression && SYNC_ARRAY_CALLBACKS.has(name)) return [0];
4513
4472
  switch (name) {
@@ -4664,10 +4623,9 @@ function create$6(context) {
4664
4623
  addIdentifierBinding(left, node.right, node.range[0]);
4665
4624
  return;
4666
4625
  }
4667
- if (left.type !== AST_NODE_TYPES.MemberExpression) return;
4626
+ if (left.type !== AST_NODE_TYPES.MemberExpression || left.property.type !== AST_NODE_TYPES.Identifier) return;
4668
4627
  const object = Extract.unwrap(left.object);
4669
- const property = Extract.getPropertyName(left.property);
4670
- if (object.type === AST_NODE_TYPES.Identifier && property != null) addMemberBinding(object, property, node.right, node.range[0]);
4628
+ if (object.type === AST_NODE_TYPES.Identifier) addMemberBinding(object, left.property.name, node.right, node.range[0]);
4671
4629
  },
4672
4630
  CallExpression(node) {
4673
4631
  calls.push(node);
@@ -4682,7 +4640,7 @@ function create$6(context) {
4682
4640
  addJsxRef(expression);
4683
4641
  },
4684
4642
  MemberExpression(node) {
4685
- if (Extract.getPropertyName(node.property) !== "current") return;
4643
+ if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== "current") return;
4686
4644
  refAccesses.push(getRefAccess(node));
4687
4645
  },
4688
4646
  "Program:exit"(program) {
@@ -4755,7 +4713,7 @@ function create$6(context) {
4755
4713
  const boundary = Traverse.findParent(call, isBoundary);
4756
4714
  if (boundary == null || !isReachedDuringRender(call, boundary)) continue;
4757
4715
  const callee = Extract.unwrap(call.callee);
4758
- const calleeName = getCalleeName(call);
4716
+ const calleeName = Extract.getCalleeName(call);
4759
4717
  const callArguments = call.arguments;
4760
4718
  if (core.isHookCall(call) || calleeName === "mergeRefs" || calleeName === "render" && callee.type === AST_NODE_TYPES.MemberExpression) continue;
4761
4719
  for (const argument of callArguments) {
@@ -7008,12 +6966,8 @@ function isHookDecl(node) {
7008
6966
  if (node.id.type !== AST_NODE_TYPES.Identifier) return false;
7009
6967
  const init = node.init;
7010
6968
  if (init == null || init.type !== AST_NODE_TYPES.CallExpression) return false;
7011
- const callee = Extract.unwrap(init.callee);
7012
- switch (callee.type) {
7013
- case AST_NODE_TYPES.Identifier: return core.isHookName(callee.name);
7014
- case AST_NODE_TYPES.MemberExpression: return callee.property.type === AST_NODE_TYPES.Identifier && core.isHookName(callee.property.name);
7015
- default: return false;
7016
- }
6969
+ const name = Extract.getCalleeName(init);
6970
+ return name != null && core.isHookName(name);
7017
6971
  }
7018
6972
  function isInitializedFromRef(context, name, initialScope, seen = /* @__PURE__ */ new Set()) {
7019
6973
  if (seen.has(name)) return false;
@@ -7098,8 +7052,7 @@ function create$5(context) {
7098
7052
  if (setupFnRef.current === node) setupFnRef.current = null;
7099
7053
  };
7100
7054
  function isThenCall(node) {
7101
- const callee = Extract.unwrap(node.callee);
7102
- return callee.type === AST_NODE_TYPES.MemberExpression && Extract.getPropertyName(callee.property) === "then";
7055
+ return Extract.unwrap(node.callee).type === AST_NODE_TYPES.MemberExpression && Extract.getCalleeName(node) === "then";
7103
7056
  }
7104
7057
  function isUseStateCall(node) {
7105
7058
  return core.isUseStateLikeCall(node, additionalStateHooks);
@@ -7143,7 +7096,7 @@ function create$5(context) {
7143
7096
  const innerCallee = Extract.unwrap(callee.callee);
7144
7097
  if (innerCallee.type !== AST_NODE_TYPES.MemberExpression) return false;
7145
7098
  if (!("name" in innerCallee.object)) return false;
7146
- const isAt = Extract.getPropertyName(innerCallee.property) === "at";
7099
+ const isAt = Extract.getCalleeName(callee) === "at";
7147
7100
  const [index] = callee.arguments;
7148
7101
  if (!isAt || index == null) return false;
7149
7102
  return getStaticValue(index, context.sourceCode.getScope(node))?.value === 1 && isIdFromUseStateCall(innerCallee.object);
@@ -7365,7 +7318,7 @@ function create$4(context) {
7365
7318
  const innerCallee = Extract.unwrap(callee.callee);
7366
7319
  if (innerCallee.type !== AST_NODE_TYPES.MemberExpression) return false;
7367
7320
  if (!("name" in innerCallee.object)) return false;
7368
- const isAt = Extract.getPropertyName(innerCallee.property) === "at";
7321
+ const isAt = Extract.getCalleeName(callee) === "at";
7369
7322
  const [index] = callee.arguments;
7370
7323
  if (!isAt || index == null) return false;
7371
7324
  return getStaticValue(index, context.sourceCode.getScope(node))?.value === 1 && isIdFromUseStateCall(innerCallee.object);
@@ -7590,7 +7543,7 @@ function isEvalCall(node) {
7590
7543
  case AST_NODE_TYPES.Identifier: return callee.name === "eval";
7591
7544
  case AST_NODE_TYPES.MemberExpression:
7592
7545
  if (!Check.isIdentifier(Extract.unwrap(callee.object), "globalThis")) return false;
7593
- return Extract.getPropertyName(callee.property, (n) => callee.computed ? null : n.name) === "eval";
7546
+ return !callee.computed && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "eval";
7594
7547
  default: return false;
7595
7548
  }
7596
7549
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.14.8",
3
+ "version": "5.14.10",
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,12 +45,12 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.5.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/core": "5.14.8",
49
- "@eslint-react/eslint": "5.14.8",
50
- "@eslint-react/jsx": "5.14.8",
51
- "@eslint-react/var": "5.14.8",
52
- "@eslint-react/shared": "5.14.8",
53
- "@eslint-react/ast": "5.14.8"
48
+ "@eslint-react/ast": "5.14.10",
49
+ "@eslint-react/jsx": "5.14.10",
50
+ "@eslint-react/core": "5.14.10",
51
+ "@eslint-react/shared": "5.14.10",
52
+ "@eslint-react/eslint": "5.14.10",
53
+ "@eslint-react/var": "5.14.10"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.17",
@@ -59,7 +59,7 @@
59
59
  "eslint": "^10.7.0",
60
60
  "react": "^19.2.7",
61
61
  "react-dom": "^19.2.7",
62
- "tsdown": "^0.22.5",
62
+ "tsdown": "^0.22.7",
63
63
  "tsl": "^1.0.30",
64
64
  "tsl-dx": "^0.13.2",
65
65
  "typescript": "6.0.3",