Skip to content

fix(js): parse short hand identifier in Astro JSX files#9846

Merged
ematipico merged 5 commits intomainfrom
fix/astro-shorthand-props-parsing
Apr 8, 2026
Merged

fix(js): parse short hand identifier in Astro JSX files#9846
ematipico merged 5 commits intomainfrom
fix/astro-shorthand-props-parsing

Conversation

@ematipico
Copy link
Copy Markdown
Member

Summary

Closes #9140

Fixed with AI agent.

Test Plan

Added new tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 3e90593

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages L-Grit Language: GritQL labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53178 53178 0
Passed 51958 51958 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.71% 97.71% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 38 38 0
Passed 37 37 0
Failed 1 1 0
Panics 0 0 0
Coverage 97.37% 97.37% 0.00%

markdown/commonmark

Test result main count This PR count Difference
Total 652 652 0
Passed 652 652 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5467 5467 0
Passed 1915 1915 0
Failed 3552 3552 0
Panics 0 0 0
Coverage 35.03% 35.03% 0.00%

ts/babel

Test result main count This PR count Difference
Total 640 640 0
Passed 569 569 0
Failed 71 71 0
Panics 0 0 0
Coverage 88.91% 88.91% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18876 18876 0
Passed 13014 13014 0
Failed 5861 5861 0
Panics 1 1 0
Coverage 68.94% 68.94% 0.00%

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 196 skipped benchmarks1


Comparing fix/astro-shorthand-props-parsing (3e90593) with main (616ee2e)

Open in CodSpeed

Footnotes

  1. 196 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9093dbb9-ab00-4701-ba47-950a7e4e2a25

📥 Commits

Reviewing files that changed from the base of the PR and between 5c4197d and 3e90593.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/a11y/no_label_without_control.rs

Walkthrough

This PR introduces an AST node and end-to-end support for Astro-only JSX shorthand attributes ({ident}). Changes add JsxShorthandAttribute to the grammar and node kinds, extend the parser to recognise { identifier } inside .astro embeddings, add formatter rules and formatter wiring, and update analyzer/lint/assist logic to treat shorthand attributes alongside spread attributes. Tests (parser and workspace regression) ensure shorthand attrs parse in .astro files and are rejected outside Astro contexts.

Possibly related PRs

Suggested reviewers

  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: adding support for parsing Astro shorthand JSX attributes (e.g., {title}).
Description check ✅ Passed The PR description is related to the changeset, referencing issue #9140 and indicating tests were added, though it's minimal.
Linked Issues check ✅ Passed The PR fully addresses issue #9140 by implementing parser support for Astro shorthand attributes and adding comprehensive test coverage to validate the fix.
Out of Scope Changes check ✅ Passed All changes are within scope: parser updates, formatter support, lint rule adjustments, grammar definitions, and test cases directly address the shorthand attribute parsing issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/astro-shorthand-props-parsing

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/icy-views-melt.md:
- Line 5: The changeset sentence "Fixed
[`#9140`](https://github.com/biomejs/biome/issues/9140): Biome now parses Astro's
attribute shorthand inside `.astro` files. The following snippet no longer
reports a parse error:" must end with a full stop; update that line in
.changeset/icy-views-melt.md by replacing the trailing colon ":" with a period
"." so the sentence ends with a full stop.

In `@crates/biome_js_analyze/src/lint/a11y/no_label_without_control.rs`:
- Around line 286-288: The current match arm unconditionally returns false for
AnyJsxAttribute::JsxShorthandAttribute, which causes valid shorthand attributes
like <label {htmlFor}> to be treated as unassociated; update the logic in the
association-detection function (the match handling
AnyJsxAttribute::JsxShorthandAttribute) to inspect the shorthand's
identifier/name rather than blanket-failing: if the shorthand identifier is
"htmlFor" (and optionally "for" depending on supported syntaxes) treat it as an
associated control (do not return false), otherwise continue to handle other
shorthand cases as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d9a9d38a-d83d-480c-95ce-ca035399ae05

📥 Commits

Reviewing files that changed from the base of the PR and between 616ee2e and 63f63bb.

⛔ Files ignored due to path filters (7)
  • crates/biome_js_factory/src/generated/node_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_js_factory/src/generated/syntax_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_js_parser/tests/js_test_suite/error/jsx_shorthand_attribute_outside_astro.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_syntax/src/generated/kind.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_js_syntax/src/generated/macros.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_js_syntax/src/generated/nodes.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_js_syntax/src/generated/nodes_mut.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (15)
  • .changeset/icy-views-melt.md
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
  • crates/biome_js_analyze/src/assist/source/use_sorted_attributes.rs
  • crates/biome_js_analyze/src/lint/a11y/no_label_without_control.rs
  • crates/biome_js_analyze/src/lint/performance/use_google_font_preconnect.rs
  • crates/biome_js_formatter/src/generated.rs
  • crates/biome_js_formatter/src/jsx/any/attribute.rs
  • crates/biome_js_formatter/src/jsx/attribute/mod.rs
  • crates/biome_js_formatter/src/jsx/attribute/shorthand_attribute.rs
  • crates/biome_js_formatter/src/jsx/tag/opening_element.rs
  • crates/biome_js_parser/src/syntax/jsx/mod.rs
  • crates/biome_js_parser/tests/js_test_suite/error/jsx_shorthand_attribute_outside_astro.jsx
  • crates/biome_service/src/workspace/server.tests.rs
  • xtask/codegen/js.ungram
  • xtask/codegen/src/js_kinds_src.rs

Comment thread .changeset/icy-views-melt.md
Comment thread crates/biome_js_analyze/src/lint/a11y/no_label_without_control.rs Outdated
@ematipico ematipico requested review from a team April 7, 2026 13:16
Comment thread crates/biome_js_parser/src/syntax/jsx/mod.rs
Comment thread crates/biome_js_parser/src/syntax/jsx/mod.rs Outdated
@ematipico ematipico requested a review from dyc3 April 7, 2026 16:37
@ematipico ematipico merged commit b7134d9 into main Apr 8, 2026
17 of 20 checks passed
@ematipico ematipico deleted the fix/astro-shorthand-props-parsing branch April 8, 2026 06:45
@github-actions github-actions bot mentioned this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Project Area: project A-Tooling Area: internal tools L-Grit Language: GritQL L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Astro: parsing fails for shorthand props ({title}) when inside expression

2 participants