-
Notifications
You must be signed in to change notification settings - Fork 1
feat(js): arrange babel plugins respectfully to vue and svetle frameworks #492
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 fixes Babel parser configuration for Vue and Svelte framework files by properly handling JSX syntax and enabling TypeScript detection based on script tag attributes. The changes enable correct parsing of framework files and JavaScript files that contain JSX syntax, which previously failed due to missing parser plugins.
Key Changes
- Extracted and refactored Babel parser plugin selection logic into a testable utility function with comprehensive test coverage
- Implemented framework file preprocessing to extract script blocks and detect TypeScript language attribute from Vue/Svelte components
- Enhanced HawkCatcher error reporting with additional context (source code, line numbers, stack frames) for better debugging
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
workers/javascript/tests/parser.test.ts |
New comprehensive test suite for parser utilities covering framework file extraction, line number mapping, and plugin selection for all supported file types |
workers/javascript/tests/index.test.ts |
Added integration tests for Vue and Svelte component function context resolution; cleaned up trailing whitespace in existing tests |
workers/javascript/src/utils.ts |
Implemented utility functions for framework file parsing: countLineBreaks, cleanSourcePath, prepareSourceForParsing, and getBabelParserPluginsForFile |
workers/javascript/src/index.ts |
Integrated new utility functions for parser plugin selection and framework file preprocessing; enhanced HawkCatcher error context with additional debugging information |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
* Fix: Improve quota notification and blocking logic (#489) * Improve quota notification and blocking logic Refactored the quota check to ensure workspaces are blocked and notified only when appropriate. Added logging for both blocking and approaching quota limits, and clarified notification task handling. * Suppress magic number lint warning in logger Added an ESLint directive to ignore the magic number warning for the percentage calculation in the workspace events limit log message. * Fix: save workspace blocked date (#491) * pull new hawk types * Track blocked date for workspaces in LimiterWorker Adds a 'blockedDate' property to workspaces when blocking and unblocking them. This allows tracking when a workspace was blocked or cleared, improving auditability and state management. * Add and populate blockedDate for blocked workspaces Introduces the blockedDate field to workspace updates in dbHelper and ensures it is set for all blocked workspaces, including a temporary fix for existing records missing this field. This change supports better tracking of when a workspace was blocked and prepares for future removal of the migration code. * Add tests for blockedDate handling in workspaces Extended tests to cover setting and clearing the blockedDate field when blocking and unblocking workspaces. Added scenarios for updating blockedDate when missing and verifying correct behavior during workspace state transitions. * Update index.ts * Refactor blocked workspace reminder to use days after block Renamed variables and template placeholders from 'daysAfterPayday' to 'daysAfterBlock' to more accurately reflect the time since a workspace was blocked. Updated related logic, types, and templates to use the new naming and calculation. Added a utility function to compute days after block in payday.ts. * Update yarn.lock to deduplicate and reorder entries This commit cleans up the yarn.lock file by removing duplicate entries, consolidating package references, and reordering dependencies for consistency. No package versions were changed; this improves maintainability and reduces lockfile bloat. * Rename daysAfterPayday to daysAfterBlock in payload Updated variable and property names from daysAfterPayday to daysAfterBlock in SenderWorker to reflect the correct payload structure and improve clarity. * Handle undefined daysAfterBlock in reminders logic Updated countDaysAfterBlock to return undefined instead of null when blockedDate is missing. Adjusted paymaster worker logic to check for undefined, ensuring reminders are sent only when daysAfterBlock is valid. * Adjust blockedDate calculation in PaymasterWorker test Updates the blockedDate assignment to subtract days based on expectedDaysAfterBlock in the PaymasterWorker test, improving test accuracy for blocked subscriptions. * Update workers/paymaster/tests/index.test.ts Co-authored-by: Copilot <[email protected]> * Update workers/paymaster/src/index.ts Co-authored-by: Copilot <[email protected]> * Update lib/utils/payday.ts Co-authored-by: Copilot <[email protected]> * Update dbHelper.test.ts * Remove obsolete test and update blocked workspace logic Deleted a test for setting blockedDate on already blocked workspaces in limiter tests, as the scenario is no longer relevant. Updated workspace mock to include blockedDate as undefined. Simplified reminder logic in PaymasterWorker by removing unnecessary undefined check for daysAfterBlock. * Refactor blockedDate handling in workspace mocks Removed redundant logic for setting blockedDate when workspace is already blocked in LimiterWorker. Standardized blockedDate type to Date (not Date | null/undefined) in test mocks and updated test cases to use null instead of undefined where appropriate. * Update index.test.ts * Update dbHelper.test.ts * Update index.test.ts * Update index.test.ts * Update workers/paymaster/tests/index.test.ts Co-authored-by: Copilot <[email protected]> * Update index.test.ts * Update workers/paymaster/src/index.ts Co-authored-by: Copilot <[email protected]> * Update lib/utils/payday.ts Co-authored-by: Copilot <[email protected]> * Update workers/paymaster/src/index.ts Co-authored-by: Copilot <[email protected]> * Update emailOverview.ts * Update workers/limiter/src/index.ts Co-authored-by: Copilot <[email protected]> * Update lib/utils/payday.ts Co-authored-by: Peter <[email protected]> * Update index.test.ts * Update index.test.ts * Update index.ts --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Peter <[email protected]> * feat(js): arrange babel plugins respectfully to vue and svetle frameworks (#492) * feat(): arrange babel plugins respectfully to vue and svetle frameworks * chore(): add context to hawk errors and cover utils with tests * chore(): clean up * Update workers/javascript/src/utils.ts Co-authored-by: Copilot <[email protected]> * chore(): fix tests description * imp(): move getFunctionContext to utils * chore(): lint fix * chore(): improve jsdoc --------- Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Taly <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Peter <[email protected]> Co-authored-by: e11sy <[email protected]>
Problems
.vueor.svelteare parsed with babel without jsx plugin that leads to this kind of errorsSolution
.jsor framework files e.g..vuewithout <script lang=ts> ) are parsed with jsx pluginNote
We cant really enabled jsx plugin for all files because it collides with typescript plugin (
<string>barcasts are treated as html tags etc)