False positive in `prefer-rest-params` when checking arguments.length
See original GitHub issueESLint version: 2.8.0
What parser are you using?
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {"jsx": true},
},
When linting this code:
function makeTree(rootPath, branches) {
console.assert(arguments.length === 2);
console.assert(_.isArray(rootPath));
console.assert(_.isArray(branches) && _.isArray(branches[0]));
return _.map(branches, branch => rootPath.concat(branch));
}
I get this warning:
Use the rest parameters instead of 'arguments' prefer-rest-params
I believe this to be a false positive. Imho just checking arguments.length
should be an exception to this rule (possibly configurable).
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
arguments.length - JavaScript - MDN Web Docs
The arguments.length data property contains the number of arguments passed to the function. Value. A non-negative integer.
Read more >D87540 [clang-tidy] Fix false positive issue in ... - LLVM
I am submitting the patch for review, along with new regression tests to verify that the check is ok if it sees an...
Read more >Code Issues - Embold Help Center
CFRetainRelease, Check for null arguments to CFRetain/CFRelease/CFMakeCollectable ... If that is the case, the reported instance is a false positive.
Read more >Mockito. Verify method arguments - java - Stack Overflow
Have you checked the equals method for the mockable class? ... it with the eq() matcher as well as the refEq() matcher but...
Read more >prefer-rest-params - ESLint - Pluggable JavaScript Linter
There are rest parameters in ES2015. We can use that feature for variadic functions instead of the arguments variable. arguments does not have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems reasonable to me. Also, this is a relaxing enhancement, so this is a minor fix.
I will champion this.
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.