🐛 useExhaustiveDependencies
: false positive for out of scope dependency
#651
Labels
A-Linter
Area: linter
L-JavaScript
Language: JavaScript and super languages
S-Bug-confirmed
Status: report has been confirmed as a valid bug
Environment information
What happened?
When using a variable declared outside of the component scope, you should not add it to a React
useEffect
dependency array. A valid example of this in the React docs:ESLint is aware of this, and gives a warning if it is added:
However Biome falsely tells you to add it as a dependency:
https://biomejs.dev/playground/?lintRules=all&code=aQBtAHAAbwByAHQAIAB7AHUAcwBlAEUAZgBmAGUAYwB0AH0AIABmAHIAbwBtACAAJwByAGUAYQBjAHQAJwA7AAoACgBsAGUAdAAgAGQAaQBkAEkAbgBpAHQAIAA9ACAAZgBhAGwAcwBlADsACgAKAGYAdQBuAGMAdABpAG8AbgAgAEEAcABwACgAKQAgAHsACgAgACAAdQBzAGUARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABpAGYAIAAoACEAZABpAGQASQBuAGkAdAApACAAewAKACAAIAAgACAAIAAgAGQAaQBkAEkAbgBpAHQAIAA9ACAAdAByAHUAZQA7AAoAIAAgACAAIAAgACAALwAvACAABScgAE8AbgBsAHkAIAByAHUAbgBzACAAbwBuAGMAZQAgAHAAZQByACAAYQBwAHAAIABsAG8AYQBkAAoAIAAgACAAIAB9AAoAIAAgAH0ALAAgAFsAXQApADsACgAgACAALwAvACAALgAuAC4ACgB9AA%3D%3D
Expected result
You should not be prompted to add an out-of-scope variable to the dependency array.
Code of Conduct
The text was updated successfully, but these errors were encountered: