Skip to content

Bug: eslint-plugin-react-hooks - Broken resolution in 7.0.1 #35045

Description

@eidryn

React version: N/A

Steps To Reproduce

  1. Install eslint-plugin-react-hooks@v7.0.1
  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

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