unicorn/prefer-reflect-apply
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-reflect-apply": "error",
},
},
];foo.apply(null, [42]);Function.prototype.apply.call(foo, null, [42]);foo.apply(this, [42]);Reflect.apply(foo, null, [42]);Reflect.apply(foo, this, [42]);Reflect.apply(foo, null, arguments);Examples from the ESLint documentation.
unicorn/prefer-reflect-apply
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-reflect-apply": "error",
},
},
];unicorn/prefer-reflect-apply
unicorn plugin · style
{
"rules": {
"unicorn/prefer-reflect-apply": "error"
}
}Biome does not have this rule.
Prefer borrowing methods from the prototype instead of the instance.
Prefer Response.json() over new Response(JSON.stringify()).
Prefer omitting the catch binding parameter.
Prefer Set#has() over Array#includes() when checking for existence or non-existence.
Prefer Number() over parseFloat() and base-10 parseInt().
Enforce combining multiple Array#{push,unshift}(), Element#classList.{add,remove}(), and importScripts() into one call.