Skip to content
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 a 'requireForBlockBody' modifier to the 'arrow-parens' rule (fixes #6557) #6558

Merged
merged 1 commit into from Aug 3, 2016

Conversation

nfroidure
Copy link
Contributor

The when-brace option allows to require parens for arrow functions whose body is
wrapped into curly braces like the following:

 (a) => {}

Otherwise, its behavior remains identical then with the as-needed option.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @alberto, @aubergine10 and @gyandeeps to be potential reviewers

@eslintbot
Copy link

LGTM

@jquerybot
Copy link

Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA).

📝 Please visit http://contribute.jquery.org/CLA/ to sign.

After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know.


If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check.

@SebastienElet
Copy link

👍

@platinumazure platinumazure added the do not merge This pull request should not be merged yet label Jun 29, 2016
@platinumazure
Copy link
Member

Marking "do not merge" as issue is not accepted yet.

@kaicataldo kaicataldo removed the do not merge This pull request should not be merged yet label Jul 18, 2016
@kaicataldo
Copy link
Member

Issue is now accepted

@kaicataldo
Copy link
Member

@nfroidure Thanks for contributing to ESLint! We're ready to start moving on this now that the enhancement has been discussed and accepted. The team ended up deciding on a different configuration option than the one you have here - would you be willing to update the PR so that it reflects the issue? Let me know if you have any questions!

@nfroidure
Copy link
Contributor Author

@kaicataldo thought you were on it, i can do it as well, just let me know to avoid doing it twice.

@kaicataldo
Copy link
Member

kaicataldo commented Jul 21, 2016

Ah, understand the confusion. As a champion for this enhancement it's up to me to either implement or to help someone else implement it. We'd love your contribution, if you're willing :)

If you don't have the time or are not interested, I can definitely take this on, though.

@eslintbot
Copy link

Thanks for the pull request, @nfroidure! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary must be 72 characters or shorter. Please check out our guide for how to properly format your commit summary and update it on this pull request.

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@nfroidure nfroidure changed the title Update: Add 'when-brace' option to 'arrow-parens' rule (fixes #6557) Add a 'requireForBlockBody' modifier to the 'arrow-parens' rule (fixes #6557) Jul 22, 2016
@nfroidure
Copy link
Contributor Author

@kaicataldo done ;). I amended the commit and renamed it, just tell me if i also have to change the branch name.

@eslintbot
Copy link

Thanks for the pull request, @nfroidure! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary must be 72 characters or shorter. Please check out our guide for how to properly format your commit summary and update it on this pull request.

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@nfroidure
Copy link
Contributor Author

@eslintbot For sure, wait a minute ⌚

@eslintbot
Copy link

LGTM

@kaicataldo
Copy link
Member

No worries on the branch name :) The team will start reviewing and we'll leave comments here, should we feel anything needs to be changed/updated. Haven't had a chance to look at the PR yet but will try to do so ASAP. Thanks for contributing!

* `"always"` (default) requires parens in all cases.
* `"as-needed"` allows ommitting parens in some cases.

This rule has an object option for exceptions to the `"as-needed"` option:

You can set the option in configuration like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we don't need this line anymore.

@btmills
Copy link
Member

btmills commented Jul 23, 2016

Just a handful of minor tweaks, otherwise LGTM. Thanks @nfroidure!

@ljharb
Copy link
Sponsor Contributor

ljharb commented Jul 23, 2016

@nfroidure Thank you!! I'm looking forward to enabling this rule in Airbnb's linter config :-)

/*eslint-env es6*/

(a) => {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on adding a => ({}); to the correct examples?

@kaicataldo
Copy link
Member

Left some suggestions. Thanks so much for working on this @nfroidure!

@kaicataldo
Copy link
Member

@nfroidure Just wanted to check in and see if there's anything I can do to help get this landed. Looks like we need to rebase and resolve a merge conflict as well.

@nfroidure
Copy link
Contributor Author

@kaicataldo everything is well just had no time to dive back in this PR. I'll try to give it a look this week.

@eslintbot
Copy link

LGTM

@nfroidure
Copy link
Contributor Author

@kaicataldo just adapted the PR to your recommendations and rebased:

  • about the duplicate it already was on the previous tests and was not sure of its usefulness. I removed both.
  • i added a test for the () => ({}) case.
  • was not aware of the BlockStatement node type and its implications, just replaced it and it actually fixed the edge case you pointed out, nice catch ;).
  • both {a, b} => a + b and [a, b] => a + b leads to a syntax error so i did not test them. Just added some tests to check ({a, b}) => a + b and ([a, b]) => a + b as valid.

@eslintbot
Copy link

LGTM

@nfroidure
Copy link
Contributor Author

@ljharb i pushed it before rebasing to give you the opportunity to review the changes before the rebase but it appeared to be a minor conflict ;)


let sourceCode = context.getSourceCode();


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline

@kaicataldo
Copy link
Member

Looks like a rebase is needed, but otherwise this is looking great to me.

…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) => {}
 ```
@eslintbot
Copy link

LGTM

@nzakas
Copy link
Member

nzakas commented Aug 3, 2016

@kaicataldo feel free to merge if you think this is ready.

@kaicataldo
Copy link
Member

LGTM. Thanks for contributing, @nfroidure!

@kaicataldo kaicataldo merged commit 30d71d6 into eslint:master Aug 3, 2016
@nfroidure
Copy link
Contributor Author

Was a great pleasure to help on a product i use on a daily basis. Keep up the good work guys 😘

@nfroidure nfroidure deleted the arrow-parens-brace branch August 4, 2016 06:53
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants