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
Add func-style exception for single-expression arrow functions #1897
Comments
At first glance, this seems like a far too specific exception that doesn't fit with the purpose of the rule. I could see an argument to exempt arrow functions from this rule and then create a new rule that has options for how you want to format it. |
Yeah, separate rules for arrow functions probably would be the smartest approach. |
How would you envision such a rule working? |
Honestly, I think the exemption is the important part. That way you could prefer function declarations but carve out an exception for disposable, lightweight functions like those predicates. |
did we land somewhere? |
I think we can create an option |
Update: `allowArrowFunctions` option for `func-style` rule (fixes #1897)
Is there a release planned for this? |
@robcolburn Seems released now in 1.7. |
With the addition of arrow functions, I think it would be great to have an exception for the declaration func-style rule. Namely, you should be able to enforce declaration style for all functions other than single-expression (implicit return) arrow functions.
It would look something like this:
"func-style": [2, "declaration", {"allowSimpleArrowFunctionExpression": true}],
and would behave identically to the normal rule, but allow the following:
const isOdd = (n) => n % 2 == 1;
This is a purely stylistic option that I imagine would be used primarily for exempting map/filter/reduce predicates.
The text was updated successfully, but these errors were encountered: