|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Keep Knip Green During Active Refactor |
| 4 | +nav_order: 1 |
| 5 | +parent: Applied Practice Patterns |
| 6 | +grand_parent: Nice-to-Have |
| 7 | +--- |
| 8 | + |
| 9 | +# Keep Knip Green During Active Refactor |
| 10 | + |
| 11 | +## Problem |
| 12 | + |
| 13 | +Knip findings can be valid and still block progress in the middle of multi-PR work. Typical cases: |
| 14 | + |
| 15 | +- a file intentionally removed in one PR but still referenced in another open branch |
| 16 | +- dependencies temporarily present during migration |
| 17 | +- exported types kept as public API even when not used internally |
| 18 | + |
| 19 | +## Value |
| 20 | + |
| 21 | +- CI stays green for the team. |
| 22 | +- Temporary debt is explicit instead of hidden. |
| 23 | +- Cleanup work is tracked and reversible. |
| 24 | + |
| 25 | +## When to use |
| 26 | + |
| 27 | +Use this pattern only when all conditions are true: |
| 28 | + |
| 29 | +1. The work is intentionally split across multiple PRs. |
| 30 | +2. Every suppression has an owner and linked ticket. |
| 31 | +3. Every suppression has a removal trigger (date or merge milestone). |
| 32 | + |
| 33 | +## Flow (Human + LLM) |
| 34 | + |
| 35 | +1. Run Knip and classify findings into: |
| 36 | + - real dead code (remove now) |
| 37 | + - intentional API surface (document and allowlist) |
| 38 | + - temporary in-progress state (short-term suppression) |
| 39 | +2. Apply real fixes first (delete files, remove unused exports/dependencies). |
| 40 | +3. Add minimal temporary suppressions in Knip config with reason + ticket + expiry. |
| 41 | +4. Re-run Knip and confirm clean output before merge. |
| 42 | +5. Create follow-up cleanup task and fail that task if suppressions remain past expiry. |
| 43 | + |
| 44 | +## Example Config Pattern |
| 45 | + |
| 46 | +Use a config file where suppressions can be commented and reviewed: |
| 47 | + |
| 48 | +```ts |
| 49 | +// knip.config.ts |
| 50 | +export default { |
| 51 | + // Temporary: FE-142, remove after refactor phase 2 (2026-03-15) |
| 52 | + ignoreDependencies: ['autoprefixer'], |
| 53 | + |
| 54 | + // Temporary: FE-142, file removed after router split lands |
| 55 | + ignore: ['src/lib/index.ts'], |
| 56 | +}; |
| 57 | +``` |
| 58 | + |
| 59 | +## Example Triage Outcome |
| 60 | + |
| 61 | +Given a report like: |
| 62 | + |
| 63 | +- `src/lib/index.ts` deleted |
| 64 | +- `autoprefixer` removed |
| 65 | +- `handleGetBase`, `handleListNamespaces`, `handleGetVariant` exports removed |
| 66 | +- `ListNamespacesInput`, `ListResumesInput`, `NamespaceRoutes`, `VariantInfo` intentionally kept as public API |
| 67 | + |
| 68 | +A clean policy is: |
| 69 | + |
| 70 | +1. Keep completed removals as-is. |
| 71 | +2. Keep intentional API exports documented in API-contract docs. |
| 72 | +3. Only suppress what is still transient, and time-box it. |
| 73 | + |
| 74 | +## References |
| 75 | + |
| 76 | +- [Applied Practice Patterns](applied-practice-patterns.md) |
| 77 | +- [CI Quality Gates](ci-quality-gates.md) |
| 78 | +- [Documentation Structure](../03-should-have/documentation-structure.md) |
0 commit comments