Skip to content

Commit

Permalink
Fix namespace rule runtime crash (#499)
Browse files Browse the repository at this point in the history
* Fix `namespace` rule runtime crash

* Don't do `namespace.get()` twice

* Add changelog note
  • Loading branch information
wKich authored and benmosher committed Aug 18, 2016
1 parent 90dedd7 commit f4d1458
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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 f4d1458

Please sign in to comment.