Skip to content

Commit 3ee20d5

Browse files
author
Hiroki Okada
committed
fix(biome_grit_patterns): properly handle name and value metavariables for JsxAttribute GritQL queries
Fixes #8079.
1 parent c738a1c commit 3ee20d5

6 files changed

Lines changed: 29 additions & 2 deletions

File tree

.changeset/wicked-bushes-scream.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#8079](https://github.com/biomejs/biome/issues/8079): Properly handle `name` and `value` metavariables for `JsxAttribute` GritQL queries.
6+
7+
The following `biome search` command no longer throws an error:
8+
9+
```
10+
biome search 'JsxAttribute($name, $value) as $attr where { $name <: "style" }'
11+
```

crates/biome_grit_patterns/src/grit_target_language/js_target_language/generated_mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub const LEGACY_TREESITTER_COMPATIBILITY_PATTERNS: &[LegacyTreeSitterPattern] =
127127
LegacyTreeSitterPattern {
128128
name: "jsx_attribute",
129129
kind: JsSyntaxKind::JSX_ATTRIBUTE,
130-
slots: &[],
130+
slots: &[("name", 0), ("value", 1)],
131131
},
132132
LegacyTreeSitterPattern {
133133
name: "jsx_element",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
JsxAttribute($name, $value) as $attr where {
2+
$name <: "style"
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: crates/biome_grit_patterns/tests/spec_tests.rs
3+
expression: jsx_attributes
4+
---
5+
SnapshotResult {
6+
messages: [],
7+
matched_ranges: [
8+
"1:6-1:16",
9+
],
10+
rewritten_files: [],
11+
created_files: [],
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div style={{}}>{children}</div>;

xtask/codegen/src/generate_grit_mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const JS_TREESITTER_PATTERNS: &[TreeSitterPattern] = &[
275275
TreeSitterPattern {
276276
name: "jsx_attribute",
277277
biome_kind: "JSX_ATTRIBUTE",
278-
slots: &[],
278+
slots: &[("name", 0), ("value", 1)],
279279
},
280280
TreeSitterPattern {
281281
name: "jsx_element",

0 commit comments

Comments
 (0)