Repository navigation
Conversation
✅ Deploy Preview for eslint-code-explorer ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Provide and consume AST results src/components/ast-provider.tsx, docs/adding-languages.md |
ASTProvider memoizes parsing and selector matching and exposes results through useAST. Language instructions now direct contributors to add parsing cases in parseCode. |
Connect the editor to AST results src/components/code-editor.tsx, src/app.tsx, src/components/ast/index.tsx, src/components/esquery-selector-input.tsx, src/hooks/use-explorer.ts |
App wraps the panels with ASTProvider and uses CodeEditor. CodeEditor displays and updates the active language’s code and passes matched ranges to Editor. AST consumers import useAST from the provider. ExplorerState is exported. |
Memoize and report scope analysis src/components/scope/index.tsx |
Scope memoizes analysis by AST result and JavaScript options. Scope-analysis errors and AST errors each render ErrorState. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Sequence Diagram(s)
sequenceDiagram
participant useExplorer
participant ASTProvider
participant parseCode
participant addEsqueryMatchedNodes
participant useAST
participant CodeEditor
participant Editor
useExplorer->>ASTProvider: Provide parsing inputs and selector
ASTProvider->>parseCode: Parse language, code, and options
parseCode-->>ASTProvider: Return parse result
ASTProvider->>addEsqueryMatchedNodes: Match nodes using result and selector
CodeEditor->>useAST: Read AST result from context
useAST-->>CodeEditor: Return AST result
CodeEditor->>Editor: Pass active code and matched ranges
Suggested reviewers: dmartens
Merge Risk: 
Minimal · up to 97624
-
No actionable merge-blocking issue was identified; the change is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 9 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
DMartens
left a comment
There was a problem hiding this comment.
Thank you for the PR.
I am assuming this is PR lays the groundwork for the mentioned the issue?
| ], | ||
| ); | ||
| const astResult = useMemo( | ||
| () => addEsqueryMatchedNodes(astParseResult, selector), |
There was a problem hiding this comment.
Shouldn't we move addEsqueryMatchedNodes move into its own context provider / memoized hook?
The data is required for the input and the editor but not the AST view.
There was a problem hiding this comment.
The AST tree highlights matched nodes too.
| children: React.ReactNode; | ||
| }; | ||
|
|
||
| const ASTProviderContext = createContext<ASTResult | null>(null); |
There was a problem hiding this comment.
I am unsure why we should convert this hook to a context.
Can you please explain the reasoning for this change?
There was a problem hiding this comment.
Each useAST() call parsed the code on its own, so up to three components re-parsed on every edit and selector keystroke. The context parses once and shares the result.
Yes. |
|
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
|
There's a merge conflict now. @xbinaryx, could you please take a look? |
Prerequisites checklist
AI acknowledgment
What is the purpose of this pull request?
Every component that called
useAST()parsed the code on its own. Up to three are mounted at once (App,EsquerySelectorInput, and the AST or Scope tab), so each code edit could trigger three parses. Even typing in the ESQuery selector re-parsed the code in each of them.The Scope tab had a separate problem. The React Compiler silently skipped the
Scopecomponent because of a conditional inside atry/catch. With nothing memoized,eslintScope.analyzeran on every render of the tab, including on every selector keystroke.What changes did you make? (Give an overview)
ASTProviderthat parses the code once and shares the result through context.useAST()now reads from that context.try/catchinScopeinto ananalyzeScopehelper and memoized the analysis on the AST and the JS options.ExplorerStatetype for the parse input, and updateddocs/adding-languages.mdto point to the new file.Related Issues
#64
Is there anything you'd like reviewers to focus on?
Summary by CodeRabbit