biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.22k stars 440 forks source link

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

Open blutorange opened 1 week ago

blutorange commented 1 week ago

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

h-a-n-a commented 1 week ago

I would be happy to help!

chansuke commented 1 week ago

@h-a-n-a go ahead💪