Skip to content

fix(oxc): tolerate stdout notices ahead of oxlint's JSON payload#476

Merged
yuyinws merged 2 commits into
vitejs:mainfrom
dvcolomban:fix/oxc-lint-invalid-json
Jul 26, 2026
Merged

fix(oxc): tolerate stdout notices ahead of oxlint's JSON payload#476
yuyinws merged 2 commits into
vitejs:mainfrom
dvcolomban:fix/oxc-lint-invalid-json

Conversation

@dvcolomban

Copy link
Copy Markdown
Contributor

Summary

parseOxlintOutput calls JSON.parse directly on oxlint's raw stdout. When oxlint's own file-discovery matches zero files (e.g. a package in a monorepo that isn't opted into oxlint, or any project with an empty/mismatched include glob), oxlint prints a human-readable notice — No files found to lint. Please check your paths and ignore patterns. — to stdout before the JSON payload, even when invoked with -f json. That leading line breaks JSON.parse, and the devtools-oxc:run-lint RPC surfaces a generic Oxlint returned invalid JSON error instead of reporting a clean zero-diagnostics result.

Reproduced directly:

$ oxlint -f json
No files found to lint. Please check your paths and ignore patterns.
{ "diagnostics": [],
              "number_of_files": 0,
              ...
            }

Fix

parseOxlintOutput now skips to the first { in stdout before parsing, so any leading notice oxlint prints doesn't break JSON parsing. Falls back to parsing the raw string unchanged if no { is found, preserving existing error behavior for genuinely invalid output.

Test plan

  • Added a regression test reproducing the exact stdout shape (notice line + JSON) and asserting it now parses to a zero-diagnostics summary.
  • pnpm vitest run packages/oxc/src/node/__tests__/lint-results.test.ts — 6/6 passing.
  • pnpm -C packages/oxc run lint — clean.

Oxlint can print human-readable notices (e.g. "No files found to lint...")
to stdout before the JSON payload even when run with `-f json` — this
happens for any project where oxlint's default file discovery matches
zero files (e.g. a package that isn't opted into oxlint in a monorepo
with a default-deny root config). `parseOxlintOutput` called `JSON.parse`
on the raw stdout, so that leading notice broke parsing and the lint-run
RPC failed with "Oxlint returned invalid JSON" instead of reporting zero
diagnostics.
@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@476

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@476

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@476

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@476

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@476

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@476

commit: 22550b0

@antfu
antfu requested a review from yuyinws July 24, 2026 18:07
@yuyinws
yuyinws merged commit c9504ce into vitejs:main Jul 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants