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