-
-
Notifications
You must be signed in to change notification settings - Fork 794
fix(grit): correct JSX element slot indices for GritQL patterns #8411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 10b472a The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
WalkthroughAdds explicit slot mappings for legacy Tree-sitter JSX patterns: Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (7)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.tsx📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (6)📚 Learning: 2025-11-28T09:08:10.091ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-12-04T13:29:49.287ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
🧬 Code graph analysis (1)crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.tsx (1)
⏰ 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)
🔇 Additional comments (3)
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. Comment |
58c344e to
4b170a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.changeset/fix-jsx-slot-indices.md (2)
5-5: Use past tense for the description.Per coding guidelines, describe what was done using past tense. Change "Fix" to "Fixes" or "Fixed".
-Fix incorrect slot indices for JSX elements in GritQL patterns. +Fixes incorrect slot indices for JSX elements in GritQL patterns.
9-9: Slight redundancy with "adds...and adds".Consider rephrasing to avoid the repeated verb.
-Also adds the missing `type_arguments` slot and adds slots for `JSX_ATTRIBUTE` (`name` and `initializer`). +Adds the missing `type_arguments` slot and slots for `JSX_ATTRIBUTE` (`name` and `initializer`).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.changeset/fix-jsx-slot-indices.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets for user-facing changes usingjust new-changeset; use headers with####or#####only; keep descriptions concise (1-3 sentences) and focus on user-facing changes
Use past tense when describing what was done ('Added new feature'), present tense when describing Biome behavior ('Biome now supports'); end sentences with a full stop
For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use adiffcode block
Files:
.changeset/fix-jsx-slot-indices.md
🪛 LanguageTool
.changeset/fix-jsx-slot-indices.md
[grammar] ~7-~7: Did you mean “indexed”?
Context: ...rectly mapped to index 2, but should be index 3 (after type_arguments at index 2). ...
(SHOULD_BE_DO)
⏰ 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). (2)
- GitHub Check: Test Node.js API
- GitHub Check: autofix
4b170a4 to
66aa190
Compare
|
Hi! I'm I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit (1)
3-14: Consider aligning legacy and native pattern tests.The legacy and native patterns test slightly different element/attribute names ("span" vs "button", "className" vs "id"). Whilst this doesn't affect correctness, aligning them would make the parallel structure clearer.
Also note that
type_argumentsis only tested forjsx_self_closing_element(line 6) but not forjsx_opening_element. If opening elements can have type arguments, consider adding that test case as well.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.snapis excluded by!**/*.snapand included by**crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (5)
.changeset/fix-jsx-slot-indices.md(1 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit(0 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx(0 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit(1 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.tsx(1 hunks)
💤 Files with no reviewable changes (2)
- crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx
- crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/fix-jsx-slot-indices.md
- crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.tsx
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to **/*.tsx : For Node.js package development, build WebAssembly bindings and JSON-RPC bindings; run tests against compiled files after implementing features or bug fixes
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.{js,ts,tsx,jsx,json,css} : Test rules using snapshot tests via the `insta` library with test cases in `tests/specs/<group>/<rule_name>/` directories prefixed by `invalid` or `valid`
Applied to files:
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.jsonc : Use `.jsonc` files in test specs with code snippets as array of strings to test rules in script environment (no import/export syntax)
Applied to files:
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit
📚 Learning: 2025-11-28T09:08:10.091Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to **/*.tsx : For Node.js package development, build WebAssembly bindings and JSON-RPC bindings; run tests against compiled files after implementing features or bug fixes
Applied to files:
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Applied to files:
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit
⏰ 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). (8)
- GitHub Check: Documentation
- GitHub Check: Check Dependencies
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: End-to-end tests
- GitHub Check: Test Node.js API
🔇 Additional comments (1)
crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit (1)
1-15: Verify test coverage for theattributesslot.The PR objectives mention adding
name,type_arguments, andattributesslots, but I don't see an explicit test for theattributesslot (e.g.,jsx_opening_element(attributes = ...)orjsx_self_closing_element(attributes = ...)). Lines 5 and 11-14 test individual attributes viajsx_attributepatterns, but not theattributesslot directly.Please confirm whether the
attributesslot requires explicit testing, or if the current attribute pattern tests are sufficient. If needed, consider adding patterns like:jsx_opening_element(attributes = $attrs)Additionally, verify that all added slots have corresponding test coverage before merging.
dyc3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually change any behavior, it just changes tests.
Sorry, was rebasing local branch and the actual fix got lost. Updated now. |
2e5594a to
831c33e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
xtask/codegen/src/generate_grit_mappings.rs (1)
286-294: JSX TreeSitter slot indices are consistent with generated mappingsThe added
slotsfor the JSX self‑closing/opening patterns match the generatedLegacyTreeSitterPatternentries and keep legacy vs native mappings in sync, so GritQL slot filters should now work as expected. If you’re ever bored, a tiny comment somewhere noting that1=name,2=type_arguments,3=attributescome from the TreeSitter child order would save future archaeology—but that’s strictly optional.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.snapis excluded by!**/*.snapand included by**crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (7)
.changeset/fix-jsx-slot-indices.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(0 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx(0 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit(1 hunks)crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.tsx(1 hunks)xtask/codegen/src/generate_grit_mappings.rs(1 hunks)
💤 Files with no reviewable changes (2)
- crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.grit
- crates/biome_grit_patterns/tests/specs/tsx/jsx_attributes.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.grit
- crates/biome_grit_patterns/tests/specs/tsx/jsx_slots.tsx
- .changeset/fix-jsx-slot-indices.md
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust format) to format Rust and TOML files before committing
Files:
xtask/codegen/src/generate_grit_mappings.rscrates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
🧠 Learnings (8)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Applied to files:
xtask/codegen/src/generate_grit_mappings.rscrates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)
Applied to files:
xtask/codegen/src/generate_grit_mappings.rscrates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Set the `language` field in `declare_lint_rule!` to the primary language (js for JavaScript, jsx for JSX, ts for TypeScript, tsx for TSX) that the rule applies to
Applied to files:
xtask/codegen/src/generate_grit_mappings.rscrates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead
Applied to files:
xtask/codegen/src/generate_grit_mappings.rscrates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced
Applied to files:
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance
Applied to files:
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding
Applied to files:
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs
⏰ 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). (10)
- GitHub Check: End-to-end tests
- GitHub Check: Documentation
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: autofix
- GitHub Check: Parser conformance
- GitHub Check: Test Node.js API
🔇 Additional comments (1)
crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs (1)
138-146: Legacy JSX slots now wired correctlyThe new
slotsentries for the legacy JSX self‑closing/opening elements line up with the generator definitions and will make queries likejsx_self_closing_element(name = "div")andjsx_opening_element(name = "div")behave as advertised. Nothing to nitpick here.
Add name, type_arguments, and attributes slots for jsx_self_closing_element and jsx_opening_element patterns. This enables patterns like: jsx_self_closing_element(name = "div") jsx_opening_element(type_arguments = TsTypeArguments()) Consolidates jsx_attributes test into jsx_slots test.
831c33e to
10b472a
Compare
…ejs#8411) Co-authored-by: ematipico <[email protected]> Co-authored-by: dyc3 <[email protected]>
Add missing slots for JSX element patterns in GritQL.
The
jsx_self_closing_elementandjsx_opening_elementpatterns were missing slot definitions, preventing patterns likejsx_self_closing_element(name = "div")from working.Changes
name,type_arguments, andattributesslots forjsx_self_closing_elementname,type_arguments, andattributesslots forjsx_opening_elementjsx_attributestest intojsx_slotstest