Rule: static-this
Ban the use of this
in static methods.
Rationale
Static this
usage can be confusing for newcomers.
It can also become imprecise when used with extended classes when a static this
of a parent class no longer specifically refers to the parent class.
Notes:
Has Fixer
Config
Config examples
"static-this": true
Schema
null
Code examples:
Disallows the `this` keyword usage in static context.
"rules": { "static-this": true }
Passes
class Pass {
static getName() {
return 'name'
}
static getFullname() {
return `full ${Pass.getName()}`
}
}
Fails
class Fail {
static getName() {
return 'name'
}
static getFullname() {
return `full ${this.getName()}`
}
}