@knip/mcp 0.0.2 → 0.0.3

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