Skip to content

Code Style Help #14945

Answered by kachkaev
Cmeem asked this question in Q&A
Jun 17, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

👋 @Cmeem! If you remove new line after {, the result will be more compact:

Prettier 2.8.8
Playground link

--parser babel

Input:

const options = {
  active: true,
  ...('day' === 'hour' ? { hour: true
  } : { day: true
  })
};

Output:

const options = {
  active: true,
  ...("day" === "hour" ? { hour: true } : { day: true }),
};

Overall, it’s best to not worry about such things and focus on code logic rather than code style.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Cmeem
Comment options

Answer selected by Cmeem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants