Repository navigation
📝 Astro comments aren't correctly recognized #8294
Copy link
Copy link
Labels
L-HTMLLanguage: HTML and super languagesLanguage: HTML and super languagesS-EnhancementStatus: Improve an existing featureStatus: Improve an existing featureS-Has workaroundStatus: has a workaround, so users can still work with the bugStatus: has a workaround, so users can still work with the bug
Description
Environment information
CLI:
Version: 2.3.7
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.4.1
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: unset
Biome Configuration:
Status: Loaded successfully
Path: biome.json
Formatter enabled: true
Linter enabled: true
Assist enabled: true
VCS enabled: true
Formatter:
Format with errors: unset
Indent style: Space
Indent width: unset
Line ending: unset
Line width: 100
Attribute position: unset
Bracket spacing: unset
Includes: unset
JavaScript Formatter:
Enabled: unset
JSX quote style: unset
Quote properties: unset
Trailing commas: unset
Semicolons: As needed
Arrow parentheses: unset
Bracket spacing: unset
Bracket same line: true
Quote style: Double Quotes
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Attribute position: unset
JSON Formatter:
Enabled: unset
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Trailing Commas: unset
Expand lists: unset
CSS Formatter:
Enabled: unset
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Quote style: unset
GraphQL Formatter:
Enabled: unset
Indent style: unset
Indent width: unset
Line ending: unset
Line width: unset
Bracket spacing: unset
Quote style: unset
Workspace:
Open Documents: 0Configuration
Playground link
Code of Conduct
- I agree to follow Biome's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
L-HTMLLanguage: HTML and super languagesLanguage: HTML and super languagesS-EnhancementStatus: Improve an existing featureStatus: Improve an existing featureS-Has workaroundStatus: has a workaround, so users can still work with the bugStatus: has a workaround, so users can still work with the bug
Activity
ematipico commentedon Nov 27, 2025
That's an unfortunate thing about Astro. I'm not very keen on supporting two types of comments. As for now, I'd say we should focus on HTML comments
dhruvkb commentedon Dec 1, 2025
The behaviours of the two different kinds of comments are different. HTML style comments
<!-- ... -->are present in the DOM but JS style comments{/* ... */}are not. It would be really nice if they could be supported (or at the very least, recognised as valid syntax).ematipico commentedon Dec 1, 2025
I don't understand why you talk about behaviour, comments are comments, they have the same semantics; and I know about the two kinds of comments: when inside an expression, Astro switches to JSX-like syntax.
The huge hole is that there's no rule or standard when it comes to comments inside an expression
You might answer both, but then we aren't parsing JSX-like anymore, but something else, which doesn't have a standard even in the Astro website.
dyc3 commentedon Dec 2, 2025
@ematipico On the page that he linked it says:
Which means that the two comment styles have different behavior.
Regarding comments inside expressions like that, for the duration of the embedded expression we have to switch to the javascript parser (which also could be jsx enabled), where html comments
<!-- foo -->are invalid, and/* foo */is valid. It's not standardized, but that's how the tools behave (at least some of them).ematipico commentedon Dec 2, 2025
But we don't do any transformation, so whether the Astro compiler decides to remove them or not, it doesn't concern us because, and a suppression comment of Biome could be used both ways.
Am I missing something?
dyc3 commentedon Dec 4, 2025
If we don't treat it like trivia, then suppression comments won't work at all. Do we have tests for it yet? I don't recall seeing any during reviews.
ematipico commentedon Dec 4, 2025
No we don't have tests, and we don't parse them yet.
cworld1 commentedon Dec 24, 2025
I need this also. Is there any method to temporary disable this error msg?
Boston343 commentedon Jan 26, 2026
Potential related issue I just came across trying this out in an astro project related to multi-line comments in the astro frontmatter.
If you have a multi line comment like the below, then the rest of the file will show a bunch of errors:
playground demo
dyc3 commentedon Jan 26, 2026
@Boston343 That sounds like a different issue. Can you file a new issue for it?
tomkel commentedon Feb 17, 2026
I'm using JS-style comments in Astro, in order to control eslint like so:
It's a parsing error in biome.
The astro docs present a valid use case: for comments that you want removed from the final build.
astrochemx commentedon Feb 20, 2026
Starting in Biome
2.4.0, Astro files fail to parse when a template expression block is empty ({ }) or contains only a comment ({ /* comment */ }). The parser throws the error:Expected a valid expression in template syntax. This suggests the parser no longer considers a comment to be a valid inhabitant of a template expression block. This was working correctly in2.3.15and earlier versions, so this appears to be a regression.My use case:
Example Biome Output
Temporary Workaround
For those affected by this regression, you can bypass the
parseerror by moving the comment/suppression inside a dynamic attribute expression. This satisfies the parser's requirement for a "valid expression" while still keeping the comment on the relevant line:Playground Link
UPD. Created a separate issue #9165.
Update dependency @biomejs/biome to v2.5.10 (#19)
Update dependency @biomejs/biome to v2.5.10 (#39)