Skip to content

Commit f4d1458

Browse files
wKichbenmosher
authored andcommitted
Fix namespace rule runtime crash (#499)
* Fix `namespace` rule runtime crash * Don't do `namespace.get()` twice * Add changelog note
1 parent 90dedd7 commit f4d1458

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
55

66
## [Unreleased]
7+
### Fixed
8+
- [`namespace`] exception for get property from `namespace` import, which are re-export from commonjs module ([#416])
79

810
## [1.13.0] - 2016-08-11
911
### Added

src/rules/namespace.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ exports.create = function namespaceRule(context) {
131131
break
132132
}
133133

134+
const exported = namespace.get(dereference.property.name)
135+
if (exported == null) return
136+
134137
// stash and pop
135138
namepath.push(dereference.property.name)
136-
namespace = namespace.get(dereference.property.name).namespace
139+
namespace = exported.namespace
137140
dereference = dereference.parent
138141
}
139142

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as b } from './b'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {}

tests/src/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,8 @@ export const SYNTAX_CASES = [
8484
code: 'export * from "./issue-370-commonjs-namespace/bar"',
8585
settings: { 'import/ignore': ['foo'] },
8686
}),
87+
88+
test({
89+
code: 'import * as a from "./commonjs-namespace/a"; a.b',
90+
}),
8791
]

0 commit comments

Comments
 (0)