Skip to content

Commit

Permalink
[Fix] named: for importing from a module which re-exports named exp…
Browse files Browse the repository at this point in the history
…orts from a `node_modules` module

Fixes #1446.
  • Loading branch information
redbugz authored and ljharb committed Dec 12, 2019
1 parent cc5bde5 commit 392c6b9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- [`extentions`]: Fix scope regex ([#1611], thanks [@yordis])
- [`no-duplicates`]: allow duplicate imports if one is a namespace and the other not ([#1612], thanks [@sveyret])
- Add some missing rule meta schemas and types ([#1620], thanks [@bmish])
- [`named`]: for importing from a module which re-exports named exports from a `node_modules` module ([#1569], [#1447], thanks [@redbugz], [@kentcdodds])

### Changed
- [`import/external-module-folders` setting] behavior is more strict now: it will only match complete path segments ([#1605], thanks [@skozin])
Expand Down Expand Up @@ -655,6 +656,7 @@ for info on changes for earlier releases.
[#1589]: https://github.com/benmosher/eslint-plugin-import/issues/1589
[#1586]: https://github.com/benmosher/eslint-plugin-import/pull/1586
[#1572]: https://github.com/benmosher/eslint-plugin-import/pull/1572
[#1569]: https://github.com/benmosher/eslint-plugin-import/pull/1569
[#1563]: https://github.com/benmosher/eslint-plugin-import/pull/1563
[#1560]: https://github.com/benmosher/eslint-plugin-import/pull/1560
[#1551]: https://github.com/benmosher/eslint-plugin-import/pull/1551
Expand All @@ -670,6 +672,7 @@ for info on changes for earlier releases.
[#1493]: https://github.com/benmosher/eslint-plugin-import/pull/1493
[#1472]: https://github.com/benmosher/eslint-plugin-import/pull/1472
[#1470]: https://github.com/benmosher/eslint-plugin-import/pull/1470
[#1447]: https://github.com/benmosher/eslint-plugin-import/pull/1447
[#1439]: https://github.com/benmosher/eslint-plugin-import/pull/1439
[#1436]: https://github.com/benmosher/eslint-plugin-import/pull/1436
[#1435]: https://github.com/benmosher/eslint-plugin-import/pull/1435
Expand Down Expand Up @@ -1089,3 +1092,5 @@ for info on changes for earlier releases.
[@yordis]: https://github.com/yordis
[@sveyret]: https://github.com/sveyret
[@bmish]: https://github.com/bmish
[@redbugz]: https://github.com/redbugz
[@kentcdodds]: https://github.com/kentcdodds
1 change: 1 addition & 0 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default class ExportMap {
if (name !== 'default') {
for (let dep of this.dependencies) {
let innerMap = dep()
if (innerMap == null) return { found: true, path: [this] }
// todo: report as unresolved?
if (!innerMap) continue

Expand Down
1 change: 1 addition & 0 deletions tests/files/re-export-common-star.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './common'
1 change: 1 addition & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ruleTester.run('named', rule, {
test({code: 'import { destructingRenamedAssign } from "./named-exports"'}),
test({code: 'import { ActionTypes } from "./qc"'}),
test({code: 'import {a, b, c, d} from "./re-export"'}),
test({code: 'import {a, b, c} from "./re-export-common-star"'}),
test({code: 'import {RuleTester} from "./re-export-node_modules"'}),

test({ code: 'import { jsxFoo } from "./jsx/AnotherComponent"'
Expand Down

0 comments on commit 392c6b9

Please sign in to comment.