Skip to content

Add Biome and fix all lint/format issues - #2

Merged
kamath merged 6 commits into
mainfrom
cursor/add-biome-ce1f
Sep 24, 2026
Merged

kamath merged 6 commits into
mainfrom
cursor/add-biome-ce1f

Conversation

@kamath

@kamath kamath commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Biome 2.5 as the repo's linter and formatter and fixes everything it reports. Also adds a CI workflow, so pull requests are linted, built, type-checked, and unit-tested.

Biome runs in three places, and warnings fail all three:

  • pnpm check runs pnpm lint (which is biome check --error-on-warnings .) before type-checking each package.
  • A pre-push hook, installed by pnpm install through simple-git-hooks, runs pnpm lint. Set SKIP_SIMPLE_GIT_HOOKS=1 to bypass it.
  • CI: see below.

CI (.github/workflows/ci.yml)

Runs on pull requests and on pushes to main, with two parallel jobs:

  • biome (about 7s): biomejs/setup-biome installs the Biome version pinned in pnpm-lock.yaml, then runs biome ci --error-on-warnings ..
  • check (about 70s): pnpm/setup@v3 installs the pnpm version from packageManager plus the latest Node 22.x, then runs pnpm install --frozen-lockfile with a cached store. After that it runs pnpm build, pnpm -r check, and pnpm test.
    • The build has to run first because the web app's type-check imports routeTree.gen.ts, which only the Vite build generates.
    • The tests run .ts files directly, so they need Node 22.18 or newer. Node 22.x satisfies that.

Commits

  1. Add Biome: biome.json, root scripts, and a README note.
  2. Apply Biome formatting and safe lint fixes: generated output only.
  3. Fix Biome lint diagnostics: hand fixes for the 74 remaining diagnostics.
  4. Pre-push hook and fail on warnings.
  5. CI: Biome job.
  6. CI: build, type-check, and unit tests job.

Config choices

  • 2-space indent, double quotes, and a 100-column line width. The code is already written in this style, and 100 columns gave a roughly net-neutral diff.
  • Uses the recommended rules with no rules turned off.
  • worker-configuration.d.ts is excluded because Wrangler generates it (about 15.7k lines).
  • CSS tailwindDirectives is enabled so @source in styles.css parses.
  • simple-git-hooks is declined in allowBuilds. Its own postinstall is not needed because the root prepare script installs the hook.

Hand-written lint fixes

  • noNonNullAssertion (54): replaced with explicit narrowing. Examples: a type guard for ownsSession, tab lookups that check their result, a CDP Quad tuple type, and assert.ok narrowing in tests.
  • noExplicitAny (13): added AXNode and FrameTreeNode interfaces for the CDP payloads that snapshots read. evaluate, evaluateIn, and Locator.apply are now generic with an unknown default. The remaining raw CDP JSON goes through a single documented CdpPayload alias.
  • React: added type="button". Message parts render through a MessagePart component, so the index key appears in one place.
  • Other: noAssignInExpressions and noImplicitAnyLet.

The repo has exactly three biome-ignore comments, each with a reason: the CdpPayload alias, the message part index key, and the scroll effect's trigger dependencies.

Two small behavior changes:

  • tab.close now throws "No tab is open." instead of crashing on undefined.
  • The tools package's temporary-session shutdown skips browser.stop when a handle has no sessionId.

Testing

  • Both CI jobs pass on this PR. The check job ran 62/62 unit tests.
  • Locally, against headless Chrome: test:runtime passes and pnpm test:e2e passes 14/14.
  • The pre-push hook blocked a push with a lint warning, blocked one with a lint error, and allowed a clean push.

Not changed

The engines fields and the README still say Node 22.13+. That is enough to run pnpm 11, but running the .ts sources directly (for example pnpm test or pnpm cli) needs 22.18+. I left it as is because the published packages may really support 22.13.

Open in Web Open in Cursor 

cursoragent and others added 3 commits September 24, 2026 14:54
Co-authored-by: Anirudh Kamath <kamath@users.noreply.github.com>
Co-authored-by: Anirudh Kamath <kamath@users.noreply.github.com>
Replace non-null assertions with explicit narrowing, type the CDP
accessibility and frame-tree payloads that snapshots read, and route
remaining untyped CDP JSON through one documented CdpPayload alias.
Add a button type, and split message part rendering so the index key
lives in one place.

Co-authored-by: Anirudh Kamath <kamath@users.noreply.github.com>
@kamath
kamath marked this pull request as ready for review September 24, 2026 15:13
@kamath
kamath merged commit c0a7878 into main Sep 24, 2026
3 checks passed
cursor Bot pushed a commit that referenced this pull request Sep 24, 2026
Main (#2) added Biome with the recommended preset and formatter and
reformatted the codebase. Conflicts resolved by normalizing formatting on
both sides and three-way merging the content:

- biome.json/package.json: main's config and scripts, plus the
  no-type-assertion plugin.
- page.ts: keep main's Quad tuple and area(); derive Quad from a zod
  tuple schema so the quads cast stays removed.
- examples/02-mcp-server: keep main's sessions guard and this branch's
  sessionId shape narrowing.
- tools.test.ts: keep main's non-null-assertion removals, with zod parsing
  in place of the casts.
- api.chat.ts: type `let messages` for noImplicitAnyLet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants