Skip to content

Commit

Permalink
added support for deep crawls over ES7 exported namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Feb 24, 2016
1 parent b73420c commit a55c974
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export default class ExportMap {
} else if (s.type === 'ExportSpecifier' && namespaces.has(s.local.name)){
let namespace = m.resolveReExport(namespaces.get(s.local.name), path)
if (namespace) exportMeta.namespace = namespace.named
} else if (s.type === 'ExportNamespaceSpecifier') {
exportMeta.namespace = remoteMap.named
}

// todo: JSDoc
Expand Down
19 changes: 19 additions & 0 deletions tests/src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,23 @@ describe('getExports', function () {
})
})

context('exported static namespaces', function () {
const espreeContext = { parserPath: 'espree', parserOptions: { sourceType: 'module' }, settings: {} }
const babelContext = { parserPath: 'babel-eslint', parserOptions: { sourceType: 'module' }, settings: {} }

it('works with espree & traditional namespace exports', function () {
const a = ExportMap.parse(getFilename('deep/a.js'), espreeContext)
expect(a.errors).to.be.empty
expect(a.named.get('b').namespace).to.exist
expect(a.named.get('b').namespace.has('c')).to.be.true
})

it('works with babel-eslint & ES7 namespace exports', function () {
const a = ExportMap.parse(getFilename('deep-es7/a.js'), babelContext)
expect(a.errors).to.be.empty
expect(a.named.get('b').namespace).to.exist
expect(a.named.get('b').namespace.has('c')).to.be.true
})
})

})

0 comments on commit a55c974

Please sign in to comment.