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

[Namespace] add check for null ExportMap #1235

Merged
merged 1 commit into from
Apr 11, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ module.exports = {
}

path.push(property.key.name)
testKey(property.value, namespace.get(property.key.name).namespace, path)
const dependencyExportMap = namespace.get(property.key.name)
// could be null when ignored or ambiguous
if (dependencyExportMap !== null) {
testKey(property.value, dependencyExportMap.namespace, path)
}
path.pop()
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/files/re-export-common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { a as foo } from './common'
5 changes: 5 additions & 0 deletions tests/src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ const valid = [
parser: 'babel-eslint',
}),

// #1144: should handle re-export CommonJS as namespace
test({
code: `import * as ns from './re-export-common'; const {foo} = ns;`,
}),

// JSX
test({
code: 'import * as Names from "./named-exports"; const Foo = <Names.a/>',
Expand Down