@knip/mcp 0.0.4 → 0.0.6

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.
Files changed (55) hide show
  1. package/docs/docs/blog/brief-history.md +30 -0
  2. package/docs/docs/blog/for-editors-and-agents.md +127 -0
  3. package/docs/docs/blog/knip-v3.mdx +88 -0
  4. package/docs/docs/blog/knip-v4.mdx +149 -0
  5. package/docs/docs/blog/knip-v5.mdx +190 -0
  6. package/docs/docs/blog/migration-to-v1.md +65 -0
  7. package/docs/docs/blog/release-notes-v2.md +46 -0
  8. package/docs/docs/blog/slim-down-to-speed-up.md +269 -0
  9. package/docs/docs/blog/state-of-knip.md +191 -0
  10. package/docs/docs/blog/two-years.mdx +107 -0
  11. package/docs/docs/explanations/comparison-and-migration.md +129 -0
  12. package/docs/docs/explanations/entry-files.md +70 -0
  13. package/docs/docs/explanations/plugins.md +319 -0
  14. package/docs/docs/explanations/why-use-knip.md +128 -0
  15. package/docs/docs/features/auto-fix.mdx +333 -0
  16. package/docs/docs/features/compilers.md +172 -0
  17. package/docs/docs/features/integrated-monorepos.md +61 -0
  18. package/docs/docs/features/monorepos-and-workspaces.md +134 -0
  19. package/docs/docs/features/production-mode.md +95 -0
  20. package/docs/docs/features/reporters.md +302 -0
  21. package/docs/docs/features/rules-and-filters.md +102 -0
  22. package/docs/docs/features/script-parser.md +156 -0
  23. package/docs/docs/features/source-mapping.md +100 -0
  24. package/docs/docs/guides/configuring-project-files.md +205 -0
  25. package/docs/docs/guides/contributing.md +24 -0
  26. package/docs/docs/guides/handling-issues.mdx +646 -0
  27. package/docs/docs/guides/issue-reproduction.md +94 -0
  28. package/docs/docs/guides/namespace-imports.md +125 -0
  29. package/docs/docs/guides/performance.md +97 -0
  30. package/docs/docs/guides/troubleshooting.md +136 -0
  31. package/docs/docs/guides/using-knip-in-ci.md +54 -0
  32. package/docs/docs/guides/working-with-commonjs.md +72 -0
  33. package/docs/docs/index.mdx +160 -0
  34. package/docs/docs/overview/configuration.md +104 -0
  35. package/docs/docs/overview/features.md +66 -0
  36. package/docs/docs/overview/getting-started.mdx +195 -0
  37. package/docs/docs/overview/screenshots-videos.md +42 -0
  38. package/docs/docs/playground.mdx +38 -0
  39. package/docs/docs/reference/cli.md +485 -0
  40. package/docs/docs/reference/configuration.md +413 -0
  41. package/docs/docs/reference/dynamic-configuration.mdx +72 -0
  42. package/docs/docs/reference/faq.md +441 -0
  43. package/docs/docs/reference/issue-types.md +43 -0
  44. package/docs/docs/reference/jsdoc-tsdoc-tags.md +122 -0
  45. package/docs/docs/reference/known-issues.md +64 -0
  46. package/docs/docs/reference/plugins/.gitkeep +0 -0
  47. package/docs/docs/reference/plugins.md +238 -0
  48. package/docs/docs/reference/related-tooling.md +46 -0
  49. package/docs/docs/sponsors.mdx +65 -0
  50. package/docs/docs/typescript/unused-dependencies.md +86 -0
  51. package/docs/docs/typescript/unused-exports.md +87 -0
  52. package/docs/docs/writing-a-plugin/argument-parsing.md +202 -0
  53. package/docs/docs/writing-a-plugin/index.md +376 -0
  54. package/docs/docs/writing-a-plugin/inputs.md +162 -0
  55. package/package.json +5 -3
