Skip to content

Commit

Permalink
When populating ExportMap, only load file if it's not ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo authored and ljharb committed Oct 28, 2019
1 parent 1b96580 commit fb8ae71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

### Fixed
- `default`: make error message less confusing ([#1470], thanks [@golopot])
- Improve performance of `ExportMap.for` by only loading paths when necessary. ([#1519], thanks [@brendo])
- Support export of a merged TypeScript namespace declaration ([#1495], thanks [@benmunro])
- [`import/order`]: fix autofix to not move imports across fn calls ([#1253], thanks [@tihonove])
- [`prefer-default-export`]: fix false positive with type export ([#1506], thanks [@golopot])
Expand Down Expand Up @@ -610,6 +611,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#1519]: https://github.com/benmosher/eslint-plugin-import/pull/1519
[#1506]: https://github.com/benmosher/eslint-plugin-import/pull/1506
[#1495]: https://github.com/benmosher/eslint-plugin-import/pull/1495
[#1472]: https://github.com/benmosher/eslint-plugin-import/pull/1472
Expand Down Expand Up @@ -998,3 +1000,4 @@ for info on changes for earlier releases.
[@TrevorBurnham]: https://github.com/TrevorBurnham
[@benmunro]: https://github.com/benmunro
[@tihonove]: https://github.com/tihonove
[@brendo]: https://github.com/brendo
13 changes: 10 additions & 3 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,18 @@ ExportMap.for = function (context) {
return null
}

// check for and cache ignore
if (isIgnored(path, context)) {
log('ignored path due to ignore settings:', path)
exportCache.set(cacheKey, null)
return null
}

const content = fs.readFileSync(path, { encoding: 'utf8' })

// check for and cache ignore
if (isIgnored(path, context) || !unambiguous.test(content)) {
log('ignored path due to unambiguous regex or ignore settings:', path)
// check for and cache unambigious modules
if (!unambiguous.test(content)) {
log('ignored path due to unambiguous regex:', path)
exportCache.set(cacheKey, null)
return null
}
Expand Down

0 comments on commit fb8ae71

Please sign in to comment.