eslint-plugin-array-func icon indicating copy to clipboard operation
eslint-plugin-array-func copied to clipboard

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

Open regseb opened this issue 2 years ago • 0 comments

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();

regseb avatar Jan 17 '23 10:01 regseb