Higher order functions and the arrow-parens rule
See original GitHub issueThe arrow-parens
rule requiring parentheses for blocks and no parentheses for one-liners takes no account of higher order functions.
I find it downright bizarre that I should be required to write code like the following:
return next => (action) => {
// etc
};
I don’t know whether this is a config issue or an eslint issue.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
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 >Higher Order Functions: Reduce() - Medium
A higher order function is a function that takes in a function as an argument or returns a function. With ES6 syntax this...
Read more >Expected parentheses around arrow function argument ...
Parentheses around the parameter to an arrow function are optional in ES6 when there's ... This is controlled by the arrow-parens option.
Read more >Understanding Higher-Order Functions in JavaScript
Although it may sound complicated, it isn't. What makes JavaScript suitable for functional programming is that it accepts Higher-Order Functions ...
Read more >arrow-parens - Rule
Rule: arrow-parens. Requires parentheses around the parameters of arrow function definitions. Rationale. Maintains stylistic consistency with other arrow ...
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
Here is an example that doesn’t make any sense:
Where is the consistency between
(script)
andlink
? Looks so bad!It should be always or never (i’m talking about single argument in function signature)
Just now found this issue myself, taking a look at:
https://github.com/airbnb/javascript/blob/7e865a4e8ab5e26062fcdc9437166c6e1c269599/packages/eslint-config-airbnb-base/rules/es6.js#L25
Yeah, I gotta admit I’m a bit bewildered by
requireForBlockBody
being true. But I guess I fall into the camp wherearrow-parens
are always required. Helps me visually associate that arg to the arrow function rather than to the wrapping function. 1 char diff between arrow function and assignment is not sufficient for my tastes.Thank goodness for overrides. 🙄