Skip to content

Conversation

@wagenet
Copy link
Contributor

@wagenet wagenet commented Oct 28, 2025

Prior to this change, certain JS Plugin failures would just point to Oxlint internals instead of the actual JS error.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 28, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI labels Oct 28, 2025
@wagenet wagenet marked this pull request as ready for review October 28, 2025 01:35
@wagenet wagenet requested a review from camc314 as a code owner October 28, 2025 01:35
Copilot AI review requested due to automatic review settings October 28, 2025 01:35
Copy link
Contributor

Copilot AI left a 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 improves error handling for JS Plugin failures by adding proper cleanup and validation logic. Previously, when a JS Plugin failed, internal state would remain corrupted, leading to errors that pointed to Oxlint internals rather than the actual JS error source.

Key Changes:

  • Added comprehensive state cleanup in initCompiledVisitor to handle previous compilation failures
  • Added input validation in mergeVisitFns to catch invalid data early with clear error messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

function mergeVisitFns(visitFns: VisitFn[]): VisitFn {
// Validate that visitFns is actually an array
if (!isArray(visitFns)) {
throw new TypeError(`Expected visitFns to be an array, but got ${typeof visitFns}`);
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses template literal syntax but typeof on an array returns 'object', which isn't very helpful. Consider using Array.isArray() check result or providing the actual value type in a more descriptive way, e.g., Expected visitFns to be an array, but got ${visitFns === null ? 'null' : typeof visitFns}.

Suggested change
throw new TypeError(`Expected visitFns to be an array, but got ${typeof visitFns}`);
throw new TypeError(`Expected visitFns to be an array, but got ${visitFns === null ? 'null' : typeof visitFns}`);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant