How to make this task?
- User
How to make this task?
Assistant
Based on the provided repository context and issue description, I'll break down how to approach implementing a JavaScript plugin runtime for Biome. Here's a structured plan:
-
Core Runtime Implementation
- First, we need to implement the basic JavaScript engine integration following the discussion in #2467
- The runtime needs to interface with Biome's existing analyzer infrastructure shown in
biome_js_analyzeandbiome_js_transformcrates - Initial proof-of-concept should focus on basic script evaluation
-
Integration with Biome's Analysis System
- Looking at
biome_js_analyze/src/lib.rs, we can see the analyzer framework that plugins need to hook into - Key components to integrate with:
analyze_with_inspect_matcherfunction for rule executionRuleRegistryfor registering plugin rulesAnalyzerSignalfor emitting diagnostics
- Looking at
-
TypeScript Support
- Leverage existing
biome_js_transformcrate for TypeScript transpilation - Add transpilation step before script evaluation in the runtime
- Leverage existing
-
API Design The JavaScript API should expose:
typescript// Example API structure interface BiomePlugin { // Register lint rules registerRule(rule: { name: string; create: (context: RuleContext) => RuleListener; }): void; // Emit diagnostics context: { report(diagnostic: { message: string; loc: Location; fix?: () => void; }): void; }; // Node traversal callbacks [Redacted Person]: { on(nodeType: string, callback: (node: Node) => void): void; }; } -
Implementation Steps:
-
Create new crate
biome_js_plugin_runtimethat will:- Initialize JS engine
- Load and evaluate plugin scripts
- Provide bridge between JS and Rust
-
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.