no-this-before-super
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-this-before-super"],
"exclude": ["no-this-before-super"]
}
}
}Disallows use of this or super before calling super() in constructors.
The access to this or super before calling super() in the constructor of
derived classes leads to ReferenceError. To prevent it, this lint rule
checks if there are accesses to this or super before calling super() in
constructors.
Invalid:
class A extends B {
constructor() {
this.foo = 0;
super();
}
}
class C extends D {
constructor() {
super.foo();
super();
}
}
Valid:
class A extends B {
constructor() {
super();
this.foo = 0;
}
}
class C extends D {
constructor() {
super();
super.foo();
}
}
class E {
constructor() {
this.foo = 0;
}
}