You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if I understand the purpose of closureIndex and dependenciesIndex for this rule - shouldn't you specify the stability of the result(s), not the arguments passed?
For example, I want to declare my custom useEffectEvent ponyfill returns a stable result:
import*asReactfrom'react';typeAnyFunction=(...args: unknown[])=>unknown;functionuseEffectEvent<TextendsAnyFunction>(callback?: T) {constref=React.useRef<AnyFunction|undefined>(()=>{thrownewError('Cannot call an event handler while rendering.');});React.useInsertionEffect(()=>{ref.current=callback;});returnReact.useCallback<AnyFunction>((...args)=>ref.current?.(...args),[],)asT;}
The hooks configuration allows you to configure hooks whose closures should be checked against a list of dependencies, similar to how the dependencies array of useEffect() is checked, for instance. For useEffect(), closureIndex is 0 (since that argument contains the closure to check) and dependenciesIndex is 1 (since that argument is the dependencies array).
I think what you are looking for is mentioned in this issue: #1128
Environment information
Rule name
useExhaustiveDependencies
Playground link
https://biomejs.dev/playground/?code=aQBtAHAAbwByAHQAIAAqACAAYQBzACAAUgBlAGEAYwB0ACAAZgByAG8AbQAgACcAcgBlAGEAYwB0ACcAOwAKAAoAdAB5AHAAZQAgAEEAbgB5AEYAdQBuAGMAdABpAG8AbgAgAD0AIAAoAC4ALgAuAGEAcgBnAHMAOgAgAHUAbgBrAG4AbwB3AG4AWwBdACkAIAA9AD4AIAB1AG4AawBuAG8AdwBuADsACgAKAGYAdQBuAGMAdABpAG8AbgAgAHUAcwBlAEUAZgBmAGUAYwB0AEUAdgBlAG4AdAA8AFQAIABlAHgAdABlAG4AZABzACAAQQBuAHkARgB1AG4AYwB0AGkAbwBuAD4AKABjAGEAbABsAGIAYQBjAGsAPwA6ACAAVAApACAAewAKACAAIABjAG8AbgBzAHQAIAByAGUAZgAgAD0AIABSAGUAYQBjAHQALgB1AHMAZQBSAGUAZgA8AEEAbgB5AEYAdQBuAGMAdABpAG8AbgAgAHwAIAB1AG4AZABlAGYAaQBuAGUAZAA%2BACgAKAApACAAPQA%2BACAAewAKACAAIAAgACAAdABoAHIAbwB3ACAAbgBlAHcAIABFAHIAcgBvAHIAKAAnAEMAYQBuAG4AbwB0ACAAYwBhAGwAbAAgAGEAbgAgAGUAdgBlAG4AdAAgAGgAYQBuAGQAbABlAHIAIAB3AGgAaQBsAGUAIAByAGUAbgBkAGUAcgBpAG4AZwAuACcAKQA7AAoAIAAgAH0AKQA7AAoACgAgACAAUgBlAGEAYwB0AC4AdQBzAGUASQBuAHMAZQByAHQAaQBvAG4ARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIAByAGUAZgAuAGMAdQByAHIAZQBuAHQAIAA9ACAAYwBhAGwAbABiAGEAYwBrADsACgAgACAAfQApADsACgAKACAAIAByAGUAdAB1AHIAbgAgAFIAZQBhAGMAdAAuAHUAcwBlAEMAYQBsAGwAYgBhAGMAawA8AEEAbgB5AEYAdQBuAGMAdABpAG8AbgA%2BACgACgAgACAAIAAgACgALgAuAC4AYQByAGcAcwApACAAPQA%2BACAAcgBlAGYALgBjAHUAcgByAGUAbgB0AD8ALgAoAC4ALgAuAGEAcgBnAHMAKQAsAAoAIAAgACAAIABbAF0ALAAKACAAIAApACAAYQBzACAAVAA7AAoAfQAKAGYAdQBuAGMAdABpAG8AbgAgAEEAcABwACgAKQAgAHsACgAgACAAYwBvAG4AcwB0ACAAcwB0AGEAYgBsAGUAIAA9ACAAdQBzAGUARQBmAGYAZQBjAHQARQB2AGUAbgB0ACgAKAApACAAPQA%2BACAAewB9ACkAOwAKACAAIABSAGUAYQBjAHQALgB1AHMAZQBFAGYAZgBlAGMAdAAoACgAKQAgAD0APgAgAHsACgAgACAAIAAgAHMAdABhAGIAbABlACgAKQA7AAoAIAAgAH0ALAAgAFsAXQApADsACgB9AA%3D%3D
Expected result
I'm not sure if I understand the purpose of
closureIndex
anddependenciesIndex
for this rule - shouldn't you specify the stability of the result(s), not the arguments passed?For example, I want to declare my custom
useEffectEvent
ponyfill returns a stable result:Code of Conduct
The text was updated successfully, but these errors were encountered: