no-array-method-this-argument
March 27, 2026 ยท View on GitHub
๐ Disallow using the this argument in array methods.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง๐ก This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.
The rule disallows using the thisArg argument in array methods:
- If the callback is an arrow function or a bound function, the
thisArgwon't affect it. - If you intend to use a custom
thisin the callback, it's better to use the variable directly or usecallback.bind(thisArg).
This rule checks following array methods accepts thisArg:
Array.from()Array#every()Array#filter()Array#find()Array#findLast()Array#findIndex()Array#findLastIndex()Array#flatMap()Array#forEach()Array#map()Array#some()
This rule is fixable when the callback is an arrow function and the thisArg argument has no side effect.
Examples
// โ
const foo = bar.find(element => isUnicorn(element), baz);
// โ
const foo = bar.find(element => isUnicorn(element));
// โ
const foo = bar.map(function (element) {
return this.unicorn(element);
}, baz);
// โ
const foo = bar.map(function (element) => {
return baz.unicorn(element);
});
// โ
const foo = bar.map(function (element) => {
return this.unicorn(element);
}.bind(baz));