no-class-assign
JavaScript / TypeScriptsuspiciousno fixdefault: errorjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports an assignment to a class that is declared by name (class K {} K = 1;).
Why it matters
Section titled “Why it matters”A class declaration creates a binding, and replacing it means the name stops standing for the class: later code that uses the name (new K()) gets something else, and the class is no longer reachable by that name.
To fix, assign to another variable, or declare the class with let K = class {} where reassigning is intended.
Example
Section titled “Example”import d, { n as m } from "m";import * as ns from "ns";...class K { static f() { K = 1; } } K = 2; (class L { f() { L = 1; } });...const o = { c }; const [q] = [c]; var v = 1; v = 2; let l = 1; l = 2;Configuration
Section titled “Configuration”js: lint: rules: no-class-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-class-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-class-assign |
full |