google / eslint-config-google

ESLint shareable config for the Google JavaScript style guide
Apache License 2.0
1.74k stars 140 forks source link

Require parens in arrow function arguments (arrow-parens) #45

Closed doasync closed 5 years ago

doasync commented 7 years ago

The "as-needed", { "requireForBlockBody": true } rule is directly inspired by the Airbnb JS Style Guide.

If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency.

googlebot commented 7 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


kaspnilsson commented 7 years ago

+1

philipwalton commented 7 years ago

But the Google JS style guide doesn't make the same recommendation as the Airbnb JS style guide. This is what the Google JS style guide says:

Tip: It is a good practice to use parentheses even for single-argument arrows, since the code may still parse reasonably (but incorrectly) if the parentheses are forgotten when an additional argument is added.

For example, this would be valid according to the as-needed rule, but Google style recommends against it:

doSomething(a, b, c, d => e => f);