-
Notifications
You must be signed in to change notification settings - Fork 47
refactor: cached parse template literal #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors template literal parsing to improve caching by separating parsing from visitor traversal. Instead of requiring visitors during parsing, it now caches the parsed AST and allows optional visitor execution during retrieval.
- Makes the visitor parameter optional in the parse function
- Introduces a new
parseTemplateLiteral
utility that handles caching and optional visitor traversal - Updates all rule implementations to use the new unified interface
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/template-parser/lib/traverser.js | Makes parent parameter optional with default value |
packages/template-parser/lib/template-parser.js | Makes visitor parameter optional and conditionally executes traversal |
packages/template-parser/lib/index.js | Exports traverse function publicly |
packages/eslint-plugin/lib/rules/utils/template-literal.js | Replaces getCachedParseResult with parseTemplateLiteral that handles both caching and visitor execution |
packages/eslint-plugin/lib/rules/utils/visitors.js | Updates to use new parseTemplateLiteral function |
packages/eslint-plugin/lib/rules/*.js | Updates all rules to use parseTemplateLiteral instead of separate parse and traverse calls |
packages/eslint-plugin/tests/rules/utils/template-literal.test.js | Adds tests for caching behavior and visitor execution |
packages/eslint-plugin/tests/rules/*.test.js | Adds test cases for template literal parsing with different syntax patterns |
Comments suppressed due to low confidence (1)
packages/template-parser/lib/template-parser.js:15
- The parameter name 'visitor' is inconsistent with the JSDoc comment which still references 'visitors' (plural). Consider updating the JSDoc to use 'visitor' (singular) to match the parameter name.
function parse(node, sourceCode, visitor) {
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
==========================================
+ Coverage 98.30% 98.52% +0.22%
==========================================
Files 82 82
Lines 2657 2651 -6
Branches 726 730 +4
==========================================
Hits 2612 2612
+ Misses 45 39 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Description