eslint-plugin-react-hooks-extra 2.0.0-next.169 → 2.0.0-next.170

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 +4 -11
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import * as ER from "@eslint-react/core";
4
4
  import { constVoid, getOrElseUpdate, identity, not } from "@eslint-react/eff";
5
5
  import * as VAR from "@eslint-react/var";
6
6
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
7
+ import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
7
8
  import { match } from "ts-pattern";
8
9
  import { ESLintUtils } from "@typescript-eslint/utils";
9
10
 
@@ -29,7 +30,7 @@ const rules = { "react-hooks-extra/no-direct-set-state-in-use-effect": "warn" };
29
30
  //#endregion
30
31
  //#region package.json
31
32
  var name = "eslint-plugin-react-hooks-extra";
32
- var version = "2.0.0-next.169";
33
+ var version = "2.0.0-next.170";
33
34
 
34
35
  //#endregion
35
36
  //#region src/rules-hooks/use-no-direct-set-state-in-use-effect.ts
@@ -96,11 +97,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
96
97
  const [index] = node.callee.arguments;
97
98
  if (!isAt || index == null) return false;
98
99
  const indexScope = context.sourceCode.getScope(node);
99
- const indexValue = VAR.toStaticValue({
100
- kind: "lazy",
101
- node: index,
102
- initialScope: indexScope
103
- }).value;
100
+ const indexValue = getStaticValue(index, indexScope)?.value;
104
101
  return indexValue === 1 && isIdFromUseStateCall(callee.object);
105
102
  }
106
103
  case AST_NODE_TYPES.Identifier: return isIdFromUseStateCall(node.callee, 1);
@@ -108,11 +105,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
108
105
  if (!("name" in node.callee.object)) return false;
109
106
  const property = node.callee.property;
110
107
  const propertyScope = context.sourceCode.getScope(node);
111
- const propertyValue = VAR.toStaticValue({
112
- kind: "lazy",
113
- node: property,
114
- initialScope: propertyScope
115
- }).value;
108
+ const propertyValue = getStaticValue(property, propertyScope)?.value;
116
109
  return propertyValue === 1 && isIdFromUseStateCall(node.callee.object, 1);
117
110
  }
118
111
  default: return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "2.0.0-next.169",
3
+ "version": "2.0.0-next.170",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,12 +42,12 @@
42
42
  "@typescript-eslint/utils": "^8.42.0",
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-pattern": "^5.8.0",
45
- "@eslint-react/ast": "2.0.0-next.169",
46
- "@eslint-react/eff": "2.0.0-next.169",
47
- "@eslint-react/core": "2.0.0-next.169",
48
- "@eslint-react/shared": "2.0.0-next.169",
49
- "@eslint-react/var": "2.0.0-next.169",
50
- "@eslint-react/kit": "2.0.0-next.169"
45
+ "@eslint-react/ast": "2.0.0-next.170",
46
+ "@eslint-react/kit": "2.0.0-next.170",
47
+ "@eslint-react/eff": "2.0.0-next.170",
48
+ "@eslint-react/var": "2.0.0-next.170",
49
+ "@eslint-react/core": "2.0.0-next.170",
50
+ "@eslint-react/shared": "2.0.0-next.170"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.1.12",