Skip to content

Commit 6f895eb

Browse files
committed
refactor: replace toStaticValue with getStaticValue
1 parent b721efd commit 6f895eb

File tree

21 files changed

+26
-74
lines changed

21 files changed

+26
-74
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0-next.169
1+
2.0.0-beta.69

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/monorepo",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"private": true,
55
"description": "Monorepo for eslint-plugin-react-[x, dom, web-api, hooks-extra, naming-convention].",
66
"keywords": [

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/core",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
55
"homepage": "https://github.com/Rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-debug/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-debug",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint plugin for debugging related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-dom",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint plugin for React DOM related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-hooks-extra/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-hooks-extra",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-hooks-extra/src/rules-hooks/use-no-direct-set-state-in-use-effect.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getSettingsFromContext } from "@eslint-react/shared";
66
import * as VAR from "@eslint-react/var";
77
import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
88
import type { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
9+
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
910
import type { Scope } from "@typescript-eslint/utils/ts-eslint";
1011

1112
import { match } from "ts-pattern";
@@ -142,11 +143,7 @@ export function useNoDirectSetStateInUseEffect<Ctx extends RuleContext>(
142143
return false;
143144
}
144145
const indexScope = context.sourceCode.getScope(node);
145-
const indexValue = VAR.toStaticValue({
146-
kind: "lazy",
147-
node: index,
148-
initialScope: indexScope,
149-
}).value;
146+
const indexValue = getStaticValue(index, indexScope)?.value;
150147
return indexValue === 1 && isIdFromUseStateCall(callee.object);
151148
}
152149
// const [data, setData] = useState();
@@ -162,11 +159,7 @@ export function useNoDirectSetStateInUseEffect<Ctx extends RuleContext>(
162159
}
163160
const property = node.callee.property;
164161
const propertyScope = context.sourceCode.getScope(node);
165-
const propertyValue = VAR.toStaticValue({
166-
kind: "lazy",
167-
node: property,
168-
initialScope: propertyScope,
169-
}).value;
162+
const propertyValue = getStaticValue(property, propertyScope)?.value;
170163
return propertyValue === 1 && isIdFromUseStateCall(node.callee.object, 1);
171164
}
172165
default: {

packages/plugins/eslint-plugin-react-naming-convention/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-naming-convention",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint plugin for naming convention related rules.",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-web-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-web-api",
3-
"version": "2.0.0-next.169",
3+
"version": "2.0.0-beta.69",
44
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
55
"keywords": [
66
"react",

packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/utils";
99
import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";
1010
import type { EventListenerEntry } from "../types";
1111

12+
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
1213
import { isMatching, match, P } from "ts-pattern";
1314
import { createRule, getPhaseKindOfFunction } from "../utils";
1415

@@ -102,7 +103,7 @@ function getOptions(node: TSESTree.CallExpressionArgument, initialScope: Scope):
102103
break;
103104
}
104105
default: {
105-
v = VAR.toStaticValue({ kind: "lazy", node: value, initialScope }).value;
106+
v = getStaticValue(value, initialScope)?.value;
106107
break;
107108
}
108109
}

0 commit comments

Comments
 (0)