Skip to content

🐛 parse: Parse error in tailwind @variant syntax #8269

Description

@jbergstroem

Environment information

CLI:
  Version:                      2.3.7
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         xterm-ghostty
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         /path/to/repo/biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

..using:

{
  "css": {
    "parser": {
      "tailwindDirectives": true
    }
  }
}

What happened?

Biome complains about parsing the following syntax which tailwind has no problems consuming:

@utility container {
  padding-inline: 1rem;
  margin-inline: auto;

  @variant 2xl {
    max-width: 1400px;
  }
}
preset.css:72:13 lint/correctness/noUnknownTypeSelector ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Unknown type selector is not allowed.

    70 │   margin-inline: auto;
    71 │
  > 72 │   @variant 2xl {
       │             ^^
    73 │     max-width: 1400px;
    74 │   }

  ℹ See MDN web docs for more details.

  ℹ Consider replacing the unknown type selector with valid one.

I'm guessing it fails because css variables cannot start with a digit (if I remember correctly) - but this seems to be pretty common: https://github.com/search?type=code&q=%22%40variant+2xl+%7B%22

Expected result

Biome should accept this syntax given its widespread use and acceptance by the tailwind parser.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ParserArea: parserL-CSSLanguage: CSS and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions