New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive in prefer-rest-params
when checking arguments.length
#5990
Comments
Hmm. This is a tough one. On the one hand, it would be easy to add a rest param and assert that its length is zero; on the other hand, introducing another variable that you won't even really use just to satisfy the rule would be pretty silly. @eslint/eslint-team Do we consider this a bug, or an enhancement request? |
It's an enhancement request, but one I don't think we should do. The purpose of the rule is to flag uses of |
@nzakas No, that is not how you would replace the |
@michaelficarra fair enough, are you willing to champion this option? |
No. By support, I meant endorse. I do not plan on participating. |
@mik01aj, thanks for contributing. @nzakas, I'm torn on this one. While I do think the provided example doesn't show the full breadth of situations in which arguments.length is preferable, there are lots of good use cases, especially libraries with lots of variadic functions. Looking at the jQuery source, for example, yields 19 uses of arguments.length to power heavily overloaded functions. Now, I'm not a fan of such parameter hockey in my own APIs, but arguments.length is nifty to have around even if you don't want arguments itself. I'm not going to champion this one but I would give it a 👍 if someone else did. |
@eslint/eslint-team is anyone willing to champion this? |
It seems reasonable to me. I will champion this. |
Just to make sure, we are expanding this to support any member expression checks where |
@platinumazure, seems correct. |
@platinumazure According to docs on MDN, there are just these:
I don't think that accessing the |
Right, I agree @mik01aj but the rule is about prefering rest parameters over arguments, so erroring on using arguments other than as a parameter shouldn't cause an issue. |
@platinumazure good point, thx. Agree. |
ESLint version: 2.8.0
What parser are you using?
When linting this code:
I get this warning:
I believe this to be a false positive. Imho just checking
arguments.length
should be an exception to this rule (possibly configurable).The text was updated successfully, but these errors were encountered: