From 392c6b9c44b8fab54d973b9e344ce1c0c6d1a1cc Mon Sep 17 00:00:00 2001 From: redbugz Date: Thu, 12 Dec 2019 01:43:02 -0700 Subject: [PATCH] [Fix] `named`: for importing from a module which re-exports named exports from a `node_modules` module Fixes #1446. --- CHANGELOG.md | 5 +++++ src/ExportMap.js | 1 + tests/files/re-export-common-star.js | 1 + tests/src/rules/named.js | 1 + 4 files changed, 8 insertions(+) create mode 100644 tests/files/re-export-common-star.js diff --git a/CHANGELOG.md b/CHANGELOG.md index c3ae3a21a..609762ffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]) @@ -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 @@ -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 @@ -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 diff --git a/src/ExportMap.js b/src/ExportMap.js index 5f95efa1a..525f64a48 100644 --- a/src/ExportMap.js +++ b/src/ExportMap.js @@ -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 diff --git a/tests/files/re-export-common-star.js b/tests/files/re-export-common-star.js new file mode 100644 index 000000000..89a3196b1 --- /dev/null +++ b/tests/files/re-export-common-star.js @@ -0,0 +1 @@ +export * from './common' diff --git a/tests/src/rules/named.js b/tests/src/rules/named.js index b010dfd25..303df1e14 100644 --- a/tests/src/rules/named.js +++ b/tests/src/rules/named.js @@ -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"'