✅ This rule is turned on by default.
Disallow reassigning const
variables.
We cannot modify variables that are declared using const keyword. It will raise a runtime error.
Examples of incorrect code for this rule:
const a = 0;
a = 1;
const b = 0;
b += 1;
Examples of correct code for this rule:
const a = 0;
console.log(a);
var b = 0;
b += 1;
To enable this rule in the CLI or using the config file, you can use:
::: code-group
oxlint --deny no-const-assign
{
"rules": {
"no-const-assign": "error"
}
}
:::