better support for import collision checking - todo: check exports for collisions

This commit is contained in:
Sebastian McKenzie
2015-01-07 09:08:34 +11:00
parent a9af8d39a2
commit 0dafdd6969
42 changed files with 106 additions and 74 deletions

View File

@@ -50,7 +50,8 @@ DefaultFormatter.prototype.checkImportAssignments = function () {
var file = this.file;
var isLocalReference = function (node, scope) {
return t.isIdentifier(node) && localImports[node.name];
var localImport = localImports[node.name];
return t.isIdentifier(node) && localImport && localImport !== node;
};
var check = function (node) {
@@ -69,7 +70,7 @@ DefaultFormatter.prototype.checkImportAssignments = function () {
}
check(left);
} else if (t.isDeclaration(node) && !t.isImportDeclaration(node)) {
} if (t.isDeclaration(node)) {
_.each(t.getIds(node, true), check);
}
}

View File

@@ -384,6 +384,7 @@ t.getIds = function (node, map, ignoreTypes) {
t.getIds.nodes = {
AssignmentExpression: ["left"],
ImportBatchSpecifier: ["name"],
ImportSpecifier: ["name", "id"],
ExportSpecifier: ["name", "id"],
VariableDeclarator: ["id"],