2017-03-04 10:46:01 -05:00

17 lines
464 B
JavaScript

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