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

🐛 CSS parser does not recognize multiple semicolons after a declaration #3836

Closed
1 task done
blutorange opened this issue Sep 9, 2024 · 4 comments · Fixed by #4315
Closed
1 task done

🐛 CSS parser does not recognize multiple semicolons after a declaration #3836

blutorange opened this issue Sep 9, 2024 · 4 comments · Fixed by #4315
Labels
A-Formatter Area: formatter L-CSS Language: CSS S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@blutorange
Copy link

blutorange commented Sep 9, 2024

Environment information

CLI:
  Version:                      1.8.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.19.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/4.4.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

Biome's CSS parser raises a parser error when a CSS declaration ends with multiple semicolons, e.g.

.foo {
  color: red;;
}

Sorry if it was reported already, but I couldn't find an issue for that.

Expected result

The CSS file parses correctly. The formatter could simply remove multiple semicolons. This is what prettier does

image

More info

For some context: One of my colleagues use IntelliJ to author a CSS file, and it did not show any errors. During the pre-commit hook, when biome was called to format the CSS file, it reported a syntax error in the CSS file. Took him some time to find the issue. It turned out the issue was that a declaration in the CSS file had 2 semicolons at the (;)

I took a look at the CSS specification. If I understand it correctly, CSS syntax 3, 5.4.5, Consume a list of declarations allows for multiple semicolons:

Repeatedly consume the next input token
  <semicolon-token>
    Do nothing.

Various other tools such as IntelliJ, VSCode or https://jigsaw.w3.org/css-validator/validator also accept multiple semicolons. Biome however produces a parser error (tested with 1.8.3)

image

According to this comment here in declaration_or_rule_list_block.rs, the parser only seems to consider a single semicolon for now.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added A-Formatter Area: formatter L-CSS Language: CSS S-Bug-confirmed Status: report has been confirmed as a valid bug labels Sep 9, 2024
@h-a-n-a
Copy link
Contributor

h-a-n-a commented Sep 9, 2024

I would be happy to help!

@chansuke chansuke assigned chansuke and h-a-n-a and unassigned chansuke Sep 9, 2024
@chansuke
Copy link
Member

chansuke commented Sep 9, 2024

@h-a-n-a
go ahead💪

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Oct 10, 2024

Sorry. I'm a little bit busy in these days and I cannot handle this at the moment. I have to unassign ;-(.
I'm still happy to help biome issues when I'm free in the future.
cc @chansuke

@denbezrukov
Copy link
Contributor

I guess we can modify CssDeclarationWithSemicolon if we want to support it

CssDeclarationWithSemicolon =
    declaration: CssDeclaration
    ';'*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-CSS Language: CSS S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants