eslint/no-const-assign Correctness ​
What it does ​
Disallow reassigning const
variables.
Why is this bad? ​
We cannot modify variables that are declared using const keyword. It will raise a runtime error.
Example ​
Examples of incorrect code for this rule:
js
const a = 0;
a = 1;
const b = 0;
b += 1;
Examples of correct code for this rule:
js
const a = 0;
console.log(a);
var b = 0;
b += 1;
How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny no-const-assign
json
{
"rules": {
"no-const-assign": "error"
}
}