chore: set up Knip - #506
Merged
Merged
Conversation
Add Knip (https://knip.dev) to find unused files, dependencies and exports across the workspace. - Add knip as a devtools catalog dependency and a `knip` root script. - Add knip.jsonc tuned for this monorepo's structure: per-workspace entry overrides for build entries not covered by package.json exports/bin, nuxt.config/uno.config paths for the packages/{oxc, rolldown,vite} Nuxt apps nested under src/, and ignoreFiles for fixtures/snapshots and Nuxt auto-import trees that Knip's Nuxt plugin can't trace back to source given the nested srcDir layout. - Fix the dependency-hygiene issues Knip's plugin detection surfaced along the way: packages/rolldown and packages/vite use the nuxi CLI without declaring nuxt; packages/core imports unocss/vite without declaring unocss; packages/ui uses @floating-ui/dom without declaring it (as a peerDependency, matching its other UI peers). - Wire a non-blocking Knip step into CI so findings surface in every build; flipping it to blocking is a follow-up once the existing findings below are triaged. Knip now reports a small set of real, pre-existing findings (2 dead files, 70 unused devDependencies, 82 unlisted dependencies, 53 unused exports, 44 unused exported types, 1 duplicate export, 1 unresolved import, 2 unlisted binaries, 6 unused catalog entries) — left as-is for a follow-up cleanup pass rather than folded into this setup. This PR was created with the help of an agent.
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
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.
Description
Adds Knip to find unused files, dependencies and exports across the workspace.
knipto thedevtoolscatalog and a rootknipscript (pnpm knip).knip.jsonc, tuned for this repo's monorepo structure:entryoverrides only where they're not already covered bypackage.json#exports/bin(which Knip resolves back to source via sourcemaps) — e.g. the standalone client dev app inpackages/core,webext's flatsrc/*.tsbuild, and the examples'playground/dev apps.nuxt/unocssconfig path overrides forpackages/{oxc,rolldown,vite}, whose Nuxt apps live nested undersrc/(srcDir: 'app') rather than at the workspace root.ignoreFilesfor fixtures/snapshots, plus thepackages/{oxc,rolldown,vite}/src/app/**Nuxt app trees — Knip's Nuxt plugin registers its component/composable auto-import compilers relative to the workspace root rather than the resolvednuxt.configlocation, so anything consumed only via Nuxt's auto-import (template tags, unimport) in these nested apps can't be traced back to source and is misreported as unused.src/node/**,src/modules/**andsrc/shared/**are unaffected.packages/rolldownandpackages/viteinvoke thenuxiCLI in their own build scripts without declaringnuxt.packages/core's standalone client importsunocss/vitewithout declaringunocss.packages/uiuses@floating-ui/domwithout declaring it — added as apeerDependency, matching its other UI peer deps.Knipstep into CI (non-blocking viacontinue-on-error, since the repo has pre-existing findings — see below).With this config, Knip reports a clean, structural baseline plus a small set of real, pre-existing findings left for a follow-up cleanup pass rather than folded into this setup PR: 2 dead files, 70 unused devDependencies, 82 unlisted dependencies, 53 unused exports, 44 unused exported types, 1 duplicate export, 1 unresolved import, 2 unlisted binaries, and 6 unused catalog entries.
Linked Issues
Additional context
Run
pnpm knipto see the current findings. Once they're triaged (fixed or added toignore*/ignoreFiles), the CI step'scontinue-on-error: truecan be dropped to make it blocking.This PR was created with the help of an agent.