Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix [import/named] for importing from a module which re-exports * from node_modules or commonjs module #1569

Merged
merged 2 commits into from Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
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
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
@@ -0,0 +1 @@
export * from './common'
1 change: 1 addition & 0 deletions tests/files/re-export-node_modules.js
@@ -0,0 +1 @@
export * from 'eslint'
2 changes: 2 additions & 0 deletions tests/src/rules/named.js
Expand Up @@ -26,6 +26,8 @@ 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"'
, settings: { 'import/resolve': { 'extensions': ['.js', '.jsx'] } } }),
Expand Down