File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ export default createRule<[], MessageID>({
89
89
const [ index ] = n . arguments ;
90
90
if ( ! isAt || ! index ) return O . none ( ) ;
91
91
const initialScope = context . sourceCode . getScope ( n ) ;
92
+ // const data = useState();
93
+ // const index = 1;
94
+ // data[index]();
92
95
const value = getStaticValue ( index , initialScope ) ;
93
96
if ( value ?. value === 1 ) return O . fromNullable ( n . callee . object ) ;
94
97
return O . none ( ) ;
@@ -123,7 +126,7 @@ export default createRule<[], MessageID>({
123
126
const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
124
127
const cleanUpFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
125
128
const indirectFunctionCalls = MutRef . make ( Chunk . empty < TSESTree . CallExpression > ( ) ) ;
126
- const indirectSetStateCalls = new Map < TSESTreeFunction , Chunk . Chunk < TSESTree . CallExpression > > ( ) ;
129
+ const indirectSetStateCalls = new WeakMap < TSESTreeFunction , Chunk . Chunk < TSESTree . CallExpression > > ( ) ;
127
130
// const onEffectFunctionEnter = (_: TSESTreeFunction) => {};
128
131
// const onEffectFunctionExit = (_: TSESTreeFunction) => {};
129
132
return {
Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ export default createRule<[], MessageID>({
90
90
} , n . callee ) ;
91
91
const [ index ] = n . arguments ;
92
92
if ( ! isAt || ! index ) return O . none ( ) ;
93
+ // const data = useState();
94
+ // const index = 1;
95
+ // data[index]();
93
96
const initialScope = context . sourceCode . getScope ( n ) ;
94
97
const value = getStaticValue ( index , initialScope ) ;
95
98
if ( value ?. value === 1 ) return O . fromNullable ( n . callee . object ) ;
@@ -125,7 +128,7 @@ export default createRule<[], MessageID>({
125
128
const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
126
129
const cleanUpFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
127
130
const indirectFunctionCalls = MutRef . make ( Chunk . empty < TSESTree . CallExpression > ( ) ) ;
128
- const indirectSetStateCalls = new Map < TSESTreeFunction , Chunk . Chunk < TSESTree . CallExpression > > ( ) ;
131
+ const indirectSetStateCalls = new WeakMap < TSESTreeFunction , Chunk . Chunk < TSESTree . CallExpression > > ( ) ;
129
132
// const onEffectFunctionEnter = (_: TSESTreeFunction) => {};
130
133
// const onEffectFunctionExit = (_: TSESTreeFunction) => {};
131
134
return {
You can’t perform that action at this time.
0 commit comments