Skip to content

no-class-assign

Reports an assignment to a class that is declared by name (class K {} K = 1;).

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.

Reported
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;
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.

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

Tool Rule Match
eslint no-class-assign full