@@ -0,0 +1,485 @@
1
+ ---
2
+ title: CLI Arguments
3
+ ---
4
+
5
+ ## General
6
+
7
+ ### `--help`
8
+
9
+ Shortcut: `-h`
10
+
11
+ Prints a summary of this page.
12
+
13
+ ### `--version`
14
+
15
+ Shortcut: `-V`
16
+
17
+ Print the version number.
18
+
19
+ ### `--no-progress`
20
+
21
+ Shortcut: `-n`
22
+
23
+ Don't show dynamic progress updates. Progress is automatically disabled in CI
24
+ environments.
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
+ ### `--config [file]`
173
+
174
+ Use an alternative path for the configuration file. Default locations:
175
+
176
+ - `knip.json`
177
+ - `knip.jsonc`
178
+ - `.knip.json`
179
+ - `.knip.jsonc`
180
+ - `knip.js`
181
+ - `knip.ts`
182
+ - `package.json#knip`
183
+
184
+ Shortcut: `-c`
185
+
186
+ ### `--tsConfig [file]`
187
+
188
+ Shortcut: `-t`
189
+
190
+ Use an alternative path for the TypeScript configuration file.
191
+
192
+ Using `-t jsconfig.json` is also supported.
193
+
194
+ Default location: `tsconfig.json`
195
+
196
+ ### `--workspace [dir]`
197
+
198
+ [Lint a single workspace][9] including its ancestor and dependent workspaces.
199
+ The default behavior is to lint all configured workspaces.
200
+
201
+ Shortcut: `-W`
202
+
203
+ ### `--directory [dir]`
204
+
205
+ Default: `cwd` (current directory)
206
+
207
+ Run the process from a different directory.
208
+
209
+ ### `--no-gitignore`
210
+
211
+ Ignore `.gitignore` files.
212
+
213
+ ### `--include-entry-exports`
214
+
215
+ When a repository is self-contained or private, you may want to include entry
216
+ files when reporting unused exports:
217
+
218
+ ```sh
219
+ knip --include-entry-exports
220
+ ```
221
+
222
+ Also see [includeEntryExports][10].
223
+
224
+ ### `--include-libs`
225
+
226
+ Getting false positives for exports consumed by external libraries? Try the
227
+ `--include-libs` flag:
228
+
229
+ ```sh
230
+ knip --include-libs
231
+ ```
232
+
233
+ Also see [external libs][11].
234
+
235
+ ### `--isolate-workspaces`
236
+
237
+ By default, Knip optimizes performance using [workspace sharing][12] to existing
238
+ TypeScript programs, based on the compatibility of their `compilerOptions`. This
239
+ flag disables this behavior and creates one program per workspace, which is
240
+ slower but memory usage is spread more evenly over time.
241
+
242
+ ## Modes
243
+
244
+ ### `--production`
245
+
246
+ Lint only production source files. This excludes:
247
+
248
+ - entry files defined by plugins:
249
+ - test files
250
+ - configuration files
251
+ - Storybook stories
252
+ - `devDependencies` from `package.json`
253
+
254
+ Read more at [Production Mode][13].
255
+
256
+ ### `--strict`
257
+
258
+ Isolate workspaces and consider only direct dependencies. Implies [production
259
+ mode][14].
260
+
261
+ Read more at [Production Mode][13].
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`
280
+
281
+ ### `--watch`
282
+
283
+ Watch current directory, and update reported issues when a file is modified,
284
+ added or deleted.
285
+
286
+ Watch mode focuses on imports and exports in source files. During watch mode,
287
+ changes in `package.json` or `node_modules` may not cause an updated report.
288
+
289
+ ## Filters
290
+
291
+ Available [issue types][16] when filtering output using `--include` or
292
+ `--exclude`:
293
+
294
+ - `files`
295
+ - `dependencies`
296
+ - `optionalPeerDependencies`
297
+ - `unlisted`
298
+ - `unresolved`
299
+ - `exports`
300
+ - `nsExports`
301
+ - `classMembers`
302
+ - `types`
303
+ - `nsTypes`
304
+ - `enumMembers`
305
+ - `duplicates`
306
+
307
+ ### `--exclude`
308
+
309
+ Exclude provided issue types from report. Can be comma-separated or repeated.
310
+
311
+ Example:
312
+
313
+ ```sh
314
+ knip --exclude classMembers,enumMembers
315
+ knip --exclude classMembers --exclude enumMembers
316
+ ```
317
+
318
+ ### `--include`
319
+
320
+ Report only provided issue types. Can be comma-separated or repeated.
321
+
322
+ Example:
323
+
324
+ ```sh
325
+ knip --include files,dependencies
326
+ knip --include files --include dependencies
327
+ ```
328
+
329
+ ### `--dependencies`
330
+
331
+ Shortcut to include all types of dependency issues:
332
+
333
+ ```sh
334
+ --include dependencies,optionalPeerDependencies,unlisted,binaries,unresolved
335
+ ```
336
+
337
+ ### `--exports`
338
+
339
+ Shortcut to include all types of export issues:
340
+
341
+ ```sh
342
+ --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates
343
+ ```
344
+
345
+ ### `--experimental-tags`
346
+
347
+ Deprecated. Use [--tags][17] instead.
348
+
349
+ ### `--tags`
350
+
351
+ Exports can be tagged with known or arbitrary JSDoc/TSDoc tags:
352
+
353
+ ```ts
354
+ /**
355
+ * Description of my exported value
356
+ *
357
+ * @type number
358
+ * @internal Important matters
359
+ * @lintignore
360
+ */
361
+ export const myExport = 1;
362
+ ```
363
+
364
+ And then include (`+`) or exclude (`-`) these tagged exports from the report
365
+ like so:
366
+
367
+ ```shell
368
+ knip --tags=-lintignore,-internal
369
+ knip --tags=+custom
370
+ ```
371
+
372
+ This way, you can either focus on or ignore specific tagged exports with tags
373
+ you define yourself. This also works for individual class or enum members.
374
+
375
+ The default directive is `+` (include) and the `@` prefix is ignored, so the
376
+ notation below is valid and will report only exports tagged `@lintignore` or
377
+ `@internal`:
378
+
379
+ ```shell
380
+ knip --tags @lintignore --tags @internal
381
+ ```
382
+
383
+ ## Reporters & Preprocessors
384
+
385
+ ### `--reporter [reporter]`
386
+
387
+ Available reporters:
388
+
389
+ - `symbols` (default)
390
+ - `compact`
391
+ - `codeowners`
392
+ - `json`
393
+ - `markdown`
394
+
395
+ Can be repeated. Example:
396
+
397
+ ```sh
398
+ knip --reporter compact
399
+ ```
400
+
401
+ Also see [Reporters & Preprocessors][18].
402
+
403
+ ### `--reporter-options [json]`
404
+
405
+ Pass extra options to the preprocessor (as JSON string, see --reporter-options
406
+ example)
407
+
408
+ Example:
409
+
410
+ ```sh
411
+ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
412
+ ```
413
+
414
+ ### `--preprocessor [preprocessor]`
415
+
416
+ Preprocess the results before providing it to the reporters.
417
+
418
+ Can be repeated. Examples:
419
+
420
+ ```sh
421
+ knip --preprocessor ./my-preprocessor.ts
422
+ ```
423
+
424
+ ```sh
425
+ knip --preprocessor preprocessor-package
426
+ ```
427
+
428
+ ### `--preprocessor-options [json]`
429
+
430
+ Pass extra options to the preprocessor as JSON string.
431
+
432
+ ```sh
433
+ knip --preprocessor ./preproc.ts --preprocessor-options '{"key":"value"}'
434
+ ```
435
+
436
+ Also see [Reporters & Preprocessors][18].
437
+
438
+ ## Exit code
439
+
440
+ The default exit codes:
441
+
442
+ | Code | Description |
443
+ | :--: | :--------------------------------------------------------------- |
444
+ | `0` | Knip ran successfully, no lint issues |
445
+ | `1` | Knip ran successfully, but there is at least one lint issues |
446
+ | `2` | Knip did not run successfully due to bad input or internal error |
447
+
448
+ ### `--no-exit-code`
449
+
450
+ Always exit with code zero (`0`), even when there are lint issues.
451
+
452
+ ### `--max-issues`
453
+
454
+ Maximum number of issues before non-zero exit code. Default: `0`
455
+
456
+ ### `--max-show-issues`
457
+
458
+ Maximum number of issues per type to display (does not affect exit code).
459
+
460
+ ### `--no-config-hints`
461
+
462
+ Suppress configuration hints.
463
+
464
+ ### `--treat-config-hints-as-errors`
465
+
466
+ Exit with non-zero code (`1`) if there are any configuration hints.
467
+
468
+ [1]: https://bun.sh
469
+ [2]: ../reference/known-issues.md
470
+ [3]: https://no-color.org/
471
+ [4]: https://www.npmjs.com/package/picocolors
472
+ [5]: #--isolate-workspaces
473
+ [6]: https://github.com/oven-sh/bun/issues/9271
474
+ [7]: ../guides/troubleshooting.md#trace
475
+ [8]: #--trace
476
+ [9]: ../features/monorepos-and-workspaces.md#lint-a-single-workspace
477
+ [10]: ./configuration.md#includeentryexports
478
+ [11]: ../guides/handling-issues.mdx#external-libraries
479
+ [12]: ../guides/performance.md#workspace-sharing
480
+ [13]: ../features/production-mode.md
481
+ [14]: #--production
482
+ [15]: ../features/auto-fix.mdx
483
+ [16]: ./issue-types.md
484
+ [17]: #--tags
485
+ [18]: ../features/reporters.md