-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
feat(format/html): implement bracketSameLine #4968
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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
9 changes: 9 additions & 0 deletions
9
crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/element.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div | ||
id="hello" | ||
class="world really-long-class-name another-really-long-class-name" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
> | ||
hello world | ||
</div> |
68 changes: 68 additions & 0 deletions
68
crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/element.html.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: elements/bracket-same-line/element.html | ||
--- | ||
# Input | ||
|
||
```html | ||
<div | ||
id="hello" | ||
class="world really-long-class-name another-really-long-class-name" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
> | ||
hello world | ||
</div> | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Attribute Position: Auto | ||
Bracket same line: false | ||
Whitespace sensitivity: strict | ||
Indent script and style: false | ||
----- | ||
|
||
```html | ||
<div | ||
id="hello" | ||
class="world really-long-class-name another-really-long-class-name" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
>hello world</div> | ||
``` | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Attribute Position: Auto | ||
Bracket same line: true | ||
Whitespace sensitivity: strict | ||
Indent script and style: false | ||
----- | ||
|
||
```html | ||
<div | ||
id="hello" | ||
class="world really-long-class-name another-really-long-class-name" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo">hello world</div> | ||
``` |
6 changes: 6 additions & 0 deletions
6
crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/options.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../../../../../../packages/@biomejs/biome/configuration_schema.json", | ||
"formatter": { | ||
"bracketSameLine": true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/self-closing.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<selfclosing | ||
id="hello" | ||
class="world" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
/> | ||
66 changes: 66 additions & 0 deletions
66
...s/biome_html_formatter/tests/specs/html/elements/bracket-same-line/self-closing.html.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: elements/bracket-same-line/self-closing.html | ||
--- | ||
# Input | ||
|
||
```html | ||
<selfclosing | ||
id="hello" | ||
class="world" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
/> | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Attribute Position: Auto | ||
Bracket same line: false | ||
Whitespace sensitivity: strict | ||
Indent script and style: false | ||
----- | ||
|
||
```html | ||
<selfclosing | ||
id="hello" | ||
class="world" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
/> | ||
``` | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Attribute Position: Auto | ||
Bracket same line: true | ||
Whitespace sensitivity: strict | ||
Indent script and style: false | ||
----- | ||
|
||
```html | ||
<selfclosing | ||
id="hello" | ||
class="world" | ||
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" /> | ||
``` |
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.
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.
If we need to follow the spec, self closing elements don't exist in HTML. Perhaps we can add another case
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.
Self closing elements technically do exist, they are called "void elements" in the spec, and they are defined as elements that have no children, and therefore do not have a closing tag. Syntactically, they do not need the
/
and it is ignored by browsers. Prettier always adds the/
for void elements.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.
That's something we might want to discuss later, but I was thinking of diverging from Prettier and not adding the slash at the end. Maybe we could consider an option in case users want to add them