react icon indicating copy to clipboard operation
react copied to clipboard

Bug: `eslint-plugin-react-hooks` - Broken resolution in `7.0.1`

Open eidryn opened this issue 3 months ago • 5 comments

React version: N/A

Steps To Reproduce

  1. Install [email protected]
  2. Configure with a .config.ts configuration (although an issue raised in zod-validation-error shows esm/resolve so may also flag with a .js config)
  3. Run npx eslint .
  4. Error printed:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v4' is not defined by "exports" in /node_modules/zod-validation-error/package.json
    at exportsNotFound (node:internal/modules/esm/resolve:313:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:660:9)
    at resolveExports (node:internal/modules/cjs/loader:650:36)
    at Function._findPath (node:internal/modules/cjs/loader:717:31)
    at Function._resolveFilename (node:internal/modules/cjs/loader:1369:27)
    at Function.resolve (node:internal/modules/helpers:157:19)
    at jitiResolve (node_modules/jiti/dist/jiti.cjs:1:148703)
    at jitiRequire (node_modules/jiti/dist/jiti.cjs:1:150290)
    at node_modules/jiti/dist/jiti.cjs:1:157987
    at node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:20:16

The current behavior

There is an error when running eslint - Downgrading to 7.0.0 resolves both the above error, and the typescript issue below.

The expected behavior

There is no error running eslint.

Type Discrepancy

Additionally, with v7.0.1, typescript complains that the react-hooks plugin is not the correct type:

// Truncated
 Types of property 'configs' are incompatible.
    Type '{ recommended: { plugins: string[]; rules: RulesConfig; }; 'recommended-latest': { plugins: string[]; rules: RulesConfig; }; flat: { recommended: ReactHooksFlatConfig; "recommended-latest": ReactHooksFlatConfig; }; }' is not assignable to type 'Record<string, ConfigObject<RulesConfig> | LegacyConfigObject<RulesConfig, RulesConfig> | ConfigObject<RulesConfig>[]>'.
      Property 'flat' is incompatible with index signature.
        Type '{ recommended: ReactHooksFlatConfig; "recommended-latest": ReactHooksFlatConfig; }' is not assignable to type 'ConfigObject<RulesConfig> | LegacyConfigObject<RulesConfig, RulesConfig> | ConfigObject<RulesConfig>[]'
// Truncated

eidryn avatar Nov 04 '25 23:11 eidryn

After upgrading eslint-plugin-react-hooks to 7.0.1, I get this error when running ESLint:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v4' is not defined by "exports" in /path/to/node_modules/.pnpm/[email protected][email protected][email protected]_/node_modules/zod-validation-error/package.json

We are not yet ready to upgrade to Zod v4, so I fixed this error with a pnpm override:

{
    "overrides": {
        "eslint-plugin-react-hooks>zod-validation-error": "4.0.2"
    }
}

However, then I get this error running ESLint:

A config object has a "plugins" key defined as an array of strings. It looks something like this:

    {
        "plugins": ["react-hooks"]
    }

Flat config requires "plugins" to be an object, like this:

    {
        plugins: {
            react-hooks: pluginObject
        }
    }

On the other hand, if I install exactly 7.0.0, then I don't have the issue with zod-validation-error, but I do still see the error message when running ESLint about the plugins key.

benjaminblack avatar Nov 05 '25 00:11 benjaminblack

I'm having the same issue and also fixed it by downgrading. Can we get this addressed so users don't have to downgrade?

DAcodedBEAT avatar Nov 10 '25 21:11 DAcodedBEAT

Same issue here

lavv425 avatar Nov 17 '25 12:11 lavv425

Same issue.

OrRosenblatt avatar Nov 24 '25 06:11 OrRosenblatt

This bug was introduced in this commit.

- Updated `zod-validation-error` import paths to
`zod-validation-error/v4`
- Bumped min `zod-validation-error ` version to `^3.5.0` 

Unlike zod, which was upgraded to ^3.25.0 to support the /v4 export, zod-validation-error^3 does not have a /v4 export, which is causing runtime errors with this change.

quisido avatar Nov 29 '25 00:11 quisido