deno_lint logodeno_lint

All rules/no-class-assign

no-class-assign

Recommended

Disallows modifying variables of class declarations

Declaring a class such as class A {}, creates a variable A. Like any variable this can be modified or reassigned. In most cases this is a mistake and not what was intended.

Invalid:

class A {}
A = 0; // reassigning the class variable itself

Valid:

class A {}
let c = new A();
c = 0; // reassigning the variable `c`