Skip to content

Remove remaining unused files flagged by Knip - #4393

Merged
wojtekn merged 4 commits into
trunkfrom
remove-remaining-dead-code
Jul 31, 2026
Merged

Remove remaining unused files flagged by Knip#4393
wojtekn merged 4 commits into
trunkfrom
remove-remaining-dead-code

Conversation

@wojtekn

@wojtekn wojtekn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Related issues

  • N/A

How AI was used in this PR

Third follow-up in the Knip dead-code cleanup series (after #4293 and #4313). Used Claude Code with Knip to surface unused files, then manually verified each one had no live references — carefully distinguishing genuinely-dead files from same-named symbols in other modules (e.g. a CLI wordpress.ts with identical export names, and a SitesListContent that lives in the non-classic selector). Only files with zero real importers were removed.

Proposed Changes

Removes the last batch of unused files Knip flagged. No user-visible impact — none of these were reachable. This clears the dead-code backlog so Knip now reports zero unused files.

  • Removes a sync-sites re-export barrel that nothing imported (its underlying hooks are imported directly and stay).
  • Removes an unused chain of WordPress download/version/setup helpers in the desktop app that only referenced each other; the CLI has its own equivalent implementations that are unaffected.
  • Removes a stale "classic" variant of the sync-sites modal selector that was superseded by the current selector.
  • Removes an unused Spinner component from the agentic UI.
  • Cleans up the now-orphaned test mocks that referenced the removed setup helper.

Testing Instructions

  • npm run typecheck passes for both studio-app and @studio/ui.
  • npm test -- apps/studio/src/tests/site-server.test.ts apps/studio/src/tests/ipc-handlers.test.ts apps/studio/src/modules/sync passes (63 tests) — covers the areas whose test mocks were touched.
  • npx knip now reports zero unused files.
  • Smoke-test site creation and the sync "pull remote site" flow to confirm no regression.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
Deletes the unused sync-sites barrel, download-utils/wp-versions/wordpress-setup libs, the stale classic sync-sites modal selector, and the unused agentic-UI Spinner. Also drops the now-orphaned wordpress-setup test mocks.
@wpmobilebot

wpmobilebot commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 0470b44 vs trunk

app-size

Metric trunk 0470b44 Diff Change
App Size (Mac) 1367.52 MB 1367.52 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk 0470b44 Diff Change
load 1046 ms 1011 ms 35 ms ⚪ 0.0%

site-startup

Metric trunk 0470b44 Diff Change
siteCreation 6518 ms 6532 ms +14 ms ⚪ 0.0%
siteStartup 2391 ms 2362 ms 29 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim bcotrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I was worried these could still be used in npm scripts or Fastlane but I didn't find any blockers.

Nit:

  • apps/ui/src/components/spinner/style.module.css is now orphaned, so the whole spinner/ dir can go. Knip isn't configured for css files, so maybe this is intentional. Feel free to address it later if that's the case
@wojtekn

wojtekn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@bcotrim good catch, I removed this one, too.

wojtekn added a commit that referenced this pull request Jul 31, 2026
## Related issues

- Related to `npx knip` cleanup

## How AI was used in this PR

Claude Code ran `npx knip`, then cross-referenced every finding against
actual imports across the whole monorepo to distinguish three cases:
genuinely-unused deps, deps declared in the wrong workspace, and knip
false positives. Each conclusion was verified with `npm why`, a full
`npm run typecheck`, and a re-run of knip. All findings and edits were
reviewed by a human before opening this PR.

## Proposed Changes

`npx knip` reported ~38 unused dependencies, but most were not actually
dead — they were declared in a workspace that never imports them (knip
reports per-workspace, so a dep used only from a sibling package reads
as "unused" where it's declared). This PR sorts every finding into the
correct bucket:

- **Removed genuinely-unused deps** that no code imports anywhere
(`compression`, `compressible`, `strip-ansi`, `@wp-playground/common`,
`@wordpress/html-entities`, `@wordpress/rich-text`).
- **Removed redundant duplicate declarations** where the real consumer
already declares the package (e.g.
`http-proxy`/`tar`/`yauzl`/`fast-deep-equal` in `apps/studio` that
belong to `apps/cli`/`packages/common`; the `express` trio in `apps/cli`
already present in `apps/local`/`apps/hosted`; `patch-package`
duplicated from root). These packages stay installed — they're still
required elsewhere — so nothing changes at runtime.
- **Relocated deps to the workspace that actually uses them**
(`electron2appx` → root, used by `scripts/`; `@types/yauzl` →
`apps/cli`).
- **Fixed two knip config gaps** that were generating ~24 false
positives: `apps/studio` now lists `electron.vite.config.ts` as an
entry, and `packages/data-liberation-agent` now has an `entry` plus
`.tsx` in its project glob.

The result is that each workspace's `package.json` accurately declares
what it imports, instead of relying on npm hoisting. The lockfile
shrinks accordingly (only `compression`/`compressible` and their private
subtree are physically removed; everything else is dedup bookkeeping).

Dev-tooling/manifest change only — no runtime or user-visible behavior
changes.

A separate, pre-existing issue (knip's ~22 "unlisted" phantom
dependencies — imported but declared nowhere, resolving via hoisting) is
intentionally **out of scope** and will be handled in a follow-up.

## Testing Instructions

- `npm install` — completes cleanly, no peer-dependency conflicts
(removes the now-unreferenced `compression` subtree).
- `npm run typecheck` — passes across all six workspaces, confirming no
removed/moved dep broke resolution.
- `npx knip` — the only remaining "unused" findings are the
deliberately-kept ones (`@sentry/react` via Vite `manualChunks`,
`@wp-playground/cli` spawned as a binary, `@automattic/wp-babel-makepot`
via `npx` in a Fastfile, and `hpagent`/`rehype-raw`/`@types/shell-quote`
which sit behind orphaned files being removed in #4393).

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@wojtekn
wojtekn merged commit 41e7523 into trunk Jul 31, 2026
13 checks passed
@wojtekn
wojtekn deleted the remove-remaining-dead-code branch July 31, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants