# chore: add Knip checks

Knip detects unused files and dependencies; running it locally and in CI keeps the monorepo clean and prevents dead code from accumulating.

| | |
| --- | --- |
| Status | MERGED |
| Source | github:vitest-dev/vitest#10847 |
| Original | https://github.com/vitest-dev/vitest/pull/10847 |
| Workspace | Showcase |
| Tags | github, code, jsonc, config, typescript, json |

## What it does

**Most of this change is one file: pnpm-lock.yaml holds 73% of the edited lines.**

48 files changed across 4 areas of vitest-dev/vitest, 926 added and 424 removed.

Knip detects unused files and dependencies; running it locally and in CI keeps the monorepo clean and prevents dead code from accumulating.

**Diagram: Where the change landed. Node size is not to scale; the line counts are exact.**

- vitest (48 files, 1350 lines) [accent]
- Config (8 files, 997 lines) [bad]
- Source (38 files, 316 lines) [accent]
- Build & CI (1 file, 36 lines) [bad]
- Docs (1 file, 1 lines) [neutral]
- pnpm-lock.yaml (+728 −254) [bad]
- vitest -> Config
- vitest -> Source
- vitest -> Build & CI
- vitest -> Docs
- Config -> pnpm-lock.yaml : heaviest

- **Heaviest file.** pnpm-lock.yaml, +728 −254, which is 73% of the change.
- **No test changed.** 38 source files changed with no accompanying test edit.
- **Configuration touched.** pnpm-lock.yaml, package.json, package.json. Config changes are small in the diff and large in effect.
- **Spread.** 48 files, 1350 changed lines in total.

## How it works

**The largest single edit is in knip.jsonc.**

Quoted verbatim from the diff. This is the biggest hunk by changed lines, which is where a reviewer's attention usually belongs first.

**Diagram: Source files matched to test files by filename. A name-based match, so treat it as a prompt to look rather than as proof.**

- NO TEST CHANGED (38)
  - knip.jsonc (+108 −0) [bad]
  - utils.ts (+1 −30) [bad]
  - types.ts (+4 −9) [bad]
  - types.ts (+0 −12) [bad]
  - esmWalker.ts (+6 −6) [bad]
- TEST CHANGED TOO (0)
  - no source file paired [bad]

```diff
@@ -0,0 +1,108 @@
+{
+  "$schema": "https://unpkg.com/knip@6/schema-jsonc.json",
+  "ignoreWorkspaces": [
+    "examples/*",
+    "test/e2e/dts/*",
+    "test/e2e/fixtures/conditions-pkg"
+  ],
+  "ignoreBinaries": ["yq"],
+  "ignoreIssues": {
+    "docs/.vitepress/blog.data.ts": ["files"],
+    "docs/.vitepress/components/*.vue": ["files"],
+    "docs/.vitepress/contributors.ts": ["types"],
+    "docs/.vitepress/meta.ts": ["exports"],
+    "docs/.vitepress/sponsors.ts": ["files"],
+    "docs/.vitepress/theme/*.vue": ["files"],
+    // Test workspaces are package API consumers, not Knip lint targets; many
+    // intentionally contain dead, virtual, and unresolved fixture modules.
+    "test/**": [
+      "files",
+      "devDependencies",
+      "unlisted",
```

_knip.jsonc, +108 −0. The largest hunk in the largest file._

## File map

**Every file this change touches, heaviest first.**

Role is inferred from the path and risk from the path and the line count. Neither was read from the code.

| File | Role | Change | Risk |
| --- | --- | --- | --- |
| `pnpm-lock.yaml` | application code | modified, patch unavailable (generated or vendored file) | high |
| `knip.jsonc` | application code | added, +108 −0 | medium |
| `.github/workflows/knip.yml` | application code | added, +36 −0 | high |
| `packages/snapshot/src/port/utils.ts` | application code | modified, +1 −30 | low |
| `packages/ui/client/composables/explorer/types.ts` | application code | modified, +4 −9 | low |
| `packages/browser/src/types.ts` | application code | modified, +0 −12 | low |
| `packages/mocker/src/node/esmWalker.ts` | application code | modified, +6 −6 | low |
| `packages/ui/types.ts` | application code | modified, +0 −12 | low |
| `packages/ui/client/composables/client/index.ts` | application code | modified, +2 −8 | low |
| `packages/browser/src/client/tester/rpc.ts` | test coverage | modified, +0 −8 | low |
| `packages/pretty-format/src/plugins/DOMElement.ts` | application code | modified, +2 −6 | low |
| `packages/snapshot/src/client.ts` | application code | modified, +1 −7 | low |
| `package.json` | application code | modified, +4 −3 | low |
| `packages/ui/client/utils/task.ts` | application code | modified, +0 −7 | low |
| `packages/browser-playwright/src/commands/utils.ts` | application code | modified, +0 −6 | low |
| `packages/browser/src/client/tester/trace.ts` | test coverage | modified, +3 −3 | low |
| `packages/pretty-format/src/plugins/ReactTestComponent.ts` | test coverage | modified, +3 −3 | low |
| `packages/web-worker/src/utils.ts` | application code | modified, +0 −6 | low |
| `packages/browser/src/client/utils.ts` | application code | modified, +2 −2 | low |
| `packages/pretty-format/src/plugins/AsymmetricMatcher.ts` | application code | modified, +2 −2 | low |
| `packages/pretty-format/src/plugins/DOMCollection.ts` | application code | modified, +2 −2 | low |
| `packages/pretty-format/src/plugins/Immutable.ts` | application code | modified, +2 −2 | low |
| `packages/pretty-format/src/plugins/ReactElement.ts` | application code | modified, +2 −2 | low |
| `packages/snapshot/src/port/mockSerializer.ts` | application code | modified, +2 −2 | low |

## Receipts

**Where each number above comes from.**

All of it is arithmetic over the file list and the check results, so it can be recomputed from the source.

- **Claim.** 48 files changed, +926 −424.
  - Evidence: knip.jsonc (+108 −0); .github/workflows/knip.yml (+36 −0); packages/snapshot/src/port/utils.ts (+1 −30)
  - Where: https://github.com/vitest-dev/vitest/pull/10847
- **Claim.** pnpm-lock.yaml carries 73% of the changed lines.
  - Evidence: 982 of 1350 changed lines
  - Where: pnpm-lock.yaml
- **Claim.** It arrived as 4 commits.
  - Evidence: chore: add knip checks
  - Where: commit cccb688
- **Claim.** CI reports 0 failing of 28.
  - Evidence: Merge Reports
  - Where: CI check: Merge Reports
- **Claim.** The change drew 1 comment.
  - Evidence: ### <span aria-hidden="true">✅</span> Deploy Preview for *vitest-dev* ready! | Name | Link | |:-:|------------------------| |<span aria-hidd…
  - Where: comment by netlify[bot]

## Where to attack

**What the shape of this diff suggests looking at first.**

These come from structure alone: which areas were touched, what was not touched alongside them, and what CI says. None of them is a judgement about the code.

- **Configuration changed** (high)
  - pnpm-lock.yaml, package.json, packages/ui/package.json changed. A config edit is usually a handful of lines and decides behaviour for an entire environment, so diff size is a poor guide to its blast radius.
  - Mitigation: Check what reads each of these values, and in which environments they differ.
- **Source changed with no test changed** (medium)
  - 38 source files changed and no test file moved with them. Existing tests may already cover this, or they may not; the diff cannot say which.
  - Mitigation: Confirm whether coverage already exists for the changed paths before approving.
- **pnpm-lock.yaml dominates the diff** (medium)
  - 73% of the changed lines are in one file, so reviewing the other 47 files carefully still leaves most of the change unread.
  - Mitigation: Budget the review time accordingly.
- **1 file has no visible patch** (low)
  - pnpm-lock.yaml could not be retrieved, so nothing in this brief accounts for their contents.
  - Mitigation: Open these directly in the source.

## Merge order

**A reading order for the review, not a deployment plan.**

Ordered by how expensive each part is to get wrong, which is a structural property rather than an informed one.

1. **Review the configuration changes.** pnpm-lock.yaml, package.json, package.json. Smallest diff, widest effect.
2. **Then pnpm-lock.yaml.** The largest single file in the change, +728 −254.
3. **Decide whether a test is needed.** Nothing in this change adds or edits one.

## What this brief could not check

- No language model read this change. Every statement here is computed from file paths, line counts, and CI status, so it describes the shape of the diff and not what the diff means.
- 1 patch(es) were not retrieved, so any file among them is described by its stat line only.
- No test file changed, so nothing here is evidence that the change works.
