Repository navigation
bun check - a TypeScript type checker builtin to Bun - #44361
Merged
Merged
Conversation
Collaborator
|
Updated 10:22 AM PT - Oct 6th, 2026
❌ @Jarred-Sumner, your commit 0ad8bcd has 1 failures in
Add 🧪 To try this PR locally: bunx bun-pr 44361That installs a local version of the PR into your 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.
…ent things can both be noted
…th it; helpers for related information
…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>
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
```
This was referenced Oct 14, 2026
This was referenced Oct 22, 2026
This was referenced Nov 9, 2026
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This adds a TypeScript type checker to Bun.
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. Ifbun checkandtsc7 disagree about an error, that's a bug in Bun.packages/nextin the Next.js repo, 2,881 files:tsc6.0.2tsc7.0.2 (typescript-go)bun check(How that was measured is under Performance.)
It only type checks. It doesn't emit JavaScript,
.d.tsfiles, 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 checklooks for the nearesttsconfig.jsonand checks whateverfiles,includeandexcludeselect. It uses all of your CPU cores.Errors go to stdout. The summary goes to stderr.
If your
package.jsonalready has acheckscript,bun checkstill runs that script, like it does today.bun --checkwith no file is the type checker in every project."check": "bun check"works too: inside that script, and in the scripts it runs,bun checkis the type checker.bun --filter '*' checkandbun --workspaces checkstill run each package'scheckscript.Check some files
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 hasreferences, the referenced project that does. So it works in the layoutcreate vitegives you.A directory means the part of the project that's in it, so
bun check .is the same asbun check. If the project has no files there, likebun check scriptswhenincludeis["src"], Bun checks every file in the directory that isn't excluded, each with thetsconfig.jsonnearest to it.Choose a tsconfig
Without a tsconfig
bun check index.tsworks 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.jsonat the root,bun checkchecks everything below the current directory. Each file gets the options of thetsconfig.jsonnearest to it, and each file is only checked once.Project references
referencesare followed liketsc -bdoes, 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, liketsc -bdoes.--check--checktype 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.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 --checkrestarts the process like--watchdoes, so the code is checked again before it runs.A file without an extension,
-e,-pand 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.--conditionsand--loaderapply to the check: with--loader .js:ts, every.jsfile of your project is TypeScript.--checkdoesn't cover files loaded with--preload.bun checkdoes, if yourtsconfig.jsonincludes them.bun --watch --check src/index.ts bun test --watch --checkA
package.jsonscript has no entry point to start from, so Bun checks the whole project first, likebun check. Same with--filter,--paralleland--sequential.bun run --check dev bun --check --filter '*' build--tsconfig-overrideapplies to the check too, so the type checker reads the sametsconfig.jsonas the bundler and the runtime. So doestsconfiginBun.build.Bun.buildtakescheck: true. A type error fails the build like any other build error, and nothing is written. The check uses theconditionsandloaderof the build.Compiler options as flags
Any compiler option works as a flag, like in
tsc. Flags overridetsconfig.json.bun check --noUncheckedIndexedAccess bun check --strict false bun check --target es2022Output
In a terminal:
When there are more than 50 errors, identical errors are grouped and sorted by how often they happen.
--allprints every one.When stdout isn't a terminal, you get the same format as
tsc --pretty false, so problem matchers and scripts written fortsckeep working.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.
With
AGENT=1:What you need installed
That's for
console,fetch,Bunandbun:test.bun initinstalls it for you.You don't need the
typescriptpackage. TypeScript'slib.*.d.tsfiles (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.Flags
-p,--project <path>tsconfig.json, or the directory that holds one--pretty/--no-pretty--all--threads <n>--timing--cwd <path>--strict,--target, ...tscDocs 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 thetsconfig.jsonthat Bun finds by itself says the same thing. Now that build reads the file in place of everytsconfig.json, like--tsconfig-override. For both, a directory means thetsconfig.jsonin it, liketsc -p. Other builds in the same process, and the program's own imports, aren't affected, even while it's running.--tsconfig-overrideprintedInternal error: directory mismatch for directory "/app/custom.json", fd 3. You don't need to do anything, but this indicates a bug.every time, forbun buildand forbun run.pidfd_open, a child process that exits could interrupt a system call of the main thread withEINTR. Code that doesn't retry, like an addon orbun:ffi, saw a failedread(). It also madespawn.test.tsfail in about half of the ASAN builds of this branch.Intentional differences from
tscnoEmit,declarationandincrementaldon't change anything.bun checkhas no--watch.bun --watch --check <file>checks before every restart.pluginsincompilerOptions) aren't loaded.listFiles,listFilesOnlyandtraceResolutionwork. Other options that only print things, likeexplainFiles, are ignored.npm i --save-devsaybun add -d.lib.*.d.tsfiles are built in. A path in one of them is printed asbundled:///libs/lib.dom.d.ts.Unknown compiler option 'strct'. Did you mean 'strict'?package.jsonisn't installed, a note names thepackage.jsonand says how to runbun installfor it.tsc, a note says how many files weren't checked:Stopped before type checking 2 files. Fix the errors above to see the rest.export =in a module that has other exports) is also reported when the other export is in adeclare moduleblock in another file.tsc6.0.2 reports it too.tsc7.0.2 only does when both are in one file.acc = apply(run, ["x", acc])in a loop, where the parameter is a tuple:tsc7.0.2 reports TS2345 because the array literal loses its tuple type.tsc6.0.2 doesn't, andbun checkdoesn't.tsc.You can see it with 2 files:
With
allowJs,checkJsandstrict:ac--singleThreadedor--checkers 1a_user.jsrenamed tozz_user.jsbun check, either nameHow 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 checkagainst the realtscfrom 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
tsc7.0.2 and withbun check, once for everytsconfig.jsonin it. "Identical" means both report the same set of (file, line, column, error code).tsconfig.jsonfilestscbun checksrc/tsconfig.jsonThe 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
distfolders don't resolve. A project with no errors only shows thatbun checkraises 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,
tscreports 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 oftenbaseUrl, which TypeScript 7 removed, and checks no types at all.bun checkstops 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
tscnames the typestring | (object & { url?: string; })andbun checknames its alias.For vscode, next.js and elysia that's every
tsconfig.jsonin 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 withreferences(138 of them) are compared againsttsc -b, the rest againsttsc -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 -brepeats 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:
rootDir, or isn't listed in the project) change from run to run. We ran it 6 times per config.bun checkis allowed to report what any of the 6 runs reported, and has to report what all 6 did.-bbuild 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
.tssources and atsconfig.json, checked where they sit innode_modules:tscbun check<%= dasherize(name) %>@actions/github-script@arrows/array@arrows/composition@arrows/dispatch@arrows/error@arrows/multimethodatomically@aws-crypto/sha1-browser@aws-crypto/sha256-browser@aws-crypto/sha256-js@aws-crypto/util@azure/arm-appservice@azure/arm-resources@bcoe/v8-coveragebenny@braintree/sanitize-url@braintree/sanitize-urlcomment-parsercomment-parsercomment-parsercomment-parsercomment-parsercomment-parsercomment-parser@compodoc/ngd-core@compodoc/ngd-transformerconvexconvex-helperscsp_evaluatordevcertdexie-react-hookseditions@electric-sql/pglite-socket@electric-sql/pglite-socket@electric-sql/pglite-socket@electric-sql/pglite-tools@electric-sql/pglite-tools@embroider/reverse-exportsexample-typescriptexpo-assetexpo-assetexpo-assetexpo-constantsexpo-constantsexpo-constantsexpo-file-systemexpo-file-systemexpo-file-systemexpo-fontexpo-fontexpo-fontexpo-hapticsexpo-imageexpo-keep-awakeexpo-keep-awakeexpo-keep-awakeexpo-linkingexpo-modules-autolinkingexpo-modules-autolinkingexpo-modules-autolinkingexpo-modules-coreexpo-modules-coreexpo-modules-coreexpo-splash-screenexpo-sqliteexpo-status-barexpo-status-barexpo-symbolsexpo-system-uiexpo-web-browser@expo/devcert@expo/devcert@expo/dom-webview@expo/log-boxfeed@glimmer/component@huggingface/jinjahuman-idhuman-idhuman-idhuman-idimport-in-the-middleimport-in-the-middleimport-path-rewritejunit-xmlkhroma@layerup/layerup-security@lokalise/node-apimerge-anythingmimetext@monaco-editor/reactmongodbmongodbmongodbmongodbmoo-colornext-mdx-remote-clientnpx-importoblivious-setonigasmopenapi3-tsopencontrolpath-data-parserpickleparserpinopinopinopinopiscinapiscinapkg-pr-newpkg-pr-newpkg-pr-newpkg-pr-newpkg-pr-newpkg-pr-new@pnpm/config.env-replace@pnpm/network.ca-fileprotractorreact-static-example-typescript@redocly/openapi-coreresolve-package-pathresolve-package-pathresolve-package-pathrxjsrxjsrxjssignal-polyfill@stablelib/base64@statelyai/inspect@streamparser/json@supabase/ssrtemplatetunnel-ratunfurl.jsuri-js@vercel/agent-eval-playground@verdaccio/core@verdaccio/logger-prettify@verdaccio/url@verdaccio/utilsvite-plugin-externalize-depsvscode-tas-client@wdio/xvfbwebpodwithworkbox-coreworkbox-core@workflow/worldyaml-ast-parserWe developed against most of the repos in the first table, so try it on your own project:
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.
tscbun checkstrictoffskipLibCheckoffcheckJsdeclarationisolatedModuleswithverbatimModuleSyntaxisolatedDeclarationserasableSyntaxOnlywith legacy decoratorsnodenext"types": []"lib": ["es5"]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 checkhas to produce the same files, byte for byte..errors.txt.types.symbols.js.trace.jsontraceResolutionNot every test has every kind of baseline. The
.errors.txtbaselines contain 966 different error codes.A
.jsbaseline also has the JavaScript thattscemits. That part isn't compared, because Bun has its own transpiler. The same goes for the.js.mapand.sourcemap.txtbaselines.bun checkdoesn'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 bysync.tsfrom a typescript-go tag). All 5 kinds run in CI:bun bd test test/cli/check/conformanceGenerated programs
TypeScript's tests only have a few forms of some things. Take this:
tscreports TS7022 oncur. Its type needs the type ofs, which needs what the loop assigns at the bottom, which needscur. 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
tscandbun checkon it, and compares. There's no expected output stored anywhere.tscis the oracle.These are in
test/cli/check/differential.test.ts, and all of them pass:string & {}, what they're indexed by, how a name is written in a destructuring or an object literaltscprintstscprintstscprints.d.tsthatskipLibCheckhides: 13 forms of base type, 9 kinds of declaration, 36 usestscprintstscprintsinfertscprintstscprintsexport =: what it exports, whatdeclare moduleadds to it, how it's imported, 3 messagestscprintstscprintstscprintstscprintsthis: 9 types, 28 usestscprintstscprintstsc -bprints, in orderIt also generates small projects, for file names that differ only in case, like
import "./Button"forbutton.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 withforceConsistentCasingInFileNameson, off and unset.files), in which spellings, in which order, from wheretscprintsButton.tsandbutton.tstscprintstsc -bprintstsconfig.jsonwith a value that isn't JSON, like"strict": tru: 28 kinds of value in 30 placestscprintstsconfig.jsonwhose root is a list, like[{ "compilerOptions": {} }]tscprintsreferencesand 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 missingtsc -bprints, in orderimport()andrequire()withimportorrequiresomewhere in their text, which changes whattscsays about why a file is in the programtscprintsThe index signature and overload programs end with a line that has a type error, and
tschas to report it. After a syntax error neither of them checks anything, and then they'd agree about everything. CI runs 70 of the 840tsconfig.jsonfiles, 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.jsoninstalls next to 6 astypescript7. You can also point it at anothertsc:TSC=/path/to/typescript-7/tsc bun bd test test/cli/check/differential.test.tsThese run locally against
tscand aren't in the repo yet:tscsuper, references to itself, 2 members with one nametsccreates lazilyThe 1 in module augmentation is the wording of a message. In 28 of the messages that are cut off,
tscdoesn'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,tscreports an error andbun checkreports 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.
tsccrashes with a stack overflow on 23 more of those programs, which aren't counted.bun checkreports an error in all 23.Is it overfit to the tests?
esModuleInterop,noUncheckedIndexedAccess,definePropertyand so on).internal/checkerare named in comments, so you can read the two side by side.test/cli/check/check.test.ts, with the output oftscas 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
tscagainst its own regressions, andtscnever 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.tstodifferential-cases-4.test.tsruntsc7.0.2 andbun checkon 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 namedc:.tscreportstscdoesn't reportThe 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/effectfrom Effect (496 files, and about as hard on a type checker as TypeScript gets), breaks 4 files at a time, runstscandbun check, and compares every error with its whole message. There are 32 ways to break a file: swap 2 arguments, drop a type argument, turnneverintounknown, delete an overload, reverse a conditional type, removereadonly, and so on.tscbun checkbun checkModule resolution
With
traceResolution,tsclogs every step of resolving every import: each file it looks for, eachpackage.jsonit reads, each condition inexportsit tries.bun checkprints 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.jsonsays "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.jsonfiles 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
ifstatements in afinallyblock, 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.tsc7.0.2 takes 53.Everything else
Adding a type checker shouldn't make
bun runorbun buildslower when you aren't type checking. Parsing 7,012 TypeScript files (37 MB) takes 1.003x the instructions it does onmain, andtypescript.js(9 MB) takes 0.995x.Performance
tsc7.0.2 with default settings againstbun checkon 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:
tsc7.0.2bun checksrcpackages/nextscriptspackages/reactCPU time:
tsc7.0.2bun checksrcpackages/nextscriptspackages/reactPeak memory:
tsc7.0.2bun checksrcpackages/nextscriptspackages/reactMeasured 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
tsc6.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, thenbun check --skipLibCheck false, which also checks every declaration file in@types/bun,@types/nodeand React against the built-inlib.*.d.tsfiles:bun init -ybun init --reactbun init --react=tailwindbun init --react=shadcnProjects that have an older
typescriptinstalled.bun checkreports the same errors as it does with the files of the TypeScript 7.0.2 package:typescriptA test compares all 108 built-in files with the
typescriptpackage, byte for byte.Also compared with
tsc7.0.2, with the same output: 150 valid, outdated, misspelled, empty and wrongly typed values intsconfig.json. Windows line endings, a byte order mark, UTF-16 and emoji in source files. Paths with spaces, Cyrillic, Japanese and accents. Atsconfig.jsonthat extends 1 package, 2 packages or a missing one. Both kinds of decorators. The config files thatcreate vitewrites. A workspace whose packages import each other's sources.bun check | head -1with 24,000 errors exits normally. Ctrl-C in a terminal ends it in 35 ms with exit code 130.What hasn't been tested
tscon real projects only ran on macOS arm64. CI builds this for Windows x64 and arm64, macOS, Linux glibc and musl, Android and FreeBSD, and runstest/cli/checkwherever it runs Bun's tests.unsafecode doesn't run under Miri.Known problems
Where it differs from
tsc7.0.2:bun checkgives 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'spackages-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.The types returned by '[bufferTime](...)[groupBy]' are incompatiblewhere 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.strictoff: 7 of typescript-go's 74 errors are missing, and there are 5 that it doesn't report.package.jsonare accepted. typescript-go rejects them.interface Foo extends Partial<Foo>, or any other mapped type ofFoo, is an error in both (TS2310). Whattscsays after it depends on what's asked for first,FooorPartial<Foo>. Within a filebun checksays the same. Across files it can differ, becausetscgoes by the order of the whole program. WithskipLibCheckoff, an interface of the library that's extended like that can have members inbun checkthat it doesn't have intsc.bun checksays it couldn't finish the file and exits with code 1.if (t === null || t === undefined) return;on a generict: T,for (const [k, v] of Object.entries(t)) v.foogets TS18046,'v' is of type 'unknown', wheretscaccepts it. 38 are in unusual code or unusual command lines. For example,function f({ a = 1, b = g(a) }) {}gets a false TS7022, and inenum E { A = 1, B = next(E.A) }withfunction next(e: E)a false TS2502. In a directory with ajsconfig.jsonand notsconfig.json,bun checkchecks that project wheretscgoes on to the parent'stsconfig.json. The other 215 are next to another error, without the default library, or in code nobody writes on purpose.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.