Repository navigation
Check unused JavaScript exports in pre-commit, beside vulture - #5028
Merged
Merged
Conversation
The export check was a test in the daily `journeys` tier, whose runs fail every day with hundreds of failures, so its findings went unread: main carried eight exports nothing reads, seven of them left by #4724 and #4873. It now runs as `leaf-dev unused-exports`, a pre-commit hook beside vulture, so a pull request's lint step and `wt merge` check the whole tree on every change. The check itself is unchanged and takes about two seconds. Seven of the eight lose `export`, since only their own module uses them: `readDocumentHeaders`, `SHOT_VIEWS`, `outlineDocument`, `containedSpace` and `selectableOfferElement` (also dropped from `widget-elements.js`), and the re-exports of `runtimeRootState` from `check-api.js` and lit's `Directive` from `framework.js`, whose one user imports lit directly.
A one-off knip scan of dependencies flagged 33; uuid is the one with no reader anywhere in the tree. The others are bundled from build/entries, loaded by evals or tests/*.mjs, or resolved as types and peers.
Marking what changed since the user last saw the page was turned off in #4890 by commenting out its mount, which left `createSinceSeen` as the one export the unused-exports check still reported. By the user's choice it is deleted rather than kept parked; restoring it means restoring the module from 792abf4 and its mount in `application.js`. With it go what only it used: `version.js`'s `offerComparison`, `stopComparison` and the `offered` path of `showComparison`; the `keepalive` option of `deliverBookkeeping` and `postEvent`, which only the departing `seen` send set; and `runtime.seen`. The six arrival tests it skipped are deleted, and `test_since_seen.py` becomes `test_changes_in_place.py` for the comparison and at-work tests that remain. The server's reading of `seen` events is unchanged; no tab posts one.
# Conflicts: # browser/runtime/application.js # browser/runtime/version.js # dist/kernel/kernel.json # dist/kernel/runtime/check-api.js
delivery.js's bookkeeping send is a third caller beside the gesture queue and the error report.
leaf-agent
approved these changes
Nov 1, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 2, 2026
The export check from #5028 counted an export as read wherever a Python, HTML or Markdown file named it as a word. The package references document the public API by name, so every facade re-export of a public name stayed alive: on main it reported nothing while twelve exports had no reader. This replaces it with knip, run by pre-commit like vulture and dependency-cruiser. `knip.config.js` lists the modules something other than an import loads (boot, the public package API, the suite's `check-api.js` windows, `lf-*` widget modules, the render gate's probes, scripts the suite injects, and the Node, Workers and harness programs), and resolves `/runtime/`, `/vendor/` and `/widgets/` through `tests/served-paths.mjs`, the composition the runtime tests already use. The `knip` hook (knip 6.44.1, installed by pre-commit as dependency-cruiser is) reports unused modules, exports and types, and takes about ten seconds. Measured on two trees: | Tree | Word check | knip | |---|---|---| | main before this change | nothing | the twelve exports below, and five false findings (see below) | | main before #5014 | that change's eight | six of the eight, the twelve, and the three `version.js` exports only `since-seen.js` read | Knip misses what only an entry's loader reads: an entry's exports all count as read, so an unused re-export on `check-api.js` or an unused helper exported from a render-gate probe module goes unreported. Those were the two of #5014's eight it missed. Removed, as nothing reads them: - the re-exports of `elementAxes` (`element-frame.js`), lit's `classMap`, `styleMap` and `unsafeHTML` (`framework.js`), `langForPath` (`syntax.js`, so `browser/AGENTS.md`'s owner index now names `language-paths.js`, which defines it), and `nameAction`, `relabel`, `offerElement`, `selectableOffer`, `selectableOffered` and `generated` (`widget-elements.js`); - `export` on `timeline-view.js`'s `clock`; - `leaf-dev unused-exports`, the `imports` reading in `tests/js_facts.mjs`, and its dev test. `leaf.js` now hands `page-geometry.js` the five `target-paint.js` functions it calls instead of the module namespace. Knip's documented namespace-import heuristic (its guide, "Namespace Imports") credits a namespace import that its module both reads members of and passes whole with only the members read, so it reported those five as unused; `knip.config.js` notes this. Validation: the hook passes on the merged tree and fails on a planted unused export, a re-export only prose names, and an orphan module; every pre-commit hook, `pnpm run check:browser`, the 737 runtime tests and an aim browser test pass. > _This was written by Claude Code on behalf of max-sixty_
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.
The JavaScript export check (
tests/journeys/test_unused_exports.py) ran only in the dailyjourneystier. That run has failed every day this week, with over a hundred failures each time, so an orphaned export reached main and stayed until Tend triaged the daily report: #4724 and #4873 left seven on 30 and 31 October, and #5014 removed them on 1 November. Vulture, its Python counterpart, runs as a pre-commit hook, which both landing paths (a pull request's lint step andwt merge's pre-merge) run over the whole tree, so the change that orphans a Python definition is the one told.This moves the export check beside vulture:
leaf-dev unused-exportsholds the check, unchanged, with the test's docstring as its module header. It takes about two seconds..pre-commit-config.yamlruns it asunused-exports, woken locally by the file kinds that export or read (.js,.mjs,.ts,.py,.html,.md,worker/wrangler.toml). CI runs every hook on every file.It also removes what #5014's deletion of
since-seen.jsleft behind:keepaliveoption ofdeliverBookkeepingandpostEvent, which only the departingseensend set, andruntime.seen, which onlysince-seen.jsread;since-seen.jswas unmounted. The module, renamedtest_changes_in_place.py, keeps the comparison and at-work tests;change-walk.js,events.md,read_state.py,agent_state.pyandbrowser/AGENTS.mdthat described the turned-off marking. The server's reading ofseenevents is unchanged, and no tab posts one.And it drops the
uuiddevDependency, which no module imports. A one-off knip scan of dependencies flagged 33; the other 32 are bundled frombuild/entries, loaded by evals ortests/*.mjs, or resolved as types and peers. As #2326 and #3423 found for exports, knip would need more configuration than it saves, so it is not added as a gate.Validation:
leaf-dev unused-exportsand every pre-commit hook pass on the changed files;pnpm run check:browser, the 737 runtime tests, and the browser test for comparison bars and thehwalk pass.