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

Most upvoted comments

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 the ExportMap, unfortunately it seems the wrong one.

To be clear: react-scripts start fails because of this regression. We could work around it for yarn eslint but the same workaround does not work for the linting that happens as part of react-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 via yarn eslint but did not work when compiling/linting via react-scripts start. We had to downgrade to 2.24.2 for it to work.