Skip to content

Commit

Permalink
explicitly exit cycles (#210 again)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Mar 8, 2016
1 parent 9b92849 commit b1d196c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import isIgnored from './ignore'
const exportCaches = new Map()

export default class ExportMap {
constructor() {
constructor(path) {
this.path = path
this.namespace = new Map()
// todo: restructure to key on path, value is resolver + map of names
this.reexports = new Map()
Expand Down Expand Up @@ -76,7 +77,7 @@ export default class ExportMap {
}

static parse(path, context) {
var m = new ExportMap()
var m = new ExportMap(path)

try {
var ast = parse(path, context)
Expand Down Expand Up @@ -236,13 +237,21 @@ export default class ExportMap {
const { local, getImport } = this.reexports.get(name)
, imported = getImport()
if (imported == null) return undefined

// safeguard against cycles, only if name matches
if (imported.path === this.path && local === name) return undefined

return imported.get(local)
}

for (let dep of this.dependencies.values()) {
let innerMap = dep()
// todo: report as unresolved?
if (!innerMap) continue

// safeguard against cycles
if (innerMap.path === this.path) continue

let innerValue = innerMap.get(name)
if (innerValue !== undefined) return innerValue
}
Expand Down
1 change: 0 additions & 1 deletion tests/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { CLIEngine } from 'eslint'

describe('CLI regression tests', function () {
describe('issue #210', function () {
this.timeout(10000)
let cli
before(function () {
cli = new CLIEngine({
Expand Down

0 comments on commit b1d196c

Please sign in to comment.