-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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/named falsely reports import as not found (regression in 2.25) #2294
Comments
With 2.25.2, even the default import triggers a false positive:
yields
But it works with eslint-plugin-import 2.24 |
I've also found a simpler way to reproduce the error: (new commit in same repo https://github.com/ludofischer/eslint-plugin-import-error-demo).
Removing the dynamic import from the code of the CommonJS module removes the eslint warning. |
A https://unpkg.com/browse/svgo@2.8.0/package.json does indeed point to https://unpkg.com/browse/svgo@2.8.0/lib/svgo-node.js. Thanks for the repro repo; I'll check it out. |
Wouldn't the expected behaviour to avoid analysing SVGO by default since it's not ESM? In the second commit of repro repo you should see that removing the dyanmic |
There's a I see that removing the |
The named rule docs say
That made me think the issue in 2.25 is not ignoring the import from a CJS module. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is still an issue for us after we tried to update the dependencies of our React app. The workaround of using a |
@BalzGuenat please file a bug on CRA if it doesn't support |
To be clear: |
I continue to be happy to review a PR that fixes the regression - that "use |
In the case I posted the reason it works in 2.24 is because 2.24 constructs a |
I think I have found the source of the bug but I have no idea how to fix it. I believe the problem occurred in commit 7c382f0, line 408. In order to analyze dynamic imports, this commit does not return Now I think in the case I've submitted the expected behaviour would be to return The error occurs when trying to import from a CommonJS module that uses dynamic |
Fix import-js#2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ambiguous modules when analysing named imports. In this way, the named rule accepts named imports from CJS modules that contain dynamic imports. Also fix the case where the importing module uses a require() call.
Fix import-js#2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ambiguous modules when analysing named imports. In this way, the named rule accepts named imports from CJS modules that contain dynamic imports. Also fix the case where the importing module uses a require() call.
Fix import-js#2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ambiguous modules when analysing named imports. In this way, the named rule accepts named imports from CJS modules that contain dynamic imports. Also fix the case where the importing module uses a require() call.
Fix import-js#2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ambiguous modules when analysing named imports. In this way, the named rule accepts named imports from CJS modules that contain dynamic imports. Also fix the case where the importing module uses a require() call.
I've opened #2341 that should fix at least the case I've reported. |
eslint-plugin-import version: 2.25.0 and 2.25.2
eslint version: 7.32 and 8.1
Reproduction repo: https://github.com/ludofischer/eslint-plugin-import-error-demo
When using the
optimize
named import from the svgo 2.8 library, since 2.25 eslint-plugin-import reportswhile the import was correctly handled as valid in eslint-plugin-import 2.24. svgo uses CommonJS with just a
main
package.json
field that points to this file: https://github.com/svg/svgo/blob/master/lib/svgo-node.jsThe text was updated successfully, but these errors were encountered: