Skip to content

Fix false positive lint error with large number of branches #24287

Merged
gaearon merged 5 commits intofacebook:mainfrom
scyron6:bug-24279-conditional-hook
Apr 7, 2022
Merged

Fix false positive lint error with large number of branches #24287
gaearon merged 5 commits intofacebook:mainfrom
scyron6:bug-24279-conditional-hook

Conversation

@scyron6
Copy link
Contributor

@scyron6 scyron6 commented Apr 6, 2022

…trc.js to use es2020.

Summary

Fixes #24279. JavaScript could not handle the large integer when there were numerous conditional statements before and after the hook. This was causing rounding errors which resulted in a conditional being evaluated incorrectly. I switched the functions to use BigInts instead and updated the eslintrc.js. If using BigInts is not acceptable, I'll be happy to try and find a different solution.

How did you test this change?

The user who created the issue linked to a repository that showed the bug. I copied that exact code and pasted into the tests file. This test now passes.
Link to repository: https://github.com/SanderRonde/eslint-hook-bug

Now when I open that file in my local instance, there is no error message for the hook.
image

When I run all tests in ESLintRulesOfHooks-test.js, everything passes.
image

Unfortunately, when I ran yarn test --prod, I got several errors that were unrelated to ESLintRulesOfHooks. I am not sure if this is normal.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [eslint-plugin-exhaustive-deps] hook wrongly marked as conditional (at exact number of conditionals in FC)

4 participants