Skip to content

bun check - a TypeScript type checker builtin to Bun - #44361

Merged
Jarred-Sumner merged 293 commits into
mainfrom
claude/bun-check
Oct 6, 2026
Merged

Jarred-Sumner merged 293 commits into
mainfrom
claude/bun-check

Conversation

@Jarred-Sumner

@Jarred-Sumner Jarred-Sumner commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

This adds a TypeScript type checker to Bun.

bun check                        # type check the project
bun --check src/index.ts         # type check, then run
bun build --check src/index.ts   # type check, then bundle
bun test --check                 # type check, then run the tests

It's a port of the type checker in typescript-go 7.0.2. You get the same errors as tsc, with the same error codes, messages, lines and columns. If bun check and tsc 7 disagree about an error, that's a bug in Bun.

packages/next in the Next.js repo, 2,881 files:

CPU time Peak memory
tsc 6.0.2 14.8 s 2.33 GB
tsc 7.0.2 (typescript-go) 6.9 s 1.78 GB
bun check 2.4 s 0.69 GB

(How that was measured is under Performance.)

It only type checks. It doesn't emit JavaScript, .d.ts files, sourcemaps or .tsbuildinfo. There's no language server, so your editor keeps using TypeScript.

Most of this description is about how we tested it. What's still wrong is at the bottom.

Usage

Check a project

bun check looks for the nearest tsconfig.json and checks whatever files, include and exclude select. It uses all of your CPU cores.

$ bun check
src/index.ts(3,25): error TS2322: Type 'string' is not assignable to type 'number'.
Found 1 error in 1 file, checked 2 files [14.00ms]
$ echo $?
1
$ bun check
✓ No type errors in 2 files [14.00ms]
$ echo $?
0

Errors go to stdout. The summary goes to stderr.

If your package.json already has a check script, bun check still runs that script, like it does today. bun --check with no file is the type checker in every project. "check": "bun check" works too: inside that script, and in the scripts it runs, bun check is the type checker.

bun --check

bun --filter '*' check and bun --workspaces check still run each package's check script.

Check some files

bun check src/index.ts
bun check src/server packages/shared

Bun checks those files and everything they import. Each file is checked in the project your editor uses for it. That's the nearest tsconfig.json, or, if that one doesn't include the file but has references, the referenced project that does. So it works in the layout create vite gives you.

A directory means the part of the project that's in it, so bun check . is the same as bun check. If the project has no files there, like bun check scripts when include is ["src"], Bun checks every file in the directory that isn't excluded, each with the tsconfig.json nearest to it.

Choose a tsconfig

bun check -p packages/server
bun check -p tsconfig.test.json

Without a tsconfig

bun check index.ts works in an empty directory. These are the defaults:

{
  "lib": ["ESNext"], "target": "ESNext", "module": "Preserve", "moduleDetection": "force",
  "jsx": "react-jsx", "allowJs": true, "moduleResolution": "bundler",
  "allowImportingTsExtensions": true, "verbatimModuleSyntax": true,
  "noEmit": true, "strict": true, "skipLibCheck": true
}

In a monorepo with no tsconfig.json at the root, bun check checks everything below the current directory. Each file gets the options of the tsconfig.json nearest to it, and each file is only checked once.

Project references

references are followed like tsc -b does, except you don't have to build anything first and nothing gets written to disk. Each project is checked with its own compiler options. Errors are printed one project at a time, in build order. A file that 2 projects include is checked in both, and its errors are printed once for each, like tsc -b does.

$ bun check
packages/app/src/index.ts(2,14): error TS2322: Type 'number' is not assignable to type 'string'.
Found 1 error in 1 file, checked 176 files across 2 projects [544.00ms]

--check

--check type checks the entry point and everything it imports before doing anything else. If there's a type error, Bun prints it, exits with code 1, and your code doesn't run.

$ bun --check src/good.ts
hello Ada

$ bun --check src/bad.ts
src/bad.ts(3,21): error TS2322: Type 'string' is not assignable to type 'number'.
Found 1 error in 1 file, checked 2 files
$ echo $?
1

With --watch, every restart is checked first. After a type error Bun waits for the next change in any file of the program, including files that only have types. --hot --check restarts the process like --watch does, so the code is checked again before it runs.

A file without an extension, -e, -p and a script on stdin are checked as TypeScript, which is how Bun runs them. If a file imports an HTML page, the scripts of that page are checked too. --conditions and --loader apply to the check: with --loader .js:ts, every .js file of your project is TypeScript.

--check doesn't cover files loaded with --preload. bun check does, if your tsconfig.json includes them.

bun --watch --check src/index.ts
bun test --watch --check
$ bun build --check src/good.ts --outdir out
Bundled 2 modules

  good.js  131 bytes  (entry point)

$ bun build --check src/bad.ts --outdir out
3 | console.log(greet({ age: "36" }));
                        ^
error: TS2322: Type 'string' is not assignable to type 'number'.
    at /app/src/bad.ts:3:21

1 | export function greet(user: { name?: string; age: number }) {
                                                 ^
note: TS6500: The expected type comes from property 'age' which is declared here on type '{ name?: string | undefined; age: number; }'
   at /app/src/greet.ts:1:46
$ ls out
ls: out: No such file or directory
$ bun test --check
src/bad.test.ts(3,39): error TS2322: Type 'string' is not assignable to type 'number'.
Found 1 error in 1 file, checked 3 files

A package.json script has no entry point to start from, so Bun checks the whole project first, like bun check. Same with --filter, --parallel and --sequential.

bun run --check dev
bun --check --filter '*' build

--tsconfig-override applies to the check too, so the type checker reads the same tsconfig.json as the bundler and the runtime. So does tsconfig in Bun.build.

Bun.build takes check: true. A type error fails the build like any other build error, and nothing is written. The check uses the conditions and loader of the build.

const result = await Bun.build({
  entrypoints: ["./src/index.ts"],
  outdir: "./out",
  check: true,
  throw: false,
});

for (const log of result.logs) {
  console.error(`${log.position?.file}:${log.position?.line}: ${log.message}`);
}
// /app/src/index.ts:3: TS2322: Type 'string' is not assignable to type 'number'.

Compiler options as flags

Any compiler option works as a flag, like in tsc. Flags override tsconfig.json.

bun check --noUncheckedIndexedAccess
bun check --strict false
bun check --target es2022

Output

In a terminal:

1 | import { greet } from "./user";
2 |
3 | const message = greet({ id: "1", name: "Ada" });
                            ^
error: TS2322: Type 'string' is not assignable to type 'number'.
    at src/index.ts:3:25

2 |   id: number;
      ^
note: The expected type comes from property 'id' which is declared here on type 'User'
   at src/user.ts:2:3

Found 1 error in 1 file, checked 2 files [14.00ms]

When there are more than 50 errors, identical errors are grouped and sorted by how often they happen. --all prints every one.

1 | export const v0: number = "0";
                 ^
error: TS2322: Type 'string' is not assignable to type 'number'.
    at m1.ts:1:14
    60 times in 2 files
      30  m1.ts:1
      30  m2.ts:1

When stdout isn't a terminal, you get the same format as tsc --pretty false, so problem matchers and scripts written for tsc keep working.

src/index.ts(3,25): error TS2322: Type 'string' is not assignable to type 'number'.

In GitHub Actions, errors are also printed as workflow commands so they show up as annotations on the diff, also when the step runs in a subdirectory.

::error file=src/index.ts,line=3,col=25,endLine=3,endColumn=27,title=TS2322::Type 'string' is not assignable to type 'number'.

With AGENT=1:

<error file="src/index.ts" line="3" column="25" code="TS2322">
Type 'string' is not assignable to type 'number'.
<source>
1 | import { greet } from "./user";
2 |
3 | const message = greet({ id: "1", name: "Ada" });
                            ^^
</source>
<related file="src/user.ts" line="2" column="3">The expected type comes from property 'id' which is declared here on type 'User'</related>
</error>

What you need installed

bun add -d @types/bun

That's for console, fetch, Bun and bun:test. bun init installs it for you.

You don't need the typescript package. TypeScript's lib.*.d.ts files (Array, Promise, the DOM and so on) are built into Bun. They're always the ones from TypeScript 7.0.2, no matter which version your project has installed. Your editor may still want the package.

$ bun -p process.versions.typescript
7.0.2

Flags

Flag What it does
-p, --project <path> A tsconfig.json, or the directory that holds one
--pretty / --no-pretty Source around each error, or one line per error
--all Show every error instead of grouping identical ones above 50
--threads <n> Number of threads. Default: one per core
--timing Print how long loading and checking took
--cwd <path> Set the working directory
--strict, --target, ... Any compiler option, as for tsc

Docs are in docs/runtime/check.mdx.

Also fixed

3 bugs that aren't in the type checker. We ran into them while testing it, and they're on main too.

  • Bun.build({ tsconfig: "./custom.json" }) ignored the option. The 3 tests for it passed anyway, because in each of them the tsconfig.json that Bun finds by itself says the same thing. Now that build reads the file in place of every tsconfig.json, like --tsconfig-override. For both, a directory means the tsconfig.json in it, like tsc -p. Other builds in the same process, and the program's own imports, aren't affected, even while it's running.
  • --tsconfig-override printed Internal error: directory mismatch for directory "/app/custom.json", fd 3. You don't need to do anything, but this indicates a bug. every time, for bun build and for bun run.
  • On Linux without pidfd_open, a child process that exits could interrupt a system call of the main thread with EINTR. Code that doesn't retry, like an addon or bun:ffi, saw a failed read(). It also made spawn.test.ts fail in about half of the ASAN builds of this branch.

Intentional differences from tsc

  • No emit. noEmit, declaration and incremental don't change anything.
  • bun check has no --watch. bun --watch --check <file> checks before every restart.
  • Language service plugins (plugins in compilerOptions) aren't loaded.
  • listFiles, listFilesOnly and traceResolution work. Other options that only print things, like explainFiles, are ignored.
  • Messages that tell you to run npm i --save-dev say bun add -d.
  • The lib.*.d.ts files are built in. A path in one of them is printed as bundled:///libs/lib.dom.d.ts.
  • A misspelled compiler option gets a suggestion: Unknown compiler option 'strct'. Did you mean 'strict'?
  • If an import fails because a package in package.json isn't installed, a note names the package.json and says how to run bun install for it.
  • If a syntax error or an invalid option stops the type check, like it does in tsc, a note says how many files weren't checked: Stopped before type checking 2 files. Fix the errors above to see the rest.
  • TS2309 (export = in a module that has other exports) is also reported when the other export is in a declare module block in another file. tsc 6.0.2 reports it too. tsc 7.0.2 only does when both are in one file.
  • acc = apply(run, ["x", acc]) in a loop, where the parameter is a tuple: tsc 7.0.2 reports TS2345 because the array literal loses its tuple type. tsc 6.0.2 doesn't, and bun check doesn't.
  • You get the same errors no matter how many threads it uses or what order the files are in. That isn't always true of tsc.

You can see it with 2 files:

// a_user.js
const p = new Packet()
p.a = 1
// z_packet.js
class Packet {
  constructor () {
    this.a = null
    this.c = null
  }
  own () { return this.c }
}

With allowJs, checkJs and strict:

TS7008 on a TS7008 on c
tsc 6.0.2 yes yes
tsgo 7.0.2 --singleThreaded or --checkers 1 yes yes
tsgo 7.0.2, default no yes
all of the above, with a_user.js renamed to zz_user.js no yes
bun check, either name yes yes

How did you verify your code works?

This is about 150,000 lines of new code, so there's a lot of room for mistakes. A type checker that's wrong once in a thousand files is worse than not having one, and "the tests pass" isn't a good enough reason to trust it. Most of the work here went into trying to prove it wrong.

Everything below compares bun check against the real tsc from TypeScript 7.0.2 on the same files. None of it compares against what we think the answer should be.

Real projects

Each of these repos is checked with tsc 7.0.2 and with bun check, once for every tsconfig.json in it. "Identical" means both report the same set of (file, line, column, error code).

Project tsconfig.json files Identical Errors in tsc Errors in bun check Messages worded differently
vercel/ai 52 52 9,742 9,742 0
anthropics/anthropic-sdk-typescript 16 16 596 596 0
apollographql/apollo-client 7 7 559 559 0
arktypeio/arktype 5 5 389 389 0
withastro/astro 12 12 1,996 1,996 0
axios/axios 1 1 105 105 0
vuejs/core 6 5 1,359 1,358 0
date-fns/date-fns 3 3 1 1 0
discordjs/discord.js 2 2 3 3 0
drizzle-team/drizzle-orm 3 3 10,786 10,786 0
Effect-TS/effect 10 10 2 2 0
elysiajs/elysia 4 4 53 53 0
excalidraw/excalidraw 7 7 11,048 11,048 0
fastify/fastify 1 1 0 0 0
TanStack/form 13 13 124 124 0
gcanti/fp-ts 2 2 3 3 0
sindresorhus/got 1 1 2 2 0
graphql/graphql-js 3 3 24 24 0
unjs/h3 1 1 0 0 0
honojs/hono 6 6 14,239 14,239 0
immerjs/immer 1 1 5 5 0
gcanti/io-ts 2 2 3 3 0
pmndrs/jotai 2 2 7 7 0
sindresorhus/ky 2 2 52 52 0
kysely-org/kysely 6 6 1,185 1,185 0
langchain-ai/langchainjs 41 41 5,273 5,273 0
lit/lit 34 34 2,588 2,588 0
mikro-orm/mikro-orm 17 17 87,981 87,981 0
mobxjs/mobx 3 3 186 186 0
mswjs/msw 10 10 5,878 5,878 0
nestjs/nest 30 30 27,345 27,345 0
vercel/next.js 356 356 3,690 3,690 0
unjs/nitro 5 5 742 742 0
nuxt/nuxt 3 3 11 11 0
openai/openai-node 4 4 6 6 0
microsoft/playwright 4 4 22 22 0
preactjs/preact 1 1 1 1 0
prisma/prisma 44 44 24,201 24,201 0
puppeteer/puppeteer 10 10 2,701 2,701 0
TanStack/query 15 15 686 686 0
react-hook-form/react-hook-form 2 2 3 3 0
remix-run/react-router 14 14 6,735 6,735 0
reduxjs/redux 1 1 0 0 0
reduxjs/redux-toolkit 8 8 142 142 0
remeda/remeda 7 7 13 13 0
rollup/rollup 9 9 107 107 0
TanStack/router 29 29 4,853 4,853 0
ReactiveX/rxjs 10 10 22,271 22,271 7
sequelize/sequelize 16 16 6,768 6,768 0
solidjs/solid 7 7 740 740 0
storybookjs/storybook 19 19 1,401 1,401 0
stripe/stripe-node 4 4 42 42 0
sveltejs/svelte 5 5 186 186 0
vercel/swr 4 4 314 314 0
TanStack/table 20 20 574 574 0
tldraw/tldraw 4 4 0 0 0
gvergnaud/ts-pattern 2 2 2 2 0
total-typescript/ts-reset 2 2 4 4 0
millsp/ts-toolbelt 1 1 3 3 0
sindresorhus/type-fest 2 2 0 0 0
typeorm/typeorm 4 4 959 959 0
microsoft/TypeScript 4 4 613 613 0
typescript-eslint/typescript-eslint 35 35 18,392 18,392 0
urql-graphql/urql 2 2 17 17 0
fabian-hiller/valibot 2 2 1 1 0
pmndrs/valtio 1 1 0 0 0
vitest-dev/vitest 18 18 2,111 2,111 0
microsoft/vscode, src/tsconfig.json 1 1 0 0 0
vscode's extensions, tests and base configs 105 105 5,685 5,685 0
statelyai/xstate 8 8 545 545 0
jquense/yup 1 1 1 1 0
colinhacks/zod 10 10 191 191 0
pmndrs/zustand 1 1 0 0 0
all 72 1,103 1,102 286,267 286,266 7

The error counts show how much there was to compare. They aren't what you'd get building these projects properly. Each row adds up all of its configs, each checked by itself, and most of the projects are installed but not built, so imports of their own dist folders don't resolve. A project with no errors only shows that bun check raises no false alarms. One with thousands shows that it finds the same problems in the same places. 82 of the configs have no errors in either.

VS Code's own build is src/tsconfig.json: 9,795 files, 0 errors in both. The other 105 configs in that repo are its extensions, its tests and base configs that only exist to be extended. The extensions' dependencies aren't installed here, which is where 5,272 of those errors come from.

There's no config that passes in one and fails in the other.

Not every one of those is a comparison of types. Of the 637 configs of the 69 repos, tsc reports type errors in 494 (276,703 errors) and nothing in 82. In the other 61 it stops at an error about the config itself, most often baseUrl, which TypeScript 7 removed, and checks no types at all. bun check stops there too, so those 61 only compare that error. For 7 repos that's every config we have: discord.js, fp-ts, io-ts, preact, ts-toolbelt, urql and yup.

The table counts an error as the same if the file, line, column and code are. Comparing the whole text of all 277,975 errors, with the lines under them, 9 are worded differently: the 7 in rxjs that are under Known problems, and 1 in sequelize that 2 configs report, where tsc names the type string | (object & { url?: string; }) and bun check names its alias.

For vscode, next.js and elysia that's every tsconfig.json in the repo. The other 69 repos have 1,311 between them, and we dropped the ones that give the same answer as another config in the same repo. Configs with references (138 of them) are compared against tsc -b, the rest against tsc -p.

That comparison is about which errors there are. For order and repeats we took every config with references, 317 in 21 of the repos, and compared the error lines one by one as they're printed. tsc -b repeats a line in 26 of them, 1,047 lines in all, because 2 projects include the same file. 316 are identical. The other one is the vercel-ai config below, and it's identical to the second build.

2 places where the comparison is lenient:

  • typescript-go's TS6059 and TS6307 (a file isn't under rootDir, or isn't listed in the project) change from run to run. We ran it 6 times per config. bun check is allowed to report what any of the 6 runs reported, and has to report what all 6 did.
  • One config (in vercel-ai) is compared against typescript-go's second -b build instead of its first. Its first build caches "this file doesn't exist" for outputs that it then writes, and reports 167 errors that go away if you run it again.

Elysia's Eden Treaty turns the type of a whole server into a typed client, which is about as hard on a type checker as real code gets. Besides the repo, we check apps with 17, 50 and 200 routes, and a program that uses edenFetch, WebSockets, macros, guards, file uploads, cookies, SSE and validators from zod, valibot and arktype, each with correct and incorrect calls. Every error and every message is identical. One of the apps is a test in this PR.

These are npm packages that publish their .ts sources and a tsconfig.json, checked where they sit in node_modules:

Package Version Files Errors in tsc Errors in bun check Messages worded differently
<%= dasherize(name) %> 0.0.0 6 1 1 0
@actions/github-script 7.0.1 7 0 0 0
@arrows/array 1.4.1 97 0 0 0
@arrows/composition 1.2.2 28 4 4 0
@arrows/dispatch 1.0.3 11 0 0 0
@arrows/error 1.0.2 3 2 2 0
@arrows/multimethod 1.4.1 12 4 4 0
atomically 1.7.0 11 26 26 0
@aws-crypto/sha1-browser 5.2.0 5 14 14 0
@aws-crypto/sha256-browser 5.2.0 5 14 14 0
@aws-crypto/sha256-js 5.2.0 5 15 15 0
@aws-crypto/util 5.2.0 5 15 15 0
@azure/arm-appservice 15.0.0 69 12 12 0
@azure/arm-resources 5.2.0 25 2 2 0
@bcoe/v8-coverage 0.2.3 8 6 6 0
benny 3.7.1 13 10 10 0
@braintree/sanitize-url 7.1.1 4 1 1 0
@braintree/sanitize-url 7.1.2 4 1 1 0
comment-parser 1.2.4 35 25 25 0
comment-parser 1.4.1 35 27 27 0
comment-parser 1.4.5 35 27 27 0
comment-parser 1.4.6 35 27 27 0
comment-parser 1.4.7 35 27 27 0
comment-parser 1.4.8 35 1 1 0
comment-parser 1.4.9 35 1 1 0
@compodoc/ngd-core 2.1.1 3 0 0 0
@compodoc/ngd-transformer 2.1.3 3 36 36 0
convex 1.28.2 174 135 135 0
convex-helpers 0.1.104 30 1 1 0
csp_evaluator 1.1.1 22 0 0 0
devcert 1.2.3 11 14 14 0
dexie-react-hooks 4.4.0 23 0 0 0
editions 6.22.0 4 6 6 0
@electric-sql/pglite-socket 0.0.6 8 2 2 0
@electric-sql/pglite-socket 0.1.3 9 2 2 0
@electric-sql/pglite-socket 0.2.7 10 3 3 0
@electric-sql/pglite-tools 0.2.7 7 2 2 0
@electric-sql/pglite-tools 0.3.3 7 2 2 0
@embroider/reverse-exports 0.2.0 3 86 86 0
example-typescript 1.0.0 7 13 13 0
expo-asset 11.1.5 25 80 80 0
expo-asset 12.0.13 25 74 74 0
expo-asset 57.0.18 26 94 94 0
expo-constants 17.1.6 6 69 69 0
expo-constants 18.0.13 6 67 67 0
expo-constants 57.0.19 6 87 87 0
expo-file-system 18.1.10 18 79 79 0
expo-file-system 19.0.22 22 52 52 0
expo-file-system 57.0.7 36 70 70 0
expo-font 13.3.1 19 18 18 0
expo-font 14.0.11 21 56 56 0
expo-font 57.0.4 24 2 2 0
expo-haptics 15.0.8 4 53 53 0
expo-image 3.0.11 32 94 94 0
expo-keep-awake 14.1.4 4 5 5 0
expo-keep-awake 15.0.8 4 52 52 0
expo-keep-awake 57.0.2 4 70 70 0
expo-linking 8.0.12 13 69 69 0
expo-modules-autolinking 2.1.10 22 3 3 0
expo-modules-autolinking 3.0.25 40 2 2 0
expo-modules-autolinking 57.0.13 46 1 1 0
expo-modules-core 2.3.13 41 25 25 0
expo-modules-core 3.0.30 44 57 57 0
expo-modules-core 57.0.18 46 75 75 0
expo-splash-screen 31.0.13 4 53 53 0
expo-sqlite 14.0.6 14 34 34 0
expo-status-bar 3.0.9 5 56 56 0
expo-status-bar 57.0.1 6 72 72 0
expo-symbols 1.0.8 5 55 55 0
expo-system-ui 6.0.9 8 52 52 0
expo-web-browser 15.0.11 7 52 52 0
@expo/devcert 1.2.0 11 25 25 0
@expo/devcert 1.2.1 11 84 84 0
@expo/dom-webview 57.0.1 8 76 76 0
@expo/log-box 57.0.4 42 74 74 0
feed 4.2.2 12 0 0 0
@glimmer/component 2.1.1 4 5 5 0
@huggingface/jinja 0.3.4 6 0 0 0
human-id 4.1.1 3 0 0 0
human-id 4.1.3 3 0 0 0
human-id 4.2.0 3 0 0 0
human-id 4.2.1 3 0 0 0
import-in-the-middle 1.14.0 3 2 2 0
import-in-the-middle 1.15.0 3 2 2 0
import-path-rewrite 0.0.1 4 5 5 0
junit-xml 1.2.0 5 1 1 0
khroma 2.1.0 50 148 148 0
@layerup/layerup-security 1.6.0 5 0 0 0
@lokalise/node-api 12.8.0 226 1 1 0
merge-anything 2.4.4 3 6 6 0
mimetext 3.0.28 8 7 7 0
@monaco-editor/react 4.7.0 3 4 4 0
mongodb 6.21.0 131 64 64 0
mongodb 7.5.0 131 1 1 0
mongodb 7.6.0 132 1 1 0
mongodb 7.7.0 132 62 62 0
moo-color 1.0.3 12 33 33 0
next-mdx-remote-client 1.1.2 15 1 1 0
npx-import 1.1.4 4 1 1 0
oblivious-set 2.0.0 3 14 14 0
onigasm 2.2.5 5 33 33 0
openapi3-ts 2.0.2 12 11 11 0
opencontrol 0.0.6 5 52 52 0
path-data-parser 0.1.0 4 0 0 0
pickleparser 0.2.1 19 278 278 0
pino 10.3.0 17 3 3 0
pino 10.3.1 17 3 3 0
pino 8.17.2 17 42 42 0
pino 9.14.0 17 42 42 0
piscina 3.1.0 28 34 34 0
piscina 4.8.0 46 46 46 0
pkg-pr-new 0.0.53 4 8 8 0
pkg-pr-new 0.0.71 4 44 44 0
pkg-pr-new 0.0.72 4 12 12 0
pkg-pr-new 0.0.75 4 12 12 0
pkg-pr-new 0.0.87 4 48 48 0
pkg-pr-new 0.0.88 4 48 48 0
@pnpm/config.env-replace 1.1.0 3 11 11 0
@pnpm/network.ca-file 1.0.2 3 11 11 0
protractor 7.0.0 7 1 1 0
react-static-example-typescript None 10 17 17 0
@redocly/openapi-core 1.34.20 278 49 49 0
resolve-package-path 1.2.7 4 116 116 0
resolve-package-path 2.0.0 4 116 116 0
resolve-package-path 3.1.0 4 104 104 0
rxjs 7.3.0 250 2 2 0
rxjs 7.8.1 251 1 1 0
rxjs 7.8.2 251 1 1 0
signal-polyfill 0.2.2 25 14 14 0
@stablelib/base64 1.0.1 3 15 15 0
@statelyai/inspect 0.4.0 11 22 22 0
@streamparser/json 0.0.21 29 1 1 0
@supabase/ssr 0.5.2 12 4 4 0
template 0.0.0 35 63 63 0
tunnel-rat 0.1.2 3 0 0 0
unfurl.js 6.4.0 14 16 16 0
uri-js 4.2.2 10 1 1 0
@vercel/agent-eval-playground 0.1.3 40 106 106 0
@verdaccio/core 8.0.0-next-8.1 19 3 3 0
@verdaccio/logger-prettify 8.0.0-next-8.0 9 15 15 0
@verdaccio/url 13.0.0-next-8.1 6 2 2 0
@verdaccio/utils 7.0.1-next-8.1 11 7 7 0
vite-plugin-externalize-deps 0.10.0 4 0 0 0
vscode-tas-client 0.3.3 7 0 0 0
@wdio/xvfb 9.27.2 5 16 16 0
webpod 0.0.2 4 8 8 0
with 7.0.2 3 10 10 0
workbox-core 7.3.0 30 34 34 0
workbox-core 7.4.1 30 34 34 0
@workflow/world 5.0.0-beta.27 29 4 4 0
yaml-ast-parser 0.0.43 38 167 167 0
all 151 4,096 4,496 4,496 0

We developed against most of the repos in the first table, so try it on your own project:

bunx -p typescript@7.0.2 tsc --noEmit --pretty false > tsc.txt
bun check --no-pretty > bun.txt
diff tsc.txt bun.txt

If there's a difference, please open an issue.

Compiler options the projects don't use

Projects only exercise the options they've chosen. So the 69 repos are checked again under 11 other sets of options.

Options Projects Identical Errors in tsc Errors in bun check
every strictness flag on 69 69 100,756 100,756
strict off 69 68 76,960 76,958
skipLibCheck off 69 69 90,609 90,609
checkJs 69 69 84,122 84,122
declaration 69 69 80,495 80,495
isolatedModules with verbatimModuleSyntax 69 69 80,622 80,622
isolatedDeclarations 62 62 34,982 34,982
erasableSyntaxOnly with legacy decorators 69 69 71,577 71,577
nodenext 69 69 85,238 85,238
"types": [] 69 69 105,818 105,818
"lib": ["es5"] 69 69 83,872 83,872

typescript-go crashes or times out on 7 repos with isolatedDeclarations, so those aren't compared. Of the 896,192 errors both report across all 11 sets, 21 are worded differently.

TypeScript's own tests

typescript-go runs TypeScript's compiler and conformance tests on itself (12,762 files). Some tests ask for several sets of compiler options, which makes 13,101 runs. For each one it commits what it expects, as files. bun check has to produce the same files, byte for byte.

Baseline What it holds Tests Identical
.errors.txt every error, with the source around it 13,101 13,101
.types the printed type of every expression and name 12,463 12,463
.symbols the symbol of every name, with where it is declared 12,463 12,463
.js the declaration files that are emitted, and the errors in them 13,032 13,032
.trace.json the log of how every import was resolved, with traceResolution 151 151

Not every test has every kind of baseline. The .errors.txt baselines contain 966 different error codes.

A .js baseline also has the JavaScript that tsc emits. That part isn't compared, because Bun has its own transpiler. The same goes for the .js.map and .sourcemap.txt baselines. bun check doesn't write declaration files for you either. It generates them in memory for projects that other projects reference, and that's the code these baselines test.

typescript-go's test runner skips 45 tests, and 8 more when it compares what's emitted. This one skips the same ones.

The tests and the baselines are vendored in this PR as one file (test/cli/check/typescript-go/bundle.zst, 8 MB, written by sync.ts from a typescript-go tag). All 5 kinds run in CI:

bun bd test test/cli/check/conformance

Generated programs

TypeScript's tests only have a few forms of some things. Take this:

let s: S | null = mk();
while (s) {
  const cur = { v: s };
  s = cur.v;
}

tsc reports TS7022 on cur. Its type needs the type of s, which needs what the loop assigns at the bottom, which needs cur. There are thousands of ways to write that loop, and a type checker can pass every one of TypeScript's tests and still say nothing about most of them.

So there are generators. Each one writes a cross product with one function per line, runs tsc and bun check on it, and compares. There's no expected output stored anywhere. tsc is the oracle.

These are in test/cli/check/differential.test.ts, and all of them pass:

What it generates Functions What has to match
narrowing: the reference, the guard, the control flow around it, what happens before the use 46,080 every error and its message
variables without a type annotation 29,484 every error and its message
calls with callbacks: the callee, the form of the callback, the context of the call 9,984 every error and its message
circular references, directly and through a second declaration 9,196 every error and its message
a variable in a loop that's assigned back, in 12 kinds of loop 20,304 which loops have an error
index signatures: 14 kinds of key like string & {}, what they're indexed by, how a name is written in a destructuring or an object literal 4,522 every line tsc prints
index signatures: the key of the source and the key of the target, in assignments, inference and redeclarations 1,248 every line tsc prints
a circular reference next to a call with overloads and a callback 3,888 every line tsc prints
an interface that extends a mapped type of itself, in a .d.ts that skipLibCheck hides: 13 forms of base type, 9 kinds of declaration, 36 uses 4,212 every line tsc prints
the same in a file that's checked, with the declaration before its use 4,212 every line tsc prints
a conditional type inside another one that checks the same type, with infer 480 every line tsc prints
a boolean: 13 ways to get one, 16 types it isn't assignable to, 8 ways to assign it 1,664 every line tsc prints
a package with export =: what it exports, what declare module adds to it, how it's imported, 3 messages 144 every line tsc prints
a parameter property that is a pattern: 5 modifiers, 5 patterns, 3 sets of options 75 every line tsc prints
a function from an index signature that is tested and not called: 11 receivers, 11 tests 119 every line tsc prints
a generator with literals where any type is expected: 14 contexts, 10 generators 140 every line tsc prints
a conditional or a mapped type over this: 9 types, 28 uses 252 every line tsc prints
a type that is generic as an object, as an index, as both or as neither: 13 types, 12 places 156 every line tsc prints
what a project with references imports: 5 imports, 5 sets of options, 3 sets of references 75 every line tsc -b prints, in order

It also generates small projects, for file names that differ only in case, like import "./Button" for button.ts. macOS and Windows take those for the same file and Linux doesn't, so it runs on both kinds of file system. Every case runs with forceConsistentCasingInFileNames on, off and unset.

What it generates Cases What has to match
how a file is referred to (8 forms of import and reference, packages, files), in which spellings, in which order, from where 150 every line tsc prints
the same where case matters, plus 2 real files like Button.ts and button.ts 167 every line tsc prints
a project reference that's spelled differently from the directory, or in 2 spellings 27 every line tsc -b prints
tsconfig.json with a value that isn't JSON, like "strict": tru: 28 kinds of value in 30 places 840 every line tsc prints
tsconfig.json whose root is a list, like [{ "compilerOptions": {} }] 9 every line tsc prints
3 projects with references and files that all of them include: the order at the top, who references whom, a project that doesn't exist, a type library that's missing 189 every line tsc -b prints, in order
import() and require() with import or require somewhere in their text, which changes what tsc says about why a file is in the program 44 every line tsc prints

The index signature and overload programs end with a line that has a type error, and tsc has to report it. After a syntax error neither of them checks anything, and then they'd agree about everything. CI runs 70 of the 840 tsconfig.json files, because each one takes 2 processes. All 840 were compared on a laptop.

It runs in CI against TypeScript 7.0.2, which test/package.json installs next to 6 as typescript7. You can also point it at another tsc:

TSC=/path/to/typescript-7/tsc bun bd test test/cli/check/differential.test.ts

These run locally against tsc and aren't in the repo yet:

What it generates Programs Different from tsc
classes: access, overriding, initialization, heritage, super, references to itself, 2 members with one name 290,000 0
overloads, inference, variance (21 groups) 1,300,000 0
JSX: 48 tags, 48 lists of attributes, 23 forms of children 63,770 0
where a long type is cut off in a message 1,060,000 0
2 declarations of one variable or property 123,891 0
module augmentation through re-exports and aliases 210 1
JSDoc tags on every kind of host, in checked JavaScript 68,334 0
class expressions that refer to what holds them 40,128 21
type annotations inside an expression that refer to what's being declared 50,688 95
symbols that tsc creates lazily 15,444 25
immediately invoked functions 19,200 21
type aliases that refer to themselves without end, through 36 kinds of type 517 28

The 1 in module augmentation is the wording of a message. In 28 of the messages that are cut off, tsc doesn't agree with itself from run to run, and those aren't counted.

The 4 rows before the last are all code that refers to itself while it's being declared, like class A { x = { a: null! as { p: A["x"] } } }. In 3 of those 162, tsc reports an error and bun check reports nothing for that declaration.

In the 28 of the last row, both report errors, but not the same list: TS2589 is at another position or in another order, or the TS2538 next to it is missing. tsc crashes with a stack overflow on 23 more of those programs, which aren't counted. bun check reports an error in all 23.

Is it overfit to the tests?

  • We searched the type checker's code for the names of TypeScript's tests. Of the 12,271 names that are 12 characters or longer, 19 appear in code. All 19 are also the name of a compiler option or a builtin (esModuleInterop, noUncheckedIndexedAccess, defineProperty and so on).
  • It's a port. 1,791 of the 2,770 functions in typescript-go's internal/checker are named in comments, so you can read the two side by side.
  • A bug found in a real project or by a generator gets reduced to a few lines and added to test/cli/check/check.test.ts, with the output of tsc as the expected output. A test is only added if it fails without the fix. There are 431 tests in that file.

Read side by side with typescript-go

Passing tests doesn't show that a port behaves like the original. TypeScript's tests guard tsc against its own regressions, and tsc never had this port's bugs. So every function of typescript-go's checker, binder, module resolver, config parser, program and build mode was read next to its counterpart here. Wherever the two could behave differently, the reader had to write a small program that shows it and run both tools on it. A second reader ran each program again and tried to refute it.

1,706 of those programs are in test/cli/check/differential-cases.json. differential-cases-1.test.ts to differential-cases-4.test.ts run tsc 7.0.2 and bun check on each, on every platform where CI runs Bun's tests, and the output has to be the same. Windows skips 3 that need a directory named c:.

What the program is about Programs
an error that tsc reports 671
an error that tsc doesn't report 538
the words of a message 419
the position of an error 55
the order of the errors 22
a crash 1

The programs on which the two disagree are under "Known problems".

Threads

It uses all of your cores, so the answer could depend on which thread gets somewhere first.

One of the tests generates 60 modules that all enter the same cycles (variance of type parameters, recursive type aliases, functions and constants without annotations) and checks them on 1, 2, 3, 8 and 16 threads. The output has to be byte for byte the same. typescript-go reports 518, 519, 521 and 525 errors for that program with 1, 2, 4 and 8 checkers.

Broken code

You run a type checker on code you're in the middle of writing. The worst thing it can do there is give up on a file and say everything is fine.

One of the tests takes 268 valid files from TypeScript's tests and damages each in 7 ways (truncate, delete a token, insert a stray token, swap 2 tokens, replace a token, cut at a random byte, delete a line), then appends a type error. With 17 more written by hand, that's 1,893 files. Every one of them has to report something.

Breaking real code

Most of the code in the projects above compiles. To see what happens to real code with errors in it, a script takes packages/effect from Effect (496 files, and about as hard on a type checker as TypeScript gets), breaks 4 files at a time, runs tsc and bun check, and compares every error with its whole message. There are 32 ways to break a file: swap 2 arguments, drop a type argument, turn never into unknown, delete an overload, reverse a conditional type, remove readonly, and so on.

Mutations Errors in tsc Different error codes Missing in bun check Only in bun check Worded differently
913 2,925 67 0 0 8

Module resolution

With traceResolution, tsc logs every step of resolving every import: each file it looks for, each package.json it reads, each condition in exports it tries. bun check prints the same log. For 69 of the projects above that's 8,463,167 lines, and all 69 logs are identical.

typescript-go resolves on several threads, so which lookup of a package.json says "cached" changes between runs. Both logs go through the normalization that typescript-go's own test runner uses for that.

Overflow checks and assertions

A release build doesn't check for integer overflow, so an index that wraps around can go unnoticed as long as the output looks right. All of TypeScript's tests and all 637 tsconfig.json files from the survey also run on a build with overflow checks and debug assertions turned on. Nothing panics and the output is the same.

Big inputs

16 tests generate programs that grow in one direction: 400 if statements in a finally block, 400 nested loops, a chain of 400 method calls, a union of 100 object types narrowed one member at a time, 400 overloads, and so on. An exponential algorithm doesn't finish at those sizes.

4 more are long instead of deep: 40,000 top-level lines of export const v = o.a.b.c + k.y.y.x, of template expressions, and of calls with callbacks. 16,000 lines of the first take 0.15 seconds. tsc 7.0.2 takes 53.

Everything else

Adding a type checker shouldn't make bun run or bun build slower when you aren't type checking. Parsing 7,012 TypeScript files (37 MB) takes 1.003x the instructions it does on main, and typescript.js (9 MB) takes 0.995x.

Performance

tsc 7.0.2 with default settings against bun check on 16 threads. 16-core Apple silicon, 5 rounds, alternating between the two. Wall clock time is the fastest round, CPU time and memory are medians. Both report exactly the same errors in every row.

Wall clock time:

Project Files tsc 7.0.2 bun check Faster
vscode src 9,795 5.98 s 1.24 s 4.8x
mikro-orm 2,883 5.97 s 1.20 s 5.0x
next.js packages/next 2,881 1.82 s 0.28 s 6.4x
next.js, root 3,547 1.28 s 0.42 s 3.1x
storybook scripts 1,039 0.96 s 0.27 s 3.5x
nuxt 839 0.80 s 0.27 s 3.0x
playwright 706 0.64 s 0.15 s 4.2x
lit packages/react 6 2.12 s 0.46 s 4.6x

CPU time:

Project Files tsc 7.0.2 bun check Less
vscode src 9,795 32.1 s 15.2 s 2.1x
mikro-orm 2,883 29.4 s 11.2 s 2.6x
next.js packages/next 2,881 6.8 s 2.8 s 2.5x
next.js, root 3,547 5.2 s 4.2 s 1.2x
storybook scripts 1,039 4.8 s 1.8 s 2.6x
nuxt 839 4.2 s 1.7 s 2.5x
playwright 706 3.6 s 1.3 s 2.8x
lit packages/react 6 2.8 s 0.5 s 5.6x

Peak memory:

Project Files tsc 7.0.2 bun check Less
vscode src 9,795 7.97 GB 2.14 GB 3.7x
mikro-orm 2,883 6.67 GB 1.35 GB 4.9x
next.js packages/next 2,881 1.81 GB 0.71 GB 2.5x
next.js, root 3,547 1.33 GB 0.55 GB 2.4x
storybook scripts 1,039 1.39 GB 0.56 GB 2.5x
nuxt 839 1.14 GB 0.51 GB 2.2x
playwright 706 1.06 GB 0.46 GB 2.3x
lit packages/react 6 0.63 GB 0.24 GB 2.6x

Measured with other work running on the machine (load average 6 to 13), and with a release build of the type checker on its own, not a release build of Bun. The tsc 6.0.2 number at the top is the better of 2 runs on Node 25.6, on the same machine under the same load.

Long-running processes

Bun.build({ check: true }) can run many times in one process. A test runs repeated builds and checks that memory doesn't grow.

A first run

bun init, then bun check --skipLibCheck false, which also checks every declaration file in @types/bun, @types/node and React against the built-in lib.*.d.ts files:

Template Files checked Errors
bun init -y 244 0
bun init --react 254 0
bun init --react=tailwind 256 0
bun init --react=shadcn 279 0

Projects that have an older typescript installed. bun check reports the same errors as it does with the files of the TypeScript 7.0.2 package:

Project Installed typescript Errors
dayjs 2.9.2 0
immer 5.0.2 5
svelte 5.5.4 62
zod 5.5.4 31
drizzle-orm 5.6.3 10,845
solid 5.7.3 352
vercel/ai 5.8.3 1,561
lit 5.9.2 1,891
apollo-client 5.9.3 461

A test compares all 108 built-in files with the typescript package, byte for byte.

Also compared with tsc 7.0.2, with the same output: 150 valid, outdated, misspelled, empty and wrongly typed values in tsconfig.json. Windows line endings, a byte order mark, UTF-16 and emoji in source files. Paths with spaces, Cyrillic, Japanese and accents. A tsconfig.json that extends 1 package, 2 packages or a missing one. Both kinds of decorators. The config files that create vite writes. A workspace whose packages import each other's sources.

bun check | head -1 with 24,000 errors exits normally. Ctrl-C in a terminal ends it in 35 ms with exit code 130.

What hasn't been tested

  • The comparisons against tsc on real projects only ran on macOS arm64. CI builds this for Windows x64 and arm64, macOS, Linux glibc and musl, Android and FreeBSD, and runs test/cli/check wherever it runs Bun's tests.
  • ThreadSanitizer hasn't run on this version.
  • Most of the unsafe code doesn't run under Miri.
  • Only TypeScript 7.0.2. We haven't tried syncing to a newer typescript-go.

Known problems

Where it differs from tsc 7.0.2:

  • typescript-go's answer for a file can depend on which other files are in the program, in what order, and on how many checkers it uses. bun check gives the same answer at any thread count, and everything here is compared against typescript-go with 1 checker. It shows in 1 of the 1,103 configs above: in vuejs/core's packages-private/tsconfig.json, 1 of typescript-go's 940 errors is missing, a TS2345. Reduced to 3 files, typescript-go reports that error with "files": ["global.ts", "model.ts"] and doesn't with ["model.ts", "global.ts"] or ["model.ts"]. Neither file imports the other.
  • In rxjs, 7 of 22,030 messages explain the error along a shorter path: The types returned by '[bufferTime](...)[groupBy]' are incompatible where typescript-go has '[bufferTime](...)[bufferTime](...)[groupBy]'. The position, the code and the first line of the message are the same. It has the same cause: the order the files are checked in.
  • nuxt with strict off: 7 of typescript-go's 74 errors are missing, and there are 5 that it doesn't report.
  • Single-quoted strings in package.json are accepted. typescript-go rejects them.
  • interface Foo extends Partial<Foo>, or any other mapped type of Foo, is an error in both (TS2310). What tsc says after it depends on what's asked for first, Foo or Partial<Foo>. Within a file bun check says the same. Across files it can differ, because tsc goes by the order of the whole program. With skipLibCheck off, an interface of the library that's extended like that can have members in bun check that it doesn't have in tsc.
  • More than 332 variables without annotations in one loop, each initialized with the one before it: bun check says it couldn't finish the file and exits with code 1.
  • On 254 of the small programs written while reading the two side by side, the output differs. 1 is ordinary code: after if (t === null || t === undefined) return; on a generic t: T, for (const [k, v] of Object.entries(t)) v.foo gets TS18046, 'v' is of type 'unknown', where tsc accepts it. 38 are in unusual code or unusual command lines. For example, function f({ a = 1, b = g(a) }) {} gets a false TS7022, and in enum E { A = 1, B = next(E.A) } with function next(e: E) a false TS2502. In a directory with a jsconfig.json and no tsconfig.json, bun check checks that project where tsc goes on to the parent's tsconfig.json. The other 215 are next to another error, without the default library, or in code nobody writes on purpose.
  • The order of the members of a union of anonymous object types in a message can be different.
  • A type alias that refers to itself without end gets TS2589 from both, but it can be at another position, and a TS2538 next to it can be missing. That's 28 of 517 generated programs.
  • The lines under an error that explain it can differ: 8 of 2,925 errors after breaking Effect's source.
  • for (!function () { n in e; }(); ;) break; is a syntax error in typescript-go 7.0.2. It isn't in TypeScript 6 or here. Minified jQuery 3 has that code.

This adds 5.94 to 7.21 MB to the binary, depending on the platform.

None of this would exist without typescript-go. It's the code this is ported from, the baselines that say what the type of every expression is, and a binary to compare against on any project.

@robobun

robobun commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 10:22 AM PT - Oct 6th, 2026

❌ @Jarred-Sumner, your commit 0ad8bcd has 1 failures in Build #123595 (All Failures):

  • 📦 Binary size — 12 over 0.50 MB
  • targetthis build canary: main #123538
    sizeΔ
    ❌ bun-darwin-aarch6467.11 MB60.94 MB+6.17 MB
    ❌ bun-darwin-x6473.98 MB66.84 MB+7.14 MB
    ❌ bun-linux-aarch6483.87 MB77.05 MB+6.81 MB
    ❌ bun-linux-x6484.39 MB77.50 MB+6.89 MB
    ❌ bun-linux-aarch64-musl76.82 MB69.88 MB+6.94 MB
    ❌ bun-linux-x64-musl78.42 MB71.33 MB+7.09 MB
    ❌ bun-linux-aarch64-android89.73 MB83.41 MB+6.31 MB
    ❌ bun-linux-x64-android93.82 MB86.65 MB+7.17 MB
    ❌ bun-freebsd-x6492.22 MB85.36 MB+6.86 MB
    ❌ bun-freebsd-aarch6493.13 MB86.37 MB+6.76 MB
    ❌ bun-windows-x6491.41 MB84.20 MB+7.21 MB
    ❌ bun-windows-aarch6478.90 MB72.96 MB+5.94 MB

    Add [skip size check] to the commit message if this increase is intentional.


🧪   To try this PR locally:

bunx bun-pr 44361

That installs a local version of the PR into your bun-44361 executable, so you can run:

bun-44361 --bun

…o is tried first

- The type of a string literal is found by what the literal says, in an array: no hashing and no lock. There is one for nearly every string in a program.
- Tables many threads add to are in 256 parts, from 64. The place of an entry goes by what is kept of its hash, so a part grows without looking at what it is a table of, which it did while holding its lock.
- To tell whether a call of an overloaded function is in error, all that is asked is whether any overload applies. The one the call was resolved to is tried first, which spares inferring type arguments for those before it: 4% fewer instructions on a big project.
…second time

Choosing among overloads tries each candidate, which for a generic one means inferring its type arguments. The one that was chosen was then inferred for once more. If none of the arguments waits for the others there is nothing more to find out, and what the trial came to is taken. 13% fewer instructions on code that is mostly calls of overloaded generic functions, as tests are.
For a person at a terminal:
- What is underlined goes by how wide characters are shown: two columns for most of what is written in East Asia and for emoji.
- Of a line that is longer than the terminal is wide, the part around the error is shown.
- A message that does not fit goes on in the next line, indented, and is broken between words.
- Types and names quoted in a message have the colors they have in source.
- The reasons under an error are drawn as a tree.
- The summary lists the twelve files with the most errors, and says how many there are in the rest.

Also what is wrong with `compilerOptions` as written: an option there is no such thing as (with the one that was probably meant), a value of the wrong kind, and where in the file. What older versions of TypeScript took is let through. Not asked for by anything yet.
The biggest files are checked first. Among the rest, how long a file takes has little to do with how long it is, and in order of size the few that ask a lot of their types all came at the very end, where one thread worked and the others waited.

- Files that are not big are checked in no particular order, the same each time.
- When one of them takes long, what else is in its directory goes first: files that use the same types tend to be next to each other.
A big project takes seconds, in which nothing was shown. At a terminal, once 300 ms have gone by, a line on stderr says that the program is being loaded, then how many files have been checked and how many errors have been found. The bar goes by bytes of source, which the time goes by more than by files: the biggest files are checked first. The line is gone before the errors are shown. Nothing of it is shown to an agent or where stderr is no terminal.
… contextual types

Stores and tables:
- The element with a number is reached in four instructions.
- `mapper`, `intern` and `intern_sig` hash once and look at nothing but the thread's own table on a hit. Pairs that are in order are not sorted, and nothing is boxed before it is known to be new.
- What a table keeps for the thread is reached without a dynamic cast, and with one look at what is the thread's own instead of two.
- A short name is compared as four numbers.

Calls:
- The pass that reports on calls asks for the type of each argument once.
- Whether the number of arguments is right is told without looking at types unless something is left out or spread.
- The order overloads are tried in is kept.
- For something with one signature its parameters and type parameters are asked for once.

Contextual types:
- What a union comes to for an object literal is worked out once for the literal, not for each member.
- That there is nothing to prepare above an expression is remembered for what is around it.
- What a nested literal or a function in a literal is expected to be is looked up once.

No answer changes.
Relations:
- What is known on the way down a comparison (that no simple rule applies, the key, that it is not in the cache, what the two types are, their members) is passed on instead of being found out again at each level.
- `T | undefined` of an optional property, plain references to global types and what a mapped type's target has a symbol of are kept.
- The relater keeps the recursion identity of each type on its stacks.
- Object against object, and a member of a union against the union, are answered before anything is looked up.

Declarations:
- What a type parameter extends and its default are table loads, kept only if what they were read from is kept.
- Declared type parameters, identity mappers and global types are found in arrays, not by hashing.
- A flag says whether a type can hold an object literal. What awaiting a type gives is kept.

Shapes:
- A checker has its last answers at hand for members, signatures, parameters and type parameters of signatures.
- Whether a type may be reduced is a flag. Names in a shape are found through a plain table of positions.
- A property with one declaration keeps it in place, and a shape kept for all threads gives back the room it does not use.

No answer changes.
… and inference

- `instantiate` answers the easy cases with one look at the type, and has a small table of its own in front of the shared one.
- What pairs of types come to as a union is remembered where nothing but the members is looked at. `filter` and `map_type` allocate nothing for a union that stays as it is.
- What the parameter of a mapped type extends is kept. `tuple[number]` reads the index signature of the array the tuple is based on.
- A question is one frame on one stack, not an entry in each of five. `enter` is inlined without its rare branches. The aids for debugging test a flag and nothing else.
- The types of the expressions of the file at hand are read from the checker. `null`, `true`, `false`, numbers and strings go without a frame.
- The holes of an overloaded call are made when they are first read. A candidate that is not generic is tried as it is declared. The only signature of a type is instantiated once for the type. `returnMapper` is read off the inference just made.

No answer changes.
…and smaller trees

Passes:
- Arrays and tuples are known to be iterable at once. Passes start from the nodes they are about. The way out of an expression is not gone further than it can lead.

Lowering:
- The names a file has said before are found without hashing. `marks` is only searched where something is noted, and no list is allocated per node.

Loading:
- Which files nothing refers to is guessed from what they export, not from the names of directories: 7,000 files fewer are parsed a second time on a project of 45,000.
- A file is read with three system calls, not five, and its directory is only opened for the second file in it. A directory is listed with three.
- Paths are put together without formatting. What a specifier means in a directory is found out once. The labels of the binder are found by number.

Memory:
- Lists that grew give back what they do not use, which `shrink_to_fit` does not do under mimalloc unless a list is less than half full.
- The one declaration of a symbol is kept in the symbol. The lists most files have nothing in take one word. Places in the flow of control that nothing comes after are not kept.

No answer changes.
…ritten

An option that does not exist, a value of the wrong type and a value that is not among those an option takes were silently passed over. They are errors now (TS5023, TS5025 with a suggestion, TS5024, TS6046), shown at their place in tsconfig.json like any other error.
- A walk passes by a test that is about something else. What the operands of a test start with is worked out when a walk first gets to the test, and kept by flow node.
- What a discriminant or a comparison narrows a type to is kept by the types.
- Whether a property tells the members of a union apart is kept for all files.
- What a walk starts from is found out where a walk gets there, not before it sets out.
- Calls without effects are marked by flow node. A join of one type that is no union is that type.

No answer changes.
A union written out is the same type as an alias that stands for it, and goes by the name of the alias in messages. Which aliases counted was those that had been resolved by the time the message was put into words, which depends on what other threads have got to: the same input could print `string | Block[]` in one run and `Input` in the next.

The table of names is now filled in at once, in the order of the files, when a message first needs it. Threads that need it help find out what the aliases stand for instead of waiting. The output of a project of 45,000 files is the same byte for byte over repeated runs and with 1, 4 and 16 threads.
The message had a hole where the file goes. It also comes with TypeScript's advice now: install `@types/x`, declare the module, or amend DefinitelyTyped, by what the program has of the package.

Where TypeScript's messages say `npm i --save-dev`, `bun check` says `bun add -d`.
Such a file is parsed when the program is loaded, to find out what it imports, and again by the thread that checks it. It was also read twice. What it reads is now kept in between, and let go of when it has been checked.

Opening and reading files does not scale on macOS: 45,000 files take 0.5 s with 6 threads and 0.9 s with 16, which spend 10 s in the kernel between them. All threads were reading while they checked. 8% less time on a project of that size, for 180 MB more at the peak.
A class without a constructor is made the ways what it extends is, and each of those signatures is declared where the one it clones is. To find that place the base types of the class were asked for first, as a guard against a class that extends itself. TypeScript never asks for them there, and asking can come back to itself: a false TS2310 in `mixinWithBaseDependingOnSelfNoCrash1`. A class that extends itself has no base signatures to go on with, which ends the search by itself.
`')' expected.` came out as `'{0}' expected.`: the parser knew which token it missed and did not pass it on. An error of the parser can now name something that cannot be told from where it is. That fills TS1005 (650 places in TypeScript's tests), TS17002 and TS1209. TS6142 and TS2665 say which file a module resolved to, TS2615 which property of which mapped type.

Of 34,469 messages in TypeScript's tests, 99.2% now read the same in the first line (97.4% before) and 98.9% with every reason below it (97.2%). None has a placeholder left.

Also: a `this` parameter in a function type written in a JSDoc comment has the type that follows it. It was taken for the type of a `@this` tag, which does not count, and reported as implicitly `any` (TS7006).
… the driver of `bun check`

The development tool has a new command, `baselines`. It splits each compiler and conformance test into its files, puts them in a file system that is only in memory, checks them through the same function `bun check` calls, writes what comes out in the format of typescript-go's `.errors.txt` baselines, and compares. It needs no copy of the tests laid out on disk and no TypeScript to run, covers what a directory cannot express (drive letters, `..` above the root, odd encodings), and tests what ships: configuration errors, sorting, the words and how far each error reaches.

For that the driver can check a project through any host (`check_project`), and a configuration file can be loaded with options said after it (`load_overriding`), which a command line will need too.

Found by it so far:
- `node_modules`, `package.json` and `@types` in the root directory were looked for under `//`.
- Errors that are the same were not reported once (`SortAndDeduplicateDiagnostics`).
- Two errors with the same code that start at the same place and do not reach as far are two errors: `(a, b, c)` has one about `a` and one about `a, b`.
- Of an empty array pattern no element is asked for, so that it cannot be iterated is only said of the declaration.
Options that do not go together (`checkJs` without `allowJs`, `module` against `moduleResolution`, a `paths` entry that is not relative and thirty more) were reported by a code alone: the message had holes where the names go, and no place. `verifyCompilerOptions` is now ported with what each message names, what is said below it, and where it points: the name or the value of the option in tsconfig.json, an entry of `paths`, or the word `compilerOptions` if the option comes from elsewhere. The same for files that cannot be part of the program and for type libraries that are not found, which also say why they were asked for.

- `bun check` is `tsc --noEmit`, whatever the project says: nothing is written, so what is only wrong with where output would go is not looked into.
- What is wrong and is in no file (`Cannot find global type 'Array'.`) is reported.
- An error can come with related information (`'x' is declared here.`). Nothing fills it in yet.
…ently, and stop where tsc stops

- How much stack is in use was taken from the addresses of two locals. Under AddressSanitizer locals whose address is taken are not on the stack, so every question looked like it had run out of room and was answered "unknown": a debug build found 1 of 17 errors in a small project and said nothing about the rest. It now reads the stack pointer, as `StackCheck` does, and the limit is what the thread really has left.
- A file in which something went unanswered for want of stack is reported as such, and the exit code says so.
- `--timing` shows the most stack any file took.
- As `tsc` does: if something does not parse, that is all that is said. If the options do not go together, or a built-in type is missing, that is. Only then come the errors about types. With `baseUrl`, which TypeScript 7 removed, a project got thousands of errors about imports instead of the one that matters.
- An error can be of no length, as those TypeScript reports on missing nodes are.
…o it

Two classes of the same name in two files, or a class and a variable, were made one symbol with the declarations of both: twice the constructors, the members of either. It shows wherever two versions of a package that declares ambient modules are in one program, as with two versions of @types/node in a monorepo: `new ServerResponse({})` had "No overload matches this call" for what is a plain mismatch, and properties only one version has were there.

As `mergeSymbol` has it, the first keeps the name and stays what it was. What is refused stays what its own declarations are about. The names in its file that the binder had found it for get a symbol that stands in for the first.

In a project of 2,900 files that has 7,579 errors, 85 fewer are false and 156 fewer are missed.
…o says them

- A package that imports itself by name while `outDir`, `declarationDir` or `rootDir` map output back to input finds the input file. TS2209 and TS2210 where the root is ambiguous.
- Names that collide with what is emitted (TS2441, TS2529, TS1216), unless nothing is emitted.
- With `importHelpers`: TS2343, TS2354, TS2807 wherever syntax needs a helper that `tslib` does not have, and TS2818.
- TS1450, TS18057, "There are types at .." under TS7016, the file names in TS6263 and TS2306.
- Related information: where a variable or a member was declared before, which export default is the first, the class that could be declared, the container that hides an outer `this`, the spread that overwrites a property, where `type` is said on an import or export, the function to mark `async`, a missing `await`.
… are about is declared

- What the parser and the scanner object to ends where they said it does: the range they log is kept. Errors on a bare position or a missing node have no length.
- Grammar errors end with the node they are reported on: a list in angle brackets, a parameter, an index signature, a computed name, a decorator's `@`.
- `The parser expected to find a '}' to match the '{' token here.`
- Related information from the relation itself: `'x' is declared here.` under a missing property, `This type parameter might need an `extends` constraint.`
- Several errors with one code at one place are kept where TypeScript keeps them (TS2411, TS2420, TS2430, TS2416, TS2859).
- `noErrorTruncation`: without it long types are cut short, as tsc does.
- Syntax errors in JSON modules. A file that is no text (TS1490).
…ript-go says them

- `'x' is declared here.` under a name used before its declaration and under "Did you mean".
- `The expected type comes from property 'x' which is declared here on type 'T'`, from an index signature, from the return type of a signature.
- Where output goes: the common source directory, TS5009, TS5011, TS6059, and TS5055 / TS5056 under `outDir` and `declarationDir`.
- TS2318 for the global types that are only needed once something uses them, TS2468.
- `noCheck`, `preserveConstEnums`, `deduplicatePackages: false`.
- TS1005 and TS5024 in a configuration file.
- The test harness reads a configuration as TypeScript 7 does, takes `@pretty` and `@captureSuggestions`, and knows what emit adds and takes away.
- Many smaller things in how types are written out.
- `An argument for 'x' was not provided.`, `The last overload is declared here.`, `The call would have succeeded against this implementation, but ..`, `Did you mean to call this expression?`, `Did you forget to use 'await'?`
- The labels of tuple elements are kept, and show in messages.
- `keyof Shape` and `IteratorResult<T, TReturn>` go by those names.
- `<a b />` gives `b` the type `true`.
- A generic function nothing is inferred from is left out of the first round of overload resolution too.
TS9007 to TS9039: what of a file's exports cannot be given a type from syntax alone, with the annotation that would help as related information. A new pass that follows the route the declaration transformer takes, without writing anything. It does nothing unless `isolatedDeclarations` is on together with `declaration` or `composite`.
… is a circle

    const server = Bun.serve({ fetch() { return new Response(`${server.port}`) } })

TypeScript says TS7022 and TS7023 here, and `server` is `any`. Nothing was said, and without `noImplicitAny`, where the errors are not reported, `server` kept its type and uses of it got errors TypeScript does not have.

- `chooseOverload` holds the arguments against a candidate even where it is the only one. That was left out where nothing depends on how it goes, but what leads back from there to something under way is a circle.
- `getQuickTypeOfExpression` is real now: an initializer, an assigned value or a default that is a call or a `new` of the only signature there is, if that is not generic, is what the signature returns, and its arguments are not looked at.
- The first time a function that something is expected of is looked at, what it returns is worked out without a resolution being pushed, as in `contextuallyCheckFunctionExpressionOrObjectLiteralMethod`. Whoever asks meanwhile begins a resolution of their own.
- While a call is under way, what a rest parameter that is no plain array expects of an argument is left unreduced, as `getSpreadArgumentType` has it.
Jarred-Sumner added a commit that referenced this pull request Oct 9, 2026
### What does this PR do?

`cd test && bun check` (#44361) reported 8,080 type errors in 1,107
files. Now it reports none. `tsc` 7.0.2 agrees on both numbers.

```
$ cd test && bun check
✓ No type errors in 2,615 files [418.81ms]
```

Apart from the few files listed under "The JavaScript that did change",
every edit to a test is erased by the transpiler: annotations, type
arguments, `!`, casts, `import type`, `// @ts-expect-error`. That is
checked mechanically, see below.

#### `test/tsconfig.json`

- **`baseUrl` is gone.** TypeScript 7 rejects it (TS5102) and stops
before checking anything. `paths` resolve relative to the
`tsconfig.json` without it, in `tsc` and in Bun's resolver. Of the 1,697
distinct (directory, bare specifier) pairs imported anywhere below
`test/`, `.js` files included, one resolved through `baseUrl`:
`"harness.js"` in `pnpm-migration.test.ts`. It is `"harness"` now, which
is the same file.
- **`lib.dom` is gone.** The config says `"lib": ["ESNext"]`, but one
unused svelte fixture had `/// <reference lib="dom" />`, which adds
`lib.dom` to the whole program. With `lib.dom` loaded, bun-types steps
aside for `ReadableStream`, `WebSocket`, `CompressionStream`, `fetch`
and others, so `type: "direct"` streams, `new
CompressionStream("zstd")`, `new WebSocket(url, { headers })` and so on
were all errors.
- **`composite: false`**, like `src/js/tsconfig.json`. Tests emit no
declarations, and they import files from all over the repository, each
of which was a TS6307.
- **bun-types comes in through `include`**, like in
`src/js/tsconfig.json`. A `types` entry is looked up from the directory
of the config that extends this one, so
`bundler/transpiler/tsconfig.json` could not find it, and neither could
an editor or `bun check <file>` for a file in that directory.
- **Excluded**: code vendored from Node.js and the React Compiler,
`esbuild-decorator-tests.ts` (standard decorators, this project sets
`experimentalDecorators`), the bun-types fixture (declares globals such
as `ProcessEnv.FOO`, and `bun-types.test.ts` checks it with its own
config), and six fixture apps that have their own `package.json` and
`tsconfig.json` and whose dependencies the test installs.
- `../src/runtime/bake/client/**.ts` is no longer included. Tests import
two of those files, which still brings them in. The rest needs `lib.dom`
and belongs to `src/runtime/bake/tsconfig.json`.

Two small ambient files are new. `test/internal-for-testing.d.ts`
declares the 9 `$` intrinsics that `src/js/internal-for-testing.ts`
calls (`src/js/builtins.d.ts` and `private.d.ts` declare them next to
changes to `Error`, `Function` and other globals that tests should not
see). `test/asset-imports.d.ts` declares `*.c`, `*.cc`, `*.h`, `*.pem`,
`*.br` and `*.gzip`, which tests import as a path or as text.

Tests import a few files from outside `test/`, so those are part of the
project: 5 files in `packages/bun-error`, `packages/bun-release` and
`scripts/build` got the same kind of erased fix.

#### bun-types

Correct tests that did not type check because the declarations were
wrong. Each has a case in `test/integration/bun-types/fixture`.

| | before |
| --- | --- |
| `test.todo("label")`, `describe.todo("label")`, and the same for
`skip` | TS2554, fixes #25959. The runtime allows a missing callback for
both. `Parameters<typeof test.skip>` is unchanged, and
`describe.skip(SomeClass)` is still an error: on its own, a function is
the body |
| `test("label", { retry: 1 }, () => {})` | TS2769. It is the form in
`docs/test/index.mdx`. `Parameters<typeof test>` is unchanged |
| `test.each(["a", "b"] as const)`, `describe.each(...)` | "readonly ...
cannot be assigned to the mutable type 'unknown[]'" |
| ``expect(await sql`select 1`).toEqual([{ x: 1 }])`` | "not assignable
to parameter of type 'undefined'". For a call that is only generic in
its return type, `T` was inferred as `never` from `expect(actual?:
never)`, so that overload won. Same for `webview.evaluate()` |
| `Bun.write(path, Bun.TOML.stringify({ ... }))` | `string \| undefined`
for every input. It is `undefined` only for `undefined`, a function or a
symbol, and the return type says so now. This was about 350 of the
errors |
| `Bun.YAML.parse(buffer)` | `string` only. The runtime takes what
`Bun.TOML.parse` takes: typed arrays, `ArrayBuffer`, `DataView`, `Blob`
|
| `new ReadableStream({ type: "bytes" })` without `lib.dom` | TS2769,
and a comment said `Mode "bytes" is not supported`. The overload is the
last one, so a source typed `any` still gives `ReadableStream<any>` |
| `new Blob().slice()` without `lib.dom` | TS2339 |
| `new TextDecoderStream("utf-16le", { fatal: true })` without `lib.dom`
| TS2554 |
| `webview.goBack()`, `webview.goForward()` | declared as `back()` and
`forward()`, which do not exist at runtime |

#### The JavaScript that did change

For the type check:

- `cli/install/migration/pnpm-migration.test.ts`: `"harness.js"` is
`"harness"`, see above.
- `js/sql/wire-frames.ts` declared `export function pgParameterStatus`
twice, with the same body (TS2393). The second one is gone.
- `bundler/transpiler/macro-test.test.ts`: its three `assert { type:
"macro" }` imports are `with { type: "macro" }`. In TypeScript 7
`assert` is a syntax error (TS2880), which `// @ts-expect-error` cannot
suppress and which stops the check of the whole project. The transpiled
imports are the same. One test is new: it covers `assert` for a named,
aliased, default and namespace import and for `"bun"`, from a fixture
string.
- `js/bun/xml/generate_xml_test_suite.ts` emits the
`expect<unknown>(...)` that the generated suite now has.
- `harness.ts` passes `toMatchNodeModulesAt`, `toHaveBins`,
`toBeValidBin` and `toBeWorkspaceLink` to its own `expect.extend()`. It
declares them on `Matchers<T>` now, which applies to the whole project,
so a test that forgot to register them would type check and then fail
with "toHaveBins is not a function".
- 6 files in `integration/bun-types/fixture` have new cases. They are
only type checked.

Bugs in tests that a type error pointed at, where the alternative was a
cast that hides it. Each was run on `main` and on this branch:

| | on `main` | now |
| --- | --- | --- |
| `js/web/fetch/headers.undici.test.ts` | 14 lines are `expect(actual,
expected)`: no matcher, the second argument is the failure message |
`expect(actual).toBe(expected)`, all pass |
| `js/node/crypto/crypto.key-objects.test.ts` | an `expect()` without a
matcher, `publicKey.y` compared with itself (2x), 8 assertions after
`publicKeyFromJwk` / `privateKeyFromJwk` that check the other key, a
callback for `generateKeyPairSync()` that uses undeclared `resolve` /
`reject` | they assert what they mean to, the callback is gone, same
pass count |
| `js/bun/shell/test_builder.ts` | `import { ShellError } from "bun"` is
`undefined`, so `.error(aShellError)` throws `Right hand side of
instanceof is not an object`. `doChecks()` is not awaited in the catch
path | `$.ShellError`, awaited. The shell suite gives the same results |
| `js/bun/http/bun-serve-ssl.test.ts` | `keepAlive: false`, which
`fetch` does not read | `keepalive` |
| `js/bun/websocket/websocket-server-backpressure-buffer.test.ts` |
`maxBackpressure`, which `Bun.serve` does not read, so both tests ran
with the default limit | `backpressureLimit` |
| `bundler/bundler_splitting.test.ts` | 10 tests pass `env: "inline"`,
which is the environment of the subprocess (`0=i, 1=n, ...`) | `dotenv:
"inline"` |
| `bundler/esbuild/default.test.ts` | `automaticRuntime: false`, which
the helper does not read, so the test was a `todo` | `runtime:
"classic"`, passes, not a `todo` |
| `js/web/fetch/body.test.ts` | `const { readable } = file(url)` is
`undefined`, so the case was skipped as "fails, text is empty" |
`file(url).stream()`, passes, not skipped |
| `js/web/fetch/fetch.test.ts` | `first[0]` on an `ArrayBuffer`:
compares `undefined` with `undefined` | `Uint8Array` views, so it checks
that `arrayBuffer()` returns a copy |
| `js/bun/util/password.test.ts` | the async `hash` helper calls
`hashSync()` | `password.hash()` |
| `js/node/http/node-http.test.ts` | `socket =>
expect(socket).toBe(socket)` shadows the socket it means to compare with
| compares with the outer one |
| `cli/install/bun-install.test.ts` | with `--todo`, two `todo` tests
fail in their setup: `ctx is not defined`, and `join({ root }, ...)` |
they reach their assertions. Still `todo` |
| `js/bun/test/fake-timers/sinonjs/fake-timers.test.ts` | `let
timersModule, timersPromisesModule` shadows the two imports (inside
`describe.todo`) | the `let` is gone |
| `harness.ts` | `toHaveBins()` passes for an empty `.bin` directory,
`[].every(...)` is true | compares the number of bins. The 56 call sites
pass, also on Windows |
| `harness.ts`, `cli/install/bun-install-registry.test.ts` | `new
Error("Failed to create user:", response.statusText)` drops the status
text | it is in the message |
| `docker/index.ts` | `waitTcp()` calls `Bun.connect()` without
`socket`, which throws, so it times out on an open port | resolves in 2
ms, still times out on a closed port |
| `js/bun/archive-extract-leak-repro.ts` | `Bun.Archive.from()` does not
exist | `new Bun.Archive()`, the script runs |

#### With TypeScript 6.0.2

`cd test && bun run typecheck` goes from 8,065 errors to 2, both TS2786
in `jsx-production.tsx` and `jsx-dev.tsx`. TypeScript 6 adds an implicit
`react/jsx-runtime` import to every file of a `react-jsx` project, also
to `../src/js/internal-for-testing.ts`, where it resolves to the root's
`@types/react` 18.3 instead of `test/`'s 18.0. TypeScript 7 only adds it
to files that have JSX.

#### Not in this PR

- Nothing in CI type checks `test/`, so this can regress.
`.github/workflows/lint.yml` checks `scripts`, `src/js`, `src` and
`src/runtime/bake`.
- `bun check` at the repository root follows the references in the root
`tsconfig.json`, and `src/tsconfig.json`, `src/js/tsconfig.json` and
`src/runtime/bake/tsconfig.json` still have `baseUrl`.

### How did you verify your code works?

- `bun check`, `tsc` 7.0.2: 0 errors. `tsc` 6.0.2: the 2 above.
- **Same JavaScript.** A script transpiles each changed file at `main`
and on this branch (`bun build --no-bundle`, so with this
`tsconfig.json`'s `emitDecoratorMetadata`) and compares the output: of
662 files, 634 are byte-identical, 1 differs in the line breaks of an
object literal that prettier re-wrapped (identical with
`--minify-whitespace`), and 27 are the ones listed above.
- **Same test results.** Line numbers, columns and file sizes do change,
and some tests look at their own (`response.test.ts` snapshots `Response
(8.0 KB)` for its own source file). So I ran the 1,322 test files that
changed or that sit next to a changed helper or fixture, on `main` and
on this branch, with the same release build (linux x64, no docker):
49,644 tests pass on `main`. 1,302 files have the same exit code, the
same pass / fail / skip / todo counts and the same failing tests. The
other 20 differ in both directions (11 better, 9 worse). Run twice more
on each side, each of them gets the same result on both sides at least
once, and the one that looked worst (`serve-http2-lifecycle.test.ts`)
fails 3 of 5 runs on `main` and 1 of 5 here. The files touched after
that run were run again (191, then 161 files), with the same outcome. 70
of the 1,322 import `bun:internal-for-testing`, which a release build
only allows with `BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING` and
`BUN_GARBAGE_COLLECTOR_LEVEL` set, so they failed to load on both sides
in that run. Run again on both sides with the two variables (3,682 tests
pass on `main`): 67 are the same, and the other 3 are the same when run
on their own. I did not run anything with a debug build: there is no
native change.
- **No hunk is unnecessary.** For each hunk: revert it, run `bun check`,
keep the revert if there is still no error. 504 hunks were reverted that
way, most of them workarounds that the bun-types fixes above made
unnecessary. 2,908 hunks are left.
- `bun test test/integration/bun-types/bun-types.test.ts`: 22 pass, with
and without `lib.dom`.

<details>
<summary>Other bugs in tests that the type errors pointed at. Not fixed
here</summary>

Each was confirmed by reading what the test calls or by running it. They
need a service, another OS, the network, or a decision about what the
test should do. Paths are relative to `test/`.

- `js/bun/http/bun-serve-ssl.test.ts:128`: The loop over `serverName`s
only sets the `Host` request header, which never selects the TLS SNI
name in Bun's `fetch`; SNI is always the URL hostname (`localhost`). The
`localhost2.com` entry of the `valid 2` fixture is never exercised, even
if `keepAlive` is corrected to `keepalive`; `tls: { serverName }` would
be needed.
- `js/bun/perf_hooks/histogram.test.ts:537`: The "toJSON method" test
wraps all its assertions in `if (typeof h.toJSON === "function")`. Bun's
histogram has no `toJSON`, so the test only logs a message and passes
with zero assertions.
- `js/node/http/node-http.test.ts:1340`: "should noop keepSocketAlive"
never calls `agent.keepSocketAlive()`: the call sits in the request
handler of a server that never listens, so the only assertion that runs
is `agent.keepAlive === true`. The dead handler also passes a
`ClientRequest` instead of a socket and calls `server.end()`, which does
not exist, and `keepSocketAlive` is no longer a no-op in Bun.
- `js/sql/sql.test.ts:1224`: "Transaction throws on uncaught named
savepoint" calls the misspelled `sql.savepoit("watpoint", ...)`. The
call throws `TypeError: sql.savepoit is not a function`, `.catch(() =>
"fail")` maps any error to `"fail"`, and the test passes without ever
creating a savepoint.
- `js/valkey/reliability/connection-failures.test.ts:307`: "should
handle rapid connection/disconnection" pushes `client.close()` results
into `promises` and awaits `Promise.all`, but `close()` returns
`undefined`, so nothing is awaited. The clients never connect either,
because `new RedisClient()` is lazy. The test has no `expect` and opens
no socket.
- `js/web/abort/abort.test.ts:9`: "AbortSignal > spawn test" never runs
the 23 tests in `abort.ts`. It copies them to
`<tmpdir>/bun.test.XXXX/abort.test.ts`, then runs `bun test
/abort.test.ts` with `cwd: os.tmpdir()`; that filter matches nothing and
the child exits 1, but the test only asserts that stderr lacks "✗" and
never checks the exit code. `abort.ts` is referenced nowhere else.
- `regression/issue/25589-frame-size-connect.test.ts:147`: The three
tests in `HTTP/2 FRAME_SIZE_ERROR with @connectrpc/connect-node` never
send a request: each one only does `assert.ok(transport)` on the object
returned by `createGrpcTransport()`. `makes basic gRPC request without
FRAME_SIZE_ERROR` makes no gRPC request, the 50-header interceptor in
`transport with large headers in interceptor` never runs, and the
`EchoService` definition is unused.
- `bundler/cli.test.ts:271`: `describe.concurrent("bun build", () =>
{...}, 10_000)` passes a timeout as third argument to `describe`.
`describe` parses it but never applies it, so the tests in the block run
with the default timeout instead of 10 s.
- `js/bun/http/async-iterator-stream.test.ts:245`: "async generator
aborted doesn't crash" has its only assertions
(`toBeInstanceOf(DOMException)`, `name === "AbortError"`) inside
`catch`; if `fetch` resolved instead of rejecting, the test would pass
with zero assertions. Today `fetch` does reject, so the assertions run.
- `js/bun/http/bun-serve-ssl.test.ts:144`: The last `fetch` of the
`valid`/`valid 2` tests (`Host: "badhost.com"`) assigns `const res` and
the test ends without any assertion on it, so the only thing checked is
that the fetch does not reject.
- `js/bun/image/image.test.ts:1425`: "BMP 32-bit BI_RGB is XRGB" passes
`{ backend: "bun" }` to the `Bun.Image` constructor, which has no such
option, so it is silently ignored. The backend is the process-global
`Bun.Image.backend`. On macOS and Windows that global is `"system"` at
this point, so the test decodes through ImageIO/WIC and not through
Bun's own BMP decoder, which it means to cover.
- `js/bun/perf_hooks/histogram.test.ts:474`: "percentiles map
properties" asserts that the values of `h.percentiles` are `bigint` and
equal to those of `h.percentilesBigInt`. This bakes in Bun's divergence
from Node, where `percentiles` holds numbers. In Node the assertion only
holds because both getters return the same Map object, which the
`percentilesBigInt` getter has just refilled.
- `js/bun/test/parallel/test-http-get-can-use-Agent.ts:7`:
`test-http-get-can-use-Agent.ts` and `test-https-get-can-use-Agent.ts`
make real requests to `google.com`, which the repo's test rules forbid
("Never contact the public internet"). The tests depend on external
network access.
- `js/bun/util/filesink.test.ts:74`: `Bun.file(path).stream(64)`,
commented "test it on a small chunk size", has no effect. The chunk size
is used only for in-memory blobs and is dropped for file-backed ones, so
the FIFO reader runs with the default chunking.
- `js/first_party/ws/ws.test.ts:172`: In the `send()` tests the `typeof
data === "string"` branch is dead code: the `ws` client always emits a
`Buffer`, and the echo server re-sends the `Buffer` it received, so
string messages come back as binary frames and take the `else` branch
(`isBinary` true). `expect(isBinary).toBeFalse()` never runs, so no test
in the file checks `isBinary === false` on a client socket (only server
sockets are checked, in `isBinary` and `handles data passed along with
the upgrade request`).
- `js/node/tls/test-system-ca-https.test.ts:40`: `test.skip(skipReason)`
is called from inside the running test to skip it. `bun:test` throws
`Cannot call test.skip() inside a test. Call it inside describe()
instead.`, so on a Linux machine with no system CA bundle the test fails
instead of being skipped (reached only with `BUN_TEST_ALLOW_NET=1`;
otherwise the whole test is `test.skip`).
- `js/web/fetch/response.test.ts:52`: The `print size` test snapshots
`Bun.inspect(new Response(Bun.file(import.meta.filename)))`, which
prints the size of the test file itself. The snapshot `Response (8.0
KB)` holds only while the file is 8000 to 8049 bytes, so any edit that
moves the size out of that window breaks the test, including adding a
test to the file.

</details>

<details>
<summary>Gaps in bun-types that are left. The tests use a cast there,
never <code>@ts-expect-error</code>, so fixing the types breaks
nothing</summary>

Each was checked against the runtime (release build) and the current
declarations.

Web globals without `lib.dom`:
- `Request#clone()`, `Response#clone()`, `formData()` and `bytes()` are
inherited from undici-types and return undici's `Request` / `Response` /
`FormData` / `Uint8Array<ArrayBufferLike>`. `Bun.serve({ fetch: () =>
res.clone() })`, `new Response(await req.formData())` and `const r:
Request = req.clone()` are errors.
- The global `FormData` has no `[Symbol.iterator]`, and `values()` /
`entries()` are typed as yielding `string` only.
- `ReadableStream#getReader()` returns the reader of `node:stream/web`,
which is not assignable to the global `ReadableStreamDefaultReader`. So
`stream.getReader().readMany()` does not type check.
- `new Request(url: URL, init?)` has no overload, and there is no
`RequestInfo`.
- `ResponseInit.headers` is undici's `HeadersInit`, not
`Bun.HeadersInit` (`RequestInit` overrides it). `Bun.HeadersInit` has no
iterable member, so `new Headers(map)` is an error.
- `port.onmessage = (e: MessageEvent) => {}` on a `MessagePort` or
`BroadcastChannel` is an error: the handler gets undici's
`MessageEvent`, and `Bun.MessageEventSource` is `undefined`.
`MessageEventInit` has no `ports`.
- `Blob#stream(chunkSize)`: declared without parameters, two docs guides
show `blob.stream(1024)`.
- `URLSearchParams#toJSON()` returns `string[]` for a repeated key,
typed `Record<string, string>`.
- `WebAssembly.Exception` and `WebAssembly.Tag` are missing.
- Client `WebSocket`: `binaryType` rejects `"blob"`, `send()` / `ping()`
/ `pong()` reject a `Blob`, `WebSocketEventMap` has no `ping` / `pong`.
- `Bun.WorkerOptions` has no `execArgv`.

`bun:test`:
- `jest.mock()` and `jest.now()` are missing from `namespace jest`.
`jest.now()` is in `docs/test/dates-times.mdx`.
- `toHaveReturnedWith()`, `toHaveLastReturnedWith()`,
`toHaveNthReturnedWith(n)`: `expected` is optional at runtime and in
Jest's types.
- `expect.extend({ toBeEven(received: number) {} })` is an error: the
first parameter can only be `unknown` or `any`. Jest's types use `any`.
- `expect({ value: 1, name: undefined }).toEqual({ value: 1 })`, the
example in the JSDoc of `toStrictEqual`, is an error.

`Bun.*`:
- `Bun.JSON5.parse` takes `string` only. Like `Bun.TOML.parse`, the
runtime takes typed arrays, `ArrayBuffer`, `DataView` and `Blob`.
- `Bun.YAML.stringify` returns `undefined` for `undefined`, a function
or a symbol. It is typed `string`, where `TOML.stringify` and
`JSON5.stringify` are `string | undefined`.
- `SyncSubprocess.exitCode` is `null` when a signal killed the child,
typed `number`.
- `Bun.spawn`: `cmd` and `stdio` reject `readonly` arrays, `stdin`
rejects `ArrayBuffer` / `SharedArrayBuffer`. The error lands on `cmd`
("does not exist in type 'string[]'").
- `Bun.udpSocket({ socket: { error(socket, error) {} } })`: the runtime
calls `error` with one argument, the error, and `this` is the socket.
The sockets have `[Symbol.dispose]`, undeclared.
- `Bun.serve({ unix, http2 })` and `{ unix, idleTimeout }` are errors:
those options are only on `HostnamePortServeOptions`. `server.fetch(url,
init)` takes one parameter. `WebSocketHandler.message` is required, the
runtime wants any one handler.
- `Bun.connect({ fd, socket })` has no overload, although
`Bun.FdSocketOptions` is declared.
- `Bun.TLSOptions` lacks `crl`, `sigalgs`, `ecdhCurve`,
`allowPartialTrustChain`, `sessionTimeout`. The `Error` of `handshake()`
and `getAuthorizationError()` always has a `code`, undeclared.
- `BuildConfig.metafile` is `boolean`. `string` and `{ json?, markdown?
}` are documented and work.
- `Bun.Transpiler`: no `minify` option, `scan()` / `scanImports()` take
no `loader`, `transform(code, loader)` rejects `json`, `toml`, `yaml`,
`text` and others.
- `BuildMessage#notes`, `line`, `column` and `ResolveMessage#line`,
`column` are missing.
- `Bun.file("s3://...", s3Options)` is an `S3File` at runtime, typed
`BunFile`. `Bun.write(dest, data, options)` does not take `S3Options`,
and `Bun.write(S3File, Response | Request)` has no overload.
- `BunFile#write()` rejects a `Blob`. Its options are typed `{
highWaterMark }`, the runtime reads `createPath` and `type`.
- `Bun.hash(data)` always returns a `bigint`, typed `number | bigint`.
- `Bun.peek(rejected)` returns the rejection reason, typed `Promise<T> |
T`. The example in `docs/runtime/utils.mdx` does not type check.
- `new Bun.CryptoHasher(algorithm, hmacKey)` rejects an `ArrayBuffer`
key.
- `RedisClient`: `psubscribe()`, `punsubscribe()`, `pubsub()` are
missing, `KeyLike` excludes `ArrayBuffer`.
- `sql.array()` rejects typed arrays, and Bun returns `int[]` columns as
`Int32Array`.
- `$.ShellPromise` has no `bytes()`.
- `Bun.WebView` overloads `addEventListener` for CDP events, not
`removeEventListener`.
- `JSCallback` (`bun:ffi`) has `[Symbol.dispose]`, undeclared.

</details>

<details>
<summary>Runtime behavior noticed on the way</summary>

Each was reproduced with the release build, and compared with Node 26.3
where that applies.

- `src/js/internal/sql/shared.ts:1342`: `sql.close({ timeout: 0 })`,
documented as closing all connections immediately, behaves like
`close()` with no timeout and waits for pending queries, so it never
resolves while a connection is stuck mid-handshake. `hasTimeout =
!!timeout` is false for the number `0`, so the `timeout === 0` branch is
only reached by the string `"0"`. `sql-close-pending-connection.test.ts`
passes `"0"` to get the forced close.
- `src/ast/scope.rs:494`: Bun accepts an ES module with two top-level
`function f` / `export function f` declarations and silently keeps the
last one. Node rejects the same file with `SyntaxError: Identifier 'f'
has already been declared`, because top-level function declarations are
lexical in a module. Bun also does not report the duplicate export name.
- `src/jsc/bindings/JSNodePerformanceHooksHistogram.cpp:232`:
`Histogram.percentiles` returns a Map with `bigint` values in Bun (`Map
{ 0: 5n, 100: 5n }`), where Node returns numbers (`Map { 0 => 5, 100 =>
5 }`). `getPercentiles` has the same body as `getPercentilesBigInt`.
- `src/jsc/bindings/JSNodePerformanceHooksHistogramPrototype.cpp:39`:
`perf_hooks.createHistogram()` objects have no `toJSON()` in Bun.
`JSON.stringify(histogram)` gives `{}`, where Node gives
`{"count":1,"min":5,"max":5,"mean":5,"exceeds":0,"stddev":0,"percentiles":{...}}`.
- `src/jsc/bindings/webcore/JSDOMFormData.cpp:314`: A plain `Blob`
appended to a `FormData` without a filename comes back from `get()` and
from `Response.formData()` as `instanceof File` with `name ===
undefined` and `constructor.name === "Blob"`, and is serialized with
`filename=""`. The XHR spec and Node give such an entry the name
`"blob"` (`filename="blob"`).
`test/js/web/html/FormData-multipart-serialization.test.ts` asserts the
current behaviour (`name: undefined`, `filename=""`).
- `src/runtime/ffi/FFI.h:222`: Calling a `cc()`-compiled function whose
argument is `"cstring"` with a JS string or a `CString` object
segfaults, while the same call through `dlopen` works and the shared
types allow `string`. This is the "FIXME: bus error" behind the skipped
block in `test/js/bun/ffi/cc.test.ts`.
- `src/js/node/inspector.ts:526`: `inspector.Session#post(method)`
without a callback returns the result object in Bun and throws
synchronously on an error such as an unknown method. Node returns
`undefined` and does not throw.
`test/js/node/inspector/inspector-profiler.test.ts` asserts the Bun-only
return value, e.g.
`expect(session.post("Profiler.enable")).toEqual({})`.
- `src/runtime/crypto/PBKDF2.rs:164`: `crypto.pbkdf2(password, salt,
iterations, keylen, "md55")` with no callback throws
`ERR_CRYPTO_INVALID_DIGEST` in Bun and `ERR_INVALID_ARG_TYPE` (`The
"callback" argument must be of type function`) in Node, because Bun
validates the digest name before the callback. The `digest` test in
`test/js/node/crypto/pbkdf2.test.ts` omits the callback and so pins the
Bun-only order.

</details>
@Jarred-Sumner Jarred-Sumner mentioned this pull request Oct 10, 2026
27 tasks
Jarred-Sumner added a commit that referenced this pull request Oct 12, 2026
### What does this PR do?

Adds two commands:

- **`bun lint`**: a linter that reads ESLint and oxlint configs. 1,021
rules built in, type-aware rules included.
- **`bun format`**: a formatter that reads Prettier and oxfmt configs
and prints what they print.

Both are native, use every core, and need no packages and no config
file. Both can be configured in `bunfig.toml`.

## Compatibility

### The tools' own test suites

| Tool | Suite | Pass | Fail | Not run |
| --- | --- | ---: | ---: | ---: |
| ESLint 10.12, typescript-eslint 8.71, eslint-plugin-react 7.37.5,
-import 2.32 | their own rule tests, 505 rules | 69,640 | **0** | 303 |
| the same rules | more cases, judged by the real ESLint, 632 rules |
76,552 | 4 | 258 |
| oxlint 1.87 | its own rule tests, 504 rules | 27,702 | **0** | 63 |
| Prettier 3.9.9 | `tests/format` | 9,728 | 5 | 88 |
| oxfmt 0.72 | fixtures | 1,337 | 161 | 0 |

A lint case passes when message, location, fix and suggestions are what
the real tool reports. A format case passes when the bytes are the same.
"Total" includes the cases that are not run (15, 6, 96, 316, 101, 88,
0); failing: 0, 0, 0, 0, 0, 5, 161. Of eslint-plugin-import's 316, the
plugin itself throws under ESLint 10 in 135, 90 need babel-eslint and 71
the webpack resolver. The suites are checked in under
`test/cli/lint/conformance` and `test/cli/format/conformance` and run in
CI.

<details>
<summary>Prettier by language</summary>

| Language | Pass | Total |
| --- | ---: | ---: |
| JavaScript | 1,357 | 1,357 |
| JSX | 186 | 186 |
| TypeScript | 756 | 756 |
| Flow | 1,500 | 1,505 |
| JSON | 785 | 785 |
| CSS | 162 | 162 |
| Less | 238 | 238 |
| SCSS | 136 | 136 |
| GraphQL | 104 | 104 |
| YAML | 1,623 | 1,623 |
| Markdown | 1,572 | 1,572 |
| MDX | 32 | 32 |
| HTML | 272 | 272 |
| Vue | 189 | 189 |
| Angular | 109 | 109 |
| Handlebars | 128 | 128 |
| MJML, LWC, `misc` | 579 | 579 |
| Not run (stage-2 proposals that only Babel parses, Prettier plugins) |
0 | 88 |

</details>

### Real repositories

330 open-source repositories at a pinned commit, 135 of them with their
dependencies installed, in a sandbox. Each project's own lint and format
commands are run by the project's own tool and by `bun`. Counted by run.
Every result is of the release build of 6208ecd9 or newer; none is
carried over from an older build. Of its 975 results 12 moved against
the pass on 8c1bd4bc, about 400 performance steps earlier: 8 because
ESLint's 74 deprecated formatting rules have left `bun lint` (5 ESLint
runs that were the same now lack the reports of `quotes`, `max-len`,
`key-spacing` .., and nothing else), 2 because the `jsdoc` plugin has, 1
towards oxlint (napi-rs: which files are ignored), and 1 is a project's
own oxfmt that crashes now and then. The commits since then change what
becomes of oxlint's `jsdoc` and `vue` plugins, which are not built in,
and how `import/*` resolves beside an oxlint config. So 644 results ran
again on 7df1455c (one oxlint run, ComfyUI_frontend's, on ade5c82a),
among them all 35 oxlint runs that name one of the two plugins: 27 only
list it: a note, and oxlint's exit code; 8 turn rules of theirs on by
name: exit code 2, as for any rule that is not built in. oxlint 1.87
reports nothing of these rules in any of the 35.

| Compared with | What has to match | Same | Of | Rate |
| --- | --- | ---: | ---: | ---: |
| ESLint | exit code | 96 | 102 | 94 % |
| ESLint | `--fix`, bytes | 93 | 102 | 91 % |
| ESLint | every message, against the project's own ESLint and plugins |
73 | 102 | 72 % |
| ESLint | every message, against that or the releases that the built-in
rules follow | 80 | 102 | 78 % |
| oxlint 1.87 + tsgolint | exit code | 203 | 215 | 94 % |
| oxlint 1.87 + tsgolint | `--fix`, bytes | 208 | 215 | 97 % |
| oxlint 1.87 + tsgolint | every message | 191 | 215 | 89 % |
| oxfmt 0.72 | bytes | 227 | 240 | 95 % |
| Prettier | bytes, against theirs or 3.9.9 | 57 | 74 | 77 % |
| Prettier | exit code of `--check` | 66 | 74 | 89 % |

"Every message" compares lists, not sets: rule, severity, both ends,
text, fix objects, suggestions, suppressed messages, the files that were
linted, and the exit code.

| Beyond sameness | | Of |
| --- | ---: | ---: |
| Runs of `bun` that ended by themselves with exit code 0, 1 or 2: none
killed, hung or crashed | 951 | 951 |
| A second run in the same copy says the same | 631 | 631 |
| The project's lint command at a terminal (a pty, no `-f`): the exit
code of `-f json`, no crash | 150 | 150 |
| Projects whose config `bun lint` cannot load | 0 | |

**The 6 ESLint exit codes that differ.** Open: ComfyUI_frontend (12
`import-x/no-unresolved`: the plugin's resolver works there only with
the `NODE_PATH` that pnpm's shim exports), discord.js
`packages/discord.js` (4 `unicorn/consistent-function-scoping`). A
version that the project has and `bun` does not follow: TanStack
router-core (ESLint 9.22's `no-var`), eslint/eslint (eslint-plugin-n's
table), shadcn-ui/ui (react-hooks 7.0.1), sinon (ESLint 10.3's
`new-cap`).

Of the 88 runs that are not the same, 27 are open, 30 are a version's
drift and 31 are known differences. Some that are the same in every
message, fix and exit code: nodejs/node's whole lint command (1,383
messages in 7,924 files), eslint-plugin-unicorn (628), react-hook-form
(603), rollup (290), react-router (246).

<details>
<summary>Every run that is not the same, with its class</summary>

What "the same" means:

- **lint**: as said above; for oxlint also the length of the span.
- **`--fix`** and **format**: the bytes of every file afterwards, and
which files were read.
- **judges**: the project's own installed version first. `bun lint` and
`bun format` follow one release of each tool (ESLint 10.12.0,
typescript-eslint 8.71.1, eslint-plugin-react-hooks 7.1.1, oxlint 1.87.0
with oxlint-tsgolint 7.0.2003, oxfmt 0.72.0, Prettier 3.9.9), so each
run is also judged by that release with the project's configuration; for
oxlint and oxfmt that release is the judge.
- A tool of the project that cannot run here (it needs a build, or a
package that is not published) takes its run out of the count.

Each column "judged on" names the commit of this branch whose release
build gave the verdict. Nothing is older than 6208ecd93. The runs at a
terminal are of 6208ecd93.

| By run | the same | of | | judged on 6208ecd93 | judged on 7df1455c4 |
judged on ade5c82ae |
|---|---|---|---|---|---|---|
| ESLint: lint, identical to the project's own ESLint and plugins | 73 |
102 | 72 % | 97 | 5 | 0 |
| ESLint: lint, identical to that, or to the releases that bun follows
(ESLint 10.12; typescript-eslint 8.71.1, react-hooks 7.1.1) | 80 | 102 |
78 % | 97 | 5 | 0 |
| ESLint: --fix, the same bytes | 93 | 102 | 91 % | 97 | 5 | 0 |
| ESLint: the same exit code | 96 | 102 | 94 % | 97 | 5 | 0 |
| oxlint: lint, identical to 1.87 (rule, severity, place, length, text,
files) | 191 | 215 | 89 % | 3 | 211 | 1 |
| oxlint: --fix, the same bytes as 1.87 | 208 | 215 | 97 % | 3 | 211 | 1
|
| oxlint: the same exit code as 1.87 | 203 | 215 | 94 % | 3 | 211 | 1 |
| oxfmt: the same bytes as 0.72 | 227 | 240 | 95 % | 41 | 199 | 0 |
| oxfmt: the same exit code of --check | 229 | 240 | 95 % | 41 | 199 | 0
|
| Prettier: identical to theirs or to 3.9.9 | 57 | 74 | 77 % | 74 | 0 |
0 |
| Prettier: the same exit code of --check | 66 | 74 | 89 % | 74 | 0 | 0
|

Not the same: 88 runs: open 27, drift of a version 30, known differences
31. A run is listed once, under the first row of the table above that it
fails.

#### Open (27): a difference that is bun's to close

| Run | Judge | Exit theirs / bun | What |
|---|---|---|---|
| Comfy-Org/ComfyUI_frontend | ESLint 10.10.0 | 0 / 1 |
import-x/no-unresolved 12 only bun: the plugin's resolver works only
with the NODE_PATH that pnpm's shim exports; their exit code flaps too
(better-tailwindcss) |
| NarHakobyan/awesome-nest-boilerplate | ESLint 9.38.0 | 1 / 1 | spec
files: `vi.fn` / `jest.fn` is "a type that cannot be resolved" for bun:
no-unsafe-* 16 only bun; sonarjs' typed rules 11 only theirs (a plugin
in JavaScript gets no TypeScript program); deprecated formatting rules
(`quote-props` 61 ..) 65 only theirs |
| discordjs/discord.js:packages/discord.js | ESLint 9.39.5 | 0 / 1 |
unicorn/consistent-function-scoping 4 only bun (errors); no-eval's text
is ESLint 9's |
| graphql/graphql-js | ESLint 9.39.3 | 0 / 0 | 1 suppressed message:
import/unambiguous is placed on the whole file by bun (1:1), from the
first token by them (4:1) |
| mermaid-js/mermaid | ESLint 9.35.0 | 1 / 1 | typed rules in a .js file
(svgDraw.js): no-floating-promises 9, restrict-plus-operands 1 only bun,
with the plugin version bun follows |
| pixijs/pixijs | ESLint 9.39.2 | 0 / 0 | 18 fix objects of
jsdoc/require-param are missing in -f json; --fix writes the same bytes.
Deprecated formatting rules (`max-len` 147 ..) 149 only theirs; all else
the same (380) |
| withastro/astro | ESLint 10.12.0 | 1 / 1 | eslint-plugin-regexp: 3
suppressed reports only theirs, so 3 "unused directive" warnings only
bun; 1 file "not found by the project service" only theirs |
| Pawn-Appetit/pawn-appetit | oxlint 1.87 | 0 / 0 | React Compiler rule:
preserve-manual-memoization 1 only bun |
| arcjet/arcjet-js | oxlint 1.87 | 1 / 1 | "Unused oxlint-disable
directive" 58 only theirs |
| digirati-co-uk/iiif-manifest-editor | oxlint 1.87 | 1 / 1 |
react-hooks(exhaustive-deps) 2: another text |
| glide-browser/glide | oxlint 1.87 | 1 / 1 | "A 'declare' modifier
cannot be used in an already ambient context": 2 diagnostics against
their 16, and without the code TS(1038) |
| karakeep-app/karakeep:apps/web | oxlint 1.87 | 0 / 0 | React Compiler
rule: static-components 1 only theirs |
| monkeytypegame/monkeytype:frontend | oxlint 1.87 | 1 / 1 |
typescript(TS2307) 1 only theirs |
| openclaw/openclaw | oxlint 1.87 | 1 / 1 |
eslint(no-useless-assignment) 5 only bun |
| petyosi/react-virtuoso:packages/masonry | oxlint 1.87 | 1 / 1 | the
checker's own diagnostics (TS7031, TS7006, TS2307) 69 only theirs |
| petyosi/react-virtuoso:apps/virtuoso.dev | oxlint 1.87 | 1 / 1 | the
checker's own diagnostics (TS2307, TS7031, TS7006) 21 only theirs |
| reserve-protocol/register | oxlint 1.87 | 0 / 0 | React Compiler rule:
preserve-manual-memoization 1 only theirs |
| ietf-tools/purple | oxfmt 0.72 | 0 / 1 | 4 files only bun would
change: 1 .json, 2 .html, 1 .yaml |
| olton/metroui | oxfmt 0.72 | 2 / 2 | 1 .css, 1 .md differ; 4 .less
that 0.72 refuses; both exit 2 |
| zendeskgarden/react-components | oxfmt 0.72 | 1 / 1 | 1 .ts file only
bun would change |
| chakra-ui/chakra-ui | Prettier 3.8.3 | 1 / 1 | 8 .md only bun would
change (code blocks: their import-sorting plugin; Markdown) |
| renovatebot/renovate | Prettier 3.9.9 | 0 / 1 | 65 .md files that only
bun would change, against the same release 3.9.9 |
| tailwindlabs/tailwindcss | Prettier 3.9.6 | 0 / 1 | embedded languages
in templates (html``, css``): 32 .ts files only bun would change |
| timlrx/tailwind-nextjs-starter-blog | Prettier 3.8.1 | 1 / 1 | 1 .mdx
only theirs, 1 .cjs only bun; prettier-plugin-tailwindcss: 1 .css, 1
.tsx |
| vercel/next.js | Prettier 3.6.2 | 2 / 2 | the same bytes in 26,334
files; one file with a Babel proposal
(examples/with-custom-babel-config/pages/index.js) that their 3.6.2
formats and bun refuses; 3.9.9 exits 2 too, on another file |
| vuejs/eslint-plugin-vue | Prettier 3.9.10 | 1 / 1 | 1 .md differs |
| withastro/astro | Prettier 3.9.9 | 0 / 1 | 1 .md only bun would change
|

#### Drift of a version (30): the project has an older release than the
one bun follows, and that release explains the difference

| Run | Judge | Exit theirs / bun | What |
|---|---|---|---|
| TanStack/router:packages/router-core | ESLint 9.22.0 | 0 / 1 | two
drifts at once: ESLint 9.22's no-var reports `declare global { var }`,
10.12's does not (their disable comment is unused for bun); against
10.12 their older typescript-eslint is left
(no-unnecessary-type-assertion 2) |
| chartjs/Chart.js #1 | ESLint 8.37.0 | 0 / 0 | ESLint 8.37: places of
complexity, no-unused-vars |
| chartjs/Chart.js #2 | ESLint 8.37.0 | 0 / 0 | ESLint 8.37 /
typescript-eslint 5 |
| eslint/eslint | ESLint 10.12.0 | 0 / 1 | eslint-plugin-n's table of
Node.js versions: bun follows the newest release of the plugin |
| mastodon/mastodon | ESLint 9.39.5 | 0 / 0 | ESLint 9 looks the
configuration up from the cwd, 10 from each file: streaming/ (9 files)
is linted by 10 and by bun: 1 suppressed message |
| pinojs/pino | ESLint 9.39.5 | 0 / 0 | ESLint 9: the text of no-eval |
| sadmann7/skateshop | ESLint 8.57.0 | 1 / 1 | .eslintrc with
typescript-eslint 6 |
| webpack/webpack | ESLint 9.39.5 | 1 / 1 | ESLint 9: the text of
no-eval (2 messages); everything else of 5,521 files the same |
| TanStack/router:packages/react-router --fix | ESLint 9.22.0 | | lint
is identical with the plugin versions bun follows; the fix is that
version's |
| apollographql/apollo-client #1 --fix | ESLint 9.31.0 | | lint is
identical with the plugin versions bun follows; the fix is that
version's |
| sveltejs/svelte --fix | ESLint 10.0.0 | | ESLint 10.0:
no-useless-assignment; lint is identical to 10.12 |
| shadcn-ui/ui:apps/v4 exit code | ESLint 9.26.0 | 0 / 1 |
eslint-plugin-react-hooks 7.0.1 against 7.1.1: set-state-in-effect 38,
refs 16; identical with 7.1.1 in the place of theirs |
| sinonjs/sinon exit code | ESLint 10.3.0 | 0 / 1 | ESLint 10.3: new-cap
1; identical to 10.12 |
| diced/zipline, sanity-io/next-sanity | oxlint 1.78.0 | 0 / 2 | 1.87
refuses their configuration ("Rule 'react-compiler' not found in plugin
'react'"); bun lints and says that this rule did not run: exit 2 unless
--allow-unsupported is given |
| ixartz/Next-js-Boilerplate | oxlint 1.78.0 | 1 / 2 | as zipline, and
20 `jsdoc` rules |
| makeplane/plane:apps/web, :apps/admin, :apps/space, :apps/live,
:packages/editor, :packages/utils | oxlint 1.51.0 | 0 / 0 | 1.87 refuses
their configuration ("Rule 'prevent-abbreviations' not found in plugin
'unicorn'", 'prop-types' in 'react'); against their 1.51: other names of
plugins, other rules in the categories; the same exit code |
| olton/metroui | oxlint 1.42.0 | 0 / 0 | 1.87 refuses their
configuration ("Rule 'no-unused-vars' not found in plugin 'import'");
the same exit code as their 1.42 |
| preactjs/preact | oxlint 1.8.0 | 0 / 0 | 1.87 refuses their
configuration (four rules it does not have: camelcase, jsx-no-bind ..);
the same exit code as their 1.8 |
| vercel/ai | oxlint 1.56.0 | 0 / 1 | 1.87 refuses their configuration
("Rule 'no-unresolved' not found in plugin 'import'"); against their
1.56 the categories hold other rules |
| apollographql/apollo-client | Prettier 3.1.1 | 2 / 1 | Prettier 3.1.1:
12 files only bun would change; 3.9.9 fails with their plugin (exit 2);
6 .mdx only theirs; bun reads 438 of their 724 files (.mdx; files behind
their overrides): that part is open |
| dubinc/dub | Prettier 3.2.5 | 1 / 1 | Prettier 3.2.5 with plugins of
that age: 3.9.9 prints broken code with them, so neither judge is clean;
against 3.9.9: 4 differ, 10 only theirs |
| nextauthjs/next-auth | Prettier 3.3.3 | 2 / 1 | Prettier 3.3.3: 20
files only bun (and 3.9) would change; 3.9.9 fails with their plugin on
one file (exit 2); no byte differs from 3.9.9 elsewhere |
| shadcn-ui/taxonomy, steven-tey/precedent | Prettier 2.8.8 | 1 / 1 |
Prettier 2.8.8 with plugins of that age |

#### Known differences (31): the other tool fails here, or bun does
something else on purpose

| Run | Judge | Exit theirs / bun | What |
|---|---|---|---|
| angular/angular-cli | ESLint 10.12.0 | 0 / 0 | as jest: `max-len` 82,
`padding-line-between-statements` 1; all else the same (413) |
| jestjs/jest | ESLint 10.10.0 | 0 / 0 | ESLint's deprecated formatting
rules do not run in bun: `quotes` 2 only theirs; all else the same (653)
|
| jquery/jquery | ESLint 9.39.4 | 0 / 0 | as jest: `key-spacing` 9; all
else the same (19) |
| microsoft/playwright | ESLint 9.39.4 | 0 / 0 | as jest: `quotes` 276,
`key-spacing` 158, `comma-spacing` 117, `object-curly-spacing` 112; all
else the same (436) |
| nextauthjs/next-auth | ESLint 9.9.1 | 1 / 1 | 3 files "not found by
the project service" are fatal for them, linted by bun; in 2 .svelte
files svelte-eslint-parser throws in both: the TypeError's text is the
engine's |
| nuxt/nuxt | ESLint 10.12.0 | 1 / 1 | 37 files "not found by the
project service" are fatal for them, linted by bun; no-deprecated 3 / 1
|
| vueuse/vueuse | ESLint 10.9.1 | 0 / 0 | as jest: `spaced-comment` 2;
all else the same (68) |
| Sandakan/Nora | oxlint 1.87 | 0 / 0 | import(no-named-as-default) 1
only bun. The `import` plugin is named only inside an override; there
1.87 does not look at other modules, so its rules that ask another
module are silent; bun builds the module graph whenever such a rule is
on. The report is true of the code |
| s00d/nuxt-i18n-micro | oxlint 1.87 | 0 / 1 | not installed here:
tsconfig.json extends a file that `nuxt prepare` writes; 1.87 then
resolves no import, bun goes on without it: import(no-duplicates) 1 only
bun |
| Comfy-Org/ComfyUI_frontend exit code | oxlint 1.87 | 1 / 2 | as vitest
|
| eikowagenknecht/lootscraper exit code, jumpserver/luna #1,
jumpserver/luna #2, lihbr/lihbr-apex, nuxt-modules/prismic,
vitest-dev/vitest | oxlint 1.87 | 0 / 2 | oxlint's `jsdoc` and `vue`
plugins are not built in: rules of theirs that are on by name did not
run, and bun says so: exit 2 unless --allow-unsupported is given; every
message the same |
| chhoumann/PodNotes | oxfmt 0.72 | 2 / 0 | not installed here: 0.72
needs svelte/compiler and exits 2; bun leaves the 26 .svelte files as
they are, and says so |
| digirati-co-uk/iiif-manifest-editor | oxfmt 0.72 | 2 / 1 | 0.72 FAILS
on one file ("Invalid document: Expected end tag of kind LineSuffix"),
exit 2; bun formats it; all other bytes the same |
| generalaction/emdash:apps/emdash-desktop, mengxi-ream/read-frog |
oxfmt 0.72 | 2 / 1 | not installed here: sortTailwindcss: 0.72 exits 2
("Can't resolve 'tw-animate-css'"), bun warns and goes on; the bytes are
the same |
| heyhuynhgiabuu/proxypal | oxfmt 0.72 | 2 / 1 | not installed here:
0.72 cannot load their Tailwind 3 configuration and exits 2; bun warns;
the bytes are the same |
| ontola/atomic-server:browser/data-browser | oxfmt 0.72 | 2 / 1 | as
iiif-manifest-editor (2 files) |
| radix-ui/primitives | oxfmt 0.72 | 2 / 1 | 0.72's CSS parser refuses
one .module.css (exit 2); bun formats it; all other bytes the same |
| reshaped-ui/reshaped | oxfmt 0.72 | 2 / 1 | 0.72's CSS parser refuses
`@each` in 7 .module.css files (exit 2); bun formats them |
| salsita/node-pg-migrate | oxfmt 0.72 | 2 / 1 | 0.72 refuses `export`
in a .cjs file (exit 2); bun formats it |
| storybookjs/storybook | oxfmt 0.72 | 2 / 0 | 0.72 refuses `import` in
a .cjs file (exit 2); bun formats it |
| PrismJS/prism | Prettier 3.5.3 | 1 / 1 | three Prettier plugins that
lay JavaScript out otherwise (brace-style, space-before-function-paren,
merge): bun runs no Prettier plugin: 244 .js; 12 .md |
| alii/website | Prettier 3.9.6 | 1 / 0 | prettier-plugin-tailwindcss:
bun runs no Prettier plugin: 2 files only theirs would change |
| mickasmt/next-saas-stripe-starter | Prettier 3.9.6 | 1 / 1 | as
alii/website: 1 .tsx differs |
| shadcn-ui/ui:apps/v4 | Prettier 3.6.2 | 2 / 1 | their Prettier exits 2
here (prettier-plugin-tailwindcss needs a build); 19 files only bun
would change |
| trpc/trpc | Prettier 3.9.6 | 2 / 0 | their Prettier exits 2 here
("Unable to load your Tailwind CSS v3 config": www is not built); no
byte differs |

#### By repository

| | target | 9 October, 19:38 UTC (d9fee8c85) | now |
|---|---|---|---|
| oxlint + oxfmt in one repository: the same exit codes in both | 85 % |
132 of 143 (92 %) | 128 of 143 (90 %) |
| oxfmt: repositories with the same bytes as 0.72 | 95 % | 203 of 217
(94 %) | 204 of 217 (94 %) |
| oxlint: repositories identical to 1.87: rule, severity, place, length,
text, files, exit code, --fix | 75 % | 139 of 161 (86 %) | 143 of 161
(89 %) |
| of those: every label (span, text) the same too | | 103 of 139 (74 %)
| 142 of 144 (99 %) |
| of those: the help the same too | | 89 of 139 (64 %) | 143 of 144 (99
%) |
| Prettier: repositories identical | 80 % | 56 of 71 (79 %) | 54 of 71
(76 %) |
| ESLint: runs with the same exit code | 85 % | 89 of 102 (87 %) | 96 of
102 (94 %) |
| ESLint: repositories identical (with --fix) | 60 % | 60 of 86 (70 %) |
61 of 86 (71 %) |
| ESLint: repositories identical to the project's own version or to
10.12.0 with its configuration and plugins | | 62 of 86 (72 %) | 63 of
86 (73 %) |

#### What these numbers cannot say

- These projects are clean: their own CI keeps them so. Most runs
compare silence with silence. All 33 ESLint runs with the TypeScript
import resolver together hold 85 messages of `import/*` (counted on
0c0224b00); all 24 runs with eslint-plugin-react hold 42 messages of
`react/*` (counted on 611d8cbad). The rules' own test suites and the
differential fuzzers speak for the rest.
- No wall time in this table: the runs stood side by side on a crowded
machine.
- The terminal's own format is compared by exit code, signal and "has it
printed a summary", not by text.

</details>

## Usage

### `bun lint`

```sh
bun lint                      # eslint:recommended + typescript-eslint/recommended if there is no config
bun lint --fix src test
bun lint --type-aware         # rules that need types, on bun check's checker: no tsc, no tsgolint
bun lint --type-aware --type-check   # type errors too, in the same pass
bun lint -f json -o report.json .
bun lint --rules              # what is built in
```

- **Config**: `eslint.config.{js,mjs,cjs,ts}`, `.eslintrc.*`,
`.oxlintrc.json`, `oxlint.config.ts`. It takes the flags and output
formats of `eslint` and of `oxlint`, and behaves like the tool whose
config it finds.
- **Rules built in** (62 need types):

  | Plugin | Rules | Built in under an ESLint config |
  | --- | ---: | ---: |
  | ESLint core | 218 | 218 |
  | unicorn | 138 | |
  | typescript-eslint | 137 | 136 |
  | react | 106 | 102 |
  | vitest | 73 | |
  | `bun:test/` (new) | 65 | 65 |
  | jest | 60 | |
  | import | 46 | 46 |
  | jsx-a11y | 36 | |
  | `bun/` (new) | 29 | 29 |
  | oxc | 27 | 1 |
  | React Compiler | 26 | 26 |
  | nextjs | 21 | |
  | promise | 16 | |
  | n | 15 | 4 |
  | react-perf | 4 | |
  | react-hooks | 3 | 3 |
  | prettier | 1 | 1 |
  | **All** | **1,021** | **631** |

- **`bun:test/*`**: the rules of eslint-plugin-jest and -vitest that
make sense for `bun test`, one implementation for all three, chosen by
what the file imports. They look at files that import from `"bun:test"`
and know Bun's own API (orders of arguments, modifiers, matchers).
Without a config six are on: `no-focused-tests`, `valid-expect`,
`valid-expect-in-promise`, `valid-describe-callback`, `no-export` as
errors, `no-disabled-tests` as a warning. A fix that can break a passing
test is a suggestion.
- **Left out on purpose**: the 75 rules about layout that ESLint and
eslint-plugin-react have deprecated in favour of a formatter (`indent`,
`quotes`, `semi` ..), and oxlint's `jsdoc` and `vue` plugins. See "Known
differences".

- **Which of them answer depends on the config.** With an oxlint config,
all of them. With an ESLint config, those of the last column, each exact
by the original's own test suite: ESLint core, typescript-eslint, all
102 rules of eslint-plugin-react that are not about layout, all 46 of
eslint-plugin-import, react-hooks with the React Compiler's rules,
`prettier/prettier`, 4 rules of eslint-plugin-n and `bun/`. The other
plugins are ports of oxlint's rules, which differ from the original
plugins, so there the project's own plugin runs. A prefix means the
package only if the plugin object comes from that package:
`eslint-plugin-import-lite` under `import`, or `@eslint-react` under
`react`, answer for themselves.
- **Opting out**: `--no-native-plugin-rules` hands every plugin back to
its package; `--native-plugin-rules=import,react` names those that stay
built in.
- **Globals from the project's types**, behind a flag: `--infer-globals`
takes the globals of a file from the tsconfig or jsconfig that includes
it (`lib`, `types`, every `declare global`). `--infer-globals=fast`
reads only the compiler options and loads the types of a program only
when `no-undef` is about to report a name. Both are off by default.
- **ESLint plugins run as they are**, in JavaScript, on several VMs at
once: `context`, `sourceCode`, tokens, scopes, code paths, selectors,
fixes, processors.

### `bun format`

```sh
bun format                    # writes, prints what changed
bun format --check
bun format --stdin-filepath a.ts < a.ts
```

- **Languages**: JS, JSX, TS, Flow, JSON, CSS, SCSS, Less, GraphQL,
YAML, Markdown, MDX, HTML, Vue, Angular, Handlebars, and what is
embedded in them. A language that only a plugin of Prettier reads
(Svelte, Astro, PHP ..) goes to the project's own Prettier, if it and
the plugin are installed. With `svelte` in an oxfmt config, `.svelte`
files are left as they are, exit 2.
- **Config**: `.prettierrc*`, `prettier.config.*`, `"prettier"` in
package.json, `overrides`, `.editorconfig`, `.prettierignore`;
`.oxfmtrc.json`, `oxfmt.config.ts`. Flags of `prettier` and of `oxfmt`.
- **Built in**: import sorting (`@trivago/prettier-plugin-sort-imports`,
`@ianvs/prettier-plugin-sort-imports`,
`prettier-plugin-organize-imports`, oxfmt's `sortImports`), oxfmt's
`sortTailwindcss`, `sortPackageJson`, JSDoc. Other plugins of Prettier
are not: files of a project that names one
(`prettier-plugin-tailwindcss` ..) are left as they are, exit 2, or
formatted without it under `--allow-unsupported`.
- **It checks its output before it writes**: the result is parsed again
and compared with the input's syntax tree, comments and literals. A file
whose meaning would change is left alone and reported.

### `bunfig.toml`

```toml
[lint]
typeAware = true
maxWarnings = 0
ignorePatterns = ["vendor/**"]
nativePluginRules = ["import"]   # true (default), false, or the plugins whose built-in rules may answer

[lint.rules]
eqeqeq = ["error", "smart"]
"no-console" = "warn"

[format]
semi = false
singleQuote = true
```

- A key is the flag of the same name in camelCase, and `[format]` takes
Prettier's option names. `[lint.rules]`, `[lint.globals]`,
`[lint.parserOptions]` and `[lint.categories]` are tables.
- **Order**: command line, then `bunfig.toml`, then the tools' config
files, then the defaults. `configPrecedence = "prefer-file"` makes
`[format]` a fallback.
- An unknown key, a wrong type or a bad value is an error with file,
line and column, "Did you mean", and exit code 2. Flags that say what
one run does (`--fix`, `--init`, `--stdin`) are refused as keys.

### If the project already uses the name

A `lint` or `format` script in package.json, `./lint.ts`,
`./lint/index.*` (what can be run, so not `lint.json`),
`node_modules/.bin/lint` or an executable `lint` beside package.json
keep what `bun lint` meant before this PR. The same goes for `format`.

## Benchmarks

`microsoft/vscode` `src/` (10,149 files, 143 MB), Linux x64, 8 pinned
cores.

### Against oxlint 1.87 and oxfmt 0.72

15 alternating rounds on a shared machine, a release build of the commit
at which the tree was closed; the rows of `format` are of 8c1bd4bc. Both
linters report the same to within 0.03 % (see "How did you verify").

**Wall time, best round**

| Workload | `bun` | oxlint / oxfmt | Speedup |
| --- | ---: | ---: | ---: |
| lint, `correctness` | 0.21 s | 0.43 s | 2.0x |
| lint, recommended | 0.25 s | 0.51 s | 2.0x |
| lint, all 709 rules that both have | 0.73 s | 1.82 s | 2.5x |
| format `--check` | 0.42 s | 0.79 s | 1.9x |

**CPU time (user), median**

| Workload | `bun` | oxlint / oxfmt | Speedup |
| --- | ---: | ---: | ---: |
| lint, `correctness` | 1.52 s | 2.65 s | 1.7x |
| lint, recommended | 1.70 s | 2.96 s | 1.7x |
| lint, all 709 rules that both have | 4.86 s | 13.59 s | 2.8x |
| format `--check` | 3.02 s | 5.79 s | 1.9x |

**Instructions (user), least of 15**

| Workload | `bun` | oxlint / oxfmt | Fewer |
| --- | ---: | ---: | ---: |
| lint, `correctness` | 7.7 G | 15.8 G | 2.1x |
| lint, recommended | 8.4 G | 17.7 G | 2.1x |
| lint, all 709 rules that both have | 19.4 G | 66.7 G | 3.4x |
| format `--check` | 19.7 G | 39.9 G | 2.0x |

**Peak memory, median**

| Workload | `bun` | oxlint / oxfmt | Less memory |
| --- | ---: | ---: | ---: |
| lint, `correctness` | 119 MB | 271 MB | 2.3x |
| lint, recommended | 124 MB | 371 MB | 3.0x |
| lint, all 709 rules that both have | 517 MB | 1264 MB | 2.4x |
| format `--check` | 181 MB | 557 MB | 3.1x |

By instructions on six other repositories (next.js, node, twenty,
PostHog, ant-design, workers-sdk), with the default rules and with two
React configs: 1.6x to 2.9x fewer than oxlint. All 742 shared rules with
`import/*`, on vscode: 56 G against 303 G, 5.4x.

### Against ESLint and Prettier

Measured on earlier builds; being measured again.

**vscode's own ESLint config (8 plugins, 13,069 files), wall time.**
9,823 messages identical, fixes included; 3 differ.

| `bun lint` | ESLint 10 | Speedup |
| ---: | ---: | ---: |
| 15.8 s | 404 s | 26x |

**`prettier/prettier` as a lint rule, 8,042 real files, wall time.**
8,038 files get the same reports.

| `bun lint` (native rule) | ESLint + eslint-plugin-prettier + Prettier
| Speedup |
| ---: | ---: | ---: |
| 2.9 s | 67 s | 23x |

**Formatters, `--check` on vscode, CPU time**

| `bun format` | oxfmt 0.72 | Biome 2.5 | Prettier 3.9.9 |
| ---: | ---: | ---: | ---: |
| 2.9 s | 5.5 s | 20 s | 295 s |

With heavy third-party JavaScript plugins the gain over ESLint is
smaller: median 1.7x in wall time over 74 real runs of 5 s or more.

### Binary size

| Target | `main` | This PR | Added |
| --- | ---: | ---: | ---: |
| linux-x64 | 85.18 MB | 100.09 MB | +14.91 MB |
| linux-aarch64 | 84.68 MB | 99.80 MB | +15.13 MB |
| darwin-aarch64 | 67.85 MB | 82.50 MB | +14.66 MB |
| darwin-x64 | 74.81 MB | 90.49 MB | +15.68 MB |
| windows-x64 | 92.27 MB | 107.52 MB | +15.25 MB |

## Native eslint-plugin-react on real repositories

27 runs in 24 repositories that have the plugin in their resolved config
(versions 7.32.2 to 7.37.5), one build, three ways: built in, the
package in Bun's plugin host (`--native-plugin-rules` without `react`),
and the repository's own ESLint.

| Check, over the 24 runs whose config loaded on that build | Result |
| --- | --- |
| Built in against the package: messages, order, fix objects,
suggestions | the same in 24 |
| `--fix`, bytes | the same in 24 |
| `react/` messages, suppressed ones included | 42, the same in all
three |
| Runs that need no JavaScript engine any more | 2 |
| Runs that load fewer modules | 15 of the first 20 (react-hook-form:
750 to 24) |

These repositories are clean, so this shows silence where ESLint is
silent more than it shows the same reports.

| Repository | Built in | The package | Their ESLint |
| --- | ---: | ---: | ---: |
| shadcn-ui/ui | 2.1 s | 5.8 s | 90.4 s |
| chakra-ui | 0.59 s | 1.43 s | 22.6 s |
| mastodon | 6.6 s | 7.4 s | 100.0 s |
| playwright | 4.9 s | 4.5 s | 53.4 s |

## Known differences

**Configuration and command line**

1. An `eslint.config.*` and an `.oxlintrc.json` in one directory: `bun
lint` stops (exit 2) and asks for `--flavor=eslint` or
`--flavor=oxlint`.
2. A rule in `.oxlintrc.json` that `bun lint` does not have: oxlint
refuses the file. `bun lint` lints with everything else, names the rule
at the end and exits with 2; `--allow-unsupported` makes that a warning.
3. Beside an oxlint config, an option name that a rule does not know is
refused in oxlint's words; a wrong type or value that oxlint refuses is
accepted. Nothing that oxlint 1.87 accepts is refused (29,443 option
sets).
4. Under an ESLint config, files in other languages or for other parsers
(JSON, Markdown, CSS, Vue, Svelte, Astro, MDX) are linted by the
`eslint` package of the project, in JavaScript. Without it they are
named at the end and the exit code is 2.
5. The built-in rules follow ESLint 10.12, typescript-eslint 8.71,
eslint-plugin-react-hooks 7.1, -import 2.32, -n 18.4 and -react 7.37,
whichever versions are installed. A `note:` says so where the installed
one is older by a minor version or more.
6. Two rules that report at one place can come in another order than in
ESLint, which has first what was listened on the outer node. Where both
fix the same range the first wins, so `--fix` can write other bytes. The
rules of eslint-plugin-react say on which node they listen: with its 30
fixable rules at once on the 11,367 texts of its own tests, `--fix`
writes the plugin's bytes in 11,360, and in those looked at of the other
7 the plugin's text does not parse; the order of messages still differs
in 67 texts with 102 rules on. The core rules do not say it yet: 255 of
745 ties in ESLint's own sources come in another order. The 26 rules of
the React Compiler report while ESLint creates them, before it visits a
node, so at one place they come before every other rule and among
themselves in the order of the config: the same here.
7. There is no cap on what a file, a rule or a function may have: no
count of reports, nodes, steps or levels. What stands before the stack
is a check of the real stack, so how deep code, a config or a comment
can nest depends on the thread's stack and not on a number. The parser
and the binder nest as deep as the stack of a thread of Bun's pool
allows (4 MB; 18 MB on Windows); the threads of `bun lint`, `bun format`
and `bun check` have eight times that, for the checker, the rules and
the printers that walk the same tree. Beyond the stack the answer is an
error ("The code is nested too deeply.", Prettier's "Invalid string
length", `react/todo` "Support functions of this size", ESLint's
"Maximum call stack size exceeded"), where oxlint 1.87 ends with a
segmentation fault and ESLint with a `RangeError`. Hostile input costs
what it costs in the tool that is stood in for: 33 shapes in 47 rules
are the square of their size, as in ESLint, and patterns beyond
minimatch's and brace-expansion's reach are as slow as there. What is
left are bounds of the machine: `stylish` stops padding its rows where
ESLint ends with `RangeError: Invalid string length`. `--threads` above
1,024 counts as 1,024. A file of more than 2^29 - 24 bytes, which
JavaScript could not hold as a string, is not read (`EFBIG`); of what is
no regular file (`/dev/null`, a pipe) at most 64 MB are.
8. A plugin or rule in JavaScript that leaves a rejection unhandled:
ESLint stops with exit 2, `bun lint` prints the error and goes on.
9. `-f junit`, `checkstyle`, `gitlab` and `sarif` print oxlint's layout
under an ESLint config too, under the name `bun lint`. ESLint 10 ships
none of them.
10. `bun format`: `printWidth` and `tabWidth` have no upper bound and
take what Prettier takes, from every source (flags, JSON, YAML, TOML,
JSON5, programs, overrides, `.editorconfig`): of 536 cases none prints
other bytes. What is no integer is refused in Prettier's words, with its
exit code. Left: `--print-width -1` as two arguments is an unknown flag
here, a warning in Prettier; `0x10`, `1_000` and `05` in a
`.prettierrc.json` are read, where `JSON.parse` refuses the file. Beside
an oxfmt config nothing that oxfmt 0.72 takes is refused or printed
otherwise (222 cases); `tabWidth: 0` is formatted, where oxfmt panics.
The flags `--check`, `--list-different` and `--write` are refused
together where the tool that is stood in for refuses them, with its
sentence and exit code and nothing written (893 cases; `[error]` stands
where oxfmt has `Error:`).
11. What ESLint 10.12 gets wrong, `bun lint` gets wrong with it. One
case is known: `--fix` with `no-var` and `one-var` together turns `if
(x) { var a = 1; var b = 2; } return b;` into `let a = 1, b = 2;`, where
`b` is then not defined. ESLint has fixed it (eslint/eslint#21389), in
no release yet. The fix objects of all 106 fixable core rules are those
of 10.12.0 (10,330 cases), and the recorded suites compare them, so this
follows with the release that has it.
12. The same for oxlint 1.87. Of 4,624 self-checking programs
(JavaScriptCore's tests), run before and after `--fix` with one rule at
a time, 479 end otherwise after a fix of oxlint's own, and `bun lint`
writes the same bytes: `no-var` 259, `unicorn/catch-error-name` 105,
`sort-keys` 19, `no-new-wrappers` 15, `unicorn/prefer-spread` 12,
`prefer-arrow-callback` 11, 19 more rules 1 to 7 each. These tests look
at what ordinary code does not (the text of a function, the order of
keys), so this is an upper bound.
13. Beside an oxlint config, `no-var` leaves a `var` that is declared
twice, each time in a `try` block of its own; oxlint writes `const` for
both.
14. A fix that would leave a file with a syntax error is not applied,
and a warning says so. ESLint, oxlint and the plugins apply it: of the
1,908 texts of eslint-plugin-import's tests, 50 end as text that does
not parse with the plugin and are left alone, or stopped a pass earlier,
here.
16. YAML is read by Bun's own parser. Prettier's suite (7,598 checks)
and 1,219 files in four sets of options print the same bytes. Of 96,458
damaged texts, 250 are refused that Prettier formats, 150 formatted that
it refuses, 9 print other bytes, and a syntax error is worded as
`Bun.YAML.parse` words it.
18. `<!--` and `-->` comments: several comment rules at once `--fix`
other bytes than ESLint 10.12, whose `-- >` is no comment.
19. The config file that is found says whose run it is, wherever it lies
and whatever flags there are. A flag of the other tool has its plain
meaning (`-D <rule>` is `--rule`) or is refused in one line with exit 2.
20. The deprecated rules about layout are not built in. A config that
turns them on gets one `note:` on stderr that names them; the exit code
is that of the rules that ran. `bun format` is what does their work.
21. oxlint's `jsdoc` and `vue`: a rule of theirs that a config turns on
by name is named and ends the run with 2, like any rule that is not
built in. A plugin that is only listed, so that a category would turn
its rules on, is a `note:` on stderr, in every format and with
`--quiet`.
22. A search that leaves the project (`bun lint ..`, `'/**/x.js'`) runs
no `eslint.config.*` that ESLint 10.12 would not run, and ends as ESLint
does. The working directory's own config is always run. Where the
working directory has no config, one counts only in and below it, or
where a plain path names it: what a pattern merely reaches gets the
defaults, and nothing of it is loaded. The same for `bun format`.
23. Beside an oxlint config, `no-useless-assignment`,
`constructor-super` and the other rules on code paths follow ESLint's
code paths. oxlint has a control flow graph of its own, which answers
otherwise in a few corners (`a = (a = f()) ? a.b : 1`, `class A { x =
id++ }`, `try` with `finally`).
24. oxlint stops at an error of its semantic checks, such as a name
declared twice, and runs no rule on that file. `bun lint` goes on.
25. A NUL in the text of an HTML element is the end of the file for
Prettier 3.9.9 and oxfmt 0.72, which drop what follows and exit with 0.
`bun format` refuses the file and leaves it.

**eslint-plugin-react and eslint-plugin-import**

1. `settings.react.version: "detect"` asks the nearest installed react
for each file; the plugin lets the first file decide for the process.
2. Where the plugin throws and ESLint's run ends (settings of the wrong
kind, `jsx-handler-names` with `ignoreComponentNames` on `<A.B>`),
nothing is reported for that rule and the run goes on.
3. `jsx-sort-props` compares names in English order. The plugin uses the
machine's default locale, or the rule's `locale`, so with `ignoreCase`
under a locale with a collation of its own (cs, sk, hu, tr, sv, da, nb,
lt), or with such a `locale`, reports and the order that `--fix` writes
can differ.
4. A file with Flow types goes to the project's own parser, and there
the package's rules answer.
5. `import/resolver: typescript` is answered by Bun's resolver following
eslint-import-resolver-typescript 4.4.5. Its options `extensions`,
`conditionNames`, `mainFields` and `alwaysTryTypes: false` are not read;
`./a.js` where only `a.jsx` exists is found.
6. With any other resolver, another parser in `import/parsers`, or a
regular expression object in `import/ignore`, the installed package's
rules run instead.
8. `import/no-unused-modules` and `import/no-cycle` answer each file as
if it were the first one linted; the package's answers can depend on the
order of the files.

## TODO

- [ ] On Windows a top-level `preload` (and `define`, `loader` ..) of
`bunfig.toml` still applies to the process that evaluates
`eslint.config.*`, `prettier.config.*` and the like. Elsewhere that
process gets `--config=/dev/null`. It needs a way to tell `bun` to read
no bunfig.toml.

**Compatibility**

- [ ] Defaults, locations and texts of ESLint 9 where ESLint 9 is
installed (45 of the 102 real ESLint runs).
- [ ] oxfmt's own departures from Prettier (161 fixtures).
- [ ] 5 Flow cases of Prettier's suite; a comment before the first `.`
of a member chain that breaks.
- [ ] JavaScript plugins get no type information.
- [ ] Types are TypeScript 7's, also where typescript-eslint runs on
TypeScript 5 or 6.
- [ ] `--infer-globals=fast` as the default: on projects that never load
the types it costs +0.1 % to +8.1 % instructions. Prepared as a change
of its own.
- [ ] `import/resolver: typescript` on one resolver instead of
TypeScript's resolution with corrections.

**Speed and robustness**

- [ ] A catastrophic regular expression from a config or an `/* eslint
rule: [..] */` comment costs about 1.8 s per match (Yarr's own
backtracking limit). Nothing limits a file or a run.
- [ ] `x = (x = (x = ( ..` 1,500 deep around 20,000 lines takes the
parser 36 s (lines x depth). ESLint refuses the file; oxlint 1.87 does
not end in 200 s.
- [ ] The type checker's file reader has no bound, as `bun check` on
`main` has none: a file of gigabytes, or a link to a device, as
`tsconfig.json` (with `--infer-globals`) or as the `package.json` of an
imported package (beside an oxlint config with `import` rules that look
at other modules) is read until there is no memory. The reader of `bun
lint` and `bun format` has the bound; it belongs in that one too, as a
change of its own.
- [ ] Memory and time of `bun format` on one very large YAML file have
not been measured again since YAML moved to Bun's parser (858 real
files: 3 % more instructions).
- [ ] Tens of thousands of different keys in one object of a config file
cost the square: 80,000 keys, about 1 MB, take 8 to 48 s (Prettier 67 s
on its own; `tsc` 7.0 14 s where `bun check` takes 25 s).
- [ ] `jsx-sort-props` with a collator for the machine's locale, or the
rule's `locale`.
- [ ] What JSON has no word for, as an option of a rule in
`eslint.config.*`: `Infinity` (as in `{ max: Infinity }`), `-Infinity`,
`NaN`, functions, symbols, bigints, `Map`, `Set`, `RegExp`, class
instances and a trailing `undefined` are taken or refused as by ESLint
10.12, in its words (103 of 128 cases). Left: other words for a `Date`,
a boxed number and a circular object; a key of a config object that is
`undefined` is read as absent, where ESLint refuses the config. Beside
an `oxlint.config.ts`, `Infinity` is no limit, where oxlint 1.87 refuses
the file.
- [ ] A binary file under an extension that is read leniently is
rewritten, as Prettier rewrites it. A look for NUL bytes would leave it
alone.
- [ ] A pass of `--fix` that would leave a syntax error drops all of the
fixes of that pass, not only those that break the file.
- [ ] `bun check`, on `main` (4c54c9bc6) as here: a call of a generic
function with 6,000 type parameters that are each constrained by the
next ends with a segmentation fault (`bun lint --type-aware`: from
52,000). `tsc` 6.0 says TS2589 from 110 on, a limit of its own that this
path never reaches, so from there the answers differ. The same for
function types some thousand deep in each other, and for `export *`
through 6,678 modules.
- [ ] `bun check`: generic arrow functions 5,200 deep in each other:
four functions of the checker go up through the enclosing arrows and
never ask for the stack. It holds on the 32 MB of the threads and fell
on 4 MB.
- [ ] `bun check -b` on a chain of projects, each of which refers to the
next, that are all in error (`composite` with `noEmit`): every project
repeats the errors of all below it, and 35 KB are held for each: 400
projects deep take 2.8 GB, on `main` 0.35 GB, for the same 79,800
errors. It comes with the depth: a tree of 364 projects and 10 layers of
10, in error or healthy, take 142 to 201 MB and 1.1 to 4.0 s on one
thread, less memory than `main` (212 to 311 MB; 4.2 to 16.1 s) and `tsc`
6.0 (257 to 413 MB; 1.4 to 4.2 s), and print the same bytes.
- [ ] `bun check`: an expression more than 1,000 queries deep is refused
at once ("ran out of stack") where `tsc` with a large stack completes.
Going on where the work stood is written; past the real stack it printed
TS2719 for a placeholder, so it is not in. `await`, `else if` and
ternaries at the parser's limit cost the square (15 to 70 G).
- [ ] A pattern that leaves the project still loads the configs it
reaches where the working directory has a config of oxlint or of ESLint
8 (8.57.1 does the same), and `oxfmt.config.ts` where it has a
`.prettierrc` (Prettier would not). Closed for a flat config and for no
config.
- [ ] `--stdin-filename` and `--print-config` for a path outside the
project that has no `eslint.config.*`: built-in rules, where ESLint 10
says "Could not find config file".
- [ ] 37 `.resolves` / `.rejects` that nothing awaits in Bun's own
tests, found by `bun:test/valid-expect`.
- [ ] A regular expression in the options of a rule with 26,000 groups
in each other takes 15 s in Yarr's compiler.
- [ ] Beside an oxlint config the check for "this fix would leave a
syntax error" does not see a name that is declared twice (a file that is
linted without types is not bound). It would hold back most of the 259
fixes of `no-var` above, and be other bytes than oxlint's on purpose.
- [ ] The node that a rule listens on, for the core rules too, and for
the rest of eslint-plugin-react (`jsx-tag-spacing`, `jsx-key`, an
element that closes itself).

<details>
<summary><b>For reviewers: what changes outside <code>src/lint</code>,
<code>src/format</code> and <code>src/sema/parser</code></b></summary>

- **`src/js_parser`: 27,798 lines deleted.** `bun check`, `bun lint` and
`bun format` parse with `src/sema/parser`, so the mode that #44361 added
to Bun's parser for the type checker is gone. What is left is the text
from before that PR plus 141 lines, all of which are on `main`.
`Bun.Transpiler` on 751,511 files with every loader that applies
(1,949,442 rows: a hash of the output or of each thrown message with its
place, of `scan`, of `scanImports`): 0 rows differ from `main`.
- **`Bun.markdown` changes its output for 0.45 % of real documents**
(232 of 51,234 `.md` files with the GFM extensions on, 86 with them
off). The Markdown formatter is built on `src/md`; each change is a fix
with a test in `test/js/bun/md`, judged by commonmark.js 0.31 and
micromark 4: table alignment per table, `a~~b~~c`, email autolinks,
lower-case `<!doctype`, nested links, fences outside a container, `1. `
not interrupting a paragraph, `- [ ]` over `- [x]`. 70 MB of real
Markdown to HTML takes 30 % fewer instructions.
- **Moved so that lint and format can share them**: `src/node_path`
(Node's path algorithms, out of `src/runtime/node/path.rs`),
`src/text_diff` (`bun test`'s diff), `src/glob` (one matcher for
`Bun.Glob`, minimatch, picomatch and ignore files), and text helpers in
`bun_core`. `test/internal/source-lints/shared-helpers.test.ts` keeps an
inventory of private copies that can only shrink.
- **`src/yarr`** (new), `RegularExpression.cpp`: regular expressions in
configs and rules run on JavaScriptCore's Yarr. `bun test -t` goes
through the same code.
- **`src/react_compiler`**: the React Compiler's lint rules run on Bun's
port of it, which got checks of the real stack (no count and no budget),
speed fixes, and a cure for type inference that did not end on small
inputs. Every assertion that input could reach returns an error now. On
4,801 real files its lint rules take 22 % fewer instructions than before
the speed fixes (131.3 G to 102.1 G); 8,000 JSX children 0.66 s instead
of 7.3 s. 608 of 20,000 generated programs took all the memory there is
(oxlint 1.87 does not end in 60 s on the three that were tried): the
join of two ref types went down shared structure as if it were a tree.
Two types that are held by pointers are joined once now: 25.8 s for all
608 in one process, 103 MB at the peak; where the old code ended (114 of
202 tried) the output is the same. Beside oxlint 1.87 on the 104,658
real files, all 26 rules: 23,256 findings there, 15 only here, 8 only
there; `react/purity` is 1,548 in both and in 1.86, and 698 in 1.85.
- **`src/react_compiler`, `src/ast/e.rs`,
`src/js_parser/react_compiler_host.rs`: eight fixes for wrong output**,
found by executing compiled against uncompiled code over several
renders, by parsing every output of 104,658 real files, and by looking
at where the lint rules differ from oxlint's. All eight are on `main`
too (4c54c9bc6). Each has an `itBundled` test that executes; those of
the first six fail on `main`, and for 7 and 8 the same program, built
plain and compiled by `main`, prints two different things:
1. Dead code elimination removed an unused read in a `try`, whose throw
was caught.
2. A variable reassigned in a scope inside another scope was `undefined`
from the second render on.
3. A scope that depends on a variable and reassigns it stored the new
value as the dependency. `let sum = props.start; for (..) sum = sum +
x;` with `start` 0, 0, 7, 0 gives 7, 7, 7, 7 on `main` and 7, 7, 14, 7
here.
4. `a++` in a scope did not count as a reassignment, so the update was
lost in a render that reuses the scope.
5. `memo(function Tree() { .. <Tree/> .. })` was compiled with an
unbound name, a `ReferenceError`. Upstream's invariant is back: the
function is left alone, as in babel-plugin-react-compiler 1.0.0.
6. A regular expression that ends in an escaped slash (`/^https?:\/\//`)
lost its closing slash in a compiled function: a syntax error in the
bundle.
7. A function of the module's own that is called `useCallback` or
`useMemo` was taken for React's and the call was dropped: `function
useMemo() { return "mine"; }` was never called.
8. The same for a member of any namespace import: `import * as X from
"./hooks.js"` lost its `X.useMemo(..)` and `X.useCallback(..)`, and with
`--target=bun` `X.useEffect(..)` was `undefined` and `const [s] =
X.useState("init")` was `"init"`. Named imports from other packages were
right. `React.useMemo` of `"react"` is dropped as before.

  | Fix | Real files whose output changes, of 104,658 | What changes |
  | --- | ---: | --- |
  | 1 | 5 | something in a `try` is kept; 1 had the bug |
  | 2 | 4 | 1 had the bug, 3 loops are memoized that were not |
| 3 | 28 | one kind only; 15 of 30 (scope, variable) pairs could go
stale |
  | 4 | 0 | no real file has the shape |
| 5 | 4 | the function is left alone; 3 crashed, 1 was right and loses
its memoization |
  | 6 | 83 | exactly the 83 files whose output did not parse |
| 7 | 1 | a component that was left alone is compiled, with the call
kept |
  | 8 | 0 | no real file has the shape in a compiled component |

Fixes 2, 3 and 4 are one change and must not be separated. Memoized
functions stay at 122,303. After the first six: outputs that do not
parse 0; upstream's 849 fixtures executed, release and ASAN, 849 pass.
After all eight and the speed fixes: that one file is the only one of
the 104,658 whose bytes move, and no recorded fixture output does.

**Found and not fixed**, on `main` and in babel-plugin-react-compiler
1.0.0 alike: what depends on whether a `try` throws is not reactive
(`try { JSON.parse(props.text) } catch { valid = false }` keeps the
first render's answer); `b = f((e = 0))` loses the assignment in a
render that reuses the scope. A fix for the first was in 6a982bb2 and
991d1b9b and is out again: it made the parameter of a `catch` a
dependency outside the handler, a `ReferenceError` in 3 of 5,541 real
files with a `try`. The test for that stays. New:
`react-compiler-fixtures-run.test.ts` builds 849 of upstream's fixtures
with and without the compiler, executes both and compares every render
(1 s on a release build).
- **`src/lint`: a rule is a type, not a table of callbacks.** `impl
Rule` with `const META`, `const ON` (the node kinds it listens to) and
one method per kind; no `dyn`, and the enabled rules of a file are one
bitset. Against the callback version, 237 rules on vscode: 4.2 % fewer
instructions, 1,420,096 report lines byte for byte the same.
- **`src/sema`**: binder modes without the flow graph, services for lint
rules on the checker, a reduced program that answers only which globals
exist. `bun check` shares declaration files between projects with
`main`'s code, unchanged. It runs on a pool of its own ("Bun Check n")
with eight times the stack, as the two new commands do. Three walks of
the checker that never asked for the stack, `modules_declaration`,
`check_binding_name` and `implied_by_pattern_inner`, ask now: they are
on `main` as well, where a parser and a binder with larger frames gave
up before them. In `tsconfig.json`, `extends` is followed by a loop, and
`include` and `exclude` are matched without recursion or backtracking:
`**/a/` 16 times against 34 directories took over 60 s (`tsc` 6.0: 29 s)
and takes 0.4 s. The same answers as before on 1,500 random projects
(everything that is printed, and the exit code) and on the 7,908 real
configs of 372 repositories (1,112,029 files listed).
- **`src/parsers/yaml.rs`: three changes of `Bun.YAML.parse`**, beside
`parse_as_written` for the formatter (+125 lines, no branch of it taken
by `Bun.YAML.parse`). `a: [⏎]`, the end of a flow collection at its
parent's indentation, was an error and is `{a: []}`: `yaml` 2.9 and
js-yaml 4.1 read it, the specification does not, and Bun read the same
bracket behind a scalar. `a: [x]⏎: y` was an error and is read, as the
specification has it (js-yaml refuses). `{:a b}` was `{null: "a b"}` and
is `{":a b": null}`, as both and the specification. A test for each;
`test/js/bun/yaml` 2,814 pass.
- **`src/bunfig`**: `load_config_for_tool` hands the parsed file to the
command: the same search, reader and TOML parser as for every other
section. **`src/sys`**: `extended_attributes(fd)`, so that a rewritten
file keeps its xattrs, ACL entries and SELinux label.
- **`src/jsc`, `src/runtime/cli`**: the two commands, the plugin VMs
(`lint_js.rs`), `LintNodes.cpp` (the syntax tree that a JavaScript rule
sees is built natively), `VirtualMachine::exit_and_free`. How many VMs a
run starts depends on the bytes that need one and on the memory limit,
not on time: 192 of 192 runs at four sizes, two loads, with and without
a 16 GB limit, start the same number. Eight real repositories against
the build of the day before: 1.9x to 4.0x faster in seven, within the
noise in one, with less CPU time in all.
- **`src/jsc/bindings/highway_dispatch.h`**: a call site of the SIMD
dispatch macro was a guarded function-local static; it is now one
relaxed atomic load and an indirect call, and resolving the target is a
cold function of its own, so LTO no longer inlines the guard into
thousands of callers. Every Bun process goes through it, and it is
independent of the rest of this PR.
- **A script named `lint` or `format`** now sees
`BUN_INTERNAL_SCRIPTS_OF_COMMANDS` in its environment: that is how
`"lint": "bun lint"` means the linter inside the script.
- `LICENSE.md`: attributions for the ported projects.

</details>

### How did you verify your code works?

**CI.** The whole run on the head, a52c2279, with `main` merged in,
passed: Linux 120 of 120, ASAN 20 of 20, Windows 16 of 16, macOS 4 of 4;
so did the one before the merge. An earlier one, on the commit at which
the tree was closed: Linux 120 of 120, ASAN 20 of 20 (with Rust's debug
assertions), macOS 4 of 4, Windows 15 of 16. The red test was ours and
was right: 15,000 assignments in each other got five TS2719 for a
placeholder under `bun check`, from a step that went on where the
checker used to refuse; on Linux it shows from 18,000. The step is out
(see TODO). Not required, and red in all: `binary-size`, by design, and
the lane of macOS 27, which `main` does not run
(`sql-close-pending-connection`, `node-net`); nothing here touches what
they test, but that they are unrelated is not shown.

**What left the PR.** On 11 October 104,000 lines: two development
harnesses with the oracles that only they could run, fixtures that
nothing loaded, the ports of two Prettier plugins, tables stored twice,
a second algorithm for hostile sizes in 47 rules, YAML's own parser,
twin rules. On 12 October 24,500 more: the 75 rules about layout,
oxlint's `jsdoc` and `vue`. Each step that could change behaviour was
proved old against new, byte for byte, on the suites and thousands of
files.

- The seven test suites above and 55 differential tests against the real
tools run in CI (`test/cli/lint`, `test/cli/format`, `test/cli/check`).
- The real repositories in the tables above, each with its own command
and config in a sandbox, against the real tool.
- Every rule that both have, against oxlint 1.87 itself, place for
place: 709 rules on seven real repositories (vscode, next.js, PostHog,
twenty, node, workers-sdk, ant-design). 11,169,328 reports are the same
and 3,130 are not (99.97 %); 514 of the 641 rules that report anything
agree everywhere. On the 157,000 inputs of the three tools' own suites
that oxlint can read, with all 709 rules on each: 1,488,153 the same,
2,148 not. `import/*` on vscode with its packages installed: 211,422 of
211,422.
- The work on speed changes no report. Each fast path has a debug
assertion against the slow one: 76 runs of a debug build over all those
inputs and repositories, none fired, and CI's ASAN lane has them on.
`bun build --react-compiler` on 16,981 real components, before against
after: 0 outputs differ. The compiler's 20 rules alone and in groups, 90
pairs of a config and a set of files: 0 differ. What was changed for
oxlint's flavour moved nothing under an ESLint config: the whole JSON
output on 162,946 inputs has the same checksum.
- Coverage-guided fuzzing of the parsers, printers, config readers and
the glob matcher. Black-box fuzzing of CI's release and ASAN builds with
mutated configs, options and hostile files, in a clean environment and
on a pseudo-terminal: 232,294 runs on 0c0224b0, no signal, no hang, no
exit code over 2. Files that are not valid UTF-8 with a plugin that
checks every node, token and comment: 5.2 million reports compared with
ESLint 10.12 on 09859818, none differs. Extreme numbers in every flag
and every key of `bunfig.toml` (6,160 runs), in the formatter's options
(1,092) and elsewhere in config files (1,260); config files that are
deep, long or many, to a million levels, keys or overrides (4,001); file
trees with links, devices, pipes, odd names and modes (312), and config
files that name a device (280): on the last commits no signal, and
nothing written outside the project. What these found is fixed:
`threads` without a bound, and files, links and config paths that were
read without one.
- Does the code still do what it did? 4,624 self-checking programs are
run, rewritten and run again. `bun format --write`: 5 end otherwise, as
with Prettier 3.9.9. `bun lint --fix` with the 106 fixable core rules at
once: 38, all with ESLint 10.12.0's bytes. Beside an oxlint config, all
rules at once and the 68 that fix one at a time (18,547 files written):
none that oxlint 1.87.0 does not break too. For JSX the question is what
React would be given: the 30 fixable rules of eslint-plugin-react one at
a time (139,639 files written) and all at once: none that the plugin
does not change with the same bytes. This found three faults, which are
fixed: `no-implicit-coercion` and `no-var` beside an oxlint config, and
the order in number 6 of the known differences. The fix objects of all
106 fixable core rules are those of ESLint 10.12.0 (10,330 cases), those
of 42 rules of react, react-hooks and import those of the plugins
(2,132).
- Large input. 176 and 342 real files joined into one file (25,117 and
50,234 lines), the same inside one function, 300 and 600 generated
components, one generated component of 25,665 and of 51,614 lines: every
field of every diagnostic is the same as oxlint 1.87.0's (every
category, 7 plugins; up to 62,801 diagnostics a file) and as ESLint
10.12.0's (366 rules; up to 79,836), in a fifth to a three-hundredth of
the time. The React Compiler's rules on generated components with up to
4,000 hooks, callbacks or JSX children and 16,000 statements: oxlint's
findings in all 28 sizes at which it ends; at 6,000 and 8,000, where it
ends with a segmentation fault, the finding is reported.
- Depth. Where a number used to stand before the stack there is a check
of the real stack, and a check in the parser does not protect what walks
the tree afterwards. Such a crash lives in a window of depths a few
percent wide, just below where the parser refuses, and in a release
build only: with ASAN or in a debug build the check keeps four times as
much free. So: every size in steps of 1 to 3 %, one process a file, on
CI's release builds (127c0994 to 8f6f7ed9; the older of them still have
4 MB for the threads of a command and are the more sensitive).

  | What is nested | Shapes | Runs | Signals |
  | --- | ---: | ---: | ---: |
| Config files, comments, selectors, regular expressions, globs, ignore
files | 354 | 100,249 | 1, on `main` too, fixed: an `include` of 133,271
`**/` in `tsconfig.json` |
  | Source under `bun lint`, every rule | 756 | 86,522 | 0 |
| Source for the React Compiler, `bun lint` and `bun build` | 50 |
23,309 | 0 |
  | Source under `bun format` | 142 | 22,878 | 0 |

Found this way and fixed: an `/* eslint */` comment (54 signals in 500
runs on the commit before: what was left of a tree was freed at the
bottom of a nearly full stack); a suggestion of `no-unused-vars` for
patterns in each other, where oxlint 1.87 ends with a segmentation fault
too; two aborts in JSDoc; the guard of a `match` case of Flow in `bun
format` (6 of 143 sizes; 0 now, on a main thread with 4 MB too); dotted
namespaces and patterns in `bun check` (13 of 213 sizes; 0 now);
patterns in a parameter (every size tried from 5,000 to 17,500 on 4 MB;
`main` falls at 5,000); a chain of 2,287 `extends` in `tsconfig.json`,
which is read on the main thread (`main` says "Cannot read file" from
there on, `tsc` ends with a `RangeError` from 1,500; 19,061 files are
read in 1.1 s now).

And a tool for what a sweep cannot see because another function happens
to have the larger frame: a debugger tells the stack checks of one
directory that the stack ends early and sets a hardware watchpoint below
that end. What asks stops above it; what does not ask writes there, and
the backtrace names it. Each run has a control that must hit.
`src/lint`, 6,108 files with every rule in both flavours: 20 hits in 4
functions, 0 now. `src/format`, 12,272 files in ten languages: 3 kinds,
0 now. `src/react_compiler`, 295 files: 0.
- The 21 numbers that `bun format` had (depths, lengths, counts), and
the 16 and 8 bits of `printWidth` and `tabWidth`, are gone. 25 inputs
beyond them: 25 print the bytes of Prettier 3.9.9 or oxfmt 0.72. About
20,000 shapes were then run at three depths for anything whose time or
memory doubles: none. By the clock: lists in Markdown and expansions of
Angular 40,000 to 120,000 deep, and 32,000 parameters in SCSS, took 6 to
22 s (the square of the size) and take 0.17 s. For a wrong answer
without an error: 7,000 files formatted once with 200 KB of stack and
once as usual: what is not refused and differs is always another
language inside the file, left as it is written, as Prettier does when
its own stack ends there.
- What lies outside the new directories, against `main`: 11,586 files
through the transpiler (transform, minify, scan) plus 96,000 generated
and mutated programs, 20,000 random inputs through 13 `node:path`
functions, 90,000 through `Bun.semver`, TOML, JSONC, JSON5 and JSONL,
1,713 React Compiler fixture builds: 0 differences. `Bun.markdown`:
135,000 inputs against commonmark.js and micromark, 0 regressions.

To try it:

```sh
bun run build:release
BUN=$PWD/build/release/bun
cd some/project
$BUN lint
$BUN lint --type-aware
$BUN format --check
```
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.

3 participants