// Only Component1 is used elsewhereexport const Component1 = () => <div>Used</div>;export const Component2 = () => <div>Never imported!</div>; // Knip will find this
Dead Files:
// oldUtils.ts - no imports anywhereexport const formatDate = (date: Date) => { // This entire file is unused};
Unused Dependencies:
{ "dependencies": { "used-package": "^1.0.0", "never-imported": "^2.0.0" // Knip will flag this }}
// components/index.tsexport * from "./Button";export * from "./Input";export * from "./Card";export * from "./OldComponent"; // No one uses this anymore// components/OldComponent.tsxexport const OldComponent = () => { return <div>I'm never used!</div>;};
Running knip will show:
unused-export components/index.ts:4 - export from './OldComponent'unused-file components/OldComponent.tsx - file is never imported
Note: While Knip is great at finding unused code, always verify its suggestions before deletion. Some code might be used dynamically or through reflection.