sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-this-outside-of-class`
Chiusa
#2450 aperta il 16 set 2024
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 1g 16h) (399 PR mergiate in 30 g)
Descrizione
Description
In modern JavaScript, this should not appear outside of an class.
Fail
function foo () {
this.bar;
}
function Foo(name) {
this.name = name;
}
class Foo {
foo() {
function bar() {
this.baz;
}
}
}
Pass
class Foo {
foo() {
this.name;
}
}
class Foo {
foo() {
const bar = () => {
this.name;
}
}
}
Proposed rule name
no-this-outside-of-class
Additional Info
No response