NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-const-assign"],
"exclude": ["no-const-assign"]
}
}
}Disallows modifying a variable declared as const.
Modifying a variable declared as const will result in a runtime error.
Invalid:
const a = 0;
a = 1;
a += 1;
a++;
++a;
Valid:
const a = 0;
const b = a + 1;
// `c` is out of scope on each loop iteration, allowing a new assignment
for (const c in [1, 2, 3]) {}