Skip to content

unicorn/prefer-reflect-apply Style ​

What it does ​

Why is this bad? ​

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.

Example ​

Examples of incorrect code for this rule:

javascript
foo.apply(null, [42]);

Examples of correct code for this rule:

javascript
Reflect.apply(foo, null);

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/prefer-reflect-apply
json
{
  "rules": {
    "unicorn/prefer-reflect-apply": "error"
  }
}

References ​

Released under the MIT License.