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): Implement bracketSameLine option to match Prettier #799

Merged
merged 6 commits into from Nov 21, 2023

Conversation

faultyserver
Copy link
Contributor

@faultyserver faultyserver commented Nov 20, 2023

To review: I'd recommend just checking the first commit and the third one. The second is the one with all the snapshot file updates, and the fourth is just website codegen.

Summary

This should be the last big option that Prettier supports that Biome doesn't (other than the Pragma options). All that this option does is force the closing bracket of a multiline opening JSX tag (or HTML/Vue, once those are supported) to hug onto the end of the last attribute line rather than get placed on its own line afterward.

For example:

// Existing behavior. Now also the default, meaning `bracketSameLine: true`.
<Foo
  className={somethingReallyLongThatForcesThisToWrap}
  anotherReallyLongAttribute={withAValueThatsSurelyTooLong}
  soThatEverythingWraps
>
  Hello
</Foo>

<Foo
  selfClosingTags={likeThisOne}
  stillPlaceTheBracket={onItsOwnLine}
  toIndicateThat={itClosesItself}
/>

And with the option disabled, which is the new behavior:

// New behavior, with `bracketSameLine: false`.
<Foo
  className={somethingReallyLongThatForcesThisToWrap}
  anotherReallyLongAttribute={withAValueThatsSurelyTooLong}
  soThatEverythingWraps>
  Hello
</Foo>

<Foo
  selfClosingTags={likeThisOne}
  stillPlaceTheBracket={onItsOwnLine}
  toIndicateThat={itClosesItself}
/>

Test Plan

New snapshot test in the CLI and in biome_js_formatter checks that this option is being applied correctly.

All snapshots have also been updated with the additional configuration readout.

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Formatter Area: formatter A-Website Area: website L-JavaScript Language: JavaScript and super languages labels Nov 20, 2023
Copy link
Member

@Conaclos Conaclos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks!

@Conaclos Conaclos merged commit d1e6290 into biomejs:main Nov 21, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Formatter Area: formatter A-Project Area: project A-Website Area: website L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants