Repository navigation
refactor(tooling): drop exports nothing imports (#1356) - #1369
Merged
Merged
Conversation
knip reported 100 unused exports. 55 are used only inside their own module and no file, test or harness imports them: drop them from module.exports and keep the code. The other 45 are CommonJS namespace or source-loaded uses knip does not follow, and stay.
This was referenced Nov 29, 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.
Part 2 of #1356: drop the exports nothing imports, from the 100 "unused exports" in the first knip report (#1367, ca80786).
Summary
I checked each of the 100 names with
git grep -n -wacross the whole tree. The search covered main, src, workers, scripts, test, e2e, public and the test fixtures and harnesses. Each name is SURPLUS when nothing outside its module uses it. That includes tests that load a module as source, and dynamic access such asmodule[name].module.exportsin 34 modules. Each of these is still used inside its own module, so this PR deletes no function or constant. Only the export goes. None of the modules reads its ownmodule.exports.<name>. Some names only matched a homonym, a separate local definition in another file:SESSION_ID_RE,DEFAULT_DEBOUNCE_MS,DEFAULT_TIMEOUT_MS,CHUNK_BYTES,FOLDER_SEP,PERMISSION_MODES(the renderer's own inpublic/utils.js) andasEditorText(public/viewer-panel.js's own). The trigger-actionsrefusalexport goes too.actions.refusalin trigger-watcher and session-request-namespace is the methodcreateTriggerActionsreturns, not the module export.const ns = require(x); ns.name. Examples:scheduleIpc.initandsessionTransitions.*inmain.js,naming.*in trigger-actions,archive.*in the index writer and its commands,deletion.parseWorktreeList.engine.buildDeletionUnits,results.writeScheduleRunResult,counters.readBodyFile.test/fixtures/trigger-watcher.cjs.deleteScheduleFileandrewriteJsonlAtomic.MAX_LINE_BYTESinjsonl-scan.js. The module readsmodule.exports.MAX_LINE_BYTESitself, andtest/read-session-file-streaming-1180.test.jsrewrites it.Docs
Tests
Run under Node 22, one file at a time with
--test --test-concurrency=1.node --check, and a single process loads all 34 withrequire(exit 0).eslinton the 34 files,scripts/check-docs.js --validate,scripts/check-doc-refs.js,git diff --checkandSKIP_TESTS=1 task check:fastare all clean.Not verified
classify-title-activity,fts-match,pty-size,shell-profilesandtask-records.deadcodejob will show it. I expect the report to drop by 55 exports, and the 45 false positives to remain.