Conversation
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.
✅ Coverage Report — plugin-php
✅ Coverage Report — plugin-typescript
Changed Files
✅ Coverage Report — typescript
Changed Files
|
There was a problem hiding this comment.
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-pluginworkspaces) and run it innpm 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
prettierinwordpress-plugin/viaoverridesto evict the stalewp-prettierfork 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
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.
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.
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-prettierfork so editor and CLI formatting agree.knip
knip.jsonc— root andwordpress-pluginas separate workspaces.npm run lintandlint:fix(check-only), aknipscript, and.husky/pre-commit. CI is covered automatically since it runsnpm run lint.YBlockAttributes(and its orphanedyjsimport), the unusedupdateCommande2e helper, a redundantfakeUserre-export, and the test-onlyremoveCommandFromSync/getCommandsFromSync— the latter's corrupt-entry coverage re-homed ontosubscribeToCommandSync.types.ts, e2e helpers, sidebar constants).@wordpress/sync,@wordpress/hooks, plusstylelint+@wordpress/stylelint-config(so knip's stylelint plugin creditsstylelint-config-prettier-scssvia the.stylelintrc.jsonextends). This let the now-redundanteslint-disable import/no-extraneous-dependenciesdirectives go.@types/eslint__js(@eslint/jsships its own types).wp-prettier eviction
@wordpress/scriptspullsprettierin aliased tonpm:wp-prettier@3.0.3(Automattic's fork, frozen at upstream 3.0.3). Editors resolving the plugin's copy formattedwordpress-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. Aprettieroverride inwordpress-plugin/package.jsonpins stock 3.8.x across the plugin tree so the editor and CLI agree.@wordpress/scriptsbuild/test/lint-style don't invoke prettier, so nothing breaks.Verification
npm run typecheck(root + plugin) — cleannpm run lint(ESLint + stylelint + markdownlint + Prettier + knip) — greennpm test(1269) + plugin Jest (427) — greennpm run build:all— greencommand-sync.ts98.49% lines; the re-homed corrupt-entry branch is covered