Skip to content

refactor(tooling): drop exports nothing imports (#1356) - #1369

Merged
devsuitup merged 1 commit into
mainfrom
refactor/1356-unexport
Nov 29, 2026
Merged

devsuitup merged 1 commit into
mainfrom
refactor/1356-unexport

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

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 -w across 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 as module[name].

  • 55 SURPLUS, removed from module.exports in 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 own module.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 in public/utils.js) and asEditorText (public/viewer-panel.js's own). The trigger-actions refusal export goes too. actions.refusal in trigger-watcher and session-request-namespace is the method createTriggerActions returns, not the module export.
  • 45 KEEP, knip false positives, because knip does not follow CommonJS namespace access:
    • 28 are namespace access in app code, const ns = require(x); ns.name. Examples: scheduleIpc.init and sessionTransitions.* in main.js, naming.* in trigger-actions, archive.* in the index writer and its commands, deletion.parseWorktreeList.
    • 8 are namespace access or destructuring in tests only. Examples: engine.buildDeletionUnits, results.writeScheduleRunResult, counters.readBodyFile.
    • 6 are trigger-watcher names that tests reach through the spread re-export in test/fixtures/trigger-watcher.cjs.
    • 2 are modules that a test loads as source and then calls by name: deleteScheduleFile and rewriteJsonlAtomic.
    • 1 is MAX_LINE_BYTES in jsonl-scan.js. The module reads module.exports.MAX_LINE_BYTES itself, and test/read-session-file-streaming-1180.test.js rewrites it.

Docs

  • no docs: removing exports that no module imports changes no behaviour. No doc or context describes any removed name as an export. The contexts that name these constants or functions describe them inside their module, and that stays true.

Tests

Run under Node 22, one file at a time with --test --test-concurrency=1.

  • All 34 changed modules pass node --check, and a single process loads all 34 with require (exit 0).
  • 30 test files: 1050 passed, 0 failed. The files are delete-session-guard, read-session-file-streaming-1180, local-transcript-activity, remote-activity, unsaved-guard, bg-handoff, git-changes-file, git-changes-target, git-changes-watch, session-touched-cache, activitywatch-reporter, last-known-projects, remote-enrol, remote-hosts, remote-index, remote-launch, remote-mirror, remote-send, remote-transport, remote-watch, schedule-background, search-refs-1255, composer-state, trigger-watcher, trigger-actions-results, viewer-save-guard, viewer-file-watch, transcript-api-tail, quota-reset-time and headless-claude-launch.
  • eslint on the 34 files, scripts/check-docs.js --validate, scripts/check-doc-refs.js, git diff --check and SKIP_TESTS=1 task check:fast are all clean.

Not verified

  • The other test files that mention a changed module were not run locally and are left to CI. They include the direct tests of classify-title-activity, fts-match, pty-size, shell-profiles and task-records.
  • The knip count after this change is not measured, because knip is not installed locally. The CI deadcode job will show it. I expect the report to drop by 55 exports, and the 45 false positives to remain.

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.
@devsuitup devsuitup added no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived no-docs PR changes code but no user or agent doc needs an update labels Nov 29, 2026
@devsuitup
devsuitup merged commit 4cd8ae8 into main Nov 29, 2026
10 checks passed
@devsuitup
devsuitup deleted the refactor/1356-unexport branch November 29, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived no-docs PR changes code but no user or agent doc needs an update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant