prefer-reflect-apply
March 27, 2026 ยท View on GitHub
๐ Prefer Reflect.apply() over Function#apply().
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง This rule is automatically fixable by the --fix CLI option.
Reflect.apply() is arguably less verbose and easier to understand. In addition, when you accept arbitrary methods, it's not safe to assume .apply() exists or is not overridden.
Examples
function foo() {}
// โ
foo.apply(null, [42]);
// โ
Function.prototype.apply.call(foo, null, [42]);
// โ
Reflect.apply(foo, null, [42]);
function foo() {}
// โ
foo.apply(this, [42]);
// โ
Function.prototype.apply.call(foo, this, [42]);
// โ
Reflect.apply(foo, this, [42]);
function foo() {}
// โ
foo.apply(null, arguments);
// โ
Function.prototype.apply.call(foo, null, arguments);
// โ
Reflect.apply(foo, null, arguments);
function foo() {}
// โ
foo.apply(this, arguments);
// โ
Function.prototype.apply.call(foo, this, arguments);
// โ
Reflect.apply(foo, this, arguments);