Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESLint] Check useEvent references instead #25319

Merged
merged 2 commits into from
Sep 24, 2022
Merged

[ESLint] Check useEvent references instead #25319

merged 2 commits into from
Sep 24, 2022

Commits on Sep 23, 2022

  1. [ESLint] Check useEvent references instead

    Previously the useEvent check in RulesOfHooks would collect all
    definitions of useEvent functions at the top level, record them as
    violations, then clear those violations if the useEvent function was
    later called or referened inside of an effect or another event.
    
    The flaw with this approach was in the special case where useEvent
    functions could be passed by reference inside of effects or events. The
    violation would be cleared here (since it was called at least once)
    and subsequent usages of the useEvent function would not be properly
    checked.
    
    This PR changes it so we check all identifiers that resolve to a
    useEvent function, and if they are not in an effect or event must be
    called or a lint error is emitted.
    
    Co-authored-by: Dan Abramov <[email protected]>
    poteto and gaearon committed Sep 23, 2022
    Configuration menu
    Copy the full SHA
    5739a2f View commit details
    Browse the repository at this point in the history

Commits on Sep 24, 2022

  1. Add comment

    poteto committed Sep 24, 2022
    Configuration menu
    Copy the full SHA
    67419d3 View commit details
    Browse the repository at this point in the history