eslint-plugin-import: import/named falsely reports import as not found (regression in 2.25)
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 reports
error optimize not found in 'svgo' import/named
while 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.js
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 16 (12 by maintainers)
Commits related to this issue
- fix: handle named imports from CJS modules that use dynamic import Fix #2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ... — committed to ludofischer/eslint-plugin-import by ludofischer 3 years ago
- fix: handle named imports from CJS modules that use dynamic import Fix #2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ... — committed to ludofischer/eslint-plugin-import by ludofischer 3 years ago
- fix: handle named imports from CJS modules that use dynamic import Fix #2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ... — committed to ludofischer/eslint-plugin-import by ludofischer 3 years ago
- fix: handle named imports from CJS modules that use dynamic import Fix #2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can be ignored like other ... — committed to ludofischer/eslint-plugin-import by ludofischer 3 years ago
- [Fix] `named`/`ExportMap`: handle named imports from CJS modules that use dynamic import Fix #2294 Mark ambiguous (i.e. not unambiguously ESM) modules that contain dynamic import() so that they can ... — committed to ludofischer/eslint-plugin-import by ludofischer 3 years ago
I’ve opened https://github.com/import-js/eslint-plugin-import/pull/2341 that should fix at least the case I’ve reported.
@shamilovtim have you tried
import type
to import that type?In the case I posted the reason it works in 2.24 is because 2.24 constructs a
null
ExportMap
. So in a sense 2.25 is an improvement in that at least it manages to construct theExportMap
, unfortunately it seems the wrong one.To be clear:
react-scripts start
fails because of this regression. We could work around it foryarn eslint
but the same workaround does not work for the linting that happens as part ofreact-scripts start
.This is still an issue for us after we tried to update the dependencies of our React app. The workaround of using a
type
import worked when linting viayarn eslint
but did not work when compiling/linting viareact-scripts start
. We had to downgrade to 2.24.2 for it to work.