diff --git a/CHANGELOG.md b/CHANGELOG.md index 93fb374d9..575f32559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com). ## [Unreleased] +### Fixed +- [`namespace`] exception for get property from `namespace` import, which are re-export from commonjs module ([#416]) ## [1.13.0] - 2016-08-11 ### Added diff --git a/src/rules/namespace.js b/src/rules/namespace.js index 827a8e70f..74e45ccaf 100644 --- a/src/rules/namespace.js +++ b/src/rules/namespace.js @@ -131,9 +131,12 @@ exports.create = function namespaceRule(context) { break } + const exported = namespace.get(dereference.property.name) + if (exported == null) return + // stash and pop namepath.push(dereference.property.name) - namespace = namespace.get(dereference.property.name).namespace + namespace = exported.namespace dereference = dereference.parent } diff --git a/tests/files/commonjs-namespace/a.js b/tests/files/commonjs-namespace/a.js new file mode 100644 index 000000000..0cffc87d1 --- /dev/null +++ b/tests/files/commonjs-namespace/a.js @@ -0,0 +1 @@ +export { default as b } from './b' diff --git a/tests/files/commonjs-namespace/b.js b/tests/files/commonjs-namespace/b.js new file mode 100644 index 000000000..4ba52ba2c --- /dev/null +++ b/tests/files/commonjs-namespace/b.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/tests/src/utils.js b/tests/src/utils.js index 4d607c07c..aa599112b 100644 --- a/tests/src/utils.js +++ b/tests/src/utils.js @@ -84,4 +84,8 @@ export const SYNTAX_CASES = [ code: 'export * from "./issue-370-commonjs-namespace/bar"', settings: { 'import/ignore': ['foo'] }, }), + + test({ + code: 'import * as a from "./commonjs-namespace/a"; a.b', + }), ]