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

fix(css_formatter): don't indent CSS selector when leading comments before #4392

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

fireairforce
Copy link
Member

@fireairforce fireairforce commented Oct 26, 2024

Summary

closes: #4326

I add special judge for that case:

.a {
  /* hi */
  a,
  /* me */
 div {
   color: red;
  }
}

If i get a CSS_Type_Selector like: /* hi */\n a,\n div(you can refer this from above case), i will not add an ident for this to avoid this case, the previous logic at biome_css_formatter will add an ident for this case by default.

Test Plan

add test case like:

.with-comments {
  /* hello */
  a,
  /* world */
  button {
    color: blue;
  }
}

.without-comments {
  a,
  button {
    color: blue;
  }
}

my fix as follows:

.with-comments {
  /* hello */
  a,
  /* world */
-    button {
+  button{
    color: blue;
  }
}

@github-actions github-actions bot added A-Formatter Area: formatter L-CSS Language: CSS labels Oct 26, 2024
@fireairforce fireairforce marked this pull request as ready for review October 26, 2024 12:55
@github-actions github-actions bot added the A-Changelog Area: changelog label Oct 26, 2024
Copy link

codspeed-hq bot commented Oct 26, 2024

CodSpeed Performance Report

Merging #4392 will not alter performance

Comparing fireairforce:fix-4326 (4678a23) with main (3401663)

Summary

✅ 99 untouched benchmarks

CHANGELOG.md Outdated
@@ -28,6 +28,10 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

### Formatter

### Bug fixes

- Fix [#4121](https://github.com/biomejs/biome/issues/4326), don't ident css selector when comments before. Contributed by @fireairforce
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Fix [#4121](https://github.com/biomejs/biome/issues/4326), don't ident css selector when comments before. Contributed by @fireairforce
- Fix [#4121](https://github.com/biomejs/biome/issues/4326), don't ident CSS selector when comments before. Contributed by @fireairforce

You need to add something after the word "before" because, as is, it's incomplete

Copy link
Member Author

Choose a reason for hiding this comment

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

done~ updated the changelog

@fireairforce fireairforce force-pushed the fix-4326 branch 3 times, most recently from 4bf2149 to 307a50a Compare October 31, 2024 02:32
crates/biome_css_formatter/tests/quick_test.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@ematipico ematipico changed the title fix(css_formatter): don't ident css selector when comments before fix(css_formatter): don't indent CSS selector when leading comments before Oct 31, 2024
@ematipico ematipico merged commit 9089e7d into biomejs:main Oct 31, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Formatter Area: formatter L-CSS Language: CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📝 Comments throw off CSS indentation
2 participants