sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-this-outside-of-class`
Fechada
#2.450 aberto em 16 de set. de 2024
help wantednew rule
Métricas do repositório
- Stars
- (5.022 estrelas)
- Métricas de merge de PR
- (Mesclagem média 4h 30m) (26 fundiu PRs em 30d)
Description
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