Public: anyone can read this; the crew can change it.

Delete the dead exports scripts/unused-exports.ts finds, area by area #16800

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Deletes 53 dead exports across 33 files and drops 54 stale entries from scripts/unused-exports-allow.json, taking the list from 227 to 173. I did one commit for all areas rather than one per area, in a single pull. Not run: the full suite, and the forge's check, which runs on this push.

Notes

opened this

Deletes 53 dead exports across 33 files and drops 54 stale entries from scripts/unused-exports-allow.json, taking the list from 227 to 173. I did one commit for all areas rather than one per area, in a single pull. Not run: the full suite, and the forge's check, which runs on this push.

Verification. bun x tsc --noEmit --noUnusedLocals is clean, and bun scripts/gate.ts --explain reports 32 rules satisfied. bun scripts/unused-exports.ts reports exactly the 173 kept entries, and test/unused-exports.test.ts passes. I ran 365 test files near the touched modules: 3432 tests pass and 5 fail, all in code this pull doesn't touch:

  • the heap-growth sampling tests in job-alloc
  • a chromium capture test
  • behaviors-rule (src/web/chart_hover.ts)
  • the empty-words-all count (read-grants.ts, app_flags.ts)

I did not run those on a clean base, so I can't say whether they already fail on main.

What changed

  • Deleted dead code. I removed every allow-listed export that no source file and no test file mentions. Examples are bySession/recentOrders, the display/launch URL helpers, trapAsync and the tui withFg/withBg/withAttr/withoutAttr.
  • Cascade. Deleting those left five more exports dead (shownBase, pinPlayUrl, displayOrigin, repoRoot and usePlacement's siblings in display/launch), so I removed them too. Their now-unused imports and the Hidden type went with them.
  • Pruned the list. --write dropped entries that were already stale, for example core/starts.ts startOfAccount, which src/actions/here.ts calls.
  • No new code. No function was written, so there was nothing to reuse.

What I kept. The 173 remaining entries are all used by tests and nothing else (reset*, use*, provide*ForTest, forget* and similar). The issue says an export used only by tests is not dead. The JSON format has no place for a one-line reason per entry, so the shared reason is this paragraph. If you want per-entry reasons, the file needs a new format.

Two commit-message lines. The pre-push hook demanded a Try: line and a No door: line, so the empty commit carries both. No page, route, action or tool behaves differently.

How to try it

  • bun scripts/unused-exports.ts lists the 173 kept entries.
  • bun test test/unused-exports.test.ts passes.

Closes #16269

4 earlier comments
commented

Deletes 53 dead exports across 33 files and drops 54 stale entries from scripts/unused-exports-allow.json, taking the list from 227 to 173. I did one commit for all areas rather than one per area, in a single pull. Not run: the full suite, and the forge's check, which runs on this push.

Verification. bun x tsc --noEmit --noUnusedLocals is clean, and bun scripts/gate.ts --explain reports 32 rules satisfied. bun scripts/unused-exports.ts reports exactly the 173 kept entries, and test/unused-exports.test.ts passes. I ran 365 test files near the touched modules: 3432 tests pass and 5 fail, all in code this pull doesn't touch:

  • the heap-growth sampling tests in job-alloc
  • a chromium capture test
  • behaviors-rule (src/web/chart_hover.ts)
  • the empty-words-all count (read-grants.ts, app_flags.ts)

I did not run those on a clean base, so I can't say whether they already fail on main.

What changed

  • Deleted dead code. I removed every allow-listed export that no source file and no test file mentions. Examples are bySession/recentOrders, the display/launch URL helpers, trapAsync and the tui withFg/withBg/withAttr/withoutAttr.
  • Cascade. Deleting those left five more exports dead (shownBase, pinPlayUrl, displayOrigin, repoRoot and usePlacement's siblings in display/launch), so I removed them too. Their now-unused imports and the Hidden type went with them.
  • Pruned the list. --write dropped entries that were already stale, for example core/starts.ts startOfAccount, which src/actions/here.ts calls.
  • No new code. No function was written, so there was nothing to reuse.

What I kept. The 173 remaining entries are all used by tests and nothing else (reset*, use*, provide*ForTest, forget* and similar). The issue says an export used only by tests is not dead. The JSON format has no place for a one-line reason per entry, so the shared reason is this paragraph. If you want per-entry reasons, the file needs a new format.

Two commit-message lines. The pre-push hook demanded a Try: line and a No door: line, so the empty commit carries both. No page, route, action or tool behaves differently.

How to try it

  • bun scripts/unused-exports.ts lists the 173 kept entries.
  • bun test test/unused-exports.test.ts passes.
commented

<!-- look-pages 81b7c9c6f6cd --> Look pages for 81b7c9c, from the gate:

  • look pages (inferred): this pull changes src/web/chrome.ts, src/web/space_view.ts, src/web/studio/shelf.ts; the forge pictures / (src/web/chrome.ts), /docs (src/web/chrome.ts), /explore (src/web/chrome.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

This pull deletes 53 exports that nothing calls, not even a test, and prunes the allow list. Behaviour is unchanged.

The check failed because the pull changes src/ but adds no test. I added an empty commit whose message carries a No test: line saying no behaviour changed, which the gate accepts. After that commit bun scripts/gate.ts no longer reports the missing-test rule, and the push went through. I did not re-run tsc or bun test this turn.

What to look at:

  • Existing suite: it is the characterization for this pull, since nothing was added or altered.
  • Comment wrapping: gate --fix rewrapped nothing in this diff. The ten files it still flags are outside it, and the gate leaves them to the nightly rewrap on main.
  • Pages: the gate infers that pages importing src/web/chrome.ts, such as / and /explore, should be looked at. Only unreachable exports were removed, so nothing visible should change.

To try it, open the preview at https://lab--16800--forge-trevato-apps.open-platform.sh and load / and /explore.

🤖 Generated with Claude Code

commented

I didn't change any code for the look-pages note. Its list of pages was only inferred from which files the diff touches, so I answered it with a commit line instead.

The src/web/chrome.ts, src/web/space_view.ts and src/web/studio/shelf.ts edits only delete exports that nothing imports. No rendered page should change. I fetched /, /explore and /docs on the preview, and each returned 200. I didn't compare the rendered output with main.

I pushed an empty commit with a No look: line, which the gate accepts in place of a look at each inferred page. I did not run bun test, tsc or the gate again after this commit.

Please say if you want an actual look at the other pages the gate named.

🤖 Generated with Claude Code

commented

stickyAction() is back in src/web/chrome.ts, with its allow-list entry in scripts/unused-exports-allow.json. I took the keep-the-helper option rather than removing the component. The .sticky-action CSS, the gallery entry and the row in docs/design/sections/5-components.md all stay and point at a function that exists again.

The other 52 deletions are unchanged. They are exports with no caller in src, test or scripts, so no page, route, action or tool changes.

I committed and pushed this as afc9f90be. The commit message carries No test: and No look: lines because it only restores an export. bun x tsc --noEmit printed nothing. bun scripts/unused-exports.ts exits 0, on this branch and on main. I did not run bun test or bun scripts/design-lint.ts.

While checking that, I mistakenly overwrote the working tree with files from main. I reset it to the pushed commit and the tree is clean. Nothing from that reached the branch.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs