Skip to content

build: add knip and evict the stale wp-prettier fork#102

Merged
pento merged 4 commits into
mainfrom
add-knip
Jun 7, 2026
Merged

build: add knip and evict the stale wp-prettier fork#102
pento merged 4 commits into
mainfrom
add-knip

Conversation

@pento

@pento pento commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds knip for unused files/dependencies/exports detection, wires it into the lint + pre-commit flows, fixes everything it flagged, and separately evicts the stale wp-prettier fork so editor and CLI formatting agree.

knip

  • New knip.jsonc — root and wordpress-plugin as separate workspaces.
  • Wired into npm run lint and lint:fix (check-only), a knip script, and .husky/pre-commit. CI is covered automatically since it runs npm run lint.
  • Dead code removed: YBlockAttributes (and its orphaned yjs import), the unused updateCommand e2e helper, a redundant fakeUser re-export, and the test-only removeCommandFromSync / getCommandsFromSync — the latter's corrupt-entry coverage re-homed onto subscribeToCommandSync.
  • Stopped exporting symbols used only within their own file (various types.ts, e2e helpers, sidebar constants).
  • Declared genuinely-used deps that were only transitive: @wordpress/sync, @wordpress/hooks, plus stylelint + @wordpress/stylelint-config (so knip's stylelint plugin credits stylelint-config-prettier-scss via the .stylelintrc.json extends). This let the now-redundant eslint-disable import/no-extraneous-dependencies directives go.
  • Dropped @types/eslint__js (@eslint/js ships its own types).

wp-prettier eviction

@wordpress/scripts pulls prettier in aliased to npm:wp-prettier@3.0.3 (Automattic's fork, frozen at upstream 3.0.3). Editors resolving the plugin's copy formatted wordpress-plugin/ files differently from the root's stock prettier 3.8.3 that the lint gate uses (e.g. ??-in-ternary parenthesization), causing format-on-save churn. A prettier override in wordpress-plugin/package.json pins stock 3.8.x across the plugin tree so the editor and CLI agree. @wordpress/scripts build/test/lint-style don't invoke prettier, so nothing breaks.

Verification

  • npm run typecheck (root + plugin) — clean
  • npm run lint (ESLint + stylelint + markdownlint + Prettier + knip) — green
  • npm test (1269) + plugin Jest (427) — green
  • npm run build:all — green
  • plugin coverage — command-sync.ts 98.49% lines; the re-homed corrupt-entry branch is covered

Add knip (unused files/dependencies/exports detection), wired into
`npm run lint`, `lint:fix`, a `knip` script, and the husky pre-commit
hook, configured via knip.jsonc with the root and wordpress-plugin as
separate workspaces. Then fix everything it flagged:

- Remove dead code: YBlockAttributes (and its now-unused yjs import),
  the updateCommand e2e helper, a redundant fakeUser re-export, and the
  test-only removeCommandFromSync / getCommandsFromSync (re-homing the
  corrupt-entry coverage onto subscribeToCommandSync).
- Stop exporting symbols only used within their own file.
- Declare genuinely-used deps that were only transitive: @wordpress/sync
  and @wordpress/hooks, plus stylelint and @wordpress/stylelint-config so
  knip's stylelint plugin credits stylelint-config-prettier-scss (which
  lets the now-redundant eslint-disable directives go).
- Drop @types/eslint__js (@eslint/js ships its own types).

Also evict wp-prettier: @wordpress/scripts pulls prettier in as
npm:wp-prettier@3.0.3 (a fork frozen at upstream 3.0.3), so editors
resolving the plugin's copy formatted wordpress-plugin/ files differently
from the root's stock prettier 3.8.3 that the lint gate uses. A prettier
override in wordpress-plugin/package.json pins stock 3.8.x across the
plugin tree so editor and CLI agree.

Verified: typecheck, npm run lint (incl. knip), 1269 root + 427 plugin
tests, build:all, and plugin coverage all green.
Copilot AI review requested due to automatic review settings June 7, 2026 08:10
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

✅ Coverage Report — plugin-php

Metric Value
Current coverage 99.06% (738/745)
Baseline coverage 99.06% (738/745)
Result PASS

✅ Coverage Report — plugin-typescript

Metric Value
Current coverage 99.91% (1148/1149)
Baseline coverage 99.91% (1131/1132)
Result PASS

Changed Files

File Baseline Current Status
wordpress-plugin/src/components/ConversationPanel/use-resizable-sidebar.tsx 100.00% 100.00% PASS
wordpress-plugin/src/store/types.ts SKIP (ignored)
wordpress-plugin/src/sync/command-sync.ts 100.00% 100.00% PASS
wordpress-plugin/src/sync/test/command-sync.test.ts SKIP (ignored)
wordpress-plugin/src/test-hatch.ts N/A N/A SKIP (new to coverage)
wordpress-plugin/src/test/index.test.ts SKIP (ignored)

✅ Coverage Report — typescript

Metric Value
Current coverage 96.58% (2681/2776)
Baseline coverage 96.58% (2681/2776)
Result PASS

Changed Files

File Baseline Current Status
src/wordpress/types.ts SKIP (ignored)
src/yjs/types.ts SKIP (ignored)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens the repo’s “lint as a gate” tooling by adding knip (unused files/deps/exports detection) to local + CI lint flows, removing/privatizing code surfaced by knip, and aligning formatting behavior by overriding the WordPress plugin’s aliased wp-prettier to use stock Prettier 3.8.x.

Changes:

  • Add and configure knip (root + wordpress-plugin workspaces) and run it in npm run lint, lint:fix, and the pre-commit hook.
  • Remove/stop exporting dead or file-local-only symbols and re-home the corrupt-entry test coverage onto subscribeToCommandSync.
  • Pin prettier in wordpress-plugin/ via overrides to evict the stale wp-prettier fork and avoid editor/CLI format churn.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wordpress-plugin/src/test-hatch.ts Removes now-unnecessary extraneous-deps eslint suppression for @wordpress/sync.
wordpress-plugin/src/sync/test/command-sync.test.ts Updates tests to use production write path; removes tests for removed exports; re-homes corrupt-entry coverage to subscription path.
wordpress-plugin/src/sync/command-sync.ts Removes getCommandsFromSync/removeCommandFromSync exports and associated code; cleans import lint suppressions.
wordpress-plugin/src/store/types.ts Makes store-internal interfaces non-exported to reduce unused exports.
wordpress-plugin/src/components/ConversationPanel/use-resizable-sidebar.tsx Makes sidebar width constants file-local (no longer exported).
wordpress-plugin/package.json Adds explicit dev deps needed for knip/lint accuracy; adds prettier override.
wordpress-plugin/package-lock.json Updates lockfile reflecting new deps and Prettier override (stock Prettier).
tests/unit/prompts/helpers.ts Removes unused re-export(s) flagged by knip.
tests/e2e/test.ts Makes fixture interface file-local (no longer exported).
tests/e2e/helpers/playground.ts Makes unused constants/functions file-local; removes unused helper export.
src/yjs/types.ts Removes unused Yjs import and dead YBlockAttributes type; makes some interfaces file-local.
src/wordpress/types.ts Makes wire-envelope interfaces file-local (only SyncPayload remains exported).
README.md Updates lint description to include knip.
package.json Adds knip script and wires knip into lint flows; drops unneeded types package.
package-lock.json Updates lockfile for knip and dependency graph changes.
knip.jsonc Adds knip configuration with root + plugin workspaces.
CLAUDE.md Updates local workflow docs for knip and lint changes.
.husky/pre-commit Runs knip in pre-commit in addition to lint-staged.
Files not reviewed (1)
  • wordpress-plugin/package-lock.json: Language not supported

Comment thread README.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread CLAUDE.md Outdated
pento added 3 commits June 7, 2026 18:21
Removing the well-covered getCommandsFromSync / removeCommandFromSync dropped command-sync.ts below the coverage gate. Its build-guarded __getInternals test-hatch seam was already uncovered (its only consumer, test-hatch.test.ts, mocks it), so cover both WPCE_TEST_HATCH branches directly. command-sync.ts is back to 100% line coverage.
Removing the well-covered command-sync helpers shrank the coverage denominator, tipping the overall plugin coverage ratchet below baseline. index.ts's build-guarded test-hatch import (gated on WPCE_TEST_HATCH) was uncovered; load the module with the flag enabled so the dynamic import and installTestHatch run. index.ts is now 100%, lifting overall plugin coverage back above the baseline.
Addresses CoPilot review on #102: the npm run lint one-liners in README.md and CLAUDE.md omitted stylelint (it runs via the plugin lint:style step); the pre-commit lint-staged description omitted the SCSS stylelint and PHP phpcbf/PHPStan steps; and CLAUDE.md's lint-everything line was missing knip.
Copilot AI review requested due to automatic review settings June 7, 2026 08:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • wordpress-plugin/package-lock.json: Language not supported

@pento pento merged commit aad263b into main Jun 7, 2026
9 checks passed
@pento pento deleted the add-knip branch June 7, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants