Skip to content

Bug: eslint-plugin-react-hooks not flagging hook used as value #34862

@UltimateGG

Description

@UltimateGG

In my app a zustand store is exported. These stores act as a hook, or have .getState/.setState on them. In some place I ended up using it as a value.

I only added the hooks plugin as the release notes say: If you have already installed eslint-plugin-react-compiler, you can now remove it and use eslint-plugin-react-hooks@latest

However, the plugin-react-compiler is catching this error that the hooks plugin is not. Resulting in the file silently failing to be optimized.

React version: 19.2.0
eslint-plugin-react-hooks: 7.0.0

Steps To Reproduce

  1. Use eslint-plugin-react-hooks
  2. Use a hook as a value (e.g. console.log it)
  3. In the repro, run npm run lint. You can see the compiler plugin erroring while the react-hooks plugin does not.

Link to code example: https://stackblitz.com/edit/vitejs-vite-asgtyazp?file=src%2FApp.tsx&view=editor

The current behavior

The compiler will skip the offending component silently.

The expected behavior

Eslint rule warns/errors as it does on the playground.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions