Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Jan 23, 2026

Migrate to way faster oxlint and oxfmt!

Summary by CodeRabbit

Release Notes

  • Chores

    • Migrated from ESLint and Prettier to Oxlint and Oxfmt for improved linting and code formatting
    • Updated development tooling scripts to use the new linting and formatting tools
    • Reformatted codebase for improved code consistency and readability
  • Documentation

    • Updated API documentation to reflect parameter changes in adapter functions

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR executes a comprehensive migration from ESLint+Prettier to Oxlint+Oxfmt for code linting and formatting. It includes tooling configuration updates, dependency changes, extensive code formatting normalization (collapsing multi-line statements to single lines), and minor functional adjustments to middleware hook behavior.

Changes

Cohort / File(s) Summary
Tooling Configuration
.oxlintrc.json, .oxfmtrc.json, .prettierignore, .prettierrc, eslint.config.mjs, .github/workflows/autofix.yml
Introduces Oxlint and Oxfmt configuration files; removes Prettier and ESLint configs. Updates CI workflow to run pnpm format instead of pnpm lint:fix.
Package & Dependencies
package.json
Replaces eslint/eslint-config-unjs/prettier devDependencies with oxlint/oxfmt. Updates lint script to use Oxlint and Oxfmt. Adds format script. Pins h3 dependency via resolutions.
Documentation
docs/1.guide/.../*, docs/2.utils/9.more.md, docs/4.examples/.../*, docs/99.blog/.../*
Consolidates multi-line code examples (arrow functions, chained calls, ternary expressions) into single-line forms. Updates fromWebHandler documentation signature to include handler parameter.
Examples
examples/*.mjs
Reformats multi-line chained method calls and arrow functions to single-line equivalents without semantic changes.
Source Code - Middleware & Handlers
src/handler.ts, src/middleware.ts, src/utils/middleware.ts
Consolidates function signatures to single-line format. onResponse hook behavior updated to capture and return hook output. Type signature refinements in defineValidatedHandler.
Source Code - Core & Response
src/h3.ts, src/response.ts, src/adapters.ts
Adds onRequest hook pre-processing in request flow. Simplifies Promise handling and response conversion logic. Consolidates function signatures. Minor refactoring of response construction and error handling paths.
Source Code - Types & Events
src/event.ts, src/error.ts, src/types/h3.ts, src/types/handler.ts
Collapses multi-line type/interface declarations and Symbol declarations to single lines. Minor formatting of generic parameters and type bounds.
Source Code - Utilities
src/utils/*.ts, src/utils/internal/*.ts
Extensive single-line consolidation of function signatures, type declarations, and expressions across auth, body, cache, cookie, cors, event-stream, event, fingerprint, proxy, request, response, sanitize, session, static, WebSocket modules. No semantic logic changes.
Source Code - Deprecated
src/_deprecated.ts, src/index.ts
Reformats deprecation wrapper imports/exports and consolidates public re-export blocks to single-line syntax.
Build & Changelog
build.config.mjs, CHANGELOG.md
Collapses configuration array entries to single-line form. Minor changelog formatting (space removals before phrases).
Tests
test/*.test.ts, test/unit/*.test.ts, test/bench/*.test.ts
Widespread consolidation of multi-line assertions, arrow functions, and array literals to single-line forms. Refactors error-handling test in app.test.ts to use simplified pipe chain. No logic changes to test outcomes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The review spans ~150 files with predominantly homogeneous formatting changes (single-lining, trailing comma removal) that reduce per-file complexity. However, the breadth of affected files, tooling migration requiring verification, functional behavior changes in middleware hooks (onResponse capturing output) and request flow (onRequest pre-processing), and adjustments to core handler/response logic necessitate careful cross-file validation despite the repetitive nature of formatting edits.

Possibly related PRs

  • types(onResponse): allow returning any value #1277: Updates middleware function signatures in src/utils/middleware.ts for onRequest/onResponse/onError to handle hook result captures and return behaviors, directly correlating with this PR's onResponse behavior enhancement that now returns hook output.

Poem

🐰 From linter to linter, our code hops along,
Oxfmt and Oxlint make formatting strong,
Single-lined arrows and symbols so neat,
A thousand small tweaks make the refactor complete!
No logic was harmed in this beautifying spree, 🎀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore: migrate to oxlint and oxfmt' accurately summarizes the main change: replacing ESLint/Prettier with oxlint/oxfmt tooling across the project.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pi0 pi0 marked this pull request as ready for review January 23, 2026 19:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/middleware.ts (1)

23-29: Respect explicit falsy hook overrides in onResponse.

hookResponse || response ignores intentional falsy returns (e.g., "", 0, false). Use an explicit undefined check to align with onError, which correctly allows falsy values to replace the response.

🔧 Suggested fix
-    const hookResponse = await hook(response, event);
-    return hookResponse || response;
+    const hookResponse = await hook(response, event);
+    return hookResponse !== undefined ? hookResponse : response;
🤖 Fix all issues with AI agents
In `@examples/middleware.mjs`:
- Around line 24-28: The onError callback parameters are swapped: onError
provides (error: HTTPError, event: H3Event) but the handler uses (event, error);
update the callback signature to (error, event) so you access event.req.method
from the H3Event argument, and treat the first param as the HTTPError when
referencing error.message; adjust the handler around the onError call to use
these names consistently.

In `@examples/vite.mjs`:
- Line 15: The call to html in the app.get handler is passing the request event
as the first argument but html expects either a template string or a markup
string; update the app.get callback (the handler registered via app.get) to call
html with only the markup string (i.e., remove the event parameter passed to
html), leaving app.get's handler signature intact if you need the event for
other purposes.

In `@src/middleware.ts`:
- Around line 131-132: The function is404 currently reads (val as
Response)?.status before confirming the object is a Response, which can trigger
side effects; update is404 (and its usage of isUnhandledResponse) to first check
that val instanceof Response and only then read val.status (e.g., evaluate val
instanceof Response && val.status === 404), combining that with the existing
isUnhandledResponse(val) check so no .status is accessed on non-Response values.

In `@src/utils/internal/event-stream.ts`:
- Line 72: The write calls currently swallow errors with empty .catch(), hide
failures and are inconsistent with flush(); replace the silent .catch() usage on
calls like
this._writer.write(this._encoder.encode(formatEventStreamComment(comment))).catch()
with a consistent error handler—e.g., create a private method on the class
(e.g., _handleWriteError(err)) that logs (and optionally rethrows or flags) the
error, then call .catch(this._handleWriteError.bind(this)) on every writer call
including those in flush() and other write sites so all write/encode errors are
handled uniformly.

In `@src/utils/static.ts`:
- Around line 162-163: The code is incorrectly checking the request headers
before setting response content-length: update the condition in the block that
uses meta.size and event.res.headers.set to check
event.res.headers.get("content-length") instead of
event.req.headers.get("content-length") so you only set content-length when the
response header is absent (keep the existing meta.size !== undefined &&
meta.size > 0 check and call event.res.headers.set("content-length",
String(meta.size)) on success).

In `@test/app.test.ts`:
- Around line 128-150: The test "Node.js Readable Stream with Error" was
globally disabled by passing false into it.runIf which skips coverage for all
targets; change the guard on the it.runIf call to a runtime-specific condition
(e.g., it.runIf(t.target === "node") or use t.skipIf for the specific failing
runtime) so only non-Node targets skip the test, and optionally add a comment or
link to a tracking issue; locate the it.runIf(...) call around the "Node.js
Readable Stream with Error" test and update its predicate accordingly.
🧹 Nitpick comments (3)
test/app.test.ts (1)

1-1: Fix the Transform alias typo for readability.

The misspelling is harmless but confusing for future readers.

♻️ Suggested rename
-import { Readable as NodeStreamReadable, Transform as NodeStreamTransoform } from "node:stream";
+import { Readable as NodeStreamReadable, Transform as NodeStreamTransform } from "node:stream";
-        new NodeStreamTransoform({
+        new NodeStreamTransform({
src/h3.ts (1)

54-54: Avoid the as unknown as undefined type escape.

This discards route type information and defeats type safety. Prefer a proper union (or update ~findRoute to return MatchedRoute | undefined) and pass it through.

♻️ Suggested adjustment
-    const middleware = this["~getMiddleware"](event, route as unknown as undefined);
+    const middleware = this["~getMiddleware"](event, route as MatchedRoute<H3Route> | undefined);
src/response.ts (1)

234-240: Remove stale // prettier-ignore comment.

Since the project is migrating to oxfmt, this Prettier-specific directive is no longer effective. Remove it or replace with the oxfmt equivalent if formatting control is still needed.

Suggested change
 function nullBody(method: string, status: number | undefined): boolean | 0 | undefined {
-  // prettier-ignore
   return (method === "HEAD" ||
     status === 100 || status === 101 || status === 102 ||
     status === 204 || status === 205 || status === 304
   )
 }

@pi0 pi0 merged commit 242c058 into main Jan 23, 2026
6 checks passed
@pi0 pi0 deleted the chore/oxstuff branch January 23, 2026 20:14
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