Knip Configuration
This plugin uses your project's Knip configuration. See the official Knip configuration reference for complete documentation.
Quick Setup
bash
npx knip --initConfiguration File
Create knip.json or knip.jsonc in your project root:
json
{
"$schema": "https://unpkg.com/knip@latest/schema.json",
"entry": ["src/index.ts", "src/main.ts"],
"project": ["src/**/*.ts"],
"ignore": ["**/*.test.ts", "**/*.spec.ts"]
}Key Options
| Option | Description | Reference |
|---|---|---|
entry | Entry points for your application | Entry Files |
project | Files to analyze (glob patterns) | Project Files |
ignore | Files to exclude from analysis | Handling Issues |
ignoreDependencies | Dependencies to ignore | Configuration |
ignoreBinaries | Binaries to ignore | Configuration |
Framework Plugins
Knip auto-detects frameworks and enables appropriate plugins. See Knip Plugins for the full list.
Example with explicit plugin config:
json
{
"vite": {
"config": ["vite.config.ts"]
},
"vitest": {
"config": ["vitest.config.ts"]
}
}Monorepo Configuration
For workspaces, see Knip Workspaces:
json
{
"workspaces": {
"packages/*": {
"entry": ["src/index.ts"],
"project": ["src/**/*.ts"]
}
}
}Ignore Patterns
To ignore false positives, see Handling Issues:
json
{
"ignore": ["**/fixtures/**"],
"ignoreDependencies": ["some-peer-dep"],
"ignoreExportsUsedInFile": true
}