When populating ExportMap, only load file if it's not ignored #1519
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.
I was debugging a project trying to understand better how the
import/no-deprecated
rule works. While doing this I discovered thatExportMap.for
will do a I/O hit to read thepath
even if thepath
is ignored:https://github.com/benmosher/eslint-plugin-import/blob/112a0bf442e52b25cd7029a9905df2508e191ac1/src/ExportMap.js#L313-L320
When the
path
is ignored, the function early exits and thecontent
variable is not referenced, so it's essentially a wasted I/O hit.This PR tweaks the condition to do the ignore check in one block, and check ambiguity in another.
In theory this should result in a performance boost for projects that ignore many paths as they will be skipped based off the ignore, rather than being loaded from the file system. It also cleans up the log a little bit because we know exactly why the path was ignored, because of the regex, or because it's ambiguous.