π Enforce consistent class references in static methods.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
π‘ This rule is manually fixable by editor suggestions.
This rule enforces either dynamic static dispatch with this and super, or direct references with class names.
Choosing one style makes it clear whether a static method is intended to follow subclass dispatch or stay tied to a specific class.
By default, it prefers this and super.
// β
class Foo extends Bar {
static baz() {
Foo.qux();
Bar.qux();
}
}
// β
class Foo extends Bar {
static baz() {
this.qux();
super.qux();
}
}With {preferThis: false, preferSuper: false}:
// β
class Foo extends Bar {
static baz() {
this.qux();
super.qux();
}
}
// β
class Foo extends Bar {
static baz() {
Foo.qux();
Bar.qux();
}
}Type: object
Type: boolean
Default: true
Prefer this over the current class name in static methods.
Type: boolean
Default: true
Prefer super over the superclass name in static methods.