Hi! I'm starting to use prettier
, and noticed some odd formatting with regards to arrow functions when they are nested like in the following examples.
const fn = b => c => d => 3; // This stays the same, which is good.
// but this one
const fn = b => c => d => {
return 3
};
// gets formatted to this
const fn = b =>
c =>
d => {
return 3;
};
My sentiment is that this is not very pretty, but let me know if this was done on purpose.
// FYI
const fn = fooooooooooooooooooooooooooooo => baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar => baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz => 3;
// when args get very long, it gets formatted to
const fn = fooooooooooooooooooooooooooooo => // <linebreak>
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar => baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz => 3;
// which is fine
(And obviously, thanks for the tool :heart:)
I was literally about to make this exact issue. Was working on a redux middleware:
// in:
const mw = store => next => action => {
return next(action)
}
// out:
const mw = store =>
next =>
action => {
return next(action)
};
Interesting, looks like we need to do some special handling of arrow functions used in a curried way
Just sent https://github.com/prettier/prettier/pull/1066 to fix this issue, thanks for reporting it!
Most helpful comment
Just sent https://github.com/prettier/prettier/pull/1066 to fix this issue, thanks for reporting it!