Bug: ESLint react-hooks/exhaustive-deps rule false positive on constants made with constant expressions #21274
Open
Description
React version: 16.14.0 & 17.0.2
Steps To Reproduce
- Create a constant variable with an expression made of only constants.
- Run ESLint
Code example:
const a = 1
const b = 2 / 3
const c = -1
const d = +1
useEffect(() => {
void a
void b
void c
void d
}, [])
CodeSandbox: https://codesandbox.io/s/funny-wilson-33zxb
The current behavior
I see the following ESlint warning:
React Hook useEffect has missing dependencies: 'b', 'c', and 'd'. Either include them or remove the dependency array. (react-hooks/exhaustive-deps)
The expected behavior
I see no warning.
In my example the a
variable is skipped in the ESlint warning, but not the other three variables even those they are all constant expressions.