question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prefer-spread doesn't report Reflect.apply calls.

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.8.1
  • Node Version: v6.9.0
  • npm Version: 3.10.8

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

rules:
  prefer-spread: 2

What did you do?

From the example:

foo.apply(null, args);

One of my coworkers has decided to refactor this sort of syntax using Reflect instead of spread params.

Reflect.apply(foo, null, args);

What did you expect to happen?

I would expect prefer-spread to not accept this syntax either, enforcing my coworkers to use the spread syntax. At least I think it should be possible to enforce this using a setting.

What actually happened? Please include the actual, raw output from ESLint.

Eslint didn’t report anything.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
nzakascommented, Oct 29, 2016

Our standard operating procedure is to keep rules as small as possible. The argument that “it won’t hurt to have it in the rule” only leads to large rules that are hard to maintain. Since in this case it looks like there is another way to accomplish the same thing, it seems like not updating the rule for this specific case is the best case forward.

0reactions
kaicataldocommented, Jan 10, 2017

Closing this issue as it looks like a sufficient workaround was suggested and it doesn’t look like there’s enough support to pursue an enhancement of the rule.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prefer-spread - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Reflect.apply() - JavaScript - MDN Web Docs
apply () method to call a function with a given this value and arguments provided as an array (or an array-like object). Function.prototype.apply.call(Math.floor ......
Read more >
javascript - Use of .apply() with 'new' operator. Is this possible?
I'm going to accept this one as my preferred solution, since it doesn't require modification of the original constructor (I didn't specify that...
Read more >
eslint-plugin-unicorn/prefer-reflect-apply.md at main - GitHub
Prefer Reflect.apply() over Function#apply(). This rule is enabled in the ✓ recommended config. This rule is automatically fixable by the --fix CLI ...
Read more >
What Is a Bid-Ask Spread, and How Does It Work in Trading?
A bid-ask spread is the amount by which the ask price exceeds the bid price for an asset in the market.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found