make constants and module imports synonymous - closes #954
This commit is contained in:
parent
e26f994075
commit
286ae68da2
@ -2,7 +2,7 @@ import * as messages from "../../../messages";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isVariableDeclaration(node, { kind: "const" });
|
||||
return t.isVariableDeclaration(node, { kind: "const" }) || t.isImportDeclaration(node);
|
||||
}
|
||||
|
||||
var visitor = {
|
||||
@ -38,7 +38,7 @@ var visitor = {
|
||||
|
||||
export function Scopable(node, parent, scope, file) {
|
||||
this.traverse(visitor, {
|
||||
constants: scope.getAllBindingsOfKind("const"),
|
||||
constants: scope.getAllBindingsOfKind("const", "module"),
|
||||
file: file
|
||||
});
|
||||
}
|
||||
|
||||
@ -551,17 +551,20 @@ export default class Scope {
|
||||
* Walks the scope tree and gathers all declarations of `kind`.
|
||||
*/
|
||||
|
||||
getAllBindingsOfKind(kind: string): Object {
|
||||
getAllBindingsOfKind(): Object {
|
||||
var ids = object();
|
||||
|
||||
var scope = this;
|
||||
do {
|
||||
for (var name in scope.bindings) {
|
||||
var binding = scope.bindings[name];
|
||||
if (binding.kind === kind) ids[name] = binding;
|
||||
}
|
||||
scope = scope.parent;
|
||||
} while (scope);
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
var kind = arguments[i];
|
||||
var scope = this;
|
||||
do {
|
||||
for (var name in scope.bindings) {
|
||||
var binding = scope.bindings[name];
|
||||
if (binding.kind === kind) ids[name] = binding;
|
||||
}
|
||||
scope = scope.parent;
|
||||
} while (scope);
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user