@knip/mcp 0.0.20 → 0.0.22

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 (198) hide show
  1. package/package.json +2 -2
  2. package/src/docs/docs/blog/brief-history.md +29 -0
  3. package/src/docs/docs/blog/for-editors-and-agents.md +130 -0
  4. package/src/docs/docs/blog/knip-v3.mdx +88 -0
  5. package/src/docs/docs/blog/knip-v4.mdx +149 -0
  6. package/src/docs/docs/blog/knip-v5.mdx +190 -0
  7. package/src/docs/docs/blog/migration-to-v1.md +65 -0
  8. package/src/docs/docs/blog/release-notes-v2.md +46 -0
  9. package/src/docs/docs/blog/slim-down-to-speed-up.md +269 -0
  10. package/src/docs/docs/blog/state-of-knip.md +191 -0
  11. package/src/docs/docs/blog/two-years.mdx +107 -0
  12. package/src/docs/docs/explanations/comparison-and-migration.md +133 -0
  13. package/src/docs/docs/explanations/entry-files.md +70 -0
  14. package/src/docs/docs/explanations/plugins.md +347 -0
  15. package/src/docs/docs/explanations/why-use-knip.md +128 -0
  16. package/src/docs/docs/features/auto-fix.mdx +348 -0
  17. package/src/docs/docs/features/compilers.md +172 -0
  18. package/src/docs/docs/features/integrated-monorepos.md +61 -0
  19. package/src/docs/docs/features/monorepos-and-workspaces.md +149 -0
  20. package/src/docs/docs/features/production-mode.md +95 -0
  21. package/src/docs/docs/features/reporters.md +304 -0
  22. package/src/docs/docs/features/rules-and-filters.md +102 -0
  23. package/src/docs/docs/features/script-parser.md +156 -0
  24. package/src/docs/docs/features/source-mapping.md +100 -0
  25. package/src/docs/docs/guides/configuring-project-files.md +205 -0
  26. package/src/docs/docs/guides/contributing.md +24 -0
  27. package/src/docs/docs/guides/handling-issues.mdx +708 -0
  28. package/src/docs/docs/guides/issue-reproduction.md +99 -0
  29. package/src/docs/docs/guides/namespace-imports.md +125 -0
  30. package/src/docs/docs/guides/performance.md +108 -0
  31. package/src/docs/docs/guides/troubleshooting.md +133 -0
  32. package/src/docs/docs/guides/using-knip-in-ci.md +50 -0
  33. package/src/docs/docs/guides/working-with-commonjs.md +72 -0
  34. package/src/docs/docs/index.mdx +160 -0
  35. package/src/docs/docs/overview/configuration.md +104 -0
  36. package/src/docs/docs/overview/features.md +66 -0
  37. package/src/docs/docs/overview/getting-started.mdx +205 -0
  38. package/src/docs/docs/overview/screenshots-videos.md +42 -0
  39. package/src/docs/docs/playground.mdx +38 -0
  40. package/src/docs/docs/reference/cli.md +511 -0
  41. package/src/docs/docs/reference/configuration-hints.md +146 -0
  42. package/src/docs/docs/reference/configuration.md +430 -0
  43. package/src/docs/docs/reference/dynamic-configuration.mdx +72 -0
  44. package/src/docs/docs/reference/faq.md +493 -0
  45. package/src/docs/docs/reference/integrations.md +104 -0
  46. package/src/docs/docs/reference/issue-types.md +45 -0
  47. package/src/docs/docs/reference/jsdoc-tsdoc-tags.md +133 -0
  48. package/src/docs/docs/reference/known-issues.md +86 -0
  49. package/src/docs/docs/reference/plugins/.gitkeep +0 -0
  50. package/src/docs/docs/reference/plugins/angular.md +34 -0
  51. package/src/docs/docs/reference/plugins/astro-db.md +34 -0
  52. package/src/docs/docs/reference/plugins/astro-og-canvas.md +15 -0
  53. package/src/docs/docs/reference/plugins/astro.md +44 -0
  54. package/src/docs/docs/reference/plugins/ava.md +46 -0
  55. package/src/docs/docs/reference/plugins/babel.md +41 -0
  56. package/src/docs/docs/reference/plugins/biome.md +34 -0
  57. package/src/docs/docs/reference/plugins/bumpp.md +41 -0
  58. package/src/docs/docs/reference/plugins/bun.md +34 -0
  59. package/src/docs/docs/reference/plugins/c8.md +29 -0
  60. package/src/docs/docs/reference/plugins/capacitor.md +36 -0
  61. package/src/docs/docs/reference/plugins/changelogen.md +41 -0
  62. package/src/docs/docs/reference/plugins/changelogithub.md +41 -0
  63. package/src/docs/docs/reference/plugins/changesets.md +34 -0
  64. package/src/docs/docs/reference/plugins/commitizen.md +34 -0
  65. package/src/docs/docs/reference/plugins/commitlint.md +42 -0
  66. package/src/docs/docs/reference/plugins/convex.md +34 -0
  67. package/src/docs/docs/reference/plugins/create-typescript-app.md +34 -0
  68. package/src/docs/docs/reference/plugins/cspell.md +39 -0
  69. package/src/docs/docs/reference/plugins/cucumber.md +35 -0
  70. package/src/docs/docs/reference/plugins/cypress.md +41 -0
  71. package/src/docs/docs/reference/plugins/danger.md +34 -0
  72. package/src/docs/docs/reference/plugins/dependency-cruiser.md +46 -0
  73. package/src/docs/docs/reference/plugins/docusaurus.md +40 -0
  74. package/src/docs/docs/reference/plugins/dotenv.md +32 -0
  75. package/src/docs/docs/reference/plugins/drizzle.md +34 -0
  76. package/src/docs/docs/reference/plugins/eleventy.md +35 -0
  77. package/src/docs/docs/reference/plugins/eslint.md +86 -0
  78. package/src/docs/docs/reference/plugins/execa.md +15 -0
  79. package/src/docs/docs/reference/plugins/expo.md +35 -0
  80. package/src/docs/docs/reference/plugins/expressive-code.md +40 -0
  81. package/src/docs/docs/reference/plugins/gatsby.md +49 -0
  82. package/src/docs/docs/reference/plugins/github-action.md +34 -0
  83. package/src/docs/docs/reference/plugins/github-actions.md +34 -0
  84. package/src/docs/docs/reference/plugins/glob.md +29 -0
  85. package/src/docs/docs/reference/plugins/graphql-codegen.md +46 -0
  86. package/src/docs/docs/reference/plugins/hardhat.md +34 -0
  87. package/src/docs/docs/reference/plugins/husky.md +40 -0
  88. package/src/docs/docs/reference/plugins/i18next-parser.md +46 -0
  89. package/src/docs/docs/reference/plugins/jest.md +51 -0
  90. package/src/docs/docs/reference/plugins/karma.md +39 -0
  91. package/src/docs/docs/reference/plugins/knex.md +34 -0
  92. package/src/docs/docs/reference/plugins/ladle.md +39 -0
  93. package/src/docs/docs/reference/plugins/lefthook.md +46 -0
  94. package/src/docs/docs/reference/plugins/lint-staged.md +48 -0
  95. package/src/docs/docs/reference/plugins/linthtml.md +41 -0
  96. package/src/docs/docs/reference/plugins/lockfile-lint.md +41 -0
  97. package/src/docs/docs/reference/plugins/lost-pixel.md +34 -0
  98. package/src/docs/docs/reference/plugins/markdownlint.md +34 -0
  99. package/src/docs/docs/reference/plugins/mdx.md +38 -0
  100. package/src/docs/docs/reference/plugins/mdxlint.md +38 -0
  101. package/src/docs/docs/reference/plugins/metro.md +46 -0
  102. package/src/docs/docs/reference/plugins/mocha.md +47 -0
  103. package/src/docs/docs/reference/plugins/moonrepo.md +34 -0
  104. package/src/docs/docs/reference/plugins/msw.md +35 -0
  105. package/src/docs/docs/reference/plugins/nano-staged.md +39 -0
  106. package/src/docs/docs/reference/plugins/nest.md +36 -0
  107. package/src/docs/docs/reference/plugins/netlify.md +41 -0
  108. package/src/docs/docs/reference/plugins/next-intl.md +34 -0
  109. package/src/docs/docs/reference/plugins/next-mdx.md +35 -0
  110. package/src/docs/docs/reference/plugins/next.md +52 -0
  111. package/src/docs/docs/reference/plugins/nitro.md +52 -0
  112. package/src/docs/docs/reference/plugins/node-modules-inspector.md +49 -0
  113. package/src/docs/docs/reference/plugins/node.md +50 -0
  114. package/src/docs/docs/reference/plugins/nodemon.md +30 -0
  115. package/src/docs/docs/reference/plugins/npm-package-json-lint.md +41 -0
  116. package/src/docs/docs/reference/plugins/nuxt.md +55 -0
  117. package/src/docs/docs/reference/plugins/nx.md +62 -0
  118. package/src/docs/docs/reference/plugins/nyc.md +39 -0
  119. package/src/docs/docs/reference/plugins/oclif.md +34 -0
  120. package/src/docs/docs/reference/plugins/openapi-ts.md +41 -0
  121. package/src/docs/docs/reference/plugins/oxfmt.md +46 -0
  122. package/src/docs/docs/reference/plugins/oxlint.md +46 -0
  123. package/src/docs/docs/reference/plugins/parcel.md +38 -0
  124. package/src/docs/docs/reference/plugins/payload.md +40 -0
  125. package/src/docs/docs/reference/plugins/playwright-ct.md +40 -0
  126. package/src/docs/docs/reference/plugins/playwright-test.md +29 -0
  127. package/src/docs/docs/reference/plugins/playwright.md +49 -0
  128. package/src/docs/docs/reference/plugins/plop.md +34 -0
  129. package/src/docs/docs/reference/plugins/pm2.md +37 -0
  130. package/src/docs/docs/reference/plugins/pnpm.md +34 -0
  131. package/src/docs/docs/reference/plugins/postcss.md +46 -0
  132. package/src/docs/docs/reference/plugins/preconstruct.md +34 -0
  133. package/src/docs/docs/reference/plugins/prettier.md +39 -0
  134. package/src/docs/docs/reference/plugins/prisma.md +62 -0
  135. package/src/docs/docs/reference/plugins/qwik.md +40 -0
  136. package/src/docs/docs/reference/plugins/raycast.md +34 -0
  137. package/src/docs/docs/reference/plugins/react-cosmos.md +40 -0
  138. package/src/docs/docs/reference/plugins/react-native.md +34 -0
  139. package/src/docs/docs/reference/plugins/react-router.md +37 -0
  140. package/src/docs/docs/reference/plugins/relay.md +53 -0
  141. package/src/docs/docs/reference/plugins/release-it.md +34 -0
  142. package/src/docs/docs/reference/plugins/remark.md +40 -0
  143. package/src/docs/docs/reference/plugins/remix.md +43 -0
  144. package/src/docs/docs/reference/plugins/rollup.md +49 -0
  145. package/src/docs/docs/reference/plugins/rsbuild.md +34 -0
  146. package/src/docs/docs/reference/plugins/rslib.md +34 -0
  147. package/src/docs/docs/reference/plugins/rspack.md +34 -0
  148. package/src/docs/docs/reference/plugins/rstest.md +34 -0
  149. package/src/docs/docs/reference/plugins/sanity.md +38 -0
  150. package/src/docs/docs/reference/plugins/semantic-release.md +41 -0
  151. package/src/docs/docs/reference/plugins/sentry.md +36 -0
  152. package/src/docs/docs/reference/plugins/simple-git-hooks.md +38 -0
  153. package/src/docs/docs/reference/plugins/size-limit.md +38 -0
  154. package/src/docs/docs/reference/plugins/sst.md +34 -0
  155. package/src/docs/docs/reference/plugins/starlight.md +34 -0
  156. package/src/docs/docs/reference/plugins/storybook.md +43 -0
  157. package/src/docs/docs/reference/plugins/stryker.md +34 -0
  158. package/src/docs/docs/reference/plugins/stylelint.md +41 -0
  159. package/src/docs/docs/reference/plugins/svelte.md +34 -0
  160. package/src/docs/docs/reference/plugins/sveltekit.md +34 -0
  161. package/src/docs/docs/reference/plugins/svgo.md +38 -0
  162. package/src/docs/docs/reference/plugins/svgr.md +43 -0
  163. package/src/docs/docs/reference/plugins/swc.md +34 -0
  164. package/src/docs/docs/reference/plugins/syncpack.md +41 -0
  165. package/src/docs/docs/reference/plugins/tailwind.md +34 -0
  166. package/src/docs/docs/reference/plugins/tanstack-router.md +47 -0
  167. package/src/docs/docs/reference/plugins/taskfile.md +43 -0
  168. package/src/docs/docs/reference/plugins/travis.md +34 -0
  169. package/src/docs/docs/reference/plugins/ts-node.md +30 -0
  170. package/src/docs/docs/reference/plugins/tsdown.md +46 -0
  171. package/src/docs/docs/reference/plugins/tsup.md +46 -0
  172. package/src/docs/docs/reference/plugins/tsx.md +48 -0
  173. package/src/docs/docs/reference/plugins/typedoc.md +53 -0
  174. package/src/docs/docs/reference/plugins/typescript.md +57 -0
  175. package/src/docs/docs/reference/plugins/unbuild.md +34 -0
  176. package/src/docs/docs/reference/plugins/unocss.md +39 -0
  177. package/src/docs/docs/reference/plugins/vercel-og.md +41 -0
  178. package/src/docs/docs/reference/plugins/vike.md +37 -0
  179. package/src/docs/docs/reference/plugins/vite.md +50 -0
  180. package/src/docs/docs/reference/plugins/vitepress.md +37 -0
  181. package/src/docs/docs/reference/plugins/vitest.md +72 -0
  182. package/src/docs/docs/reference/plugins/vue.md +34 -0
  183. package/src/docs/docs/reference/plugins/webdriver-io.md +34 -0
  184. package/src/docs/docs/reference/plugins/webpack.md +55 -0
  185. package/src/docs/docs/reference/plugins/wireit.md +34 -0
  186. package/src/docs/docs/reference/plugins/wrangler.md +34 -0
  187. package/src/docs/docs/reference/plugins/xo.md +40 -0
  188. package/src/docs/docs/reference/plugins/yarn.md +35 -0
  189. package/src/docs/docs/reference/plugins/yorkie.md +34 -0
  190. package/src/docs/docs/reference/plugins/zx.md +15 -0
  191. package/src/docs/docs/reference/plugins.md +146 -0
  192. package/src/docs/docs/reference/related-tooling.md +46 -0
  193. package/src/docs/docs/sponsors.mdx +64 -0
  194. package/src/docs/docs/typescript/unused-dependencies.md +86 -0
  195. package/src/docs/docs/typescript/unused-exports.md +87 -0
  196. package/src/docs/docs/writing-a-plugin/argument-parsing.md +201 -0
  197. package/src/docs/docs/writing-a-plugin/index.md +391 -0
  198. package/src/docs/docs/writing-a-plugin/inputs.md +162 -0
