no-class-assign
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-class-assign"],
"exclude": ["no-class-assign"]
}
}
}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`