import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.56k stars 1.57k forks source link

import/no-unresolved if add new alias path #2278

Closed WxSwen closed 2 years ago

WxSwen commented 3 years ago

When i add a new alias path in tsconfig,others pull my code and restart will found this error: import/no-unresolved。

And he should open the file in project and save again。It will be solved,so i think it will be a eslint cache problem?

Please tell me how to solve this error,thanks。

ljharb commented 3 years ago

Where does that error show up? On the CLI, or in vscode?

WxSwen commented 3 years ago

Where does that error show up? On the CLI, or in vscode?

In vscode, i can solve it by restart command,but this error show in command line。And we find it can change eslintrc and restart then it will clear cache,but it works。thanks

ljharb commented 3 years ago

You always have to restart vscode (and other editors) when node_modules have changed, which includes when checking out a sha with a different package.json. It's got nothing to do with eslint or this plugin.

Oliver84 commented 3 years ago

I'm seeing this in our Bitbucket Pipelines. Just started seeing this with new builds

ljharb commented 3 years ago

@Oliver84 meaning, when you add a new alias to your tsconfig, you’re seeing builds fail in CI?

Oliver84 commented 3 years ago

Sorry, I thought it was a related issue but I can file a new one for this. I'm seeing the same error with 2.25 but I'm not adding a new alias to tsconfig. Just added a new import to a regular jsx file and I'm getting:

Unable to resolve path to module 'react-toastify/esm/react-toastify'. [Error/import/no-unresolved] 1 problemerror: 'eslint' errored after 12s { "data": { "message": "Failed with 1 error", "name": "ESLintError" } } npm ERR! Test failed. See above for more details.

ljharb commented 3 years ago

I’m on mobile rn so i can’t check, but my guess is that that package doesn’t support CJS - ie, it lacks a main and relies on “exports”. If so, this plugin (like much of the ecosystem) doesn’t support that yet, and you’ll have to use import/ignore for it.

JounQin commented 2 years ago

close in favor of https://github.com/import-js/eslint-import-resolver-typescript