Skip to content

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

New issue

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

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

Already on GitHub? # to your account

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();
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant