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

feat(css_parser): allow multiple semicolons after declaration #4315

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

fireairforce
Copy link
Member

@fireairforce fireairforce commented Oct 17, 2024

Summary

closes: #3836

I introduce a new syntax for css parser which named CSS_EMPTY_DECLARATION, you can see it at my change at css.ungram, the CSS_EMPTY_DECLARATION just use to deal the multiple ; at CSS_DECLARATION_LIST which like JS parser's JS_EMPTY_STATEMENTS:

let a = 1;;;;;

image

Test Plan

I add test case for biome_css_parser like:

.a {
  color: red;;;;
  color: blue;
}

And update some test case of biome_css_formatter.

@github-actions github-actions bot added A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS labels Oct 17, 2024
@fireairforce fireairforce changed the title feat(biome_css_parser): parser should recognize multiple semicolons a… feat(biome_css_parser): recognize multiple semicolons after declaretion Oct 17, 2024
@github-actions github-actions bot added the A-Formatter Area: formatter label Oct 22, 2024
@fireairforce fireairforce marked this pull request as ready for review October 22, 2024 03:40
@fireairforce fireairforce changed the title feat(biome_css_parser): recognize multiple semicolons after declaretion feat(biome_css_parser): recognize multiple semicolons after declaration Oct 22, 2024
Copy link

codspeed-hq bot commented Oct 22, 2024

CodSpeed Performance Report

Merging #4315 will not alter performance

Comparing fireairforce:fix-3836 (26e7fa8) with main (d59d43d)

Summary

✅ 101 untouched benchmarks

@fireairforce
Copy link
Member Author

this mr is ready for review~

@ematipico
Copy link
Member

A couple of things:

@fireairforce
Copy link
Member Author

fireairforce commented Oct 22, 2024

ok, i will update the template later. i try to update the css.ungram like:

CssDeclarationWithSemicolon =
    declaration: CssDeclaration
    ';'*

But it will get an panic like:

image

And I've looked elsewhere and haven't seen similar writing methods. So i refer the statement JS_EMPTY_STAMENT of js parser and add a CSS_EMPTY_DECLARATION here.

@fireairforce fireairforce changed the title feat(biome_css_parser): recognize multiple semicolons after declaration feat(css_parser): parser multiple semicolons after declaration Oct 22, 2024
@github-actions github-actions bot added the A-Changelog Area: changelog label Oct 22, 2024
@fireairforce fireairforce changed the title feat(css_parser): parser multiple semicolons after declaration feat(css_parser): allow multiple semicolons after declaration Oct 22, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

One thing missing, then we can merge it

#[inline]
fn is_at_declaration_important(p: &mut CssParser) -> bool {
p.at(T![!]) && p.nth_at(1, T![important])
}

#[inline]
pub(crate) fn is_at_declaration_semion(p: &mut CssParser) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

Is this a typo? What does "semion" mean?

Copy link
Member Author

@fireairforce fireairforce Oct 23, 2024

Choose a reason for hiding this comment

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

yes, a typo, semicolon here, i will update later

pub(crate) struct FormatCssEmptyDeclaration;
impl FormatNodeRule<CssEmptyDeclaration> for FormatCssEmptyDeclaration {
fn fmt_fields(&self, node: &CssEmptyDeclaration, f: &mut CssFormatter) -> FormatResult<()> {
format_verbatim_node(node.syntax()).fmt(f)
Copy link
Member

Choose a reason for hiding this comment

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

This must be implemented

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, i forget here, i implement this method and add a test case for this at declaration.css test file

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Amazing work @fireairforce, thank you very much for this contribution! ❤️

@ematipico ematipico merged commit 19abdcf into biomejs:main Oct 23, 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 A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 CSS parser does not recognize multiple semicolons after a declaration
2 participants