Skip to content

🐛 Multi-line comments in Astro frontmatter can cause false positives #8882

@Boston343

Description

@Boston343

Environment information

I am developing in Antigravity on Windows 11.

Details
CLI:
  Version:                      2.3.12
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           v24.11.1
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.jsonc
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true
  HTML full support enabled:    true

Workspace:
  Open Documents:               0

What happened?

Issue I came across trying out biome in an astro project related to multi-line comments in the astro frontmatter.

If you have a multi line comment like the below, that contains something that could be a string opener (without a closer to match) then the rest of the file will show a bunch of errors:

---
/**
 * In this comment, if you add any string opening or closing, such as an apostrophy, the file will show 
 * a bunch of errors. Doesn't (remove the apostrophy in the previous word to fix) that stink? 
 */
import type { HTMLAttributes } from "astro/types";

type Props = HTMLAttributes<"div">;

const { class: className, ...rest } = Astro.props;
---

<div
  class="some-classes"
  data-state="closed"
  style="animation: none;"
  data-slot="accordion-content"
  {...rest}
>
  <div class="pt-0 pb-4">
    <slot />
  </div>
</div>

playground demo

Expected result

This should not cause errors, as anything in a comment should be valid and not interfere with later parsing.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions