no-const-assign
JavaScript / TypeScriptsuspiciousno fixdefault: errorjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”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 []) {}...Configuration
Section titled “Configuration”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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-const-assign |
full |