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

Prefer implicit return on fat arrow if possible #4928

Closed
dan1elhughes opened this issue Aug 2, 2018 · 2 comments
Closed

Prefer implicit return on fat arrow if possible #4928

dan1elhughes opened this issue Aug 2, 2018 · 2 comments
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.

Comments

@dan1elhughes
Copy link

Hi, is there an option for replacing immediately-returning fat arrow functions with implicit returns?

Prettier 1.14.0
Playground link

# Options (if any):
--single-quote

Input:

module.exports.collect = (val, memo = []) => {
  return [...memo, val];
};

Output:

module.exports.collect = (val, memo = []) => {
  return [...memo, val];
};

Expected behavior:

module.exports.collect = (val, memo = []) => [...memo, val];
@ikatyang
Copy link
Member

ikatyang commented Aug 2, 2018

Hi, this is one of our non-goals since it affects the AST, we recommend you to use fixable linter rules (e.g. arrow-body-style) to achieve it.

@ikatyang ikatyang closed this as completed Aug 2, 2018
@ikatyang ikatyang added type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker. lang:javascript Issues affecting JS labels Aug 2, 2018
@dan1elhughes
Copy link
Author

OK cool, thank you!

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Oct 31, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.
Projects
None yet
Development

No branches or pull requests

2 participants