Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule proposal: no-this-outside-of-class #2450

Open
zanminkian opened this issue Sep 16, 2024 · 0 comments
Open

Rule proposal: no-this-outside-of-class #2450

zanminkian opened this issue Sep 16, 2024 · 0 comments

Comments

@zanminkian
Copy link
Contributor

zanminkian commented Sep 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant