import-js / import-js/eslint-plugin-import

Option to preserve symlinks in `no-unresolved` for monorepos

Open
#1,706 4 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

I'm currently converting my codebase to a monorepo, and I've stumbled across an issue with no-unresolved. Even though the sibling package I reference is symlinked into node_modules, it doesn't actually see it.

To skirt this, I've tried:

  • The no-unresolved ignore option, but this doesn't actually ensure the sibling is required and symlinked in place.
  • The resolver-node, but like above, this doesn't actually ensure the package is actually symlinked in node_modules.
  • The resolver-webpack, but even though I specifically preserve symlinks in my config, you override it. Also, using this resolver only helps subprojects using webpack.
  • The third-party resolver-lerna, but doing so requires I sacrifice detection of absolute imports (which I currently use resolver-node for, but which I could use resolver-webpack for... in subprojects that use webpack).

As you can see, all of these potential solutions are just patches. If there's something I missed, please point the way. But given the prevalence of monorepo solutions—all of which rely on symlinks—I think it's safe to say the best option is to solve for the symlink problem itself. There's been quite a few issues raised on this topic.

Solutions I see:

  • A no-unresolved option that preserves symlinks.
  • A global option for import/preserve-symlinks that preserves symlinks.

Anyway, thanks for your time!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the no-unresolved rule and the resolver-webpack and import/preserve-symlinks behavior described in the issue. Reproduce the monorepo case with a symlinked sibling package and compare the proposed rule-level and global options. Done means symlink preservation works without losing absolute-import detection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.