@knip/mcp 0.0.20 → 0.0.21

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 (57) hide show
  1. package/package.json +2 -2
  2. package/src/docs/docs/blog/brief-history.md +30 -0
  3. package/src/docs/docs/blog/for-editors-and-agents.md +131 -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 +103 -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 +105 -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.md +146 -0
  51. package/src/docs/docs/reference/related-tooling.md +46 -0
  52. package/src/docs/docs/sponsors.mdx +64 -0
  53. package/src/docs/docs/typescript/unused-dependencies.md +86 -0
  54. package/src/docs/docs/typescript/unused-exports.md +87 -0
  55. package/src/docs/docs/writing-a-plugin/argument-parsing.md +202 -0
  56. package/src/docs/docs/writing-a-plugin/index.md +392 -0
  57. package/src/docs/docs/writing-a-plugin/inputs.md +162 -0
@@ -0,0 +1,708 @@
1
+ ---
2
+ title: Handling Issues
3
+ sidebar:
4
+ order: 3
5
+ ---
6
+
7
+ import { Tabs, TabItem } from '@astrojs/starlight/components';
8
+
9
+ Issues reported by Knip may contain false positives, but also tons of useful
10
+ information. Getting the most out of Knip may require some configuration.
11
+
12
+ Go over the issue types one by one. For instance, reducing the number of unused
13
+ files will also reduce the number of unused dependencies.
14
+
15
+ 1. [Unused files][1]
16
+ 2. [Unused dependencies][2]
17
+ 3. [Unresolved imports][3]
18
+ 4. [Unused exports][4]
19
+
20
+ :::tip
21
+
22
+ Try the [Knip Editor Extension][5]! Let your coding agent use the built-in
23
+ MCP Server and create a custom `knip.json` for you.
24
+
25
+ :::
26
+
27
+ ## Unused files
28
+
29
+ Getting the list of unused files right trickles down into the other issue types
30
+ as well, so we start here. Files are reported as unused if they are in the set
31
+ of `project` files, but not in the set of files resolved from the `entry` files:
32
+
33
+ ```
34
+ unused files = project files - (entry files + resolved files)
35
+ ```
36
+
37
+ :::tip
38
+
39
+ Addressing reported [Configuration Hints][6] first might help significantly,
40
+ especially when handling unused files.
41
+
42
+ :::
43
+
44
+ Common causes for unused files include:
45
+
46
+ - [Missing generated files][7]
47
+ - [Dynamic import specifiers][8]
48
+ - [Unsupported arguments in scripts][9]
49
+ - [Unsupported file formats][10]
50
+ - [Missing plugin][11]
51
+ - [Incomplete plugin][12]
52
+ - [TypeScript path aliases in monorepos][13]
53
+ - [Relative paths across workspaces][14]
54
+ - [Integrated monorepos][15]
55
+ - [Auto-mocking or auto-imports][16]
56
+
57
+ In most cases you can add `entry` patterns manually.
58
+
59
+ Use `--files` to [filter the report][17] and focus only on unused files:
60
+
61
+ ```sh
62
+ knip --files
63
+ ```
64
+
65
+ This works with other issue types as well. For instance, use `--dependencies` to
66
+ focus only on dependencies and exclude issues related to unused files and
67
+ exports.
68
+
69
+ :::caution
70
+
71
+ Don't add unused files to the `ignore` option before reading [configuring
72
+ project files][18]. Learn why and when to use `entry`, `project`, production
73
+ mode and `ignore*` patterns for better results and performance.
74
+
75
+ :::
76
+
77
+ ### Missing generated files
78
+
79
+ For certain features, Knip needs to run after relevant files are generated. For
80
+ instance, [source mapping][19] in a monorepo may require files to be built into
81
+ `dist` folders first. And generated files in the `src` directory may import
82
+ other files. For instance, the `src/routeTree.gen.ts` file generated by
83
+ `@tanstack/router` must exist so Knip can find the imported route files.
84
+
85
+ **Solution**: compile and/or generate the relevant files first so Knip can
86
+ resolve and find the source files.
87
+
88
+ If Knip still reports false positives, you may need to strategically add an
89
+ `entry` file manually.
90
+
91
+ ### Dynamic import specifiers
92
+
93
+ Dynamic import specifiers aren't resolved, such as:
94
+
95
+ ```ts
96
+ const entry = await import(path.join(baseDir, 'entry.ts'));
97
+ ```
98
+
99
+ **Solution**: add `entry.ts` to `entry` patterns.
100
+
101
+ ### Unsupported arguments in scripts
102
+
103
+ Some tooling command arguments aren't recognized:
104
+
105
+ ```json
106
+ {
107
+ "name": "my-lib",
108
+ "version": "1.0.0",
109
+ "scripts": {
110
+ "build": "unknown-build-cli --entry production.ts"
111
+ }
112
+ }
113
+ ```
114
+
115
+ **Solution**: add `production.ts` to `entry` patterns.
116
+
117
+ This works the same for any script, also those in GitHub Actions workflows or
118
+ Git hooks. See [script parser][20] for more details about Knip's script parser.
119
+
120
+ ### Unsupported file formats
121
+
122
+ Entry files referenced in HTML files (e.g. `<script src="production.js">`).
123
+
124
+ ```html
125
+ <html>
126
+ <body>
127
+ <script type="module" src="production.js"></script>
128
+ </body>
129
+ </html>
130
+ ```
131
+
132
+ **Solution**: add `production.js` to `entry` patterns. Or add an `.html`
133
+ compiler to extract and resolve the value of `<script src>` elements.
134
+
135
+ Knip has support for some popular framework formats through [compilers][21], and
136
+ additional compilers can be added for any file type. The recommended solution is
137
+ usually to add the file as shown in each example as an `entry` file.
138
+
139
+ ### Missing plugin
140
+
141
+ You might be using a tool or framework for which Knip doesn't have a plugin
142
+ (yet). Configuration and entry files (and related dependencies) may be reported
143
+ as unused because there is no plugin yet that would include those files. Two
144
+ examples:
145
+
146
+ - Configuration file `tool.config.js` contains a reference to the package
147
+ `"@tool/plugin"` → both the file and the dependency are reported as unused.
148
+ - A framework automatically imports all files matching `src/models/*.ts` → those
149
+ files are reported as unused.
150
+
151
+ **Solution**: [create a new plugin][22] for the tool or framework that's not [in
152
+ the list][23] yet. Or work around it and add `entry` patterns and maybe ignore a
153
+ dependency or two (using [`ignoreDependencies`][24]).
154
+
155
+ ### Incomplete plugin
156
+
157
+ Files may be reported as unused if existing plugins do not include that entry
158
+ file pattern yet. See the [plugins section of entry files][25] for more details.
159
+
160
+ **Solution**: [override plugin configuration][26] to customize default patterns
161
+ for existing plugins. Or even better: send a pull request to improve the plugin.
162
+
163
+ ### TypeScript path aliases in monorepos
164
+
165
+ When using TypeScript path aliases in import specifiers, aliases referencing
166
+ other workspaces are not special-cased. This may cause false positives. For
167
+ Knip, it's better to be explicit and list other workspaces as dependencies in
168
+ `package.json`.
169
+
170
+ **Solution**: move such "workspace aliases" from `compilerOptions`...
171
+
172
+ ```json title="tsconfig.json"
173
+ {
174
+ "compilerOptions": {
175
+ "paths": {
176
+ "@org/common/*": ["packages/common/*"]
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ ...to `dependencies` or `devDependencies` in `package.json`:
183
+
184
+ ```json title="package.json"
185
+ {
186
+ "name": "@org/lib",
187
+ "dependencies": {
188
+ "@org/common": "workspace:*"
189
+ }
190
+ }
191
+ ```
192
+
193
+ An additional benefit is that Knip will report unused and unlisted dependencies
194
+ from now on.
195
+
196
+ Also see [FAQ: Why can't I use path aliases to reference other workspaces?][27]
197
+
198
+ ### Relative paths across workspaces
199
+
200
+ Relative paths to import from other workspaces are not special-cased. For Knip,
201
+ it's better to be explicit and list other workspaces as dependencies in
202
+ `package.json` to be used in imports.
203
+
204
+ **Solution**: migrate from relative paths...
205
+
206
+ ```ts
207
+ import { something } from '../../common/file.ts';
208
+ ```
209
+
210
+ ...to dependency-based imports...
211
+
212
+ ```ts
213
+ import { something } from '@org/common';
214
+ ```
215
+
216
+ An additional benefit is that Knip will report unused and unlisted dependencies
217
+ from now on.
218
+
219
+ Also see [TypeScript path aliases in monorepos][13].
220
+
221
+ ### Integrated monorepos
222
+
223
+ Multiple instances of configuration files like `.eslintrc` and
224
+ `jest.config.json` across the repository may be reported as unused when working
225
+ in a (mono)repo with a single `package.json`.
226
+
227
+ **Solution**: see [integrated monorepos][28] for more details and how to
228
+ configure plugins to target those configuration files.
229
+
230
+ ### Auto-mocking or auto-imports
231
+
232
+ Some frameworks have features like "auto-mocking" or "auto-imports" enabled,
233
+ such as Jest and Nuxt.
234
+
235
+ **Solution**: include such entry files by extending the `entry` file patterns.
236
+ This is recommended in most cases:
237
+
238
+ ```json
239
+ {
240
+ "entry": ["src/index.ts", "src/models/*.ts"]
241
+ }
242
+ ```
243
+
244
+ Alternatively, exceptions and outliers can be excluded from the analysis using
245
+ negated `project` patterns:
246
+
247
+ ```json
248
+ {
249
+ "project": ["src/**/*.ts", "!**/__mocks__/**"]
250
+ }
251
+ ```
252
+
253
+ ## Unused dependencies
254
+
255
+ Dependencies imported in unused files are reported as unused dependencies.
256
+ That's why it's strongly recommended to try and remedy [unused files][1] first.
257
+ Better `entry` and `project` file coverage will solve many cases of reported
258
+ unused dependencies.
259
+
260
+ The most common causes for unused dependencies include:
261
+
262
+ - [Missing or incomplete plugins][29]
263
+ - [Unrecognized references][30]
264
+ - [Type Definition Packages][31]
265
+ - [Dependencies named after Node.js builtins][32]
266
+
267
+ Use `--dependencies` to [filter the report][17] and focus only on issues related
268
+ to dependencies:
269
+
270
+ ```sh
271
+ knip --dependencies
272
+ ```
273
+
274
+ :::caution[Monorepo]
275
+
276
+ In a monorepo, a dependency is unused in the root workspace's `package.json` if
277
+ it's also listed in a descendant workspace, and referenced only in the
278
+ descendant workspace.
279
+
280
+ :::
281
+
282
+ ### Missing or incomplete plugin
283
+
284
+ If a plugin exists and the dependency is referenced in the configuration file,
285
+ but its custom dependency finder does not detect it, then that's a false
286
+ positive. Please open a pull request or issue to fix it.
287
+
288
+ **Solution**: adding the configuration file as an `entry` file pattern may be a
289
+ temporary stopgap that fixes your situation, but it's better to create a new
290
+ plugin or fix an existing one.
291
+
292
+ ### Unrecognized reference
293
+
294
+ Sometimes a reference to a dependency is unrecognizable or unreachable to Knip,
295
+ so it's a false positive and incorrectly reported as unused.
296
+
297
+ **Solution**: add a new plugin or improve an existing one. If you don't feel
298
+ like a plugin could solve it, a last resort is to use [ignoreDependencies][24].
299
+
300
+ If a binary (or "executable") is referenced you'll want to use `ignoreBinaries`
301
+ instead. See [unlisted binaries][33].
302
+
303
+ ### Dependencies named after Node.js builtins
304
+
305
+ Some packages have the same name as a Node.js builtin (for instance `buffer` or
306
+ `process`).
307
+
308
+ **Solution**: if Knip reports such a dependency as unused, add it to
309
+ [ignoreDependencies][24].
310
+
311
+ ### Conditional or dynamic dependencies
312
+
313
+ Dependencies added conditionally in configuration files may not be detected by
314
+ Knip. This happens because Knip loads and executes config files, and conditional
315
+ logic may evaluate differently during analysis.
316
+
317
+ For example, this Playwright configuration conditionally adds a reporter:
318
+
319
+ ```ts title="playwright.config.ts"
320
+ import { defineConfig } from '@playwright/test';
321
+
322
+ const reporters: any[] = [['list']];
323
+ if (process.env.REPORT_PORTAL_ENABLED) {
324
+ reporters.push(['@reportportal/agent-js-playwright', config]);
325
+ }
326
+
327
+ export default defineConfig({
328
+ reporter: reporters,
329
+ });
330
+ ```
331
+
332
+ If `process.env.REPORT_PORTAL_ENABLED` evaluates to `false` when Knip runs, the
333
+ `@reportportal/agent-js-playwright` dependency won't be detected and may be
334
+ reported as unused.
335
+
336
+ This limitation exists because Knip executes configuration files to parse their
337
+ exported value. While Knip can parse configuration files statically using AST
338
+ (Abstract Syntax Tree) analysis, this approach becomes complex very quickly and
339
+ most of the time it is easier to use the [`ignoreDependencies`][24]
340
+ configuration option for conditionals.
341
+
342
+ ```json title="knip.json"
343
+ {
344
+ "ignoreDependencies": ["@reportportal/agent-js-playwright"]
345
+ }
346
+ ```
347
+
348
+ This pattern can be applied to any plugin that loads configuration files.
349
+
350
+ ### Type Definition Packages
351
+
352
+ #### Bundled types
353
+
354
+ Many packages come with their type definitions bundled. This means the
355
+ `package.json#types` field in the package points to an internal/local type
356
+ definition file. In this case, the separate types package is obsolete.
357
+
358
+ Knip reporting this is also useful for future regressions: if a package had a
359
+ DefinitelyTyped or similar package for its types before and later on starts
360
+ shipping those types bundled with the source code, Knip will report the obsolete
361
+ types dependency as unused.
362
+
363
+ Examples include ESLint, Webpack and React Router, rendering the
364
+ `@types/eslint`, `@types/webpack` and `@types/react-router` dependencies
365
+ obsolete respectively.
366
+
367
+ **Solution**: remove the types dependency (often `@types/...`)
368
+
369
+ #### Production types
370
+
371
+ Knip is strict in the divide between `dependencies` and `devDependencies`. Some
372
+ packages are published with one or more type packages listed in `dependencies`.
373
+ In strict production mode, even when re-exported and part of the package's
374
+ public API, Knip does not try to figure out what exactly are "production types"
375
+ and expects those in `devDependencies`.
376
+
377
+ **Solution**: list exceptions in [ignoreDependencies][24].
378
+
379
+ ### Unlisted dependencies
380
+
381
+ This means that a dependency is referenced directly in source code or
382
+ configuration, but not listed in `package.json`.
383
+
384
+ An unlisted dependency is usually a transitive dependency that's imported or
385
+ referenced directly. The dependency is installed (since it's a dependency of
386
+ another dependency) and lives in `node_modules`, but it's not listed explicitly
387
+ in `package.json`.
388
+
389
+ You should not rely on transitive dependencies for various reasons, including
390
+ control, security and stability.
391
+
392
+ **Solution**: install and list the dependency in `dependencies` or
393
+ `devDependencies`.
394
+
395
+ ### Unlisted binaries
396
+
397
+ Binaries are executable Node.js scripts. Some npm packages, when installed, add
398
+ one or more executable files to be used from scripts in `package.json`. Examples
399
+ include TypeScript that comes with the `tsc` binary, ESLint comes with `eslint`,
400
+ Next.js with `next`, and so on.
401
+
402
+ Knip detects such binaries in scripts and checks whether there's a package
403
+ installed that includes that binary. It looks up the `bin` field in the
404
+ `package.json` file of installed packages. If it doesn't find it, it will be
405
+ reported as an unlisted binary as there is no package that contains it.
406
+
407
+ Binaries that are installed on the OS already and thus likely not meant to be
408
+ installed from npm are not reported as unlisted (details: [list of ignored
409
+ binaries in source][34]).
410
+
411
+ #### Missing binaries
412
+
413
+ An unused dependency and an unlisted binary with the same name indicates
414
+ `node_modules` not containing the relevant package. And this might be caused by
415
+ either the way your package manager installs dependencies and binaries, or by
416
+ not running Knip from the root of the repository.
417
+
418
+ **Solution**: run Knip from the project root. If needed, [lint workspaces
419
+ individually][35].
420
+
421
+ Sometimes binaries and how they're reported can be a bit confusing. See this
422
+ example:
423
+
424
+ ```json
425
+ {
426
+ "name": "lib",
427
+ "scripts": {
428
+ "commitlint": "commitlint --edit"
429
+ },
430
+ "devDependencies": {
431
+ "@commitlint/cli": "*"
432
+ }
433
+ }
434
+ ```
435
+
436
+ This example works fine without anything reported, as the `@commitlint/cli`
437
+ package includes the `commitlint` binary. However, some script may contain `npx
438
+ commitlint` and here Knip assumes `commitlint` is the name of the package. This
439
+ technically works, as `commitlint` is a transitive dependency of
440
+ `@commitlint/cli`.
441
+
442
+ **Solution**: use `npx @commitlint/cli`
443
+
444
+ In some cases, using `npx` in a script may result in Knip not understanding
445
+ intention without an explicit `--yes` or `--no-install` flag.
446
+
447
+ **Solution**: use `npx --yes` or `npx --no-install` so Knip will either ignore
448
+ or consider the binary and package(s) referenced, respectively.
449
+
450
+ ## Unresolved imports
451
+
452
+ Knip may ignore or be unable to resolve an import specifier or dependency
453
+ references. The most common causes for unresolved imports:
454
+
455
+ - [Template strings][36]
456
+ - [Extensionless imports][30]
457
+ - [Unrecognized path aliases][37]
458
+ - [External aliased imports][38]
459
+
460
+ ### Template strings
461
+
462
+ Using template strings in dynamic imports might be ignored or not handled
463
+ properly by Knip, resulting in false positives. Examples of dynamic import
464
+ template strings:
465
+
466
+ ```ts
467
+ import(`./${value}.ts`);
468
+ import(`@org/name/dist/${value}.js`);
469
+ ```
470
+
471
+ **Solution**: for internal source files, add the file(s) to the `entry`
472
+ patterns. For external dependencies, add the dependency to the
473
+ `ignoreDependencies` list.
474
+
475
+ ### Extensionless imports
476
+
477
+ Knip does not support extensionless imports for some non-standard extensions,
478
+ such as for `.svg` files. Bundlers like Webpack may support this, but Knip does
479
+ not. Here's an example:
480
+
481
+ ```ts title="App.vue"
482
+ import Component from './Component'; // → Should resolve to ./Component.vue
483
+ import ArrowIcon from '../icons/Arrow'; // → Does NOT resolve to ../icons/Arrow.svg
484
+ ```
485
+
486
+ The first import is resolved properly, because `.vue` is a known extension if
487
+ the Vue plugin is enabled. The second import might not be resolved, because
488
+ `.svg` is not a known extension.
489
+
490
+ **Solution**: include the extension. Hosts supporting ES Modules (e.g. Node.js,
491
+ browsers) require a file extension for import specifiers.
492
+
493
+ ### Unrecognized path aliases
494
+
495
+ Knip considers TS config path aliases and [paths configured in knip.json][39],
496
+ but not those in e.g. Webpack or Vite configurations.
497
+
498
+ **Solution**: configure [paths][39] or try relative imports. Otherwise, use
499
+ [`ignoreUnresolved`][40] as a last resort.
500
+
501
+ ### External aliased imports
502
+
503
+ External libraries may use aliased imports that aren't resolved by Knip.
504
+
505
+ For instance, [unplugin-icons][41] does this to import icons from icon sets as
506
+ components. Such imports are reported as unused. Use the [`paths` configuration
507
+ option][39] to tell Knip where to find the icon types:
508
+
509
+ ```json title="knip.json"
510
+ {
511
+ "paths": {
512
+ "~icons/*": ["node_modules/unplugin-icons/types/[framework].d.ts"]
513
+ }
514
+ }
515
+ ```
516
+
517
+ Where `[framework]` is the name of the framework you're using (see [available
518
+ types][42]).
519
+
520
+ **Solution**: try [--include-libs][43] or configure [paths][39].
521
+
522
+ ## Unused exports
523
+
524
+ By default, Knip does not report unused exports of `entry` files.
525
+
526
+ The most common causes for unused exports include:
527
+
528
+ - [Namespace enumerations][44]
529
+ - [External libraries][45]
530
+
531
+ Use the `--exports` flag to [filter][17] and focus only on issues related to
532
+ exports:
533
+
534
+ ```sh
535
+ knip --exports
536
+ ```
537
+
538
+ Use [includeEntryExports][46] to report unused exports of entry files as well.
539
+ This can be set per workspace.
540
+
541
+ ### Namespace enumerations
542
+
543
+ For exports on an imported namespace, Knip considers all exports referenced if
544
+ that namespace is used in certain patterns like enumeration. Individual exports
545
+ are then **not** reported.
546
+
547
+ **Solution**: if all exports on imported namespaces should be considered
548
+ individually, include the `nsExports` issue type to disable the heuristic.
549
+
550
+ See [namespace imports][47] to see all related patterns.
551
+
552
+ ### External libraries
553
+
554
+ Are the exports consumed or imported by an external library, resulting in a
555
+ non-standard consumption of your exports? Here's an example:
556
+
557
+ <Tabs>
558
+ <TabItem label="index.js">
559
+ ```ts
560
+ import loadable from '@loadable/component';
561
+
562
+ export const DynamicApple = dynamic(() =>
563
+ import('./components.js').then(mod => mod.Apple)
564
+ );
565
+
566
+ export const LoadableOrange = loadable(() => import('./components.js'), {
567
+ resolveComponent: components => components.Orange,
568
+ });
569
+ ```
570
+ </TabItem>
571
+
572
+ <TabItem label="components.js">
573
+ ```ts
574
+ export const Apple = () => 'Apple';
575
+ export const Orange = () => 'Orange';
576
+ ```
577
+ </TabItem>
578
+ </Tabs>
579
+
580
+ Knip understands `Apple` is used, since it's standard usage. But `Orange` is
581
+ referenced through a function of an external library. For performance reasons,
582
+ Knip does not include external type definitions by default so it won't see the
583
+ export being referenced.
584
+
585
+ **Solution**: include the type definitions of external libraries with the
586
+ [--include-libs][43] flag:
587
+
588
+ ```shell
589
+ knip --include-libs
590
+ ```
591
+
592
+ This comes at a performance and memory penalty, but should give better results
593
+ if you need it. This flag is implied when [classMembers][48] are included (that
594
+ feature comes with roughly the same performance penalty).
595
+
596
+ ### Exclude exports from the report
597
+
598
+ To exclude false positives from the report, there are a few options:
599
+
600
+ - [Ignore exports used in file][49] for exports used internally.
601
+ - Individual exports can be [tagged using JSDoc syntax][50].
602
+ - Have the export in an entry file:
603
+
604
+ - Add the file to the `entry` file patterns array in the configuration.
605
+ - Move the export(s) to an entry file.
606
+ - Add the file to the `exports` field of `package.json`
607
+ - Re-export the unused export(s) from an entry file.
608
+
609
+ ### Missing unused exports?
610
+
611
+ Did you expect certain exports in the report, but are they missing? They might
612
+ be exported from an entry file. In that case, use [--include-entry-exports][46]
613
+ to make Knip also report unused exports in entry files.
614
+
615
+ The exports of non-standard extensions like `.astro`, `.mdx`, `.vue` or
616
+ `.svelte` are not available by default. See [compilers][21] for more details on
617
+ how to include them.
618
+
619
+ ### Class members
620
+
621
+ Unused members of exported classes are not reported by default, here's how to
622
+ enable them:
623
+
624
+ ```sh
625
+ knip --include classMembers
626
+ ```
627
+
628
+ This option is also available in the Knip configuration file. Note that this
629
+ feature comes at a cost: linting will take more time and more memory.
630
+
631
+ Individual class members can be [tagged using JSDoc syntax][50].
632
+
633
+ Classes exported from entry files are ignored, and so are their members. Use
634
+ [--include-entry-exports][46] to make Knip also report members of unused exports
635
+ in entry files.
636
+
637
+ ### Enum members
638
+
639
+ Unused enums and unused members of exported enums are reported by default.
640
+ Reporting such members can be disabled:
641
+
642
+ ```sh
643
+ knip --exclude enumMembers
644
+ ```
645
+
646
+ Individual enum members can be [tagged using JSDoc syntax][50].
647
+
648
+ Enums exported from entry files are ignored, and so are their members. Use
649
+ [--include-entry-exports][46] to make Knip also report members of unused exports
650
+ in entry files.
651
+
652
+ ## Feedback or false positives?
653
+
654
+ If you believe Knip incorrectly reports something as unused (i.e. there's a
655
+ false positive), feel free to create a [minimal reproduction][51] and open an
656
+ issue on GitHub. It'll make Knip better for everyone!
657
+
658
+ [1]: #unused-files
659
+ [2]: #unused-dependencies
660
+ [3]: #unresolved-imports
661
+ [4]: #unused-exports
662
+ [5]: ../reference/integrations.md
663
+ [6]: ../reference/configuration-hints.md
664
+ [7]: #missing-generated-files
665
+ [8]: #dynamic-import-specifiers
666
+ [9]: #unsupported-arguments-in-scripts
667
+ [10]: #unsupported-file-formats
668
+ [11]: #missing-plugin
669
+ [12]: #incomplete-plugin
670
+ [13]: #typescript-path-aliases-in-monorepos
671
+ [14]: #relative-paths-across-workspaces
672
+ [15]: #integrated-monorepos
673
+ [16]: #auto-mocking-or-auto-imports
674
+ [17]: ../features/rules-and-filters.md#filters
675
+ [18]: ./configuring-project-files.md
676
+ [19]: ../features/source-mapping.md
677
+ [20]: ../features/script-parser.md
678
+ [21]: ../features/compilers.md
679
+ [22]: ../writing-a-plugin/index.md
680
+ [23]: ../reference/plugins.md
681
+ [24]: ../reference/configuration.md#ignoredependencies
682
+ [25]: ../explanations/plugins.md#entry-files
683
+ [26]: ../explanations/entry-files.md#plugins
684
+ [27]: ../reference/faq.md#why-cant-i-use-path-aliases-to-reference-other-workspaces
685
+ [28]: ../features/integrated-monorepos.md
686
+ [29]: #missing-or-incomplete-plugin
687
+ [30]: #unrecognized-reference
688
+ [31]: #type-definition-packages
689
+ [32]: #dependencies-named-after-nodejs-builtins
690
+ [33]: #unlisted-binaries
691
+ [34]: https://github.com/webpro-nl/knip/blob/e031018e676c47d84873cc2403251c0111ef318d/packages/knip/src/constants.ts#L39-L148
692
+ [35]: ../features/monorepos-and-workspaces.md#filter-workspaces
693
+ [36]: #template-strings
694
+ [37]: #unrecognized-path-aliases
695
+ [38]: #external-aliased-imports
696
+ [39]: ../reference/configuration.md#paths
697
+ [40]: ../reference/configuration.md#ignoreunresolved
698
+ [41]: https://www.npmjs.com/package/unplugin-icons
699
+ [42]: https://github.com/unplugin/unplugin-icons/tree/main/types
700
+ [43]: ../reference/cli.md#--include-libs
701
+ [44]: #namespace-enumerations
702
+ [45]: #external-libraries
703
+ [46]: ../reference/configuration.md#includeentryexports
704
+ [47]: ../guides/namespace-imports.md
705
+ [48]: #class-members
706
+ [49]: ../reference/configuration.md#ignoreexportsusedinfile
707
+ [50]: ../reference/jsdoc-tsdoc-tags.md
708
+ [51]: ../guides/issue-reproduction.md