Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/content/docs/reference/gritql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,21 @@ JsIfStatement() as $stmt where {
}
```

You can discover node names for your code by exploring the syntax tree in the [Biome Playground](https://biomejs.dev/playground/). A complete list of all available nodes is also available in the `.ungram` files in the [`xtask/codegen`](https://github.com/biomejs/biome/tree/main/xtask/codegen) directory of the Biome repository.
You can also match specific parts of a node by name. For example, this pattern captures the first branch of a ternary expression using Biome's node field names:

```grit
JsConditionalExpression(consequent = $cons) where {
register_diagnostic(
span=$cons,
message="Found the consequent branch of a conditional expression"
)
}
```

You can discover node names and field names for your code by exploring the syntax tree in the [Biome Playground](https://biomejs.dev/playground/). A complete list of all available nodes and their fields is also available in the `.ungram` files in the [`xtask/codegen`](https://github.com/biomejs/biome/tree/main/xtask/codegen) directory of the Biome repository.

:::caution
Biome's grammar can change between versions, especially for new languages. This may cause node names to change, which could break your patterns. Be prepared to update your queries when upgrading Biome.
Biome's grammar can change between versions, especially for new languages. This may cause node names to change, which could break your patterns. Be prepared to update your queries when upgrading Biome when using node/field names in your patterns.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Tiny wording polish for readability.

Line 139 reads a bit repetitive (“when ... when ...”). A small rewrite would scan better for readers.

✍️ Suggested edit
-Biome's grammar can change between versions, especially for new languages. This may cause node names to change, which could break your patterns. Be prepared to update your queries when upgrading Biome when using node/field names in your patterns.
+Biome's grammar can change between versions, especially for new languages. This may cause node or field names to change, which could break your patterns. If your queries rely on node/field names, be prepared to update them when upgrading Biome.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Biome's grammar can change between versions, especially for new languages. This may cause node names to change, which could break your patterns. Be prepared to update your queries when upgrading Biome when using node/field names in your patterns.
Biome's grammar can change between versions, especially for new languages. This may cause node or field names to change, which could break your patterns. If your queries rely on node/field names, be prepared to update them when upgrading Biome.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content/docs/reference/gritql.mdx` at line 139, The sentence "This may
cause node names to change, which could break your patterns. Be prepared to
update your queries when upgrading Biome when using node/field names in your
patterns." is wordy and repeats "when"; replace it with a single clearer
sentence such as: "Because Biome's grammar can change between versions
(especially for new languages), node and field names may change, so be prepared
to update any patterns that depend on them when you upgrade." Locate the
original sentence in the documentation (the paragraph that begins "Biome's
grammar can change between versions...") and substitute this streamlined version
to improve readability.

:::

## JSON Patterns
Expand Down
Loading