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

Rule about new lines after curly-less arrow function bodies #889

Open
tunnckoCore opened this issue May 18, 2017 · 1 comment

Comments

@tunnckoCore
Copy link

commented May 18, 2017

Recently seen an article that has this snippet

const arr = [{ name: 'first', value: 13 }, { name: 'second', value: 7 }]
const enrichElementWithCalculatedValue =
  elem => ({ name: elem.name, calculatedValue: elem.value * 10 })
const filterElementsByValue = value =>
  elem => elem.calculatedValue > value
const aggregateElementInObject = (acc, elem) => ({
  [elem.name]: elem.calculatedValue,
  ...acc
})
const res = arr
  .map(enrichElementWithCalculatedValue)
  .filter(filterElementsByValue(100))
  .reduce(aggregateElementInObject, {})

I thought that it isn't very readable for my eyes. Not seeing such thing for the first time. So i'm thinking, is there rule for this? And if yes, could we include it in standard? A lot better would be to have a new line after the arrow function bodies. Probably, it would be good for beginners to understand that it is a function body and where it ends.

Sorry if issue is duplicate or discussed, just don't have the time to scroll over the issues right now.

Cheers :)

edit: Side note, probably it would be against Prettier's formatting, sadly?

@dcousens

This comment has been minimized.

Copy link
Member

commented May 18, 2017

Maybe a maximum density of 120 [actual] characters per 80*4 character space?

@Flet Flet added the enhancement label Nov 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.