Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hirokiokada77
Copy link
Contributor

Summary

This PR updates the GritQL pattern name mapping logic in xtask/codegen/src/generate_grit_mappings.rs to properly handle name and value metavariables for JsxAttribute GritQL queries.

The following biome search command no longer throws an error:

biome search 'JsxAttribute($name, $value) as $attr where { $name <: "style" }'

Closes #8079.

Test Plan

Added:

  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.snap
  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx
  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit

@changeset-bot
Copy link

changeset-bot bot commented Nov 21, 2025

🦋 Changeset detected

Latest commit: 3ee20d5

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-Tooling Area: internal tools L-Grit Language: GritQL labels Nov 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

This change fixes a GritQL pattern matching issue for JSX attributes. The PR updates the jsx_attribute entry in the legacy TreeSitter compatibility patterns to define explicit slot mappings for "name" and "value" fields. Previously, the pattern had empty slot definitions, causing queries that attempted to match JSX attributes by name to fail. The fix includes updates to the mappings generator, test specifications in both GritQL and TSX formats, and a changelog entry documenting the patch release.

Possibly related PRs

Suggested labels

L-Grit, A-Tooling, L-JavaScript

Suggested reviewers

  • arendjr

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the core change: fixing JsxAttribute metavariable handling in GritQL queries.
Description check ✅ Passed The description clearly explains the fix, includes the previously failing command, mentions issue closure, and lists test additions.
Linked Issues check ✅ Passed The PR directly addresses issue #8079 by enabling the previously erroring GritQL query to execute without error through proper slot mapping for JsxAttribute.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing JsxAttribute GritQL query handling: mapping updates, codegen modifications, and corresponding tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5dd20 and 3ee20d5.

⛔ Files ignored due to path filters (1)
  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/wicked-bushes-scream.md (1 hunks)
  • crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1 hunks)
  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit (1 hunks)
  • crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx (1 hunks)
  • xtask/codegen/src/generate_grit_mappings.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Test Node.js API
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: Parser conformance
🔇 Additional comments (5)
.changeset/wicked-bushes-scream.md (1)

1-11: LGTM! Clear and helpful changelog entry.

The changeset properly documents the fix with a clear example of the command that now works.

crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)

130-130: Correct slot mappings for jsx_attribute.

This generated file properly reflects the codegen changes. The slot mappings now enable $name and $value metavariables to resolve correctly in GritQL queries.

xtask/codegen/src/generate_grit_mappings.rs (1)

278-278: Excellent fix! The slot mappings enable proper metavariable resolution.

The slot indices map name to position 0 and value to position 1, which aligns with the JSX attribute AST structure. Since the PR description confirms the previously failing command now works, this validates the correctness of the mapping.

crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx (1)

1-1: Perfect test case.

Simple JSX element with a style attribute that validates the fix for matching JSX attributes by name.

crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit (1)

1-3: Spot on! This test validates the exact fix.

This pattern matches the failing query from issue #8079. The constraint on $name confirms that the slot mappings now properly resolve the name metavariable for JSX attributes.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

That's great, thank you!

@ematipico ematipico added this pull request to the merge queue Nov 21, 2025
Merged via the queue into biomejs:main with commit 6f49d95 Nov 21, 2025
14 checks passed
@github-actions github-actions bot mentioned this pull request Nov 21, 2025
@hirokiokada77 hirokiokada77 deleted the fix/gritql-jsx-attribute-metavariables branch November 21, 2025 16:29
ryan-m-walker pushed a commit to ryan-m-walker/biome that referenced this pull request Nov 23, 2025
@github-actions github-actions bot mentioned this pull request Nov 25, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Tooling Area: internal tools L-Grit Language: GritQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 grit: Cant match jsx attribute by name

2 participants