import-js / import-js/eslint-plugin-import
`import/named` false positive when re-exporting internal dependencies with pnpm
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
When using PNPM, re-exporting internal dependencies triggers import/named, while TypeScript resolves everything correctly:
Steps to reproduce
eslint: "8.52.0"
eslint-plugin-import: "2.28.1"
node: "18.12.1"
pnpm: "8.9.2"
I wasn't able to build a minimal repro in proper timeframe, but the general idea is that given
// package-outer/index.js
export * from 'package-inner'
// package-inner/index.js
export const a = 42
When installed via pnpm, results in roughly the following structure:
node_modules
├ .pnpm
│ ├ package-outer@1.0.0
│ │ └ node_modules
│ │ ├ package-inner -> .pnpm/package-inner@1.0.0/node_modules/package-inner
│ │ └ package-outer
│ │ └ ... source code ...
│ └ package-inner@1.0.0
│ └ node_modules
│ └ package-inner
│ └ ... source code ...
└ package-outer -> .pnpm/package-outer@1.0.0/node_modules/package-outer
Where eslint-plugin-import likely fails to resolve package-inner when introspecting package-outer, which results in import/named false positives.
Expected behaviour
Exports are correctly resolved from re-exported internal packages, no error is thrown
Actual behaviour
import/named is thrown
Possible workaround
The issue can be worked around by installing package-outer at the top level.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the import/named rule and the package-outer/index.js and package-inner/index.js re-export example. Reproduce the pnpm .pnpm node_modules layout described in the issue, then trace how package-inner is resolved while introspecting package-outer. Done means the re-exported a export is resolved without an import/named error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100