@@ -0,0 +1,511 @@
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
+ ### `--config [file]`
27
+
28
+ Use an alternative path for the configuration file. Default locations:
29
+
30
+ - `knip.json`
31
+ - `knip.jsonc`
32
+ - `.knip.json`
33
+ - `.knip.jsonc`
34
+ - `knip.js`
35
+ - `knip.ts`
36
+ - `package.json#knip`
37
+
38
+ Shortcut: `-c`
39
+
40
+ ### `--use-tsconfig-files`
41
+
42
+ Use `tsconfig.json` to define project files (override `project` patterns).
43
+
44
+ ### `--tsConfig [file]`
45
+
46
+ Shortcut: `-t`
47
+
48
+ Use an alternative path for the TypeScript configuration file.
49
+
50
+ Using `-t jsconfig.json` is also supported.
51
+
52
+ Default location: `tsconfig.json`
53
+
54
+ ### `knip-bun`
55
+
56
+ Run Knip using the Bun runtime (instead of Node.js + jiti).
57
+
58
+ ```shell
59
+ knip-bun
60
+ ```
61
+
62
+ This is equal to `bunx --bun knip`
63
+
64
+ Requires [Bun][1] to be installed. Also see [known issues][2] for the type of
65
+ issues this might help with.
66
+
67
+ ### NO_COLOR
68
+
69
+ The built-in reporters use the [NO_COLOR][3] friendly [picocolors][4]:
70
+
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`
90
+
91
+ ### `--include-entry-exports`
92
+
93
+ When a repository is self-contained or private, you may want to include entry
94
+ files when reporting unused exports:
95
+
96
+ ```sh
97
+ knip --include-entry-exports
98
+ ```
99
+
100
+ Also see [includeEntryExports][5].
101
+
102
+ ### `--include-libs`
103
+
104
+ Getting false positives for exports consumed by external libraries? Try the
105
+ `--include-libs` flag:
106
+
107
+ ```sh
108
+ knip --include-libs
109
+ ```
110
+
111
+ Also see [external libs][6].
112
+
113
+ ### `--isolate-workspaces`
114
+
115
+ By default, Knip optimizes performance using [workspace sharing][7] to existing
116
+ TypeScript programs, based on the compatibility of their `compilerOptions`. This
117
+ flag disables this behavior and creates one program per workspace, which is
118
+ slower but memory usage is spread more evenly over time.
119
+
120
+ ### `--no-gitignore`
121
+
122
+ Ignore `.gitignore` files.
123
+
124
+ ### `--production`
125
+
126
+ Lint only production source files. This excludes:
127
+
128
+ - entry files defined by plugins:
129
+ - test files
130
+ - configuration files
131
+ - Storybook stories
132
+ - `devDependencies` from `package.json`
133
+
134
+ Read more at [Production Mode][8].
135
+
136
+ ### `--strict`
137
+
138
+ Isolate workspaces and consider only direct dependencies. Implies [production
139
+ mode][9].
140
+
141
+ Read more at [Production Mode][8].
142
+
143
+ ### `--watch`
144
+
145
+ Watch current directory, and update reported issues when a file is modified,
146
+ added or deleted.
147
+
148
+ Watch mode focuses on imports and exports in source files. During watch mode,
149
+ changes in `package.json` or `node_modules` may not cause an updated report.
150
+
151
+ ## Scope
152
+
153
+ ### `--workspace [filter]`
154
+
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.
167
+
168
+ ### `--exclude`
169
+
170
+ Exclude provided issue types from report. Can be comma-separated or repeated.
171
+
172
+ Example:
173
+
174
+ ```sh
175
+ knip --exclude classMembers,enumMembers
176
+ knip --exclude classMembers --exclude enumMembers
177
+ ```
178
+
179
+ ### `--include`
180
+
181
+ Report only provided issue types. Can be comma-separated or repeated.
182
+
183
+ Example:
184
+
185
+ ```sh
186
+ knip --include files,dependencies
187
+ knip --include files --include dependencies
188
+ ```
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
+
206
+ ### `--dependencies`
207
+
208
+ Shortcut to include all types of dependency issues:
209
+
210
+ ```sh
211
+ --include dependencies,unlisted,binaries,unresolved,catalog
212
+ ```
213
+
214
+ ### `--exports`
215
+
216
+ Shortcut to include all types of export issues:
217
+
218
+ ```sh
219
+ --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates
220
+ ```
221
+
222
+ ### `--files`
223
+
224
+ Shortcut to include file issues:
225
+
226
+ ```sh
227
+ --include files
228
+ ```
229
+
230
+ ### `--tags`
231
+
232
+ Exports can be tagged with known or arbitrary JSDoc/TSDoc tags:
233
+
234
+ ```ts
235
+ /**
236
+ * Description of my exported value
237
+ *
238
+ * @type number
239
+ * @internal Important matters
240
+ * @lintignore
241
+ */
242
+ export const myExport = 1;
243
+ ```
244
+
245
+ And then include (`+`) or exclude (`-`) these tagged exports from the report
246
+ like so:
247
+
248
+ ```shell
249
+ knip --tags=-lintignore,-internal
250
+ knip --tags=+custom
251
+ ```
252
+
253
+ This way, you can either focus on or ignore specific tagged exports with tags
254
+ you define yourself. This also works for individual class or enum members.
255
+
256
+ The default directive is `+` (include) and the `@` prefix is ignored, so the
257
+ notation below is valid and will report only exports tagged `@lintignore` or
258
+ `@internal`:
259
+
260
+ ```shell
261
+ knip --tags @lintignore --tags @internal
262
+ ```
263
+
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
+ ```
309
+
310
+ ### `--reporter [reporter]`
311
+
312
+ Available reporters:
313
+
314
+ - `symbols` (default)
315
+ - `compact`
316
+ - `codeowners`
317
+ - `json`
318
+ - `codeclimate`
319
+ - `markdown`
320
+ - `disclosure`
321
+ - `github-actions`
322
+
323
+ Can be repeated. Example:
324
+
325
+ ```sh
326
+ knip --reporter compact
327
+ ```
328
+
329
+ Also see [Reporters & Preprocessors][14].
330
+
331
+ ### `--reporter-options [json]`
332
+
333
+ Pass extra options to the reporter (as JSON string):
334
+
335
+ Example:
336
+
337
+ ```sh
338
+ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
339
+ ```
340
+
341
+ ### `--no-config-hints`
342
+
343
+ Suppress configuration hints.
344
+
345
+ ### `--treat-config-hints-as-errors`
346
+
347
+ Exit with non-zero exit code (`1`) if there are any configuration hints.
348
+
349
+ ### `--max-issues`
350
+
351
+ Maximum number of issues before non-zero exit code. Default: `0`
352
+
353
+ ### `--max-show-issues`
354
+
355
+ Maximum number of issues per type to display (does not affect exit code).
356
+
357
+ ### `--no-exit-code`
358
+
359
+ Always exit with code zero (`0`), even when there are lint issues.
360
+
361
+ The default exit codes:
362
+
363
+ | Code | Description |
364
+ | :--: | :--------------------------------------------------------------- |
365
+ | `0` | Knip ran successfully, no lint issues |
366
+ | `1` | Knip ran successfully, but there is at least one lint issue |
367
+ | `2` | Knip did not run successfully due to bad input or internal error |
368
+
369
+ ## Troubleshooting
370
+
371
+ ### `--debug`
372
+
373
+ Shortcut: `-d`
374
+
375
+ Show [debug output][15].
376
+
377
+ ### `--memory`
378
+
379
+ ```txt frame=terminal
380
+ knip --memory
381
+
382
+ (results)
383
+
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
401
+
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]`
490
+
491
+ Trace file to see where its exports are imported. Implies [--trace][19].
492
+
493
+ [1]: https://bun.sh
494
+ [2]: ../reference/known-issues.md
495
+ [3]: https://no-color.org/
496
+ [4]: https://www.npmjs.com/package/picocolors
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
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: Configuration Hints
3
+ ---
4
+
5
+ Knip emits configuration hints to help keep your configuration file tidy and
6
+ reduce drift.
7
+
8
+ They're warnings by default, not lint findings. But addressing the hints might
9
+ improve results significantly. The hints on this page are sorted by
10
+ impact/importance (most impactful first).
11
+
12
+ Use [`--treat-config-hints-as-errors`][1] or [`treatConfigHintsAsErrors`][2] to
13
+ make any configuration hint result in a non-zero exit code and fail CI.
14
+
15
+ ## Unconfigured projects
16
+
17
+ Too many unused files in a single workspace-codebase, caused by a missing
18
+ configuration file or incomplete configuration:
19
+
20
+ ```
21
+ Create knip.json configuration file, and add entry and/or refine project files (42 unused files)
22
+ ```
23
+
24
+ Or if you have a config file:
25
+
26
+ ```
27
+ Add entry and/or refine project files (42 unused files)
28
+ ```
29
+
30
+ **Solution**: Add and refine `entry` and/or `project` patterns.
31
+
32
+ Related resources:
33
+
34
+ - [Configuration][3]
35
+ - [Monorepos & Workspaces][4]
36
+
37
+ ## Unconfigured workspaces
38
+
39
+ Too many unused files in a monorepo, caused by a missing configuration file or
40
+ incomplete configuration:
41
+
42
+ ```
43
+ Create knip.json configuration file with workspaces["packages/app"] object (42 unused files)
44
+ ```
45
+
46
+ Or if you have a config file:
47
+
48
+ ```
49
+ Add entry and/or refine project files in workspaces["packages/app"] (42 unused files)
50
+ ```
51
+
52
+ **Solution**: add a `workspaces` object to configuration. Add and refine `entry`
53
+ and/or `project` patterns. For instance, the example message translates to
54
+ configuration like this:
55
+
56
+ ```json
57
+ {
58
+ "workspaces" {
59
+ "packages/app": {
60
+ "entry": ["src/App.tsx"],
61
+ "project": ["src/**/*.ts"]
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Related resources:
68
+
69
+ - [Configuring Project Files][5]
70
+ - [Monorepos & Workspaces][4]
71
+
72
+ ## Top-level entry/project
73
+
74
+ In monorepos, Knip uses only `entry` and `project` under `workspaces`. The
75
+ top-level keys with the same name are ignored.
76
+
77
+ ```
78
+ Remove, or move unused top-level entry to one of "workspaces"
79
+ Remove, or move unused top-level project to one of "workspaces"
80
+ ```
81
+
82
+ **Solution**: Remove top-level `entry` and `project` keys, use these options in
83
+ `workspaces` instead.
84
+
85
+ ```jsonc
86
+ {
87
+ "entry": ["src/App.tsx"], // move entry/project from here... ↴
88
+ "project": ["src/**/*.ts"],
89
+ "workspaces": {
90
+ ".": {
91
+ "entry": ["src/App.tsx"], // ...to the correct workspace(s) ↲
92
+ "project": ["src/**/*.ts"],
93
+ },
94
+ },
95
+ }
96
+ ```
97
+
98
+ ## Unused entry in ignore group
99
+
100
+ An entry of an ignore list is no longer needed, remove it.
101
+
102
+ ```
103
+ Remove from ignoreWorkspaces
104
+ Remove from ignoreDependencies
105
+ Remove from ignoreBinaries
106
+ Remove from ignoreUnresolved
107
+ ```
108
+
109
+ **Solution**: Remove the entry from the array.
110
+
111
+ ## Useless patterns
112
+
113
+ A glob pattern in `entry` or `project` does not match any files.
114
+
115
+ ```
116
+ Refine entry pattern (no matches)
117
+ Refine project pattern (no matches)
118
+ ```
119
+
120
+ **Solution**: Refine or remove the `entry` or `project` entry.
121
+
122
+ ## Redundant patterns
123
+
124
+ A glob/pattern is redundant, because it's already covered by defaults or added
125
+ by an enabled plugin.
126
+
127
+ ```
128
+ Remove redundant entry pattern
129
+ Remove redundant project pattern
130
+ ```
131
+
132
+ **Solution**: Remove the `entry` or `project` entry.
133
+
134
+ ## Missing package entry file
135
+
136
+ ```
137
+ Package entry file not found
138
+ ```
139
+
140
+ **Solution**: Refine or remove the entry in `package.json`.
141
+
142
+ [1]: ./cli.md#--treat-config-hints-as-errors
143
+ [2]: ./configuration.md#treatconfighintsaserrors
144
+ [3]: ../overview/configuration.md
145
+ [4]: ../features/monorepos-and-workspaces.md
146
+ [5]: ../guides/configuring-project-files.md