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

prefer-this-arg: replace ...(foo.bind(bar)) by ...(foo, bar) #353

Open
regseb opened this issue Jan 17, 2023 · 0 comments
Open

prefer-this-arg: replace ...(foo.bind(bar)) by ...(foo, bar) #353

regseb opened this issue Jan 17, 2023 · 0 comments

Comments

@regseb
Copy link
Contributor

regseb commented Jan 17, 2023

Description

Check for the methods from, every, filter, find, findIndex, forEach, map and some that the parameter doesn't have a .bind(foo) (and prefer the use of the parameter thisArg).

Example

https://jsbin.com/neleqiwiha/edit?js,console

class Foo {
  #bar = "b";

  filter(element) {
    return this.#bar === element;
  }

  main() {
    console.log(["a", "b", "c"].filter(this.filter.bind(this)));
    console.log(["a", "b", "c"].filter(this.filter, this));
  }
};

const foo = new Foo();
foo.main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant