Add support for currying #1066

Merged
merged 1 commit into from Mar 22, 2017

Conversation

Projects
None yet
3 participants
@vjeux
Collaborator

vjeux commented Mar 21, 2017

If you write your code in a functional way where you have an arrow function for each argument, it looks better for them to be inline. I can't imagine any case where it would be used in a different way if we limit to a single argument.

Fixes #1065

@jfmengels

This comment has been minimized.

Show comment
Hide comment
@jfmengels

jfmengels Mar 21, 2017

Awesome, thanks @vjeux! (There are some conflicts on this PR though)

By the way, I sometimes also write stuff like this:

const middleware = options => (req, res, next) => {
  // ...
};

const foo = (a, b) => (c, d) => e => {
  // ...
};

where some/all of the intermediate functions have multiple arguments. If they all fit on the same line, I think they should stay there, regardless of how many arguments they take.

jfmengels commented Mar 21, 2017

Awesome, thanks @vjeux! (There are some conflicts on this PR though)

By the way, I sometimes also write stuff like this:

const middleware = options => (req, res, next) => {
  // ...
};

const foo = (a, b) => (c, d) => e => {
  // ...
};

where some/all of the intermediate functions have multiple arguments. If they all fit on the same line, I think they should stay there, regardless of how many arguments they take.

@vjeux

This comment has been minimized.

Show comment
Hide comment
@vjeux

vjeux Mar 22, 2017

Collaborator

I quickly looked through Facebook codebase and we almost never return functions from functions like this, so supporting more than one argument shouldn't change anything. Let me send an update to remove the limitation.

Collaborator

vjeux commented Mar 22, 2017

I quickly looked through Facebook codebase and we almost never return functions from functions like this, so supporting more than one argument shouldn't change anything. Let me send an update to remove the limitation.

Add support for currying
If you write your code in a functional way where you have an arrow function for each argument, it looks better for them to be inline. I can't imagine any case where it would be used in a different way if we limit to a single argument.

Fixes #1065
@jlongster

This comment has been minimized.

Show comment
Hide comment
@jlongster

jlongster Mar 22, 2017

Member

Sounds good to me 👍

Member

jlongster commented Mar 22, 2017

Sounds good to me 👍

@vjeux vjeux merged commit 60816af into prettier:master Mar 22, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jfmengels

This comment has been minimized.

Show comment
Hide comment
@jfmengels

jfmengels Mar 23, 2017

Thanks a lot! 😄

Thanks a lot! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment