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 committed Oct 28, 2019
1 parent 112a0bf commit f5123cc
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])

Expand Down Expand Up @@ -609,6 +610,7 @@ for info on changes for earlier releases.

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

[#1519]: https://github.com/benmosher/eslint-plugin-import/pull/1519
[#1495]: https://github.com/benmosher/eslint-plugin-import/pull/1495
[#1472]: https://github.com/benmosher/eslint-plugin-import/pull/1472
[#1470]: https://github.com/benmosher/eslint-plugin-import/pull/1470
Expand Down Expand Up @@ -996,3 +998,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 f5123cc

Please sign in to comment.