@@ -126,29 +126,23 @@ export const rule = {
126126 } ) ;
127127 }
128128
129- // TODO: Make more readable (and performant)
130- const isAllArgsInternal = callExpr . arguments
131- . flatMap ( ( arg ) => getDownstreamRefs ( context , arg ) )
132- . flatMap ( ( ref ) =>
133- getUpstreamReactVariables ( context , ref . identifier ) ,
134- )
135- . notEmptyEvery (
136- ( variable ) =>
137- isState ( variable ) ||
138- ( isProp ( variable ) && ! isHOCProp ( variable ) ) ,
139- ) ;
140- const isSomeArgsExternal = callExpr . arguments
141- . flatMap ( ( arg ) => getDownstreamRefs ( context , arg ) )
142- . flatMap ( ( ref ) =>
143- getUpstreamReactVariables ( context , ref . identifier ) ,
144- )
145- . some (
146- ( variable ) =>
147- ( ! isState ( variable ) && ! isProp ( variable ) ) ||
148- isHOCProp ( variable ) ,
149- ) ;
150- const isAllArgsInDeps = callExpr . arguments
151- . flatMap ( ( arg ) => getDownstreamRefs ( context , arg ) )
129+ const argsRefs = callExpr . arguments . flatMap ( ( arg ) =>
130+ getDownstreamRefs ( context , arg ) ,
131+ ) ;
132+ const argsUpstreamVariables = argsRefs . flatMap ( ( ref ) =>
133+ getUpstreamReactVariables ( context , ref . identifier ) ,
134+ ) ;
135+
136+ const isAllArgsInternal = argsUpstreamVariables . notEmptyEvery (
137+ ( variable ) =>
138+ isState ( variable ) || ( isProp ( variable ) && ! isHOCProp ( variable ) ) ,
139+ ) ;
140+ const isSomeArgsExternal = argsUpstreamVariables . some (
141+ ( variable ) =>
142+ ( ! isState ( variable ) && ! isProp ( variable ) ) ||
143+ isHOCProp ( variable ) ,
144+ ) ;
145+ const isAllArgsInDeps = argsRefs
152146 // Need to do this prematurely here because we call notEmptyEvery on the refs,
153147 // not on the upstream variables (which also filters out parameters)
154148 // TODO: Think about how to centralize that.
0 commit comments