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

challenge(formatter): Fix multi-expression template literal indention #793

Merged

Conversation

faultyserver
Copy link
Contributor

Summary

Fixes:

A nice and short one, Prettier re-uses the previous indention if the current text chunk has no newline characters, and this updates Biome to match.

The most basic case of this would be:

`
  2. Go to "${chalk.green.underline(
    "https://www.example.com/drupedalKangarooTransformer"
  )}" ${chalk.green.underline(
    "https://www.example.com/drupedalKangarooTransformer"
  )}
`

Which was being formatted as:

`
  2. Go to "${chalk.green.underline(
    'https://www.example.com/drupedalKangarooTransformer'
  )}" ${chalk.green.underline(
  'https://www.example.com/drupedalKangarooTransformer'
)}
`;

Because the text chunk after the first expression chunk was just " , with no new line character, Biome was defaulting to a new indention of 0. Now, it'll remember the previous indention it used the last time there was a line break, which was before the first expression chunk ( 2. Go to ") and apply that to the current expression as well.

Test Plan

Prettier diff snapshot now matches and has been deleted.

@github-actions github-actions bot added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Nov 19, 2023
@Conaclos Conaclos merged commit 2e863bb into biomejs:main Nov 19, 2023
12 checks passed
@faultyserver faultyserver deleted the challenge/template-literal-indention branch November 19, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants