@knip/mcp 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Knip MCP Server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
30
30
|
"zod": "^4.1.11",
|
|
31
|
-
"knip": "^5.
|
|
31
|
+
"knip": "^5.81.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18.18.0"
|
|
@@ -100,16 +100,31 @@ The following options are available inside workspace configurations:
|
|
|
100
100
|
Use `--debug` for verbose output and see the workspaces Knip includes, their
|
|
101
101
|
configurations, enabled plugins, glob options and resolved files.
|
|
102
102
|
|
|
103
|
-
##
|
|
103
|
+
## Filter workspaces
|
|
104
104
|
|
|
105
|
-
Use the `--workspace` (or `-W`) argument to
|
|
106
|
-
Knip run faster). Example:
|
|
105
|
+
Use the `--workspace` (or `-W`) argument to select one or more workspaces:
|
|
107
106
|
|
|
108
107
|
```sh
|
|
109
108
|
knip --workspace packages/my-lib
|
|
110
109
|
```
|
|
111
110
|
|
|
112
|
-
|
|
111
|
+
The filter supports multiple formats:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
knip --workspace @myorg/my-lib # Package name
|
|
115
|
+
knip --workspace '@myorg/*' # Package name glob
|
|
116
|
+
knip --workspace packages/my-lib # Directory path
|
|
117
|
+
knip --workspace './apps/*' # Directory glob
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Combine selectors to include or exclude workspaces:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
knip --workspace @myorg/* --workspace '!@myorg/legacy'
|
|
124
|
+
knip --workspace './apps/*' --workspace '@shared/utils'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This will include the target workspace(s), but also ancestor and dependent
|
|
113
128
|
workspaces. For two reasons:
|
|
114
129
|
|
|
115
130
|
- Ancestor workspaces may list dependencies in `package.json` the linted
|
|
@@ -90,7 +90,7 @@ a regex that works too:
|
|
|
90
90
|
|
|
91
91
|
<img src="/screenshots/trace-dependency.png" alt="trace dependency" class="mw500" />
|
|
92
92
|
|
|
93
|
-
Use [--workspace \[
|
|
93
|
+
Use [--workspace \[filter\]][8] to filter accordingly.
|
|
94
94
|
|
|
95
95
|
#### Legend
|
|
96
96
|
|
|
@@ -124,7 +124,7 @@ to [open an issue on GitHub][14].
|
|
|
124
124
|
[5]: ../guides/handling-issues.mdx
|
|
125
125
|
[6]: ./issue-reproduction.md
|
|
126
126
|
[7]: ../reference/known-issues.md
|
|
127
|
-
[8]: ../reference/cli.md#--workspace-
|
|
127
|
+
[8]: ../reference/cli.md#--workspace-filter
|
|
128
128
|
[9]: ../explanations/entry-files.md
|
|
129
129
|
[10]: ../explanations/plugins.md
|
|
130
130
|
[11]: ../features/production-mode.md
|
|
@@ -36,7 +36,7 @@ Also see [related tooling][2].
|
|
|
36
36
|
| [Strict mode][23] | Use `--strict` to isolate workspaces and consider only `dependencies` |
|
|
37
37
|
| [Trace][24] | Trace exports to find where they are used |
|
|
38
38
|
| [Watch mode][25] | Use `--watch` for live updates of unused files and exports |
|
|
39
|
-
| [Workspace][26] | Use `--workspace` to
|
|
39
|
+
| [Workspace][26] | Use `--workspace` to filter workspaces in a monorepo |
|
|
40
40
|
|
|
41
41
|
[1]: ../reference/issue-types.md
|
|
42
42
|
[2]: ../reference/related-tooling.md
|
|
@@ -23,152 +23,6 @@ Shortcut: `-n`
|
|
|
23
23
|
Don't show dynamic progress updates. Progress is automatically disabled in CI
|
|
24
24
|
environments.
|
|
25
25
|
|
|
26
|
-
### `knip-bun`
|
|
27
|
-
|
|
28
|
-
Run Knip using the Bun runtime (instead of Node.js + jiti).
|
|
29
|
-
|
|
30
|
-
```shell
|
|
31
|
-
knip-bun
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
This is equal to `bunx --bun knip`
|
|
35
|
-
|
|
36
|
-
Requires [Bun][1] to be installed. Also see [known issues][2] for the type of
|
|
37
|
-
issues this might help with.
|
|
38
|
-
|
|
39
|
-
### NO_COLOR
|
|
40
|
-
|
|
41
|
-
The default reporters use the [NO_COLOR][3] friendly [picocolors][4]:
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
NO_COLOR=1 knip
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Troubleshooting
|
|
48
|
-
|
|
49
|
-
### `--debug`
|
|
50
|
-
|
|
51
|
-
Shortcut: `-d`
|
|
52
|
-
|
|
53
|
-
Show debug output.
|
|
54
|
-
|
|
55
|
-
### `--memory`
|
|
56
|
-
|
|
57
|
-
```txt frame=terminal
|
|
58
|
-
knip --memory
|
|
59
|
-
|
|
60
|
-
(results)
|
|
61
|
-
|
|
62
|
-
# heapUsed heapTotal freemem
|
|
63
|
-
-- -------- --------- -------
|
|
64
|
-
0 42.09 70.91 2251.00
|
|
65
|
-
1 927.04 1042.58 1166.47
|
|
66
|
-
2 973.29 1047.33 1160.92
|
|
67
|
-
3 971.54 1079.83 1121.66
|
|
68
|
-
4 997.80 1080.33 1120.34
|
|
69
|
-
5 1001.88 1098.08 1100.72
|
|
70
|
-
6 1038.69 1116.58 1100.72
|
|
71
|
-
7 1082.12 1166.33 1100.72
|
|
72
|
-
8 1145.46 1224.50 1100.72
|
|
73
|
-
9 1115.82 1240.25 1100.72
|
|
74
|
-
10 1182.35 1249.75 973.05
|
|
75
|
-
11 637.32 1029.17 943.63
|
|
76
|
-
12 674.30 1029.33 943.39
|
|
77
|
-
13 682.24 1029.33 941.63
|
|
78
|
-
14 707.70 1029.33 937.48
|
|
79
|
-
|
|
80
|
-
Total running time: 4.3s
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Can be used with [--isolate-workspaces][5] to see the difference in garbage
|
|
84
|
-
collection during the process.
|
|
85
|
-
|
|
86
|
-
### `--memory-realtime`
|
|
87
|
-
|
|
88
|
-
Use this if Knip crashes to still see memory usage info over time:
|
|
89
|
-
|
|
90
|
-
```txt frame=terminal
|
|
91
|
-
knip --memory-realtime
|
|
92
|
-
|
|
93
|
-
# heapUsed heapTotal freemem
|
|
94
|
-
- -------- --------- -------
|
|
95
|
-
0 42.09 70.91 2251.00
|
|
96
|
-
1 927.04 1042.58 1166.47
|
|
97
|
-
...mem info keeps being logged...
|
|
98
|
-
|
|
99
|
-
(results)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### `--performance`
|
|
103
|
-
|
|
104
|
-
Use this flag to get the count and execution time of potentially expensive
|
|
105
|
-
functions in a table. Example:
|
|
106
|
-
|
|
107
|
-
```txt frame=terminal
|
|
108
|
-
$ knip --performance
|
|
109
|
-
|
|
110
|
-
(results)
|
|
111
|
-
|
|
112
|
-
Name size min max median sum
|
|
113
|
-
----------------------------- ---- -------- -------- -------- --------
|
|
114
|
-
findReferences 648 84.98 7698.61 96.41 70941.70
|
|
115
|
-
createProgram 2 6295.84 7064.68 6680.26 13360.52
|
|
116
|
-
glob 6 0.05 995.78 513.82 3150.87
|
|
117
|
-
findESLintDependencies 2 0.01 74.41 37.21 74.41
|
|
118
|
-
findGithubActionsDependencies 6 0.16 12.71 0.65 23.45
|
|
119
|
-
findBabelDependencies 2 0.00 38.75 19.37 38.75
|
|
120
|
-
...
|
|
121
|
-
|
|
122
|
-
Total running time: 5s
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
- `name`: the internal Knip function name
|
|
126
|
-
- `size`: number of function invocations
|
|
127
|
-
- `min`: the fastest invocation
|
|
128
|
-
- `max`: the slowest invocation
|
|
129
|
-
- `median`: the median invocation
|
|
130
|
-
- `sum` the accumulated time of all invocations
|
|
131
|
-
|
|
132
|
-
This is not yet available in Bun, since it does not support
|
|
133
|
-
`performance.timerify` ([GitHub issue][6]).
|
|
134
|
-
|
|
135
|
-
### `--performance-fn`
|
|
136
|
-
|
|
137
|
-
Limit the output of `--performance` to a single function to minimize the
|
|
138
|
-
overhead of the `timerify` Node.js built-in and focus on that function alone:
|
|
139
|
-
|
|
140
|
-
```txt frame=terminal
|
|
141
|
-
$ knip --performance-fn resolveSync
|
|
142
|
-
|
|
143
|
-
(results)
|
|
144
|
-
|
|
145
|
-
Name size min max median sum
|
|
146
|
-
----------- ----- ---- ---- ------ ------
|
|
147
|
-
resolveSync 66176 0.00 5.69 0.00 204.85
|
|
148
|
-
|
|
149
|
-
Total running time: 12.9s
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### `--trace`
|
|
153
|
-
|
|
154
|
-
Trace exports to see where they are imported.
|
|
155
|
-
|
|
156
|
-
Also see [Trace][7].
|
|
157
|
-
|
|
158
|
-
### `--trace-dependency [name]`
|
|
159
|
-
|
|
160
|
-
Trace package or binary name to see where it's referenced. Implies [--trace][8].
|
|
161
|
-
|
|
162
|
-
### `--trace-export [name]`
|
|
163
|
-
|
|
164
|
-
Trace export name to see where it's imported. Implies [--trace][8].
|
|
165
|
-
|
|
166
|
-
### `--trace-file [path]`
|
|
167
|
-
|
|
168
|
-
Trace file to see where its exports are imported. Implies [--trace][8].
|
|
169
|
-
|
|
170
|
-
## Configuration
|
|
171
|
-
|
|
172
26
|
### `--config [file]`
|
|
173
27
|
|
|
174
28
|
Use an alternative path for the configuration file. Default locations:
|
|
@@ -183,6 +37,10 @@ Use an alternative path for the configuration file. Default locations:
|
|
|
183
37
|
|
|
184
38
|
Shortcut: `-c`
|
|
185
39
|
|
|
40
|
+
### `--use-tsconfig-files`
|
|
41
|
+
|
|
42
|
+
Use `tsconfig.json` to define project files (override `project` patterns).
|
|
43
|
+
|
|
186
44
|
### `--tsConfig [file]`
|
|
187
45
|
|
|
188
46
|
Shortcut: `-t`
|
|
@@ -193,22 +51,42 @@ Using `-t jsconfig.json` is also supported.
|
|
|
193
51
|
|
|
194
52
|
Default location: `tsconfig.json`
|
|
195
53
|
|
|
196
|
-
###
|
|
54
|
+
### `knip-bun`
|
|
197
55
|
|
|
198
|
-
|
|
199
|
-
The default behavior is to lint all configured workspaces.
|
|
56
|
+
Run Knip using the Bun runtime (instead of Node.js + jiti).
|
|
200
57
|
|
|
201
|
-
|
|
58
|
+
```shell
|
|
59
|
+
knip-bun
|
|
60
|
+
```
|
|
202
61
|
|
|
203
|
-
|
|
62
|
+
This is equal to `bunx --bun knip`
|
|
204
63
|
|
|
205
|
-
|
|
64
|
+
Requires [Bun][1] to be installed. Also see [known issues][2] for the type of
|
|
65
|
+
issues this might help with.
|
|
206
66
|
|
|
207
|
-
|
|
67
|
+
### NO_COLOR
|
|
208
68
|
|
|
209
|
-
|
|
69
|
+
The built-in reporters use the [NO_COLOR][3] friendly [picocolors][4]:
|
|
210
70
|
|
|
211
|
-
|
|
71
|
+
```sh
|
|
72
|
+
NO_COLOR=1 knip
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Mode
|
|
76
|
+
|
|
77
|
+
### `--cache`
|
|
78
|
+
|
|
79
|
+
Enable caching.
|
|
80
|
+
|
|
81
|
+
Consecutive runs are 10-40% faster as the results of file analysis (AST
|
|
82
|
+
traversal) are cached. Conservative. Cache strategy based on file meta data
|
|
83
|
+
(modification time + file size).
|
|
84
|
+
|
|
85
|
+
### `--cache-location`
|
|
86
|
+
|
|
87
|
+
Provide alternative cache location.
|
|
88
|
+
|
|
89
|
+
Default location: `./node_modules/.cache/knip`
|
|
212
90
|
|
|
213
91
|
### `--include-entry-exports`
|
|
214
92
|
|
|
@@ -219,7 +97,7 @@ files when reporting unused exports:
|
|
|
219
97
|
knip --include-entry-exports
|
|
220
98
|
```
|
|
221
99
|
|
|
222
|
-
Also see [includeEntryExports][
|
|
100
|
+
Also see [includeEntryExports][5].
|
|
223
101
|
|
|
224
102
|
### `--include-libs`
|
|
225
103
|
|
|
@@ -230,16 +108,18 @@ Getting false positives for exports consumed by external libraries? Try the
|
|
|
230
108
|
knip --include-libs
|
|
231
109
|
```
|
|
232
110
|
|
|
233
|
-
Also see [external libs][
|
|
111
|
+
Also see [external libs][6].
|
|
234
112
|
|
|
235
113
|
### `--isolate-workspaces`
|
|
236
114
|
|
|
237
|
-
By default, Knip optimizes performance using [workspace sharing][
|
|
115
|
+
By default, Knip optimizes performance using [workspace sharing][7] to existing
|
|
238
116
|
TypeScript programs, based on the compatibility of their `compilerOptions`. This
|
|
239
117
|
flag disables this behavior and creates one program per workspace, which is
|
|
240
118
|
slower but memory usage is spread more evenly over time.
|
|
241
119
|
|
|
242
|
-
|
|
120
|
+
### `--no-gitignore`
|
|
121
|
+
|
|
122
|
+
Ignore `.gitignore` files.
|
|
243
123
|
|
|
244
124
|
### `--production`
|
|
245
125
|
|
|
@@ -251,32 +131,14 @@ Lint only production source files. This excludes:
|
|
|
251
131
|
- Storybook stories
|
|
252
132
|
- `devDependencies` from `package.json`
|
|
253
133
|
|
|
254
|
-
Read more at [Production Mode][
|
|
134
|
+
Read more at [Production Mode][8].
|
|
255
135
|
|
|
256
136
|
### `--strict`
|
|
257
137
|
|
|
258
138
|
Isolate workspaces and consider only direct dependencies. Implies [production
|
|
259
|
-
mode][
|
|
139
|
+
mode][9].
|
|
260
140
|
|
|
261
|
-
Read more at [Production Mode][
|
|
262
|
-
|
|
263
|
-
### `--fix`
|
|
264
|
-
|
|
265
|
-
Read more at [auto-fix][15].
|
|
266
|
-
|
|
267
|
-
### `--cache`
|
|
268
|
-
|
|
269
|
-
Enable caching.
|
|
270
|
-
|
|
271
|
-
Consecutive runs are 10-40% faster as the results of file analysis (AST
|
|
272
|
-
traversal) are cached. Conservative. Cache strategy based on file meta data
|
|
273
|
-
(modification time + file size).
|
|
274
|
-
|
|
275
|
-
### `--cache-location`
|
|
276
|
-
|
|
277
|
-
Provide alternative cache location.
|
|
278
|
-
|
|
279
|
-
Default location: `./node_modules/.cache/knip`
|
|
141
|
+
Read more at [Production Mode][8].
|
|
280
142
|
|
|
281
143
|
### `--watch`
|
|
282
144
|
|
|
@@ -286,23 +148,22 @@ added or deleted.
|
|
|
286
148
|
Watch mode focuses on imports and exports in source files. During watch mode,
|
|
287
149
|
changes in `package.json` or `node_modules` may not cause an updated report.
|
|
288
150
|
|
|
289
|
-
##
|
|
151
|
+
## Scope
|
|
290
152
|
|
|
291
|
-
|
|
292
|
-
`--exclude`:
|
|
153
|
+
### `--workspace [filter]`
|
|
293
154
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
155
|
+
Select one or multiple workspaces (including its ancestor and dependent
|
|
156
|
+
workspaces). The default behavior is to lint all configured workspaces.
|
|
157
|
+
|
|
158
|
+
Shortcut: `-W`
|
|
159
|
+
|
|
160
|
+
See [filter workspaces][10] for more details and examples.
|
|
161
|
+
|
|
162
|
+
### `--directory [dir]`
|
|
163
|
+
|
|
164
|
+
Default: `cwd` (current directory)
|
|
165
|
+
|
|
166
|
+
Run the process from a different directory.
|
|
306
167
|
|
|
307
168
|
### `--exclude`
|
|
308
169
|
|
|
@@ -326,12 +187,28 @@ knip --include files,dependencies
|
|
|
326
187
|
knip --include files --include dependencies
|
|
327
188
|
```
|
|
328
189
|
|
|
190
|
+
Available [issue types][11] when filtering output using `--include` or
|
|
191
|
+
`--exclude`:
|
|
192
|
+
|
|
193
|
+
- `files`
|
|
194
|
+
- `dependencies`
|
|
195
|
+
- `unlisted`
|
|
196
|
+
- `unresolved`
|
|
197
|
+
- `exports`
|
|
198
|
+
- `nsExports`
|
|
199
|
+
- `classMembers`
|
|
200
|
+
- `types`
|
|
201
|
+
- `nsTypes`
|
|
202
|
+
- `enumMembers`
|
|
203
|
+
- `duplicates`
|
|
204
|
+
- `catalog`
|
|
205
|
+
|
|
329
206
|
### `--dependencies`
|
|
330
207
|
|
|
331
208
|
Shortcut to include all types of dependency issues:
|
|
332
209
|
|
|
333
210
|
```sh
|
|
334
|
-
--include dependencies,
|
|
211
|
+
--include dependencies,unlisted,binaries,unresolved,catalog
|
|
335
212
|
```
|
|
336
213
|
|
|
337
214
|
### `--exports`
|
|
@@ -342,9 +219,13 @@ Shortcut to include all types of export issues:
|
|
|
342
219
|
--include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates
|
|
343
220
|
```
|
|
344
221
|
|
|
345
|
-
### `--
|
|
222
|
+
### `--files`
|
|
346
223
|
|
|
347
|
-
|
|
224
|
+
Shortcut to include file issues:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
--include files
|
|
228
|
+
```
|
|
348
229
|
|
|
349
230
|
### `--tags`
|
|
350
231
|
|
|
@@ -380,7 +261,51 @@ notation below is valid and will report only exports tagged `@lintignore` or
|
|
|
380
261
|
knip --tags @lintignore --tags @internal
|
|
381
262
|
```
|
|
382
263
|
|
|
383
|
-
##
|
|
264
|
+
## Fix
|
|
265
|
+
|
|
266
|
+
### `--fix`
|
|
267
|
+
|
|
268
|
+
Read more at [auto-fix][12].
|
|
269
|
+
|
|
270
|
+
### `--fix-type`
|
|
271
|
+
|
|
272
|
+
Fix only issues of type, can be comma-separated or repeated.
|
|
273
|
+
|
|
274
|
+
More info about fixable types at [issue types][11]
|
|
275
|
+
|
|
276
|
+
### `--allow-remove-files`
|
|
277
|
+
|
|
278
|
+
Allow Knip to remove files (with `--fix`).
|
|
279
|
+
|
|
280
|
+
### `--format`
|
|
281
|
+
|
|
282
|
+
Format modified files after `--fix` using the local formatter.
|
|
283
|
+
|
|
284
|
+
## Output
|
|
285
|
+
|
|
286
|
+
### `--preprocessor [preprocessor]`
|
|
287
|
+
|
|
288
|
+
Preprocess the results before providing it to the [reporter(s)][13].
|
|
289
|
+
|
|
290
|
+
Can be repeated. Examples:
|
|
291
|
+
|
|
292
|
+
```sh
|
|
293
|
+
knip --preprocessor ./my-preprocessor.ts
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
```sh
|
|
297
|
+
knip --preprocessor preprocessor-package
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Also see [Reporters & Preprocessors][14].
|
|
301
|
+
|
|
302
|
+
### `--preprocessor-options [json]`
|
|
303
|
+
|
|
304
|
+
Pass extra options to the preprocessor as JSON string.
|
|
305
|
+
|
|
306
|
+
```sh
|
|
307
|
+
knip --preprocessor ./preproc.ts --preprocessor-options '{"key":"value"}'
|
|
308
|
+
```
|
|
384
309
|
|
|
385
310
|
### `--reporter [reporter]`
|
|
386
311
|
|
|
@@ -390,7 +315,10 @@ Available reporters:
|
|
|
390
315
|
- `compact`
|
|
391
316
|
- `codeowners`
|
|
392
317
|
- `json`
|
|
318
|
+
- `codeclimate`
|
|
393
319
|
- `markdown`
|
|
320
|
+
- `disclosure`
|
|
321
|
+
- `github-actions`
|
|
394
322
|
|
|
395
323
|
Can be repeated. Example:
|
|
396
324
|
|
|
@@ -398,12 +326,11 @@ Can be repeated. Example:
|
|
|
398
326
|
knip --reporter compact
|
|
399
327
|
```
|
|
400
328
|
|
|
401
|
-
Also see [Reporters & Preprocessors][
|
|
329
|
+
Also see [Reporters & Preprocessors][14].
|
|
402
330
|
|
|
403
331
|
### `--reporter-options [json]`
|
|
404
332
|
|
|
405
|
-
Pass extra options to the
|
|
406
|
-
example)
|
|
333
|
+
Pass extra options to the reporter (as JSON string):
|
|
407
334
|
|
|
408
335
|
Example:
|
|
409
336
|
|
|
@@ -411,75 +338,174 @@ Example:
|
|
|
411
338
|
knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
|
|
412
339
|
```
|
|
413
340
|
|
|
414
|
-
### `--
|
|
341
|
+
### `--no-config-hints`
|
|
415
342
|
|
|
416
|
-
|
|
343
|
+
Suppress configuration hints.
|
|
417
344
|
|
|
418
|
-
|
|
345
|
+
### `--treat-config-hints-as-errors`
|
|
419
346
|
|
|
420
|
-
|
|
421
|
-
knip --preprocessor ./my-preprocessor.ts
|
|
422
|
-
```
|
|
347
|
+
Exit with non-zero exit code (`1`) if there are any configuration hints.
|
|
423
348
|
|
|
424
|
-
|
|
425
|
-
knip --preprocessor preprocessor-package
|
|
426
|
-
```
|
|
349
|
+
### `--max-issues`
|
|
427
350
|
|
|
428
|
-
|
|
351
|
+
Maximum number of issues before non-zero exit code. Default: `0`
|
|
429
352
|
|
|
430
|
-
|
|
353
|
+
### `--max-show-issues`
|
|
431
354
|
|
|
432
|
-
|
|
433
|
-
knip --preprocessor ./preproc.ts --preprocessor-options '{"key":"value"}'
|
|
434
|
-
```
|
|
355
|
+
Maximum number of issues per type to display (does not affect exit code).
|
|
435
356
|
|
|
436
|
-
|
|
357
|
+
### `--no-exit-code`
|
|
437
358
|
|
|
438
|
-
|
|
359
|
+
Always exit with code zero (`0`), even when there are lint issues.
|
|
439
360
|
|
|
440
361
|
The default exit codes:
|
|
441
362
|
|
|
442
363
|
| Code | Description |
|
|
443
364
|
| :--: | :--------------------------------------------------------------- |
|
|
444
365
|
| `0` | Knip ran successfully, no lint issues |
|
|
445
|
-
| `1` | Knip ran successfully, but there is at least one lint
|
|
366
|
+
| `1` | Knip ran successfully, but there is at least one lint issue |
|
|
446
367
|
| `2` | Knip did not run successfully due to bad input or internal error |
|
|
447
368
|
|
|
448
|
-
|
|
369
|
+
## Troubleshooting
|
|
449
370
|
|
|
450
|
-
|
|
371
|
+
### `--debug`
|
|
451
372
|
|
|
452
|
-
|
|
373
|
+
Shortcut: `-d`
|
|
453
374
|
|
|
454
|
-
|
|
375
|
+
Show [debug output][15].
|
|
455
376
|
|
|
456
|
-
### `--
|
|
377
|
+
### `--memory`
|
|
457
378
|
|
|
458
|
-
|
|
379
|
+
```txt frame=terminal
|
|
380
|
+
knip --memory
|
|
459
381
|
|
|
460
|
-
|
|
382
|
+
(results)
|
|
461
383
|
|
|
462
|
-
|
|
384
|
+
# heapUsed heapTotal freemem
|
|
385
|
+
-- -------- --------- -------
|
|
386
|
+
0 42.09 70.91 2251.00
|
|
387
|
+
1 927.04 1042.58 1166.47
|
|
388
|
+
2 973.29 1047.33 1160.92
|
|
389
|
+
3 971.54 1079.83 1121.66
|
|
390
|
+
4 997.80 1080.33 1120.34
|
|
391
|
+
5 1001.88 1098.08 1100.72
|
|
392
|
+
6 1038.69 1116.58 1100.72
|
|
393
|
+
7 1082.12 1166.33 1100.72
|
|
394
|
+
8 1145.46 1224.50 1100.72
|
|
395
|
+
9 1115.82 1240.25 1100.72
|
|
396
|
+
10 1182.35 1249.75 973.05
|
|
397
|
+
11 637.32 1029.17 943.63
|
|
398
|
+
12 674.30 1029.33 943.39
|
|
399
|
+
13 682.24 1029.33 941.63
|
|
400
|
+
14 707.70 1029.33 937.48
|
|
463
401
|
|
|
464
|
-
|
|
402
|
+
Total running time: 4.3s
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Can be used with [--isolate-workspaces][16] to see the difference in garbage
|
|
406
|
+
collection during the process.
|
|
407
|
+
|
|
408
|
+
### `--memory-realtime`
|
|
409
|
+
|
|
410
|
+
Use this if Knip crashes to still see memory usage info over time:
|
|
411
|
+
|
|
412
|
+
```txt frame=terminal
|
|
413
|
+
knip --memory-realtime
|
|
414
|
+
|
|
415
|
+
# heapUsed heapTotal freemem
|
|
416
|
+
- -------- --------- -------
|
|
417
|
+
0 42.09 70.91 2251.00
|
|
418
|
+
1 927.04 1042.58 1166.47
|
|
419
|
+
...mem info keeps being logged...
|
|
420
|
+
|
|
421
|
+
(results)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### `--performance`
|
|
425
|
+
|
|
426
|
+
Use this flag to get the count and execution time of potentially expensive
|
|
427
|
+
functions in a table. Example:
|
|
428
|
+
|
|
429
|
+
```txt frame=terminal
|
|
430
|
+
$ knip --performance
|
|
431
|
+
|
|
432
|
+
(results)
|
|
433
|
+
|
|
434
|
+
Name size min max median sum
|
|
435
|
+
----------------------------- ---- -------- -------- -------- --------
|
|
436
|
+
findReferences 648 84.98 7698.61 96.41 70941.70
|
|
437
|
+
createProgram 2 6295.84 7064.68 6680.26 13360.52
|
|
438
|
+
glob 6 0.05 995.78 513.82 3150.87
|
|
439
|
+
findESLintDependencies 2 0.01 74.41 37.21 74.41
|
|
440
|
+
findGithubActionsDependencies 6 0.16 12.71 0.65 23.45
|
|
441
|
+
findBabelDependencies 2 0.00 38.75 19.37 38.75
|
|
442
|
+
...
|
|
443
|
+
|
|
444
|
+
Total running time: 5s
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
- `name`: the internal Knip function name
|
|
448
|
+
- `size`: number of function invocations
|
|
449
|
+
- `min`: the fastest invocation
|
|
450
|
+
- `max`: the slowest invocation
|
|
451
|
+
- `median`: the median invocation
|
|
452
|
+
- `sum` the accumulated time of all invocations
|
|
453
|
+
|
|
454
|
+
This is not yet available in Bun, since it does not support
|
|
455
|
+
`performance.timerify` ([GitHub issue][17]).
|
|
456
|
+
|
|
457
|
+
### `--performance-fn`
|
|
458
|
+
|
|
459
|
+
Limit the output of `--performance` to a single function to minimize the
|
|
460
|
+
overhead of the `timerify` Node.js built-in and focus on that function alone:
|
|
461
|
+
|
|
462
|
+
```txt frame=terminal
|
|
463
|
+
$ knip --performance-fn resolveSync
|
|
464
|
+
|
|
465
|
+
(results)
|
|
466
|
+
|
|
467
|
+
Name size min max median sum
|
|
468
|
+
----------- ----- ---- ---- ------ ------
|
|
469
|
+
resolveSync 66176 0.00 5.69 0.00 204.85
|
|
470
|
+
|
|
471
|
+
Total running time: 12.9s
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### `--trace`
|
|
475
|
+
|
|
476
|
+
Trace exports to see where they are imported.
|
|
477
|
+
|
|
478
|
+
Also see [Trace][18].
|
|
479
|
+
|
|
480
|
+
### `--trace-dependency [name]`
|
|
481
|
+
|
|
482
|
+
Trace package or binary name to see where it's referenced. Implies
|
|
483
|
+
[--trace][19].
|
|
484
|
+
|
|
485
|
+
### `--trace-export [name]`
|
|
486
|
+
|
|
487
|
+
Trace export name to see where it's imported. Implies [--trace][19].
|
|
488
|
+
|
|
489
|
+
### `--trace-file [path]`
|
|
465
490
|
|
|
466
|
-
|
|
491
|
+
Trace file to see where its exports are imported. Implies [--trace][19].
|
|
467
492
|
|
|
468
493
|
[1]: https://bun.sh
|
|
469
494
|
[2]: ../reference/known-issues.md
|
|
470
495
|
[3]: https://no-color.org/
|
|
471
496
|
[4]: https://www.npmjs.com/package/picocolors
|
|
472
|
-
[5]:
|
|
473
|
-
[6]:
|
|
474
|
-
[7]: ../guides/
|
|
475
|
-
[8]:
|
|
476
|
-
[9]:
|
|
477
|
-
[10]:
|
|
478
|
-
[11]:
|
|
479
|
-
[12]: ../
|
|
480
|
-
[13]:
|
|
481
|
-
[14]:
|
|
482
|
-
[15]: ../
|
|
483
|
-
[16]:
|
|
484
|
-
[17]:
|
|
485
|
-
[18]: ../
|
|
497
|
+
[5]: ./configuration.md#includeentryexports
|
|
498
|
+
[6]: ../guides/handling-issues.mdx#external-libraries
|
|
499
|
+
[7]: ../guides/performance.md#workspace-sharing
|
|
500
|
+
[8]: ../features/production-mode.md
|
|
501
|
+
[9]: #--production
|
|
502
|
+
[10]: ../features/monorepos-and-workspaces.md#filter-workspaces
|
|
503
|
+
[11]: ./issue-types.md
|
|
504
|
+
[12]: ../features/auto-fix.mdx
|
|
505
|
+
[13]: #--reporter-reporter
|
|
506
|
+
[14]: ../features/reporters.md
|
|
507
|
+
[15]: ../guides/troubleshooting.md#debug
|
|
508
|
+
[16]: #--isolate-workspaces
|
|
509
|
+
[17]: https://github.com/oven-sh/bun/issues/9271
|
|
510
|
+
[18]: ../guides/troubleshooting.md#trace
|
|
511
|
+
[19]: #--trace
|