Repository navigation
bun lint, bun fmt: the first run, oxlint's order, Prettier's Tailwind plugin, native JavaScript plugins, a faster Bun.Glob - #45043
Conversation
Work in progress.
Work in progress.
Work in progress.
Work in progress.
|
Updated 10:52 PM PT - Oct 12th, 2026
@Jarred-Sumner, your commit dcbdac3 is building: |
bun lint, bun format: the first run, a page per rule, editorsbun lint, bun format: the first run, a page per rule
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (7):
- 🔴
src/glob/matcher.rs:721—A glob that ends with a backslash inside an unclosed [ now crashes bun lint and bun format with a Rust panic, where the… - 🔴
src/lint/driver/doctor.rs:542—Users of bun lint --doctor are told they can remove build packages that merely contain "eslint" in their name, such as… - 🔴
src/lint/driver/fmt/editorconfig.rs:128—Projects whose glob patterns use a brace sequence such as {1..3} or {a..c} silently stop matching those files after mer… - 🔴
src/lint/plugins/import_minimatch.rs:49—ESLint users with eslint-plugin-import rules get different reports after merging: patterns now match names that start w… - 🔴
src/md/ansi_renderer.rs:1057—CI's source lint fails on this line, so the PR cannot merge green: since.contains(&b'\n') is the byte-literal <[u8]>::c… - Also unresolved: 2 minor or pre-existing.
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (1):
- Unresolved: 1 minor or pre-existing.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🔴
test/internal/source-lints/inner-allows.test.ts:1— Maintainers lose two ratcheted source-lint safety nets after merging: the latest commit deletes test/internal/source-lints/inner-allows.test.ts and shared-helpers.test.ts with their inventory files, so a new crate-wide#![allow(..)]or a re-implemented text/path helper in a non-shared crate no longer fails CI. Neither the PR description nor the commit message states a reason or a replacement, and the diff adds no#![allow(that would have needed one. Fix: restore the two tests and their inventories (updating the inventories with--updateif the PR moved or removed entries), or state in the PR why they go and what now enforces the same invariants. [also at: test/internal/source-lints/shared-helpers.test.ts:1 - Maintainers lose two CI safety nets with no stated reason: the latest push deletestest/internal/source-lints/shared-helpers.test.tsandtest/internal/source-lints/inner-allows.test.tswith their inventory JSON files.; src/lint/CLAUDE.md:172 - Maintainers lose two CI safety nets with no stated reason: the latest push deletes test/internal/source-lints/shared-helpers.test.ts and inner-allows.test.ts together with their inventory files, so a new#![allow(..)]in a crate or a private copy of a text/path helper no longer fails CI as it did on the base branch.]Why this was flagged
Commit eafd737 ("lint, format: 153 files") deletes test/internal/source-lints/inner-allows.test.ts, inner-allows.inventory.json, shared-helpers.test.ts and shared-helpers.inventory.json. On the base branch inner-allows.test.ts asserts that no new
#![allow(..)]/#![expect(..)]appears in any tracked .rs file beyond the ratcheted inventory, and shared-helpers.test.ts asserts that no free function with a shared-helper name is re-implemented outside src/bun_core, src/paths, src/collections etc. A repo-wide grep forinner-allowsandshared-helpersat HEAD finds nothing, so nothing references or replaces them. A grep of the diff for added#![allow(or#![expect(finds no hits, so the deletion is not needed to make this PR pass. After merging, CI no longer catches either regression class; the PR description lists no such removal and the review instructions require a stated reason or replacement for every deleted safety net.Verification: normal — triggered the first time a future PR adds a crate-/module-wide
#![allow(..)]or a re-implemented text/path helper in a non-shared crate: CI no longer catches it.git diff c39c718b..HEAD --stat -- test/internal/source-lints/shows four pure deletions, attributed solely to eafd737, whose commit body is empty. A repo-wide grep forinner-allows|shared-helpersreturns nothing in HEAD.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (2):
- 🔴
src/lint/driver/native.rs:237—Users without a config who turn on a typed pair rule by its typescript-eslint name, such as @ typescript-eslint/require… - Also unresolved: 1 minor or pre-existing.
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
The last 4 reviews of this pull request each found new blocking issues. Where they share a root cause, one fix may close them together.
Still open from earlier reviews (1):
- 🔴
src/lint/driver/configs.rs:755—Users who add [[lint.overrides]] to bunfig.toml and run bun lint from a subdirectory of an ESLint flat-config project l…
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
### What does this PR do? Bun's own CI lints with `bun lint` and formats with `bun fmt`. oxlint and Prettier are gone from GitHub Actions. It also gives the linter its own tab in the docs, and records what `bun lint` reports in the docs' examples, for the website. #### CI | Workflow | Before | After | |---|---|---| | `lint.yml` | `oxlint --config=oxlint.json --format=github src/js` | `bun lint --format=github` | | `format.yml` | `prettier --plugin=prettier-plugin-organize-imports --write <paths>` | `bun fmt --plugin=prettier-plugin-organize-imports` | | `packages-ci.yml` | `bunx oxlint@0.15 --deny-warnings`, `bunx prettier --check .` | `bun lint --deny-warnings`, `bun fmt --check .` | - **`lint.yml` and `format.yml` install `canary`** instead of 1.4.2, because neither command is in a release yet. `packages-ci.yml` already did. There's a comment to pin them to 1.5.0 once it's out. **These two checks can't pass until canary has #45043.** - **What gets linted and formatted moves from arguments into `bunfig.toml`**, so `bun lint` and `bun fmt` do the right thing with no arguments. `oxlint.json`, `.prettierrc` and `.prettierignore` are unchanged, and Bun reads all three. - **The `fmt`, `lint`, `lint:fix` and `prettier` scripts are removed, not pointed at the new commands.** A project's own script wins over the command, and on a released Bun, where `bun fmt` doesn't exist, a `fmt` script that runs `bun fmt` calls itself: 616 nested processes in 5 seconds on 1.4.3. Without the scripts, an old Bun says `Script not found "fmt"`. - `oxlint` and `prettier-plugin-organize-imports` are removed from `devDependencies` (46 lines of `bun.lock`). The plugin is built into `bun fmt`. - **`prettier` stays, for editors**: `.vscode/settings.json` points format-on-save at `./node_modules/prettier`. It goes from 3.6.2 to 3.9.9, the version `bun fmt` matches, so that saving a file and CI agree. - The plugin stays a flag in CI and isn't in `.prettierrc`, as before. On save it would remove an import that the next edit is about to use. #### What the switch flagged - **75 files reformatted**, in a commit of their own. All are differences between Prettier 3.6.2 and 3.9.9: `for (;;)` without a space before `)`, unions that fit on one line, `{/* comment */}`, table widths. - **5 lint errors in `src/js`** that oxlint 1.87 reports and 1.70 didn't: four unused `_` parameters, renamed or removed, and the fuzzer harness's `eval`, which gets a disable comment. - **`packages/bun-plugin-svelte`** has no lint config, so it now gets Bun's default rules. `--fix` turned three `var`s and one `let` into `let` or `const`. `no-explicit-any` is off for that package, because its tests pass values of the wrong type on purpose. #### Docs The linter was a group inside the Runtime tab. It's now a **Linter** tab between Test Runner and Guides, which opens on the guide: | Group | Page | URL | |---|---|---| | Getting Started | Linter | `/docs/lint` (was `/docs/runtime/lint`) | | Rules | Lint rules | `/docs/lint/rules` | | | ESLint plugins | `/docs/lint/plugins` | | Formatter | Formatter | `/docs/format` (was `/docs/runtime/format`) | | Migrate | the four migration guides | unchanged | Neither old URL has been in a release. The 25 references to them are updated, including the two in `--help` and the one in the SARIF output. The site redirects the old URLs. **`docs/lint/rules/reports.json`** is new: what `bun lint` reports in each example on the rule pages, with the exact span and message. 3,047 reports in 4,173 examples, one line per page. The website uses it to underline the problems in the examples, like an editor (oven-sh/site#291). - `bun src/codegen/lint-rule-docs.ts --write` generates it, together with the rest of the generated docs. - The code that sets up each example as a small project and lints it moved from `rule-docs.test.ts` into that module, so the generator and the test run the same thing. The test's checks are unchanged, and it now also fails if `reports.json` is stale, naming the page and the command. - A few messages name a file by its whole path. That becomes `/project/file.js`, so the file is the same on every machine. - It isn't embedded in the binary. ### How did you verify your code works? With a build of `main` at #45043: | | | |---|---| | files `bun fmt` visits with no arguments, against the Prettier script's arguments (`--list-files`) | the same 3,350 | | the 75 reformatted files, against real Prettier 3.9.9 with the real plugin | 75 of 75 byte-identical | | …against real Prettier 3.6.2 | it leaves all 75 as they were, so they are version differences | | the 65 of them that are JS or TS, transpiled before and after | 65 of 65 the same bytes | | a second `bun fmt` | changes 0 files, so autofix can't ping-pong | | real Prettier 3.9.9 **without** the plugin (what an editor runs) on all 3,350 files | all formatted | | `bun lint` with no arguments, against `bun lint --config=oxlint.json src/js` | identical output | | the 5 lint errors, against real oxlint 1.87 | the same 5 | | a violation of the repo's own JS plugin rule, planted in `src/js` | reported, with real oxlint's message, position and order | | `debugger;` planted in `bench/` and in `src/` outside `src/js` | not reported | | `bun install --frozen-lockfile` | accepts the lockfile | | Bun 1.4.3 with the new `bunfig.toml` | runs. `bun fmt` says `Script not found "fmt"` | All four changed CI steps exit 0 on this branch. `bun lint` takes 140 ms for 202 files, and `bun fmt` 110 ms for 3,350. `rule-docs.test.ts` passes (123 tests), and fails with `eslint/eqeqeq: reports.json is out of date` when one message in the file is changed by hand. A build of the first two commits passes the lint, format and check suites, and `fs.glob`, `fs`, `undici`, `node:module`, `require.cache`, `node:net` and the `bun-types` tests, which cover the built-in modules that were edited. Known: `bunfig.toml` and `.prettierignore` are read from the current directory only, so `bun fmt` run from inside `test/` doesn't see the scope and would format the fixtures too. `prettier --write .` in `test/` has always done the same.
… negation again (#46240) ### Problem - Since #45043, `bun pm pack` and `bun publish` read an ignore line or a `files` entry that begins with `!(` as a group. bun 1.4.3, npm and git read a negation. With the `.npmignore` lines `*.txt` and `!(a).txt`, the tarball loses `(a).txt`. - The cause is `Pattern::from_utf8` (`src/runtime/cli/pack_command.rs:2854`). It removes the leading `!`s and puts one `!` back. In front of a `(`, the matcher sees `!(`. ### Fix - `Pattern::from_utf8` writes `!\(` when a negated pattern begins with `(`. The matcher then negates a plain `(`. - Correct because the other readers of that text, `as_positive` and `negation_reaches_below`, skip the `!` and still get the name. - Verified: `test/cli/install/bun-pack.test.ts`. 13 of the 16 new tests fail on main, and all pass here. The expected lists are from npm 11.16.0. - Self-reviewed: 9 concerns raised, 8 addressed. Not done: a tracking issue. This PR is the record. ### Background - In an ignore file, a leading `!` takes back files that an earlier line excluded. In `files`, it excludes. - A group is extglob syntax: `!(a|b)` matches any name except `a` and `b`. - Considered a read of `PatternFlags::NEGATED` in the two match loops. It rewrites both, and a `/!name` line then needs an escape too. ### Downsides - Two inputs differ from npm again, as in 1.4.3: `!!(a).txt` and `files: ["./!(a).txt"]`. On main they agree with npm by accident. - Size: `Pattern::from_utf8` grows from 530 to 536 bytes. Release `.text` stays at 81,695,461 bytes. Allocations per pattern stay at 2. - `--verbose` prints such a `files` exclusion as `\(a).txt`. <details><summary>Notes</summary> **How it was found.** By a read of the code, during work on how `Bun.Archive` reads a leading `!(`. There is no user report. No release has the regression: `LATEST` is 1.4.3 and no tag contains #45043. **Four tools.** Files packed besides `package.json`. The fixture has `(a).txt`, `a.txt`, `b.txt` and `index.js`. Row 2 has `index.js` and `lib/a.js`. Row 4 adds `sub/(a).txt` and `sub/b.txt`. | Input | npm 11.16.0 | bun 1.4.3 | main | this PR | |---|---|---|---|---| | `files: ["*.txt","!(a).txt"]` | `a.txt b.txt` | `a.txt b.txt` | `(a).txt a.txt b.txt` | `a.txt b.txt` | | `.npmignore`: `!(lib)` | `index.js lib/a.js` | `index.js lib/a.js` | nothing | `index.js lib/a.js` | | `.npmignore`: `*.txt`, `!(a).txt` | `(a).txt index.js` | `(a).txt index.js` | `index.js` | `(a).txt index.js` | | `files: ["*.txt","sub","!(a).txt"]` | `a.txt b.txt sub/b.txt` | `a.txt b.txt sub/b.txt` | `(a).txt a.txt b.txt sub/b.txt` | `a.txt b.txt sub/b.txt` | | `files: ["*.txt","./!(a).txt"]` | `(a).txt a.txt b.txt` | `a.txt b.txt` | `(a).txt a.txt b.txt` | `a.txt b.txt` | | `files: ["*.txt","!!(a).txt"]` | `(a).txt a.txt b.txt` | `a.txt b.txt` | `(a).txt a.txt b.txt` | `a.txt b.txt` | | `files: ["*.txt","./!a.txt"]` | `(a).txt a.txt b.txt` | `(a).txt b.txt` | `(a).txt b.txt` | `(a).txt b.txt` | Rows 1 to 4 are the regression. Rows 5 and 6 go back to the 1.4.3 answer, which is not npm's. Row 7 is the same on every build. No test pins rows 5 to 7. **A wider probe.** 22 fixtures: 8 ignore files as `.npmignore` and as `.gitignore`, and 6 `files` lists. Rows that differ from npm 11.16.0: 13 on main, 2 on this PR, 6 on bun 1.4.3. The 2 are the `!!(a).txt` lines. The 4 rows where this PR differs from 1.4.3 are `*` with `!(group)/**` and `(group)` with `!(group)/page.js`. There this PR gives npm's list, as main already does for a name without `(`. **What this changes in #45043.** Its table "Patterns that change meaning" says that a name with `!(` in `files` is a group. That stays true inside an entry (`src/!(test).js`, `/!(x)`). It is no longer true for an entry that begins with `!(`, where the `!` is the negation of npm and git. **What this PR leaves alone.** - `Pattern::of_bunfig` (`src/glob/pattern.rs:225`) and `bunfigGlob` (`src/lint/js_plugin/worker/eslint.js:79`) glue a `!` in front of a rewritten pattern in the same way. In `[[fmt.overrides]]`, `files = ["!./(a).js"]` is read as the group `!(a).js`. The two must change together, in a fix of their own. - The rule "Any number of leading `!` counts as one" (`pack_command.rs:2836`, from #44968). npm toggles. - `published_files` takes the `!` of a `files` entry after it drops a leading `./` (row 7). - `Bun.Archive`. It reads `!(a).txt` as an exclusion of `(a).txt` on 1.4.3 and on main. If it must read a group, as `Bun.Glob` does, is a question for a maintainer. **Measurements.** - Tests: debug builds (ASAN) of main `ea6a2c7b7c` and of this branch. The 3 new tests that pass on main are the controls with `!\(a).txt` and `![(]a).txt`. - The new tests also pass on bun 1.4.3, because the regression is not in a release. They fail on a build of main. - Allocations: gdb counts the entries of `__rust_alloc`, `__rust_alloc_zeroed` and `__rust_realloc` between entry and return of `Pattern::from_utf8`. 2 for each pattern on main and on this PR. - Size: `llvm-size -A` and `nm -S` on `bun-profile` from `bun run build:release`, for main and for this PR. - The whole file on this branch: 354 pass, 3 skip. `peak memory does not grow with the size of the tarball` timed out once in the concurrent debug run and passes alone. </details> <!-- robobun:evidence:begin --> --- **no test proof** · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/cli/install/bun-pack.test.ts <!-- robobun:evidence:end -->
What does this PR do?
Follow-up to #44805. That PR made
bun lintandbun format(nowbun fmt) match ESLint, oxlint, Prettier and oxfmt for people who migrate. This one is for someone who has none of those and typesbun lintfor the first time.With an ESLint, oxlint, Prettier or oxfmt config, what changes moves toward the tool itself: findings come in oxlint's order, files that oxlint accepts are no longer refused, and a Prettier config that names
prettier-plugin-tailwindcssis formatted and not refused. The exceptions are a few outputs of Prettier and oxfmt that change what a file means, which Bun no longer copies. Each is listed below.It also moves the host for JavaScript plugins (third-party ESLint rules) from JavaScript to native code, and runs it on the thread that lints the file. See "JavaScript plugins" below.
It fixes bugs that #44805 put on
main, two of which rewrite files they shouldn't. See "Bugs in #44805".bun formatis nowbun fmtThe formatter's subcommand is
bun fmt, likecargo fmt,go fmt,deno fmtandzig fmt. Its section inbunfig.tomlis[fmt]([fmt.sortImports],[[fmt.overrides]]). Neither name has been in a release."format"script. A script with the command's name wins over the command, sobun formatran Prettier until the script was changed.bun fmtis the formatter from the first run.bun formatis no longer a command. It runs the project'sformatscript, as it did before. Without one it saysScript not found "format"andnote: The formatter is bun fmt.[format]section inbunfig.tomlis refused (Unknown section [format],Did you mean [fmt]?), not ignored.fmt: afmtscript (withprefmtandpostfmt),fmt.ts,fmt/index.js,node_modules/.bin/fmt. Inside afmtscript,bun fmtis the formatter.--formatflag ofbun lintandbun fmt,format = ".."under[lint], the rulebun/format, and the docs URLs.Prettier plugins that are built in
bun fmtdoesn't load Prettier plugins, and it refused every file of a project whose.prettierrcnamed one it didn't know. That includedprettier-plugin-tailwindcss, the most used plugin there is (10 M downloads a week), although Bun has had a native port of it since #44805. It could only be turned on frombunfig.toml.prettier-plugin-tailwindcssin a Prettier config now just works. Leave it inplugins.file:URL intonode_modules, aURL, the imported module object, inoverrides, with--plugin, inpackage.json, in a shared config.plugins: []in an override turns it off.tailwindConfig,tailwindStylesheet,tailwindEntryPoint,tailwindFunctions,tailwindAttributes,tailwindPreserveWhitespace,tailwindPreserveDuplicates,tailwindPackageName), with the plugin's defaults, its rule for relative paths, and its error for a value of the wrong type./regex/names), which differ from oxfmt's.tailwindcssisn't installed, or is version 4 with a JavaScripttailwindConfig, or version 3 with a style sheet, the real plugin uses a Tailwind it bundles. Bun then asks the installed plugin's documentedsorterentry for the order of the classes. Nothing is ever downloaded.<DIV CLASS="…">and LWC files are sorted too.@prettier/plugin-oxcis accepted. It only swaps the parser: real Prettier prints 3,939 files byte for byte the same with and without it. Its order relative to the Tailwind plugin inpluginsmatters in Prettier, and does here.prettier-plugin-packagejson: files namedpackage.jsongo to the installed Prettier, like.sveltefiles with the Svelte plugin, and everything else is formatted natively. Before, every file of the project was refused. Bun'ssortPackageJsonisn't used for it, because it's oxfmt's order and not the plugin's: 28 of 50 made-up files come out different.pluginsas a whole..prettierrcprettier-plugin-tailwindcss@trivago/prettier-plugin-sort-imports,@ianvs/…,prettier-plugin-organize-imports@prettier/plugin-oxcprettier-plugin-packagejsonprettier-plugin-svelte,-astro,@prettier/plugin-xml,-sh,-sql,-toml,-java, …-jsdoc,-sort-json,-css-order, …)prettier-plugin-jsdocstays refused on purpose. Bun'sjsdocoption follows oxfmt's, which is a rewrite of the plugin: on 251 real files with 3,222 JSDoc comments, 26 files differ from the plugin's output.Compared with Prettier 3.9.9, the plugin 0.8.1, and Tailwind 4.3.3 and 3.4.19: 13,654 of 13,952 JavaScript and TypeScript files are byte-equal (57 contexts, 32 expressions, 4 sets of options), 2,148 of 2,176 files in HTML, Vue, Angular, LWC, Handlebars, CSS, SCSS, Less, Markdown and MDX, and all 15 Tailwind 3 projects (custom themes,
prefix,important,separator,@apply). About half of the differences are the one below. The rest: a directive inside a function insidecn(…)in TypeScript, and Vue or Angular bindings that don't parse.One deliberate difference. The real plugin trims a class string that touches other text, which joins two classes:
className={`header${open ? " active" : ""}`}becomes`header${open ? "active" : ""}`, so the element getsheaderactive. It happens in.ts,.tsx,.jsxand Vue. Bun keeps that blank.Formatting that changed what a file means
#44805 re-parsed every file after formatting it and compared the trees. That cost up to 21% of a run, and on 10,100 real files it refused none. It's off by default now, and
--debug-checkturns it on, like Prettier's flag of that name.The only inputs it ever caught were ones where Prettier's or oxfmt's own output means something else and Bun printed the same bytes. So the printers are fixed instead. Each row is in
test/cli/format, with the tool's output next to Bun's:font-family: Font\ AwesomeFont\Awesome(\Ais a hex escape)b: d\ ;,@extend .a\ ;,f(a\ , b)x |bin a selectorx|b: a descendant becomes a namespacea ? b : c;then(d ? e : f) ? g : h;with--no-semi --experimental-ternaries;before the(: one call;(a < b > cin TypeScript, broken after the>a<b>; c<!DOCTYPE html>,<textarea>,<pre>, a<script>with// ain Handlebars{{a.[]}},{{[a/b]}},{{~! b ~}}in Handlebars>+with--prose-wrap=never,? |+as a key,--- ---, a key over two lines in a flow map{{concat "p-4 flex " x}}with Tailwind sortingx--debug-checkfor Handlebars compares the two parsed trees (it only read the printer's own flag), and with Tailwind sorting on it compares the text that would be written.bun fmtno longer builds the data for the check for every JavaScript and TypeScript file when the flag isn't given.What was wrong
Found by using the merged build on a fresh project, and from the first bug reports:
bunfig.toml, 572 of the built-in rules could not be turned on (Could not find plugin "unicorn" in configuration.). Any@typescript-eslint/*rule set towarnorerrorkilled the whole run if the project had a single.jsfile.[lint.rules]or--rulewas ignored silently.bun lint --initwrote an.oxlintrc.jsonwith a$schemapointing intonode_modules/oxlint, didn't say which file it wrote, and switched the project to oxlint's rules and output..tsxfile with a conditional hook, a list withoutkeyand a stale effect dependency got no report, even though the rules are built in.prefer-const,no-explicit-anyin a.d.ts, and dead stores.no-useless-assignmentwas reported as a bug because its message doesn't say why.stylish: absolute paths, no code.bunfig.toml.--helpwas 84 lines. Messages and docs were hard to read.--staged, nothing to tell someone migrating what runs natively.bun initproject failedbun lintandbun fmt --check.With no config file
[lint.rules],--ruleand comments, under either spelling (@typescript-eslint/xortypescript/x). No plugins to list[lint.settings][[lint.overrides]][lint.rules]gets a code frame ofbunfig.tomland a plain messagerules-of-hooks,jsx-keyandexhaustive-depsare on ifreactis inpackage.json.d.tsfiles only get the rules that are errorsprettyis the default output, with a summary lineIt is overwritten on line 5 and line 12 before it is read.,The return on line 4 can end the render before it is called.,Did you mean ===?bun fmt --checkuses Bun's wording, not Prettier's[fmt]:sortImports,sortTailwindcss,sortPackageJson,jsdoc,[[fmt.overrides]]sortImportsalso sorts names in{ }and merges duplicate imports["warn", {..}]stays hugged, and a one-line table never gets a line break (TOML 1.0 parsers reject those)bun fmtskips*.min.js,*.min.cssand lock files. A file named on the command line is still formatted_unusednames are ignored byno-unused-vars[lint.rules].typeAware = trueadds the recommended set--deny-warnings,--silentand-A/-W/-Dwork on Bun's defaults. They used to switch the run to oxlint's rules, so--deny-warningsmade a failing lint passuseThing.ts)Default rules
Every rule that's on by default was tried on ordinary code: seven made-up projects (an API server, a React app, a CLI, a library, a monorepo, a folder of generated and vendored files, a collection of idioms) and the four
bun inittemplates. What got reported on code that works was turned down, narrowed or fixed. For each change, the bug the rule exists for was tried too and is still reported. All of this only applies with no ESLint or oxlint config.@typescript-eslint/no-require-importsrequire()andimportin one file.tailwind.config.tsand React Native's<Image source={require(..)}>have no alternative@typescript-eslint/ban-ts-comment// @ts-ignoreis written on purposeno-cond-assignwhile (m = re.exec(s))no-prototype-builtinsobj.hasOwnProperty(k)worksno-ex-assignerr = err instanceof Error ? err : new Error(String(err))no-control-regex@typescript-eslint/no-wrapper-object-types,no-unsafe-function-typetarget: Object,cb: Function@typescript-eslint/no-unsafe-declaration-merginginterface Bus+class Bus extends EventEmitter@typescript-eslint/no-non-null-asserted-optional-chainmap.get("a")?.v!@typescript-eslint/no-duplicate-enum-valuesenum Level { Off = 0, None = 0 }bun:test/no-exportexport const fixturein a test fileno-unsafe-assignment,-call,-member-access,-return,-argument(--type-aware)no-loss-of-precision3.14159265358979323846isn'tno-irregular-whitespaceno-unused-expressionscb && cb()@typescript-eslint/no-misused-promises<form onSubmit={asyncFn}>@typescript-eslint/no-namespacedeclare globalno-empty-patternasync ({}, use) =>{}no-fallthroughprocess.exit()process.exit()andprocess.abort()end a case. With types, so does a call that returnsneverfall-through,fallthroughandno breakcomments count tooreact-hooks/rules-of-hooksuseand Storybook'srenderuseis a parameter there, and Storybook rendersrenderas a componentreact/jsx-keysteps[step], icon tables,actions={[..]}no-constant-binary-expression{false && <X />}true,false,0,1no-undeftypeofno-unused-varsReactandhreported in files with JSX/* eslint-env */react/jsx-keycheckArraysOutsideJSX,no-constant-binary-expressionallowLiteralToggle,no-loss-of-precisionignoreDecimals. Under an ESLint config they're rejected with ESLint's own error"no-unused-expressions" = "error"keepsallowShortCircuit.--rules -f jsonand the docs show them as the defaultsdescribe,it,expect,jest,vi,cyand friends are known in*.test.*,*.spec.*,*.e2e.*,*.cy.*, in set-up files likejest.setup.tsandsetupTests.ts, and in the project's__tests__,__mocks__,test,tests,spec,e2eandcypressfoldersbun init --reacthas 0 problems underbun lint --type-aware. It had 5 errorsOn the five code projects, every error that's left is a bug that was planted there. On the folder of generated and vendored files, 309 errors became 9.
--fix-suggestionsThe flag applies every suggestion with nobody looking, so with no config it now only applies the ones that can't change code that works. The rest need
--fix-dangerously.-f jsonstill lists them all, and nothing changes under an ESLint or oxlint config.no-unused-varsconst sent = sendEmail(user);. Dropped the unusednextof an Express error handler, which Express recognizes byfn.length === 4no-unused-private-class-members#x = sideEffect();no-explicit-anyanybecameunknown: type errorsreact-hooks/exhaustive-deps[ms]became[cb, ms]: the effect runs at other timesrequire-awaitasync: callers getT, notPromise<T>await-thenableawait null;becamenull;no-array-deletedelete list[0]becamelist.splice(0, 1), which shifts every later itemban-ts-comment@ts-ignorebecame@ts-expect-error: a type error wherever the next line is fineno-empty-object-typeinterface Empty {}becametype Empty = objectno-non-null-asserted-optional-chain!no-case-declarations{ }: a later case that uses theletbreaksno-floating-promisesvoid save();: "Fixed 1 problem" with nothing fixedThe first two aren't offered at all when they'd delete code that runs. Unused imports still go, with their statement if nothing else is imported, as in ESLint and oxlint. A declaration or a disable comment that's removed takes its line with it, so
bun fmt --checkpasses afterwards.Bugs in #44805
These are on
maintoday.echo "# hi" | bun fmt --parser markdownignored stdin and rewrote every file in the directory as markdown. Without paths,--parsernow formats stdin like Prettier and never touches a file. With real Prettier 3.9.9 as the judge: 252 of 288 parser cases, 108 of 114 flag and config cases and 26 of 31 plugin cases are the same in stdout, stderr, exit code and touched files. None of the rest is about stdin (positions of some syntax errors,oxcparsers that Bun has built in). Onmain, 280 of the 288 differ--parser xwith a directory is refused with no config or an oxfmt config, with a glob to use instead. Under a Prettier config it reads every file with that parser, like Prettier (the same 39 of 45 files in a mixed project)bun --help formatandbun -h formatformatted the directory. They print helpbun --check format a.jsrewrote the file and exited 0. Flags oflintandformatthat stand before the command were dropped. They count now, as forbun --bail testbun fmtno longer re-parses what it has formatted. Addbun lintandbun format#44805 compared the syntax tree of every formatted file with the original and refused to write on a difference. On 10,100 real files that change it refused none, the only refusals were inputs where Prettier itself loses something, and it cost up to 21% of a run. It is--debug-checknow, as in Prettier.--verify,--no-verifyand theverifykey inbunfig.tomlare goneObject.create(null), an object with a throwingmessagegetter, afternode.loc = null) aborted the process. 345 combinations of where and what: no abort, and the exit code is the real tool's except where Bun doesn't run a custom parsereslint.config.mjswith a top-levelawaitthat never settles madebun lintspin forever. It's an error nowcreateandcreateOnceran throughcreateOnceunder an ESLint config. ESLint callscreate--type-aware --type-checkreported no type errors once animport/*rule was on (70 errors in real oxlint, 0 in Bun, exit 0). 22 of 28 scenarios differed from oxlint 1.87, now 0-A,-Wand-Ddidn't override rules fromextends,--fix-suggestionsdropped the safe fixes of JS plugins,globals: { x: "off" }hid a global of theenv,no-implied-evalhad the wrong severity,NaN == NaNwas reported once, and invalid values forsettings.react.versionandno-unused-varswere accepted. All now equal oxlint 1.87sourceType,parserOptions.ecmaFeaturesand strict mode per file. With 199 rules on 31,379 files, Bun reports 95.13% of what oxlint 1.87 reports, up from 90.44%, and what only Bun reports went from 1,107 to 173. No rule got worse in either direction. What's left is nearly all one thing: a script has no module scope in oxlintbun fmt --doctorsaid "You can remove: prettier" while files were skipped because of a Prettier pluginpackage.json,.prettierrcorprettier.config.jsanywhere in a project madebun fmtgive up on the whole run ("Cannot read the configuration file ...: EISDIR", exit 2). Prettier skips such folders, and so didbun lintbun -c formatandbun -l formatrewrote files and exited 0: short flags before the command were dropped.bun -c=other.toml lintis still Bun's own--configbun --config=other.toml lint: a mistake in[lint.rules]was shown with a code frame frombunfig.toml--stagedand--changeddropped files that were named through a symlinked pathbun lint --fixandbun fmtcould write a file twice when two paths lead to it (a link, or another letter case on Windows). A run writes each real file onceimport/no-cycle) was on too: Bun printed the cycle warnings and exited 0, where oxlint exits 1.cjsfile under an oxlint config, a plugin that calledmarkVariableAsUsed("first")silencedno-unused-varsfor the next variable insteadpackage.json,tsconfig.jsonor rule option nested tens of thousands of levels deep overflowed the stackLike oxlint, under an
.oxlintrc.jsonCompared with oxlint 1.87:
lint.test.tsmain, which printed them in another order.Scope::referencesis in the order in which typescript-eslint's scope manager makes them (compared on 20,000 random programs). That fixed two of Bun's own rules,no-unnecessary-parameter-property-assignmentandreact/hook-use-state, which differed from ESLint in 16 of 27 and 16 of 23 files.Variable, a view that is ESLint'sVariableone for one, for ported rules. Eleven rules use it, and three private copies are gone.awaitwas a name, and forgets every parser error since. About 50 kinds of error are accepted by oxlint that way, and now by Bun.--fix: of two fixes with the same range, the rule that oxlint runs first wins, and what is left is printed in oxlint's order.markVariableAsUsedfrom a plugin doesn't silence oxlint's ownno-unused-vars. It doesn't in oxlint either. Two tests that said otherwise had been recorded from Bun.settings,globalsorenvis there once, at its first place, with its last value. A YAML.eslintrcwith one is refused, as in ESLint 8.57.1.TS(nnnn)code, labels and help: redeclarations, duplicate and undefined exports, reserved words, assignment targets, TypeScript's grammar errors,awaitandyieldwhere they can't be, private names outside a classf(a b),x = ;,if (a {}) have oxlint's exact words, up from 4eslint-disablecomments under the default config: 821 differing files, now 0. With thejsdocorvueplugin on: 334, now 0#comments and a#!line are accepted, options for a rule that takes none are refusedProgramstart at the first token, and the scopes of oxc's source type: a script has onlyglobal, CommonJS hasglobaland a function scope withargumentscx.throw(node, "Error", message)lets a native rule fail the way a JavaScript rule does when it throwsbun lintunder{}on 9,384 real files runs 4,004 M instructions, against 4,006 M beforeDeliberately not copied from oxlint:
--fixwith 33 or more messagesawait; await (x); export {};and the like'' is not definedat 1:1), and it panics with a JavaScript pluginawaitis a name theredeclare function ();func-namesreports ittscrejects the codetypescript/prefer-function-typegrouped-accessor-pairsKnown and not yet matched: when an
overridesentry matches a file, oxlint runs its rules in another order. It rebuilds the rule list through anFxHashMapand collects it without a sort (Config::apply_overrides), so the rules run in the table's order, which also differs between x64 and arm64. Bun keeps rule-number order there. Only the order of a file's findings differs, never which are reported. On 60 open-source projects with every category on, 15,951 files have findings: 8,256 are in oxlint's exact order (7,870 before this PR's last rounds), and 1,542 of the 1,941 that have the same lines in another order are in projects withoverrides.Copied although it's worse for users, as on
main:import/no-duplicatesreports a duplicate only if the two specifiers are neighbors in oxlint's hash table. In a file with 56 duplicates it reports one. Andjest/no-identical-titleimitates an unstable sort above 20 calls with one title.The same output on every CPU
An arm64 CI lane found that one rule reported a finding on x64 and nothing on arm64. Rust's
hashbrownlooks at 16 slots at a time with SSE2 and 8 with NEON, so a table's iteration order differs between the two once it's crowded..oxlintrc.jsonhasextends, which setting of a rule wins followed the table. Also the names inexhaustive-deps' message, and the order of findings of four rules. All go through the one emulation or a sort now. It was compared with the real table on 60,000 random sequences: 0 differ, and with a width of 8 as a control 18,400 do.#![deny(clippy::iter_over_hash_type)]in the ten lint crates.Faster
CI's LTO builds,
mainat the merge base against this branch, user instructions, 13,600 real files:mainbun lint, oxlint config, every category on,-f unixbun lint,.oxlintrc.jsonwith{}bun lint, ESLint config with 5 rulesbun lint, no configtest/js/node/test/paralleltest/bundlersrc/jstest/js/buntest/clibun check, 220 filesbun fmt --check, 4 foldersbun lintwith no config was 1.7% slower thanmain, up to 5.5% in a folder of small files. None of it was in a rule. The built-in config had grown from 5 to 10 patterns, so every file cost 20 object tests and 16 pattern tests. Now an extension that no pattern can match (.md,.snap,.css) returns at once, a.jsfile doesn't ask the**/*.tsobjects, and a pattern that ends in/**is asked once per directory. This helps every ESLint-style config.Threads merged the same set of config objects in parallel, each sorting 1,600 global names twice, and every set was merged with and without the React rules. Each set is merged once, and the lists of globals are shared.
-f unixspent 610 instructions per line. It computed where a finding ends, which it doesn't print, and searched the line table for a line it already had. About a third of that now.The default format linted a whole file again with every rule to get the help of one problem it shows, and hashed each rule's name for each finding.
A disable comment walked the whole list of rules for every rule it names.
bun check: to sort a file's diagnostics, every comparison looked up and converted both files' paths, about 360 instructions, though nearly all pairs are from one file. 23 M of 4,000 M on 220 files with 12,600 errors. The output is byte-identical.The possible Jest calls of a test file are sorted as plain keys, without a call per comparison: 17 M of 1,077 M on a folder of test files.
bun lint -f jsonis 27% faster with 989 rules on 4,147 files (10.89G instructions to 7.96G), and 34% faster under an ESLint config with 218 rules (1,103M to 724M). For every file and every enabled rule, the list of deprecated rules in use allocated the rule's name and searched a table before it looked at the flag that says whether the rule is deprecated at all. The output is byte for byte the sameFinding the line starts of a file was 2% of a
bun lintrun. It is a Highway kernel now: 64 bytes at a time instead of 8JavaScript plugins: see below
Bun.Glob: see belowNew
--initadds[lint]/[fmt]tobunfig.tomlbun lint --explain <rule>prints the rule's page in the terminal.--rulesgroups by plugin with descriptions.--rules -f jsonhas IDs, aliases, descriptions and defaults.bun lint --doctor,bun fmt --doctor: what runs natively, what runs in JavaScript, which packages can go--help.--help --allshows everything, groupedbun initproject passesbun lintandbun fmt --check, in all four templates--staged,--changed[=<ref>]Docs
docs/lint/rules/<plugin>/<rule>.mdx, 1,021 pages plus a generated indextest/cli/lint/rule-docs.test.tsruns all 4,146 examples: what a page marks as reported has to be reported, what it marks as fine must not be. It also checks that every rule has a page and that the generated frontmatter is up to date.## Configuresection on 984 pages: how to turn the rule on (or off, if it's on by default) inbunfig.toml. 407 of them also list every option, set to its default, one per line. The names, types and enum values come from the option schemas the linter validates against.bun lint --rules -f jsonhasschemaanddefault_optionsnow. The test loads every snippet, and lints every example twice (rule only, and rule with the options snippet): the reports have to be identical, so a wrong default failsdocs/runtime/lint.mdxrewritten: 214 lines, was 1,265src/lint/CLAUDE.md: how to write, register, document and test a ruledocs/runtime/format.mdxrewritten: 295 lines, was 431docs/guides/lintanddocs/guides/formatWriting the pages turned up about 300 notes about rules and pages that looked wrong. Each was checked against the original tool. The real bugs in rules that are on by default are fixed here, and the pages say what the rule does.
rule-docs.test.tsalso runs all 1,512tomlsnippets throughbun fmt, so what the docs show is what the formatter prints.docs/lint/rulesis in.prettierignore: Prettier reformats the code in the examples, and many rules are about exactly that.From review of #44805
bools are bit sets.ArrayBitSet::setandis_setareconst fn, andbun_collections::ByteSet(32 bytes) can be astatic. Scanning URL-like text:[bool; 256]0.32 ns per byte,[u64; 4]0.50, thematchthat was there before 0.79 (it compiles to a 376-byte jump table),u1281.01. On a document that is 87% URLs, that is under 3% ofBun.markdown.html. Sets of one to three bytes usestrings::contains_char/contains_anysrc/glob(without the directory walker) goes from 9,235 lines to about 4,350. The ports of minimatch 10, minimatch 3, picomatch and brace-expansion are gone, along with their hard-coded limits. Lint and format convert other tools' patterns to Bun's syntax and use the same matcher asBun.Glob. Why this is safe: an instrumented build askedBun.Glob's matcher the same question at every real match call in 629 runs over 333 repos (1,870 patterns, 12.3 million calls). 90.1% of patterns already gave the same answer, 1.0% needed?(..)/@(..), 8.8% differed only in what the caller passed in, and 2 patterns really differed. See "Bun.Glob" below for what changes thereBun.GlobThe matcher rewrite also changes
Bun.Glob:?(a|b),*(a|b),+(a|b),@(a|b),!(a|b). A(without one of?*+@!in front of it is still a plain character, so Next.js route groups likeapp/(marketing)/**match as before.{1..3},{01..10},{a..e},{1..9..2}. The number in the path is compared with the range. Nothing is expanded.false). Matching no longer recurses, so+(a|b)matches 100 KB ofab.{a,b/**}matchesb/x/y,{**,a}/bmatchesx/y/b, and an unclosed{a,bis treated as literal text (it used to matchabut notb).Patterns that change meaning. The new syntax takes some strings that used to be plain text, as in picomatch, minimatch and bash with
extglob:!(g)/a.ts(g)/a.tsa.tsin any folder butg**/!(*.test).tsinscan()!(matched everything.tsfiles that are not.test.ts"workspaces": ["packages/!(b)"]error: Workspace not foundb, as in npm, pnpm and yarn*(1).txt,?(1).jscopy(1).txt,i(1).js1, then.txt. Write*[(]1).txt+(,@(,?(,*(or!(inworkspaces,sideEffects,files,--filter{1..3}1..31,2or3[, a trailing\Answers that were wrong in 1.4.3 and are right now. Each was run on the released binary.
{src/**,lib/**}(**inside braces was treated like*)src/a/b.tsfalsetrue{**,a}x/yfalsetrue{a,b}eleven times in a row (more than 10 brace groups)beleven timesfalsetruefalsetruea{(an unclosed{is literal, as in bash and minimatch)a{falsetrue{,truefalse*[!a]{,a}*bc/falsetrueHow often this matters. A search of public code (60 GitHub code-search requests) found 334 patterns with one of these sequences in a place Bun reads globs from:
new Glob(...),workspaces,files,sideEffects,.npmignore,bunfig.toml,--filter. All of them use!(. 331 clearly mean extglob, 3 are unclear, and none relies on the old reading. About 13 are in repositories that use Bun. One test (in a repository with one star) pins "Bun.Globhas no extglob" and will fail. The search can't see patterns made at run time, private code, Bun Shell, orsideEffectsin published packages.File names. Only the pattern is parsed, never the path, so a file with such a name still matches
**/*.ts. The one popular convention that contains a sequence is SvelteKit's layout reset,+page@(group).svelte: written out as a pattern, it no longer matches itself (**/+page*.sveltedoes). None of the 137 public lines that mention such a name is a glob.@scope,@modal,+page.svelte,(group)and(.)photoare unaffected.bun lintandbun fmttake the name of an existing file literally. On 12 patterns from that search,Bun.Globagrees with minimatch 10 on all 12, and with picomatch 4 on 8: on the other 4 the two libraries disagree with each other.A
(after anything else is still plain, soProgram Files (x86),code (old),app/(group)andfile(1).txtwork as before: 34 commands (install, run, test, build, pack, lint, format, ...) in each of 23 oddly named project folders behave as in a plain folder.Bun Shell is unaffected. Quoted text,
${}values and$VARare still data:${"@()!(zzz)"}/*matches nothing, and"c++(old)"/*.tsfinds the folder. 391,551 fuzzed shell runs give the same result as before, except for symlinked folders whose name really contains+(or@(.All 80,016 pattern and path pairs in
test/js/bun/glob/match.test.tsgive the same answer as before. Every pattern up to 6 characters long from the glob alphabet (113 million patterns, 26 paths, both platforms, every entry point, overflow checks on) runs without a panic.How it works. A fast loop in front decides plain patterns and takes plain brace groups inline. Behind it is one automaton over the pattern's bytes: a single backward pass over the path with bit sets, where
!(...)is the NOT of a bit that is already known. A pattern that is matched often (32 times, or once against a path of 512 bytes or more) switches to a cache of the automaton's states that is built as paths are matched. Matching does not recurse, and the time grows linearly with the length of the path.Speed against Bun 1.4.3. CI's LTO build against the released binary, through
new Bun.Glob(pattern).match(path), user instructions per call, 143 pairs of a pattern and a path. "Reused" is oneGlobmatched many times. "Fresh" is a newGlobfor every match.**/node_modules/**a/node_modules/b/c.jssrc/**/*.test.tslib/a/b/c.test.ts{src/**,lib/**}lib/a/b.ts**/{src,lib}/**/{test,spec}/**/*.{ts,js}packages/a/src/x/test/y/z.ts!**/node_modules/**src/a.ts*.[jt]sa.tsa/**/b/**/ca/x/b/y/cThe rows that are slower:
!!aaEvery version of the matcher that landed was first compared with the previous one on 642 million pairs of a pattern and a path (107 jobs, debug assertions on: the same counts per job, no loop, no panic), and the last one on 1.1 billion more from tools aimed at its new fast paths. Those tools were themselves tested with deliberate one-line bugs. They found two wrong answers that three runs of the 642 million had missed (
**/*[!a]*{a,b}on/abc/aa), both fixed, with tests.scanSync()over 50,000 files, same files found:**/*.ts**p1*/src/**/*.js**/*.{ts,tsx}bun installin a 500-package monorepo withworkspaces: ["packages/*", "apps/**"]is within noise (+0.3% to +0.8%, noise 0.5%).packages/!(internal),apps/@(web|api)andlibs/lib{1..2}work as workspace entries. Every place that asks "is this string a glob?" (workspaces,sideEffects,bun pm diff, the walker's literal fast paths, the kernel filter on Windows) knows the new syntax.The old
src/globstill compiles in a test harness, so old and new were compared in one process: 10.2 million ignore lines for oxlint and oxfmt (1 differs, and there the new code matches real oxlint), 4.3 million override and.editorconfigpatterns (0 differ). At the level of the product, 16,275 patterns went through each of 36 config options, one process each: 19 options are identical, and the rest differ on 1 to 104 broken patterns (*],(*), a bare|, unbalanced brackets) where the old code reproduced quirks of old minimatch versions.JavaScript plugins
Third-party ESLint rules (
pluginsin aneslint.config.js,jsPluginsin an.oxlintrc.json) used to run in a 5,528-line JavaScript program embedded in the binary. It reimplemented ESLint's rule API on top of arrays of numbers that Rust serialized and copied over, on separate threads that the lint threads waited for.TokenStore,SourceCode,context.reportand the fixer, the scope manager's objects, code path analysis, selector matching and the order of listener calls are C++ and Rust. Objects are made from Structures that are built once and filled by offset.code_path.js,report.js,tokens.jsandsource_code.jsare deleted, 1,976 lines of JavaScript are left, and about 500 of those only call other people's JavaScript (the project's own ESLint, Prettier and processors).Instructions, release builds, lower is better. "Before" is #44805 as merged. Both builds were run alternately in one sitting, 4 threads, lowest of 3:
getScopeon a few nodes, 2,000 files*, 2,000 filescontext.reporton every identifier, 2,000 filesIdentifier, 200 small filesgetTokenBeforeandgetTokenAfter: cost of the two callsThe first row is noisy: the old build against itself differs by 4% there, and its three runs of the second row by 6.5%. The three runs of every other row are within 0.9% of each other on the new build. The report of the first row is the same size to the byte on both builds. The row with a suggestion prints 8% more JSON on the new build, because a suggestion's
datais passed through now.Slower:
getScopeon a few nodes: +4%.sourceCode.getText(node): +0.7% against the JavaScript it replaced (the JIT inlinestext.slice, and a native call can't beat that).locis an own property now. Readinglocis 5% faster.Closer to ESLint. Everything was compared with real ESLint 10.12 (espree, and
@typescript-eslint/parser8.71.1) and real oxlint 1.87 over about 63,000 inputs. That turned up places where plugins could see a difference, now fixed:locnow equal espree's and typescript-estree's. Whole trees are byte-identical in 63,185 of 63,195 files, andvisitorKeysis byte-identical. Under an oxlint config, the layout of every node type equals oxlint 1.87's in all 25,658 TypeScript files that it parses.eslint-scopeand@typescript-eslint/scope-managerin all 25,765 and 37,428 files. In a first sample of 418 files, none matched. Values are identical in 25,763 and 37,415.thisFound,taints, the order of references,getDeclaredVariablesand names from/* eslint-env */comments were wrong.thisFoundmadeunicorn/consistent-function-scopingreport arrow functions that usethis.countand padding. Every method with every option form at every node, token, comment and text index: 63,184 of 63,193 files are identical.context.report: a report whoselineorcolumnisn't a number was dropped silently. ESLint's order of reads,RuleFixeras a class, a suggestion'sdatapassed through.SourceCode: ESLint's ten own frozen properties in its order.locof nodes in each parser's layout.undefinedasthis, as in ESLint. They got an internal object.Array.prototypecrashed the process (also in Addbun lintandbun format#44805).The 9 files that still differ everywhere are Flow syntax in
.tsx, where the syntax tree differs.Visible outside
bun lintandbun fmtBun.Glob, and everything that uses it: see above.Bun.write(Bun.stdout, new Response(asyncIterable))was a use-after-free when the reader of the pipe left while a write was parked (ASAN: heap-use-after-free in the pipe writer). The writer keeps its parent alive untilclose()returns. Same bug as io: POSIX pipe writers hold a ref on their parent from on_error until close() returns #34697Bun.spawn({ terminal })could hang forever on macOS in a blockingwait4on the JavaScript thread, when kqueue refused the exit watch. A port of spawn: reap a pty child on macOS when kqueue refuses the exit watch #41732. Fixes Bun.spawn({ terminal }): process hangs forever in __wait4_nocancel when a process-group signal races the child's own exit (macOS) #42171bun check,bun lintandbun fmtusedstd::simd. It uses Highway like the rest of Bun, andstd::simd,core::simdandfeature(portable_simd)are banned by clippy and a source lintwarn:is bold yellow in all of Bun's error output. It was dim.^under an error is in the right column when the line has wide characters (CJK, emoji).Bun.markdown.ansiandbun file.md: a word that arrives in pieces, like`code`followed by.or(followed by a link, is no longer split at the end of a line. The break goes to the last space.toHaveBeenCalledOnce()is inbun-types. The matcher already existed.lint,formatorcheckscript, file or binary still wins over the built-in command.--help,-h,--help-alland--doctor(and--explainforlint) now go to Bun, since no other tool has the last three and the migration guides send people there who still have"lint": "eslint .". Everything else,-vand--versionincluded, reaches the script.bun init: the templates passbun lint,bun lint --type-aware,bun checkandbun fmt --check. The code that changed is formatting, types,asyncdropped from route handlers that don'tawait, and an unusedreq.frontend.tsxcompiles to the same bytes as before in a plain transpile, an unminified build, with--react-fast-refreshand in the dev server's own transform. Every route answers with the same status, headers and body.lintandformat.bun -e 1+0.33% instructions,--version-0.22%, an empty file -0.12%, 20 Workers -0.11%, 1,000 ShadowRealms -0.14% (two runs of one build differ by 0.1 to 0.3%).Binary size
Against
main, in CI (the limit is 512 KB):The rule pages for
--explainare 304 KB of that, compressed. They're prose and examples: zstd at its highest level, xz and brotli all end within 3% of each other.bun lint,bun fmtandbun checkread is zstd-compressed in the binary: the rule pages, option schemas, presets,bun check's 1,371 messages, oxlint's help and the JavaScript for plugins. That saves 432 KB. It's inflated on first use, which costs 146 to 202 µs forbun check's messages and 1.3M instructions when a plugin starts. Nothing the runtime loads is compressed. Text that an ordinary run would have to inflate (the names of globals, oxlint's category tables) is left as it is: 67 to 131 µs each.Report::fix,suggest_as,labels_with,help_withandhint_withwere compiled once per closure: 832 copies, of which about 300 bytes each were the same code. That part is out of line now. 184 KB on a build without LTO, 241 to 276 KB per target in CI. A rule that reports nothing runs the same instructions as before, and a report with a fix costs 50 to 85 more.JSMap::setinlined five times in the plugin host: 62 KB.#[optimize(size)]on 258 functions that never run for a file or a config without errors:--doctor,--explain,--init,--print-config,--rules,--debug-check's comparison, and the functions that put a parser's error into oxlint's or ESLint's words. About 30% off each, 95 KB together. The rule is written next to each#![feature(optimize_attribute)]. Every function that got it had its callers read, and three that turned out to run on ordinary paths lost it again.src/collections/index_sort.rs) had 270 copies of 297 bytes, most of them onmaintoo. 190 of those bytes build the list of indices, which doesn't depend on the element type, and every comparison closure was compiled twice, because the vtable of a&mut dyn FnMutalso has acall_onceslot that nothing calls (230 unused bodies). 64 KB. The algorithm, the indices and the comparisons are the same, so ties can't change. All seven entry points were compared with the standard sorts at lengths 0 to 5,000. The bundler, the installer and the runtime use these sorts too: a bundle of 3,000 modules costs the same (-0.1% to +0.04%).linux-aarch64-androidread +448.1 KB and had 20,448 bytes left before a step to +512.1 KB, which fails the check by 72 bytes.Removed
bun lintandbun format#44805:test/internal/source-lints/shared-helpers.test.tsandinner-allows.test.ts, with their inventories (about 1,640 lines).shared-helpersflags functions by name (trim,quoted, ...) anywhere in the repo, andinner-allowsis a repo-wide policy on#![allow(..)]with an inventory of code this project doesn't own. They were useful while Addbun lintandbun format#44805 was being written, but as permanent CI they'd mostly get in other contributors' way. The other two lints from Addbun lintandbun format#44805 stay:sema-parser-recursion(guards against a real stack overflow) andshared-sorts(protects a 228 KB size saving, only looks atsrc/format).LICENSE.md: the rows from Addbun lintandbun format#44805 were audited against the tree. Rows for code that no longer exists are gone (the Svelte printer, thevueandjsdocrules, minimatch, picomatch, brace-expansion), one wrong project was corrected, and about 30 missing credits were added.code_path.js, which is mostly ESLint's code, now carries ESLint's MIT notice.How did you verify your code works?
Every item ticked above was run on a release build of this branch, on made-up projects, the way a person would use it, including on a pseudo-terminal.
New test files:
defaults,hints,init,doctor,format-doctor,explain,help,output,native-rules,messages,rule-docsundertest/cli/lint, andbunfig,wordsundertest/cli/format.The upstream suites from Add
bun lintandbun format#44805 are unchanged and pass.React defaults cost nothing measurable when they don't apply: 868 M instructions against 863 M on 3,000
.tsxfiles in 600 directories, and the same number of system calls.With an ESLint config (9 output formats) and an oxlint config (10), output before and after the hints is byte for byte the same.
Real repositories. The merged build against this branch on 333 open-source repositories, each with its own config, arguments and installed
node_modules, in a sandbox: 629 runs (204 oxlint, 108 ESLint, 243 oxfmt, 74 Prettier). 627 are identical in stdout and exit code. 1 is thethisFoundfix above (discord.js: 4 false positives gone). 1 is a.tomlfile that's now formatted in a project with no Prettier config file. An earlier pass found a regression in 13 runs (an extradatakey onreact-hooks/exhaustive-depssuggestions in-f json), which is fixed. This pass ran after the native plugin host was complete.199 ESLint core rules as a plugin on 262 TypeScript files: real ESLint and this branch agree on all 60,785 messages, in rule, position, text and fix.
Each native piece went in behind a switch, was compared with the JavaScript it replaced and with the real tools, was made the default, and the JavaScript was deleted one green build later.
Debug + ASAN with leak detection and
BUN_JSC_validateExceptionChecks=1before each deletion: the JavaScript plugin, parser, processor and Prettier plugin tests, plus an argument fuzzer for each native function (wrong types, Proxies, throwing getters, callbacks that call back in, objects kept from an earlier file, calls after the file has ended, forced GCs, low JIT thresholds).Config matching was reworked for speed, so it was compared before and after on 13,600 real files under five kinds of config, and on a made-up tree of 6,300 files (25 directories, 18 kinds of name, 14 extensions) under seven configs, with 1 and 8 threads: 22 runs, 150,000 lines of findings, all byte-identical. In debug builds every shortcut recomputes the full answer and compares.
Every speed claim is user instructions on CI's LTO builds,
mainat the merge base against this branch, alternating, best of 3 or 4. Causes were found with exact counts (callgrind on both builds), not from samples: two sampled profiles pointed at the wrong functions.Three more reviews with the one aim of breaking the last day's work, on the built binary, reporting only what reproduces. CI was green and the review bot had found nothing.
.js,a..js,a{b,c}.js,a*.jsand with invalid UTF-8) and 290 runs at 64 threads. Nothing.--allow-unsupportedturned off thepackage.jsonhand-off, so it wrote other bytes thanbun fmt;""in a path option was read as a path;nullwas accepted; a refusal blamed JSON and not the plugin; one run said a plugin has no effect and refused files because of it.-f unixprinted2:7for a plugin'slocpast the end of a line, where oxlint and every other format say3:3. Fixed. Found the order underoverridesabove.Threads: 8 configs at 1, 4, 16 and 64 threads give one report hash per config. 600 stress runs with a timeout had no hang.
A final review in five passes, with CI green and the 333 repositories identical, each looking for what all of that had missed:
main, this branch), comparing stdout, exit code, and the hash, mode and inode of every file. No regression under any ESLint, oxlint, Prettier or oxfmt config. Found the--parserdata loss and the oxlint gaps above. 63 path idioms with 4 tools, 30 stdin shapes, 26--fixflag combinations: Bun never writes a file the real tool wouldn't, apart from "no arguments means the current directory".Bun.Globand everything that uses it. Found that quoted text in Bun Shell had become glob syntax, and two.prettierignorelines that differed from Prettier, both fixed. Found thatmatch()had become quadratic in the length of the path, and then an endless loop and wrong answers in the first fix for that. All fixed: matching is linear, and see "Speed against Bun 1.4.3". Then: every pattern of up to 5 tokens (6.7M patterns, 64 paths), 111M fuzzed pairs of well-formed old syntax (22 patterns differ, and there the old answer was the bug), 151M crash-fuzz pairs, 623,616scanSynccalls over all 32 option combinations, 54,240 ignore lines against the npm package (0 differ).lintscript, and the two commands that wrote files. Then: 11 project shapes, 3 commands and 65 command lines againstmainand 1.4.3, a 253-command smoke comparison, 16 bunfig files with 10 commands: only the differences listed above.