Skip to content

fix(grit): fix queries for export { $foo } ...#9586

Merged
dyc3 merged 3 commits intomainfrom
dyc3/fix-grit-export-query-match
Mar 25, 2026
Merged

fix(grit): fix queries for export { $foo } ...#9586
dyc3 merged 3 commits intomainfrom
dyc3/fix-grit-export-query-match

Conversation

@dyc3
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 commented Mar 22, 2026

Summary

This pr fixes queries like `export { $foo } from "..."` that previously didn't work

generated by gpt 5.4

fixes #8828

Test Plan

snapshots, tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 22, 2026

🦋 Changeset detected

Latest commit: 7bd2c4a

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-Parser Area: parser A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages L-Grit Language: GritQL labels Mar 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53139 53139 0
Passed 51919 51919 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.70% 97.70% 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 5466 5466 0
Passed 1915 1915 0
Failed 3551 3551 0
Panics 0 0 0
Coverage 35.03% 35.03% 0.00%

ts/babel

Test result main count This PR count Difference
Total 636 636 0
Passed 567 567 0
Failed 69 69 0
Panics 0 0 0
Coverage 89.15% 89.15% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18875 18875 0
Passed 13013 13013 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 Mar 22, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 159 skipped benchmarks1


Comparing dyc3/fix-grit-export-query-match (7bd2c4a) with main (2088ec5)

Open in CodSpeed

Footnotes

  1. 159 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.

@dyc3 dyc3 marked this pull request as ready for review March 22, 2026 16:05
@dyc3 dyc3 requested review from a team March 22, 2026 16:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14666048-cfd9-4905-8ff5-c43a0f63a887

📥 Commits

Reviewing files that changed from the base of the PR and between 5a302ad and 7bd2c4a.

📒 Files selected for processing (1)
  • crates/biome_js_syntax/src/export_ext.rs

Walkthrough

This PR enables Grit pattern matching for named export-from statements by introducing AnyJsLiteralExportName to accept metavariables in export-name positions. It updates the parser entrypoint to parse metavariables in these positions, adds formatter and syntax bindings for the new union, adjusts identifier helpers, refines metavariable detection trimming, and adds tests and grit specs covering export { $foo } from $source.

Possibly related PRs

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary fix: enabling GritQL queries for export { $foo } ... patterns, which directly addresses the main changeset objective.
Description check ✅ Passed The description explains the motivation (fixing queries like export { $foo } from "..." that previously didn't work), references issue #8828, and outlines the test plan with snapshots and tests.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #8828 by updating grammar to accept metavariables in export-from clauses, implementing parsing logic, adding formatter support, and including test coverage for the previously failing pattern.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing GritQL pattern matching for export { $foo } from $source: grammar updates, parser changes, formatter implementations, and comprehensive test coverage with no unrelated modifications.

✏️ 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 dyc3/fix-grit-export-query-match

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

@github-actions github-actions bot added A-Linter Area: linter A-Formatter Area: formatter labels Mar 25, 2026
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.

🧹 Nitpick comments (1)
crates/biome_js_syntax/src/export_ext.rs (1)

62-65: Doc comments reference outdated type name.

The example output at lines 63-65 still shows AnyIdentifier::JsLiteralExportName("foo") and AnyIdentifier::JsLiteralExportName("baz"), but the type has been changed to AnyJsLiteralExportName.

📝 Suggested doc update
 /// [
-///     ExportedItem { identifier: Some(AnyIdentifier::JsLiteralExportName("foo")), exported: None, is_default: false },
-///     ExportedItem { identifier: Some(AnyIdentifier::JsLiteralExportName("baz")), exported: None, is_default: false },
+///     ExportedItem { identifier: Some(AnyIdentifier::AnyJsLiteralExportName("foo")), exported: None, is_default: false },
+///     ExportedItem { identifier: Some(AnyIdentifier::AnyJsLiteralExportName("baz")), exported: None, is_default: false },
 /// ]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_js_syntax/src/export_ext.rs` around lines 62 - 65, Update the
doc comment example in export_ext.rs to reflect the new type name: replace
occurrences of AnyIdentifier::JsLiteralExportName(...) with the updated
AnyJsLiteralExportName(...) so the sample ExportedItem output uses identifier:
Some(AnyJsLiteralExportName("foo")) and identifier:
Some(AnyJsLiteralExportName("baz")); ensure the rest of the ExportedItem fields
(exported, is_default) remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_js_syntax/src/export_ext.rs`:
- Around line 62-65: Update the doc comment example in export_ext.rs to reflect
the new type name: replace occurrences of
AnyIdentifier::JsLiteralExportName(...) with the updated
AnyJsLiteralExportName(...) so the sample ExportedItem output uses identifier:
Some(AnyJsLiteralExportName("foo")) and identifier:
Some(AnyJsLiteralExportName("baz")); ensure the rest of the ExportedItem fields
(exported, is_default) remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f619c6ae-3db6-41aa-8f56-afaf7bdcf940

📥 Commits

Reviewing files that changed from the base of the PR and between 90630b8 and 5a302ad.

⛔ Files ignored due to path filters (5)
  • crates/biome_grit_patterns/tests/specs/ts/export_named_from_patterns.snap is excluded by !**/*.snap and included by **
  • 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_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 (13)
  • .changeset/fix-grit-export-named-from.md
  • crates/biome_grit_patterns/src/grit_target_language.rs
  • crates/biome_grit_patterns/src/pattern_compiler/snippet_compiler.rs
  • crates/biome_grit_patterns/tests/specs/ts/export_named_from_patterns.grit
  • crates/biome_grit_patterns/tests/specs/ts/export_named_from_patterns.ts
  • crates/biome_js_analyze/src/lint/nursery/no_redundant_default_export.rs
  • crates/biome_js_formatter/src/generated.rs
  • crates/biome_js_formatter/src/js/any/literal_export_name.rs
  • crates/biome_js_formatter/src/js/any/mod.rs
  • crates/biome_js_parser/src/syntax/module.rs
  • crates/biome_js_syntax/src/export_ext.rs
  • crates/biome_js_syntax/src/identifier_ext.rs
  • xtask/codegen/js.ungram
✅ Files skipped from review due to trivial changes (8)
  • crates/biome_grit_patterns/src/grit_target_language.rs
  • crates/biome_grit_patterns/tests/specs/ts/export_named_from_patterns.grit
  • crates/biome_js_analyze/src/lint/nursery/no_redundant_default_export.rs
  • crates/biome_grit_patterns/tests/specs/ts/export_named_from_patterns.ts
  • .changeset/fix-grit-export-named-from.md
  • crates/biome_js_formatter/src/js/any/mod.rs
  • crates/biome_js_formatter/src/js/any/literal_export_name.rs
  • crates/biome_js_formatter/src/generated.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_js_parser/src/syntax/module.rs
  • xtask/codegen/js.ungram

@dyc3 dyc3 merged commit 4cafb71 into main Mar 25, 2026
20 checks passed
@dyc3 dyc3 deleted the dyc3/fix-grit-export-query-match branch March 25, 2026 11:55
@github-actions github-actions bot mentioned this pull request Mar 25, 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-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.

🐛 GritQL pattern export { $foo } from $source fails to match while export * from $source works

4 participants