Skip to content

Commit

Permalink
fix issue (and add conspicuously absent test) with 'export *'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Mar 22, 2018
1 parent f7c48b5 commit 314c0b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ExportMap.js
Expand Up @@ -383,15 +383,14 @@ ExportMap.parse = function (path, content, context) {
}

function captureDependency(declaration) {
if (declaration.source == null) return
if (declaration.source == null) return null

const p = remotePath(declaration)
if (p == null) return
if (m.imports.has(p)) return
if (p == null || m.imports.has(p)) return p

const getter = () => ExportMap.for(p, context)
m.imports.set(p, { getter, source: declaration.source })
return getter
return p
}


Expand All @@ -407,8 +406,8 @@ ExportMap.parse = function (path, content, context) {
}

if (n.type === 'ExportAllDeclaration') {
const getter = captureDependency(n)
if (getter) m.dependencies.add(getter)
const p = captureDependency(n)
if (p) m.dependencies.add(m.imports.get(p).getter)
return
}

Expand Down
1 change: 1 addition & 0 deletions tests/files/export-all.js
@@ -1 +1,2 @@
import { foo } from './sibling-with-names' // ensure importing exported name doesn't block
export * from './sibling-with-names'
15 changes: 15 additions & 0 deletions tests/src/rules/named.js
Expand Up @@ -329,3 +329,18 @@ if (!CASE_SENSITIVE_FS) {
],
})
}

// export-all
ruleTester.run('named (export *)', rule, {
valid: [
test({
code: 'import { foo } from "./export-all"',
}),
],
invalid: [
test({
code: 'import { bar } from "./export-all"',
errors: [`bar not found in './export-all'`],
}),
],
})

0 comments on commit 314c0b7

Please sign in to comment.