@@ -10,10 +10,11 @@ Knip provides the following built-in reporters:
1010- [ ` codeclimate ` ] [ 1 ]
1111- [ ` codeowners ` ] [ 2 ]
1212- ` compact `
13- - [ ` disclosure ` ] [ 3 ]
14- - [ ` github-actions ` ] [ 4 ]
15- - [ ` json ` ] [ 5 ]
16- - [ ` markdown ` ] [ 6 ]
13+ - [ ` cycles ` ] [ 3 ]
14+ - [ ` disclosure ` ] [ 4 ]
15+ - [ ` github-actions ` ] [ 5 ]
16+ - [ ` json ` ] [ 6 ]
17+ - [ ` markdown ` ] [ 7 ]
1718- ` symbols ` (default)
1819
1920Example usage:
@@ -54,16 +55,44 @@ $ knip --reporter codeclimate
5455### CODEOWNERS
5556
5657When a ` .github/CODEOWNERS ` file exists, each entry gains an ` owners ` array.
57- Point the reporter at a different path through [ ` --reporter-options ` ] [ 7 ] :
58+ Point the reporter at a different path through [ ` --reporter-options ` ] [ 8 ] :
5859
5960``` sh
6061knip --reporter json --reporter-options ' {"codeowners":"docs/CODEOWNERS"}'
6162```
6263
63- For a typed object instead of JSON to parse, write a [ custom reporter] [ 8 ] .
64- Coding agents can also call Knip through the [ MCP server] [ 9 ] , which returns
64+ For a typed object instead of JSON to parse, write a [ custom reporter] [ 9 ] .
65+ Coding agents can also call Knip through the [ MCP server] [ 10 ] , which returns
6566structured results and configuration hints directly.
6667
68+ ### Cycles
69+
70+ A verbose, multi-line tree view of [ circular dependencies] [ 11 ] . Each file path
71+ is suffixed with the location of the import that continues the cycle. Each edge
72+ shows the import kind and specifier, descends one file per level, and closes
73+ (` ↩ ` ) back to the file it started from. Enable the ` cycles ` issue type (e.g.
74+ with ` --cycles ` ) and select the reporter:
75+
76+ ``` text
77+ $ knip --cycles --reporter cycles
78+
79+ Circular dependencies (1)
80+
81+ src/i18n/index.ts:1:28
82+ └── import ./middleware → src/i18n/middleware.ts:3:15
83+ └── re-export ../core/i18n/handler → src/core/i18n/handler.ts:5:10
84+ └── import ../../i18n → src/i18n/index.ts:1:28 ↩
85+ ```
86+
87+ Knip reports representative cycle paths found while walking the module graph.
88+ This is not an exhaustive list of every possible simple cycle in a cyclic
89+ subgraph, because that can produce a noisy and very large report. If the same
90+ file participates in multiple distinct reported paths, each path is shown
91+ separately. Dynamic imports are ignored by default because they are commonly
92+ used to avoid synchronous circular loads; set [ ` cycles.dynamicImports ` ] [ 12 ] to
93+ include them. Repeated starting imports are grouped under one heading. Use
94+ [ ` cycles.allow ` ] [ 12 ] to accept known cycle paths.
95+
6796### Disclosure
6897
6998This reporter is useful for sharing large reports. Groups of issues are rendered
@@ -169,9 +198,9 @@ every issue found in one file:
169198| ` owners ` | ` { name }[] ` | Code owners, only when a ` CODEOWNERS ` file is found |
170199| _ issue type_ | array | One key per enabled issue type (see below) |
171200
172- Each entry carries a key for ** every enabled [ issue type] [ 10 ] ** , so the keys are
201+ Each entry carries a key for ** every enabled [ issue type] [ 11 ] ** , so the keys are
173202the same across entries. An array is empty when that file has no issues of that
174- type. Drop a type's key by disabling it with [ filters or rules] [ 11 ] .
203+ type. Drop a type's key by disabling it with [ filters or rules] [ 13 ] .
175204
176205Issue-type items are objects with position info:
177206
@@ -183,7 +212,7 @@ Issue-type items are objects with position info:
183212| ` col ` | ` number? ` | 1-based column |
184213| ` pos ` | ` number? ` | Character offset |
185214
186- See [ Issue types] [ 10 ] for the full set of issue-type keys.
215+ See [ Issue types] [ 11 ] for the full set of issue-type keys.
187216
188217### Markdown
189218
@@ -311,12 +340,14 @@ knip --preprocessor ./preprocess.ts
311340
312341[ 1 ] : #codeclimate
313342[ 2 ] : #codeowners
314- [ 3 ] : #disclosure
315- [ 4 ] : #github-actions
316- [ 5 ] : #json
317- [ 6 ] : #markdown
318- [ 7 ] : ../reference/cli.md#--reporter-options-json
319- [ 8 ] : #custom-reporters
320- [ 9 ] : ../reference/integrations.md
321- [ 10 ] : ../reference/issue-types.md
322- [ 11 ] : ./rules-and-filters.md
343+ [ 3 ] : #cycles
344+ [ 4 ] : #disclosure
345+ [ 5 ] : #github-actions
346+ [ 6 ] : #json
347+ [ 7 ] : #markdown
348+ [ 8 ] : ../reference/cli.md#--reporter-options-json
349+ [ 9 ] : #custom-reporters
350+ [ 10 ] : ../reference/integrations.md
351+ [ 11 ] : ../reference/issue-types.md
352+ [ 12 ] : ../reference/configuration.md#cycles
353+ [ 13 ] : ./rules-and-filters.md
0 commit comments