Repository navigation
feat(wasm): expose grit search functions to wasm - #8911
Conversation
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
WalkthroughThree new pattern-related methods were added to the biome_wasm crate's public Workspace API: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.changeset/grit-search-bindings.md:
- Around line 12-23: The example uses parsePattern as if it returns a raw
patternId, but parsePattern actually returns a Promise<ParsePatternResult>
object containing a patternId property; update the example to await and
destructure the result (e.g., const { patternId } = await
Biome.parsePattern(...) or from biome.parsePattern(...)) and then pass that
patternId into biome.searchPattern and biome.dropPattern so the calls use the
correct value type.
| ```typescript | ||
| const biome = await Biome.create({ distribution: Distribution.BUNDLER }); | ||
| const projectKey = biome.openProject().projectKey; | ||
|
|
||
| // Parse a GritQL pattern | ||
| const patternId = biome.parsePattern("const $x = 1;", "JavaScript"); | ||
|
|
||
| // Search for matches | ||
| const matches = biome.searchPattern(projectKey, "test.js", fileContent, patternId); | ||
|
|
||
| // Clean up | ||
| biome.dropPattern(patternId); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for parsePattern method definition and return type hints
rg -n "parsePattern" -g '*.{ts,js,tsx,jsx}' -B 2 -A 5 | head -100Repository: biomejs/biome
Length of output: 1590
🏁 Script executed:
#!/bin/bash
# Look for interface/type definitions related to pattern parsing
rg -n "IParsePatternResult|ParsePatternResult|patternId" -g '*.{ts,js,tsx,jsx}' -B 2 -A 2 | head -150Repository: biomejs/biome
Length of output: 1135
🏁 Script executed:
#!/bin/bash
# Check if there's documentation or implementation in the changeset area
find . -name "*.md" -o -name "*.ts" -o -name "*.js" | grep -i changeset | head -20
ls -la .changeset/ 2>/dev/null || echo "Changeset directory listing failed"Repository: biomejs/biome
Length of output: 1277
Fix the example to match the API return type.
parsePattern returns Promise<ParsePatternResult> where ParsePatternResult is an object with a patternId property. The example should destructure the result:
Suggested fix
-const patternId = biome.parsePattern("const $x = 1;", "JavaScript");
+const { patternId } = await biome.parsePattern("const $x = 1;", "JavaScript");📝 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.
| ```typescript | |
| const biome = await Biome.create({ distribution: Distribution.BUNDLER }); | |
| const projectKey = biome.openProject().projectKey; | |
| // Parse a GritQL pattern | |
| const patternId = biome.parsePattern("const $x = 1;", "JavaScript"); | |
| // Search for matches | |
| const matches = biome.searchPattern(projectKey, "test.js", fileContent, patternId); | |
| // Clean up | |
| biome.dropPattern(patternId); |
🤖 Prompt for AI Agents
In @.changeset/grit-search-bindings.md around lines 12 - 23, The example uses
parsePattern as if it returns a raw patternId, but parsePattern actually returns
a Promise<ParsePatternResult> object containing a patternId property; update the
example to await and destructure the result (e.g., const { patternId } = await
Biome.parsePattern(...) or from biome.parsePattern(...)) and then pass that
patternId into biome.searchPattern and biome.dropPattern so the calls use the
correct value type.
62effcf to
ef02264
Compare

Summary
We need to expose these functions in order to integrate it into the playground.
generated by glm-4.7
Test Plan
Tests for the js-api are in the next PR in the stack, which also tests this.
Docs