This repository was archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 653
feat(rome_formatter): Align
IR element
#2995
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR adds an alignment `FormatElement` that allows explicitly aligning content by a specific amount of spaces rather than using `indent` that uses the configured indent string. Aligning by an explicit number of spaces is e.g. needed when formatting conditional expressions where the content should be aligned to `"? "` and `: `. ## Tests I added a new doc test that demonstrates the new IR element.
!bench_formatter |
Deploying with
|
Latest commit: |
a154bc3
|
Status: | ✅ Deploy successful! |
Preview URL: | https://ae359394.tools-8rn.pages.dev |
Branch Preview URL: | https://feat-align-ir.tools-8rn.pages.dev |
Formatter Benchmark Results
|
ematipico
reviewed
Aug 3, 2022
enum Indent { | ||
/// Indent by the specified count of indention levels | ||
Simple(u16), | ||
/// Indent `indent` indention levels and add `align` spaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent
indent
indention
LOL! Any chance we can rephrase it a bit? Like:
Indents the given
indent
, by the specified indentation levels. It then adds the spaces specified byalign
ab20ccf
to
a154bc3
Compare
leops
approved these changes
Aug 4, 2022
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/tools
that referenced
this pull request
Aug 22, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an alignment
FormatElement
that allows explicitly aligning content by a specific amount of spaces rather than usingindent
that uses the configured indent string.Aligning by an explicit number of spaces is e.g. needed when formatting conditional expressions where the content should be aligned to
"? "
and:
.Prettier compatibility
Prettier's
align
IR supports not only positive numbers but alsoI'll add the functionality once needed (NEGATIVE_INFINITE will be needed for template literals)
Tests
I added a new doc test that demonstrates the new IR element.