Add rule to warn about use of `arguments` in fat arrow functions
See original GitHub issuePlease describe what the rule should do:
warn on usage of arguments inside fat arrow functions
What category of rule is this? (place an “X” next to just one item)
[ ] Enforces code style [x] Warns about a potential error [ ] Suggests an alternate way of doing something [ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
const logArgs = () => console.log(arguments);
function foo(a, b, c) {
const bar = blah => {
if(arguments.length > 1) {
console.log("too many args!");
}
};
bar(123);
}
foo(456, 789);
Why should this rule be included in ESLint (instead of a plugin)?
arguments
is not bound for fat arrow functions. The first example is quite easy to catch by a developer, as an error will be thrown. The second example would be hard to track down because arguments
is actually referring to foo
’s arguments, not bar
’s
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >New rule: Add linter for single arg fat arrow functions #309
I think we should implement this rule in the following manner: // Passes lint var foo = bar => { window.alert(bar) } foo('hello')...
Read more >arrow-parens - 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 >Arrow Functions in JavaScript: Fat & Concise Syntax - SitePoint
Learn how to use JavaScript arrow functions, understand fat and concise arrow syntax, and what to be aware of when using them in...
Read more >Why shouldn't JSX props use arrow functions or bind?
Rerendering many elements might create jank in animations. Using an inline arrow function will cause PureComponent s, and components that use shallowCompare ...
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 FreeTop 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
Top GitHub Comments
or even in ES5:
Both of these are much clearer
Now I’ve thought of it more, I think you’re right. May as well use rest params in every case. I didn’t spot the
prefer-rest-params
rule initially. Closing