eslint-plugin-array-func
eslint-plugin-array-func copied to clipboard
`prefer-this-arg`: replace `...(foo.bind(bar))` by `...(foo, bar)`
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();