fix [import/named] for importing from a module which re-exports *
from node_modules or commonjs module
#1569
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1446
Based on #1447
When re-exporting
*
from a commonjs module, or a module in node_modules which comes through as a commonjs module, do not error since the commonjs exports cannot be evaluated. Treat with similar logic to ignored modules or directly importing from a commonjs module.When re-exporting
*
, the module is listed in dependencies instead ofreexports
. There is similar logic for when re-exporting a named export, to check for a null from the exportCache, which I understand to mean an ignored or unparseable es5/commonjs module:https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L91
There is a todo in this location, and I'm not sure if this code satisfies that todo and it can be removed or not.
Also, when logging the value of
innerMap
, I never it saw it be undefined. So it's possible thecontinue
line is also no longer needed, but I am not sure.This fixes
hasDeep
, but there is similar logic inhas
andget
:https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L68
https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L146
I'm not sure if those should get similar treatment, or if those are not relevant for this issue.