Skip to content

Knip Configuration

This plugin uses your project's Knip configuration. See the official Knip configuration reference for complete documentation.

Quick Setup

bash
npx knip --init

Configuration 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

OptionDescriptionReference
entryEntry points for your applicationEntry Files
projectFiles to analyze (glob patterns)Project Files
ignoreFiles to exclude from analysisHandling Issues
ignoreDependenciesDependencies to ignoreConfiguration
ignoreBinariesBinaries to ignoreConfiguration

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
}

Released under the MIT License.