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): keep @charset double quote in single quote config #4404

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

fireairforce
Copy link
Member

@fireairforce fireairforce commented Oct 28, 2024

Summary

closes: #4384

@charset must always have double quotes: https://www.w3.org/TR/css-syntax-3/#determine-the-fallback-encoding

I add a param StringLiteralParentKind for impl FormatLiteralStringToken to judge if the CSS String's parent is a CSS_CHARSET_AT_RULE which represents the syntax like:@charset, i refer the same util at biome_js_formatter.

if the string is StringLiteralParentKind::CharsetAtRule, i will use the double quote for the string in any case, or we will execute the normal logic of biome_css_formatter.

Test Plan

Test case as follows:

@charset·"UTF-8";
@charset "iso-8859-15";
@charset "any-string-is-okay";

@github-actions github-actions bot added A-Formatter Area: formatter L-CSS Language: CSS labels Oct 28, 2024
@fireairforce fireairforce marked this pull request as ready for review October 28, 2024 06:11
Copy link

codspeed-hq bot commented Oct 28, 2024

CodSpeed Performance Report

Merging #4404 will not alter performance

Comparing fireairforce:fix-4384 (97e64a8) with main (3530f2f)

Summary

✅ 99 untouched benchmarks

@@ -158,6 +158,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
#### Bug fixes

- Fix [#4121](https://github.com/biomejs/biome/issues/4121). Respect line width when printing multiline strings. Contributed by @ah-yu
- Fix [#4384](https://github.com/biomejs/biome/issues/4384). Keep `@charset` dobule quote under any situation for css syntax rule. Contributed by @fireairforce
Copy link
Member Author

Choose a reason for hiding this comment

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

@ematipico here is my changelog, lol

@ematipico ematipico merged commit 044baf4 into biomejs:main Oct 30, 2024
13 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.

📝 css formatter adds single quotes on @charset
2 participants