2 * @fileoverview A rule to disallow modifying variables that are declared using `const`
3 * @author Toru Nagashima
8 const astUtils = require("./utils/ast-utils");
10 //------------------------------------------------------------------------------
12 //------------------------------------------------------------------------------
19 description: "disallow reassigning `const` variables",
20 category: "ECMAScript 6",
22 url: "https://eslint.org/docs/rules/no-const-assign"
28 const: "'{{name}}' is constant."
35 * Finds and reports references that are non initializer and writable.
36 * @param {Variable} variable A variable to check.
39 function checkVariable(variable) {
40 astUtils.getModifyingReferences(variable.references).forEach(reference => {
41 context.report({ node: reference.identifier, messageId: "const", data: { name: reference.identifier.name } });
46 VariableDeclaration(node) {
47 if (node.kind === "const") {
48 context.getDeclaredVariables(node).forEach(checkVariable);