Skip to content

no-const-assign

Reports a write to a const variable after its declaration: an assignment, ++ or --, or a destructuring target ([c] = [1]). The initializer is not a write.

Assigning to a const throws a TypeError when the line runs, so the program fails where the change was meant.

To fix, declare the variable with let, or stop reassigning it.

Reported
import d, { n as m } from "m";
import * as ns from "ns";
const c = 1; c = 2; c += 1; c++; [c] = [1]; ({ c } = {}); for (c of []) {}
...
js:
lint:
rules:
no-const-assign: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-const-assign in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-const-assign full