Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import/no-unresolved doesn't support package.json exports field #2853

Closed
polarstoat opened this issue Oct 15, 2023 · 1 comment
Closed

import/no-unresolved doesn't support package.json exports field #2853

polarstoat opened this issue Oct 15, 2023 · 1 comment

Comments

@polarstoat
Copy link

Using the base Airbnb config with ESLint, I'm getting false positives for packages that definitely are installed and working from the import/no-unresolved rule:

  3:18  error    Unable to resolve path to module 'conf'  import/no-unresolved

This seems to occur with packages whose package.json file has an exports field but no main field (of which sindresorhus/conf is an example).

import-js/eslint-plugin-import#1810 discusses support for this, but appears to be blocked by browserify/resolve#224.

As currently the rule does not work correctly with packages that only use an exports perhaps it should be turned off? Node has supported exports as an alternative to main as a package entry point for many years now, but until this is fixed upstream with eslint-plugin-import I think it might be best to avoid using it.

@ljharb
Copy link
Collaborator

ljharb commented Oct 16, 2023

import-js/eslint-plugin-import#1810 discusses support for this, but appears to be blocked by browserify/resolve#224.

This is correct.

Packages that fail to provide back compat with a main generally should be avoided, and since they’re in the extreme minority, you can put them in import/ignore for now. The rule remains incredibly valuable.

@ljharb ljharb closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants