-
Notifications
You must be signed in to change notification settings - Fork 302
chore: migrate to oxlint and oxfmt #1286
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
📝 WalkthroughWalkthroughThis 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
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
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
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.
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 inonResponse.
hookResponse || responseignores intentional falsy returns (e.g.,"",0,false). Use an explicitundefinedcheck to align withonError, 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 theas unknown as undefinedtype escape.This discards route type information and defeats type safety. Prefer a proper union (or update
~findRouteto returnMatchedRoute | 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-ignorecomment.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 ) }
Migrate to way faster oxlint and oxfmt!
Summary by CodeRabbit
Release Notes
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.