eslint-plugin-react-x 4.0.2-beta.2 → 4.0.2-beta.4

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 +15 -15
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -147,7 +147,7 @@ const rules$7 = {
147
147
  //#endregion
148
148
  //#region package.json
149
149
  var name$6 = "eslint-plugin-react-x";
150
- var version = "4.0.2-beta.2";
150
+ var version = "4.0.2-beta.4";
151
151
 
152
152
  //#endregion
153
153
  //#region src/utils/create-rule.ts
@@ -1657,9 +1657,9 @@ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
1657
1657
  };
1658
1658
  }
1659
1659
  }
1660
- function getOrElseUpdate(map, key, callback) {
1660
+ function getOrInsertComputed(map, key, callback) {
1661
1661
  if (map.has(key)) return map.get(key);
1662
- const value = callback();
1662
+ const value = callback(key);
1663
1663
  map.set(key, value);
1664
1664
  return value;
1665
1665
  }
@@ -1691,11 +1691,11 @@ function create$53(context) {
1691
1691
  const setStateStack = [];
1692
1692
  return defineRuleListener({
1693
1693
  CallExpression(node) {
1694
- if (!core.isThisSetState(node)) return;
1694
+ if (!core.isThisSetStateCall(node)) return;
1695
1695
  setStateStack.push([node, false]);
1696
1696
  },
1697
1697
  "CallExpression:exit"(node) {
1698
- if (!core.isThisSetState(node)) return;
1698
+ if (!core.isThisSetStateCall(node)) return;
1699
1699
  setStateStack.pop();
1700
1700
  },
1701
1701
  ClassDeclaration(node) {
@@ -3037,7 +3037,7 @@ var no_set_state_in_component_did_mount_default = createRule({
3037
3037
  function create$25(context) {
3038
3038
  if (!context.sourceCode.text.includes("componentDidMount")) return {};
3039
3039
  return defineRuleListener({ CallExpression(node) {
3040
- if (!core.isThisSetState(node)) return;
3040
+ if (!core.isThisSetStateCall(node)) return;
3041
3041
  const enclosingClassNode = ast.findParent(node, core.isClassComponent);
3042
3042
  const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentDidMount(n));
3043
3043
  if (enclosingClassNode == null || enclosingMethodNode == null || enclosingMethodNode === enclosingClassNode) return;
@@ -3067,7 +3067,7 @@ var no_set_state_in_component_did_update_default = createRule({
3067
3067
  function create$24(context) {
3068
3068
  if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
3069
3069
  return defineRuleListener({ CallExpression(node) {
3070
- if (!core.isThisSetState(node)) return;
3070
+ if (!core.isThisSetStateCall(node)) return;
3071
3071
  const enclosingClassNode = ast.findParent(node, core.isClassComponent);
3072
3072
  const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentDidUpdate(n));
3073
3073
  if (enclosingClassNode == null || enclosingMethodNode == null || enclosingMethodNode === enclosingClassNode) return;
@@ -3097,7 +3097,7 @@ var no_set_state_in_component_will_update_default = createRule({
3097
3097
  function create$23(context) {
3098
3098
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
3099
3099
  return defineRuleListener({ CallExpression(node) {
3100
- if (!core.isThisSetState(node)) return;
3100
+ if (!core.isThisSetStateCall(node)) return;
3101
3101
  const enclosingClassNode = ast.findParent(node, core.isClassComponent);
3102
3102
  const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentWillUpdate(n));
3103
3103
  if (enclosingClassNode == null || enclosingMethodNode == null || enclosingMethodNode === enclosingClassNode) return;
@@ -3430,7 +3430,7 @@ function create$16(context) {
3430
3430
  const construction = computeObjectType(context, valueExpression);
3431
3431
  if (construction == null) return;
3432
3432
  if (core.isHookCall(construction.node)) return;
3433
- getOrElseUpdate(constructions, enclosingFunction, () => []).push(construction);
3433
+ getOrInsertComputed(constructions, enclosingFunction, () => []).push(construction);
3434
3434
  },
3435
3435
  "Program:exit"(program) {
3436
3436
  for (const { directives, node: component } of api.getAllComponents(program)) {
@@ -3500,7 +3500,7 @@ function create$15(context, [options]) {
3500
3500
  [ast.SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR](node) {
3501
3501
  const enclosingFunction = ast.findParent(node, ast.isFunction);
3502
3502
  if (enclosingFunction == null) return;
3503
- getOrElseUpdate(declarators, enclosingFunction, () => []).push(node);
3503
+ getOrInsertComputed(declarators, enclosingFunction, () => []).push(node);
3504
3504
  },
3505
3505
  "Program:exit"(program) {
3506
3506
  for (const { node: component } of api.getAllComponents(program)) {
@@ -6534,8 +6534,8 @@ function create$6(context) {
6534
6534
  }
6535
6535
  default: {
6536
6536
  const init = ast.findParent(node, isHookDecl)?.init;
6537
- if (init == null) getOrElseUpdate(setStateCallsByFn, entry.node, () => []).push(node);
6538
- else getOrElseUpdate(setStateInHookCallbacks, init, () => []).push(node);
6537
+ if (init == null) getOrInsertComputed(setStateCallsByFn, entry.node, () => []).push(node);
6538
+ else getOrInsertComputed(setStateInHookCallbacks, init, () => []).push(node);
6539
6539
  }
6540
6540
  }
6541
6541
  }).with("useEffect", () => {
@@ -6555,17 +6555,17 @@ function create$6(context) {
6555
6555
  if (parent.type !== AST_NODE_TYPES.CallExpression) break;
6556
6556
  if (!core.isUseMemoCall(parent)) break;
6557
6557
  const init = ast.findParent(parent, isHookDecl)?.init;
6558
- if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
6558
+ if (init != null) getOrInsertComputed(setStateInEffectArg, init, () => []).push(node);
6559
6559
  break;
6560
6560
  }
6561
6561
  case AST_NODE_TYPES.CallExpression:
6562
6562
  if (node !== node.parent.arguments.at(0)) break;
6563
6563
  if (core.isUseCallbackCall(node.parent)) {
6564
6564
  const init = ast.findParent(node.parent, isHookDecl)?.init;
6565
- if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
6565
+ if (init != null) getOrInsertComputed(setStateInEffectArg, init, () => []).push(node);
6566
6566
  break;
6567
6567
  }
6568
- if (isUseEffectCall(node.parent)) getOrElseUpdate(setStateInEffectSetup, node.parent, () => []).push(node);
6568
+ if (isUseEffectCall(node.parent)) getOrInsertComputed(setStateInEffectSetup, node.parent, () => []).push(node);
6569
6569
  }
6570
6570
  },
6571
6571
  "Program:exit"() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "4.0.2-beta.2",
3
+ "version": "4.0.2-beta.4",
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,17 +45,17 @@
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": "4.0.2-beta.2",
49
- "@eslint-react/jsx": "4.0.2-beta.2",
50
- "@eslint-react/ast": "4.0.2-beta.2",
51
- "@eslint-react/var": "4.0.2-beta.2",
52
- "@eslint-react/shared": "4.0.2-beta.2"
48
+ "@eslint-react/ast": "4.0.2-beta.4",
49
+ "@eslint-react/core": "4.0.2-beta.4",
50
+ "@eslint-react/shared": "4.0.2-beta.4",
51
+ "@eslint-react/jsx": "4.0.2-beta.4",
52
+ "@eslint-react/var": "4.0.2-beta.4"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",
56
56
  "@types/react-dom": "^19.2.3",
57
57
  "eslint": "^10.1.0",
58
- "tsdown": "^0.21.6",
58
+ "tsdown": "^0.21.7",
59
59
  "tsl-dx": "^0.10.2",
60
60
  "@local/configs": "0.0.0",
61
61
  "@local/eff": "3.0.0-beta.72"