no-class-assign
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "tags": ["recommended"] } }
Enable full set using the Deno CLI:
deno lint --tags=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`