Skip to content

[Compiler Bug]: eslint-plugin-react-hooks silent bailout when try/catch/finally block in the same component body #35644

@TudorGiuroiu

Description

@TudorGiuroiu

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-hooks (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAHRFMCAEcA2AlggHYAuGaJVhAtgA4Qxk7A5YIAKAhjN7WBwBfHADMYEWjgwkEADzIB6EtwBuhAObcyhCNXQk6jZq3bYAsgloRhYiVIwwE3OBQNV5xlgBMEo7lD4LKJQJK66JDgAQlAaAEoI9BLeUOF6ABQAlKxUOHl4emAsTuoIAO4Akt44ALw4AHJQtABGCDDpHDx8AlkA2o4IpWUAtITeGAC6mVQzkflwhSyCdRyW1ulZtQB8OXP584UQ+AgAdPgQGuklxJXe03v7OIqKOOaEYGCEJBo4TmSwJAAhLl8kIADQ4XrXcpVKYghYkSDHM4XdJge77EF5MgwACeu0eB0RR1O50uGAAynRAtovj8FgxjnICuQJPgxOcyhgMaC8No4AALHDpNoSGDIdgkADWJAgZRI2WAWMeCKRp1FTBFMDFPLyIlEX24+Hw+KVD32qpJKPJIAAwsduCQoPRucqhLN9n8ATgADzeQiqLa2gUIOBSnBEchtHDQMj0KAsdIUgXQfDVVo4ACMOA1MAh7xwAAZMj7FP7A1QhCAwSAEQaNCgQEYmCwyLj6Lg2Jx8LEvgB5eg6Qq2cSSHAAcma3Fa+GG9B7Gi+wycLjIwwZ9EIxxgZfeZHHAG5ZukzXlnhut7S9OYIL4JRgjfhKCQRGBaWADQhBN3eyQB0PEUyA9q3AFNKijGAVHwMAUH8aCECEIA

Repro steps

  1. Install eslint-plugin-react-hooks@7.0.1 (or latest).
  2. Create a React component with a clear rule violation (e.g., useMemo with no return value).
  3. Observe that the linter correctly reports the error.
  4. Add a try/catch or try/catch/finally block anywhere inside the component body.
  5. Bug: The linter stops reporting the useMemo error (and all other compiler errors) for that component.
    Note: In the React Playground, when recreating the example, I see that the the try/catch/finally block actually throws an error, but the useMemo one is still ignored

Expected Behavior

The linter should flag the useMemo error regardless of the try/catch block present in the component.

Actual Behavior

The linter reports 0 errors. Removing the try/catch block immediately causes the useMemo error to reappear.

How often does this bug happen?

Every time

What version of React are you using?

19.1.1

What version of React Compiler are you using?

I don't use React compiler, but I use eslint-plugin-react-hooks version 7.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugType: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions