@@ -6,6 +6,7 @@ import { getSettingsFromContext } from "@eslint-react/shared";
66import * as VAR from "@eslint-react/var" ;
77import { AST_NODE_TYPES as T } from "@typescript-eslint/types" ;
88import type { ESLintUtils , TSESTree } from "@typescript-eslint/utils" ;
9+ import { getStaticValue } from "@typescript-eslint/utils/ast-utils" ;
910import type { Scope } from "@typescript-eslint/utils/ts-eslint" ;
1011
1112import { 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 : {
0 commit comments