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

Fix namespace rule runtime crash #499

Merged
merged 3 commits into from
Aug 18, 2016
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
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',
}),
]