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

Odd arrow function printing #800

Closed
cpojer opened this issue Feb 23, 2017 · 3 comments
Closed

Odd arrow function printing #800

cpojer opened this issue Feb 23, 2017 · 3 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@cpojer
Copy link

cpojer commented Feb 23, 2017

This:

const initializeSnapshotState = (
  testFile: Path,
  update: boolean,
  testPath: string,
  expand: boolean,
) => new SnapshotState(testFile, update, testPath, expand);

gets turned into this:

const initializeSnapshotState = (
  testFile: Path,
  update: boolean,
  testPath: string,
  expand: boolean,
) =>
  new SnapshotState(testFile, update, testPath, expand);

in https://github.com/cpojer/jest/blob/master/packages/jest-snapshot/src/index.js

It looks a bit odd.

https://prettier.github.io/prettier/#%7B%22content%22%3A%22const%20initializeSnapshotState%20%3D%20(%5Cn%20%20testFile%3A%20Path%2C%5Cn%20%20update%3A%20boolean%2C%5Cn%20%20testPath%3A%20string%2C%5Cn%20%20expand%3A%20boolean%2C%5Cn)%20%3D%3E%20new%20SnapshotState(testFile%2C%20update%2C%20testPath%2C%20expand)%3B%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22doc%22%3Afalse%7D%7D

@vjeux
Copy link
Contributor

vjeux commented Feb 23, 2017

Likely going to be fixed by #680. Edit, nvm it doesn't

@vjeux vjeux added the type:bug Issues identifying ugly output, or a defect in the program label Feb 23, 2017
@jlongster
Copy link
Member

jlongster commented Feb 24, 2017

Honestly I'm not a fan of bumping down contents ever from arrow functions like that. We didn't do that in early version of prettier and I had no idea some people wanted that until they filed bugs. We do it because some people do stuff like

func =>
  Promise.resolve((resolve, reject) => {
    // lots of code
  })

But in my opinion they really should just make it a block and use return. I'm not sure if we can go back on that though?

vjeux added a commit to vjeux/prettier that referenced this issue Feb 27, 2017
By adding a group, we can avoid adding a newline if the expression fits in a single line.

Fixes prettier#800
@vjeux
Copy link
Contributor

vjeux commented Feb 27, 2017

Turns out there's an easy fix for this one: #829

jlongster pushed a commit that referenced this issue Feb 27, 2017
By adding a group, we can avoid adding a newline if the expression fits in a single line.

Fixes #800
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 8, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants