Knip
What is Knip?
Section titled “What is Knip?”Knip analyzes your project and reports unused dependencies, exports, and files. It is especially useful in long-lived projects where old code paths and packages can accumulate over time.
Configuration
Section titled “Configuration”Add ignore paths to your knip.config.ts to prevent Knip from reporting false positives. This is useful to ignore paths that Knip cannot safely infer from static analysis:
const config = { ignore: ['some-config.config.ts', 'some-script.ts'],}
export default configWire it in package.json:
{ "scripts": { "knip": "knip" }}Run it with:
pnpm knipPractical Workflow
Section titled “Practical Workflow”- Run
pnpm knip. - Review findings and remove truly unused items.
- If a reported item is used by framework conventions, add a focused ignore.
- Re-run Knip until the output is clean and meaningful.