Skip to content

Commit

Permalink
Fix namespace rule runtime crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wKich committed Aug 16, 2016
1 parent 90dedd7 commit 69a1dec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ exports.create = function namespaceRule(context) {
break
}

if (namespace.get(dereference.property.name) == null) return

// stash and pop
namepath.push(dereference.property.name)
namespace = namespace.get(dereference.property.name).namespace
Expand Down
1 change: 1 addition & 0 deletions tests/files/commonjs-namespace/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as b } from './b'
1 change: 1 addition & 0 deletions tests/files/commonjs-namespace/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
4 changes: 4 additions & 0 deletions tests/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
]

0 comments on commit 69a1dec

Please sign in to comment.