2016-03-01 22:33:30 -08:00

17 lines
447 B
JavaScript

export default function ({ messages }) {
return {
visitor: {
Scope({ scope }) {
for (let name in scope.bindings) {
let binding = scope.bindings[name];
if (binding.kind !== "const" && binding.kind !== "module") continue;
for (let violation of binding.constantViolations) {
throw violation.buildCodeFrameError(messages.get("readOnly", name));
}
}
}
}
};
}