-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[arrow-parens] Add a "when-brace" option #6557
Comments
…6557) The when-brace option allows to require parens for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ``` Otherwise, its behavior remains identical then with the as-needed option.
In order to facilitate acceptance of this issue and pull request, could you please edit your original post to answer the questions raised in the Proposing a Rule Change documentation? Thanks! |
@platinumazure done, missed that part. |
Since this is part of AirBnB styleguide, I think we should consider adding an option for this. I don't like proposed name, however. Don't really have any ideas on how to name it though. I'll 👍 this |
Agree on the naming, not convinced by it too but nothing better came to me ;). |
@eslint/eslint-team We need some more +1s here. And suggestion for option name. |
👍 |
1 similar comment
👍 |
How about breaking this up a bit, and adding an option object with keys like The upshot would be making this a bit more flexible and still accommodating the AirBnB style mentioned by the OP. ( |
Do we have a champion for this? I'd suggest we look at a configuration like:
(Generally I think "block" is a more appropriate description, but could also be |
@nzakas, I think we would also need |
@IanVS hmmm, I'm not sure I understand. You can't have multiple parameters for an arrow function without parentheses (it's a syntax error). Can you explain a bit more? |
Doh, of course. I was just reading the styleguide way too literally and trying to invert it without thinking about it:
|
I can champion this! |
👍 to |
Okay @kaicataldo, the power is yours! |
Thanks! Have we decided that |
Yup! |
…le (fixes eslint#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…le (fixes eslint#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
…nt#6557) The `'as-needed'` option can now be modified with the `{requireForBlockBody: true}` option allowing to require parentheses for arrow functions whose body is wrapped into curly braces like the following: ```js (a) => {} ```
Our team would like to adopt the AirBnb best practice for arrow functions parens but it appears the current options of this rule doesn't fit it. Since we want to rely on automated coding style rules only and found out it would be useful for others too, here is the PR that fulfill it.
See https://github.com/airbnb/javascript#arrows--one-arg-parens
Discussion: SimpliField/eslint-config-simplifield#14
2.11.1
https://github.com/SimpliField/eslint-config-simplifield/blob/master/package.json#L20
'arrow-parens'
with 'as-needed' (1) is valid
with 'always' (2) is valid
The text was updated successfully, but these errors were encountered: