@knip/mcp 0.0.12 → 0.0.14

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 (140) hide show
  1. package/package.json +3 -3
  2. package/src/docs/docs/blog/for-editors-and-agents.md +44 -44
  3. package/src/docs/docs/blog/knip-v4.mdx +2 -2
  4. package/src/docs/docs/blog/two-years.mdx +1 -1
  5. package/src/docs/docs/explanations/plugins.md +16 -6
  6. package/src/docs/docs/guides/configuring-project-files.md +12 -12
  7. package/src/docs/docs/guides/contributing.md +1 -1
  8. package/src/docs/docs/guides/handling-issues.mdx +110 -64
  9. package/src/docs/docs/guides/issue-reproduction.md +4 -0
  10. package/src/docs/docs/guides/troubleshooting.md +4 -7
  11. package/src/docs/docs/index.mdx +3 -3
  12. package/src/docs/docs/overview/configuration.md +6 -6
  13. package/src/docs/docs/reference/configuration.md +17 -7
  14. package/src/docs/docs/reference/known-issues.md +32 -19
  15. package/src/docs/docs/reference/plugins/angular.md +10 -6
  16. package/src/docs/docs/reference/plugins/astro-db.md +10 -7
  17. package/src/docs/docs/reference/plugins/astro.md +10 -6
  18. package/src/docs/docs/reference/plugins/ava.md +10 -7
  19. package/src/docs/docs/reference/plugins/babel.md +9 -3
  20. package/src/docs/docs/reference/plugins/biome.md +10 -7
  21. package/src/docs/docs/reference/plugins/bumpp.md +9 -3
  22. package/src/docs/docs/reference/plugins/bun.md +6 -22
  23. package/src/docs/docs/reference/plugins/c8.md +7 -4
  24. package/src/docs/docs/reference/plugins/capacitor.md +10 -6
  25. package/src/docs/docs/reference/plugins/changelogen.md +9 -3
  26. package/src/docs/docs/reference/plugins/changelogithub.md +9 -3
  27. package/src/docs/docs/reference/plugins/changesets.md +10 -6
  28. package/src/docs/docs/reference/plugins/commitizen.md +10 -8
  29. package/src/docs/docs/reference/plugins/commitlint.md +9 -3
  30. package/src/docs/docs/reference/plugins/convex.md +10 -7
  31. package/src/docs/docs/reference/plugins/create-typescript-app.md +10 -6
  32. package/src/docs/docs/reference/plugins/cspell.md +9 -3
  33. package/src/docs/docs/reference/plugins/cucumber.md +11 -9
  34. package/src/docs/docs/reference/plugins/cypress.md +10 -6
  35. package/src/docs/docs/reference/plugins/danger.md +10 -6
  36. package/src/docs/docs/reference/plugins/dependency-cruiser.md +14 -9
  37. package/src/docs/docs/reference/plugins/docusaurus.md +10 -6
  38. package/src/docs/docs/reference/plugins/dotenv.md +8 -4
  39. package/src/docs/docs/reference/plugins/drizzle.md +10 -6
  40. package/src/docs/docs/reference/plugins/eleventy.md +11 -11
  41. package/src/docs/docs/reference/plugins/eslint.md +22 -10
  42. package/src/docs/docs/reference/plugins/expo.md +11 -11
  43. package/src/docs/docs/reference/plugins/gatsby.md +9 -3
  44. package/src/docs/docs/reference/plugins/github-action.md +10 -6
  45. package/src/docs/docs/reference/plugins/github-actions.md +10 -7
  46. package/src/docs/docs/reference/plugins/glob.md +8 -4
  47. package/src/docs/docs/reference/plugins/graphql-codegen.md +9 -3
  48. package/src/docs/docs/reference/plugins/hardhat.md +10 -6
  49. package/src/docs/docs/reference/plugins/husky.md +9 -3
  50. package/src/docs/docs/reference/plugins/i18next-parser.md +14 -9
  51. package/src/docs/docs/reference/plugins/jest.md +14 -10
  52. package/src/docs/docs/reference/plugins/karma.md +9 -3
  53. package/src/docs/docs/reference/plugins/ladle.md +11 -9
  54. package/src/docs/docs/reference/plugins/lefthook.md +13 -7
  55. package/src/docs/docs/reference/plugins/lint-staged.md +9 -3
  56. package/src/docs/docs/reference/plugins/linthtml.md +9 -3
  57. package/src/docs/docs/reference/plugins/lockfile-lint.md +9 -3
  58. package/src/docs/docs/reference/plugins/lost-pixel.md +10 -6
  59. package/src/docs/docs/reference/plugins/markdownlint.md +10 -7
  60. package/src/docs/docs/reference/plugins/mdx.md +10 -6
  61. package/src/docs/docs/reference/plugins/mdxlint.md +9 -3
  62. package/src/docs/docs/reference/plugins/metro.md +12 -9
  63. package/src/docs/docs/reference/plugins/mocha.md +15 -13
  64. package/src/docs/docs/reference/plugins/moonrepo.md +10 -8
  65. package/src/docs/docs/reference/plugins/msw.md +11 -9
  66. package/src/docs/docs/reference/plugins/nano-staged.md +9 -3
  67. package/src/docs/docs/reference/plugins/nest.md +10 -9
  68. package/src/docs/docs/reference/plugins/netlify.md +11 -9
  69. package/src/docs/docs/reference/plugins/next-intl.md +10 -6
  70. package/src/docs/docs/reference/plugins/next-mdx.md +11 -9
  71. package/src/docs/docs/reference/plugins/next.md +10 -6
  72. package/src/docs/docs/reference/plugins/node-modules-inspector.md +11 -4
  73. package/src/docs/docs/reference/plugins/node.md +12 -8
  74. package/src/docs/docs/reference/plugins/nodemon.md +8 -4
  75. package/src/docs/docs/reference/plugins/npm-package-json-lint.md +9 -3
  76. package/src/docs/docs/reference/plugins/nuxt.md +14 -8
  77. package/src/docs/docs/reference/plugins/nx.md +15 -7
  78. package/src/docs/docs/reference/plugins/nyc.md +9 -3
  79. package/src/docs/docs/reference/plugins/oclif.md +10 -6
  80. package/src/docs/docs/reference/plugins/oxlint.md +14 -9
  81. package/src/docs/docs/reference/plugins/playwright-ct.md +12 -8
  82. package/src/docs/docs/reference/plugins/playwright-test.md +10 -5
  83. package/src/docs/docs/reference/plugins/playwright.md +15 -12
  84. package/src/docs/docs/reference/plugins/plop.md +10 -6
  85. package/src/docs/docs/reference/plugins/pnpm.md +8 -5
  86. package/src/docs/docs/reference/plugins/postcss.md +9 -3
  87. package/src/docs/docs/reference/plugins/preconstruct.md +10 -6
  88. package/src/docs/docs/reference/plugins/prettier.md +9 -3
  89. package/src/docs/docs/reference/plugins/prisma.md +14 -10
  90. package/src/docs/docs/reference/plugins/react-cosmos.md +10 -6
  91. package/src/docs/docs/reference/plugins/react-router.md +9 -3
  92. package/src/docs/docs/reference/plugins/relay.md +14 -10
  93. package/src/docs/docs/reference/plugins/release-it.md +10 -7
  94. package/src/docs/docs/reference/plugins/remark.md +9 -3
  95. package/src/docs/docs/reference/plugins/remix.md +9 -3
  96. package/src/docs/docs/reference/plugins/rollup.md +14 -9
  97. package/src/docs/docs/reference/plugins/rsbuild.md +10 -6
  98. package/src/docs/docs/reference/plugins/rslib.md +10 -6
  99. package/src/docs/docs/reference/plugins/rspack.md +10 -6
  100. package/src/docs/docs/reference/plugins/rstest.md +10 -6
  101. package/src/docs/docs/reference/plugins/semantic-release.md +9 -3
  102. package/src/docs/docs/reference/plugins/sentry.md +10 -6
  103. package/src/docs/docs/reference/plugins/simple-git-hooks.md +9 -3
  104. package/src/docs/docs/reference/plugins/size-limit.md +9 -3
  105. package/src/docs/docs/reference/plugins/sst.md +10 -6
  106. package/src/docs/docs/reference/plugins/starlight.md +10 -6
  107. package/src/docs/docs/reference/plugins/storybook.md +11 -9
  108. package/src/docs/docs/reference/plugins/stryker.md +10 -6
  109. package/src/docs/docs/reference/plugins/stylelint.md +9 -3
  110. package/src/docs/docs/reference/plugins/svelte.md +9 -3
  111. package/src/docs/docs/reference/plugins/svgo.md +10 -6
  112. package/src/docs/docs/reference/plugins/svgr.md +9 -3
  113. package/src/docs/docs/reference/plugins/swc.md +10 -6
  114. package/src/docs/docs/reference/plugins/syncpack.md +9 -3
  115. package/src/docs/docs/reference/plugins/tailwind.md +10 -6
  116. package/src/docs/docs/reference/plugins/taskfile.md +10 -7
  117. package/src/docs/docs/reference/plugins/travis.md +8 -5
  118. package/src/docs/docs/reference/plugins/ts-node.md +8 -4
  119. package/src/docs/docs/reference/plugins/tsdown.md +14 -10
  120. package/src/docs/docs/reference/plugins/tsup.md +14 -10
  121. package/src/docs/docs/reference/plugins/tsx.md +12 -8
  122. package/src/docs/docs/reference/plugins/typedoc.md +13 -6
  123. package/src/docs/docs/reference/plugins/typescript.md +16 -10
  124. package/src/docs/docs/reference/plugins/unbuild.md +10 -6
  125. package/src/docs/docs/reference/plugins/unocss.md +9 -3
  126. package/src/docs/docs/reference/plugins/vercel-og.md +9 -3
  127. package/src/docs/docs/reference/plugins/vike.md +9 -3
  128. package/src/docs/docs/reference/plugins/vite.md +14 -9
  129. package/src/docs/docs/reference/plugins/vitepress.md +40 -0
  130. package/src/docs/docs/reference/plugins/vitest.md +13 -6
  131. package/src/docs/docs/reference/plugins/vue.md +10 -6
  132. package/src/docs/docs/reference/plugins/webdriver-io.md +10 -6
  133. package/src/docs/docs/reference/plugins/webpack.md +14 -9
  134. package/src/docs/docs/reference/plugins/wireit.md +10 -6
  135. package/src/docs/docs/reference/plugins/wrangler.md +10 -6
  136. package/src/docs/docs/reference/plugins/xo.md +10 -7
  137. package/src/docs/docs/reference/plugins/yarn.md +8 -5
  138. package/src/docs/docs/reference/plugins/yorkie.md +10 -6
  139. package/src/docs/docs/sponsors.mdx +2 -3
  140. package/src/texts.js +19 -29
@@ -6,16 +6,11 @@ sidebar:
6
6
 
7
7
  import { Tabs, TabItem } from '@astrojs/starlight/components';
8
8
 
9
- A long report can be frustrating. The list may contain false positives, but also
10
- tons of useful information. To get the most value out of Knip, it may require
11
- some initial configuration.
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.
12
11
 
13
- This guide helps you deal with false positives to find solutions and create the
14
- perfect report, with minimal configuration that will keep your project tidy.
15
-
16
- If you start out using Knip in a large project and have a long report, it makes
17
- sense to go over the issue types one by one. For instance, reducing the number
18
- of unused files will also reduce the number of unused dependencies.
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.
19
14
 
20
15
  1. [Unused files][1]
21
16
  2. [Unused dependencies][2]
@@ -124,8 +119,8 @@ Entry files referenced in HTML files (e.g. `<script src="production.js">`).
124
119
  compiler to extract and resolve the value of `<script src>` elements.
125
120
 
126
121
  Knip has support for some popular framework formats through [compilers][19], and
127
- additional compilers can be added for for any file type. The recommended
128
- solution is usually to add the file as shown in each example as an `entry` file.
122
+ additional compilers can be added for any file type. The recommended solution is
123
+ usually to add the file as shown in each example as an `entry` file.
129
124
 
130
125
  ### Missing plugin
131
126
 
@@ -253,6 +248,7 @@ The most common causes for unused dependencies include:
253
248
  - [Missing or incomplete plugins][27]
254
249
  - [Unrecognized references][28]
255
250
  - [Type Definition Packages][29]
251
+ - [Dependencies named after Node.js builtins][30]
256
252
 
257
253
  Use `--dependencies` to [filter the report][15] and focus only on issues related
258
254
  to dependencies:
@@ -264,8 +260,8 @@ knip --dependencies
264
260
  :::caution[Monorepo]
265
261
 
266
262
  In a monorepo, a dependency is unused in the root workspace's `package.json` if
267
- it's also listed in an descendent workspace, and referenced only in the
268
- descendent workspace.
263
+ it's also listed in a descendant workspace, and referenced only in the
264
+ descendant workspace.
269
265
 
270
266
  :::
271
267
 
@@ -288,7 +284,54 @@ so it's a false positive and incorrectly reported as unused.
288
284
  like a plugin could solve it, a last resort is to use [ignoreDependencies][22].
289
285
 
290
286
  If a binary (or "executable") is referenced you'll want to use `ignoreBinaries`
291
- instead. See [unlisted binaries][30].
287
+ instead. See [unlisted binaries][31].
288
+
289
+ ### Dependencies named after Node.js builtins
290
+
291
+ Some packages have the same name as a Node.js builtin (for instance `buffer` or
292
+ `process`).
293
+
294
+ **Solution**: if Knip reports such a dependency as unused, add it to
295
+ [ignoreDependencies][22].
296
+
297
+ #### Conditional or dynamic dependencies
298
+
299
+ Dependencies added conditionally in configuration files may not be detected by
300
+ Knip. This happens because Knip loads and executes config files, and conditional
301
+ logic may evaluate differently during analysis.
302
+
303
+ For example, this Playwright configuration conditionally adds a reporter:
304
+
305
+ ```ts title="playwright.config.ts"
306
+ import { defineConfig } from '@playwright/test';
307
+
308
+ const reporters: any[] = [['list']];
309
+ if (process.env.REPORT_PORTAL_ENABLED) {
310
+ reporters.push(['@reportportal/agent-js-playwright', config]);
311
+ }
312
+
313
+ export default defineConfig({
314
+ reporter: reporters,
315
+ });
316
+ ```
317
+
318
+ If `process.env.REPORT_PORTAL_ENABLED` evaluates to `false` when Knip runs, the
319
+ `@reportportal/agent-js-playwright` dependency won't be detected and may be
320
+ reported as unused.
321
+
322
+ This limitation exists because Knip executes configuration files to parse their
323
+ exported value. While Knip can parse configuration files statically using AST
324
+ (Abstract Syntax Tree) analysis, this approach becomes complex very quickly and
325
+ most of the time it is easier to use the [`ignoreDependencies`][22]
326
+ configuration option for conditionals.
327
+
328
+ ```json title="knip.json"
329
+ {
330
+ "ignoreDependencies": ["@reportportal/agent-js-playwright"]
331
+ }
332
+ ```
333
+
334
+ This pattern can be applied to any plugin that loads configuration files.
292
335
 
293
336
  ### Type Definition Packages
294
337
 
@@ -349,7 +392,7 @@ reported as an unlisted binary as there is no package that contains it.
349
392
 
350
393
  Binaries that are installed on the OS already and thus likely not meant to be
351
394
  installed from npm are not reported as unlisted (details: [list of ignored
352
- binaries in source][31]).
395
+ binaries in source][32]).
353
396
 
354
397
  #### Missing binaries
355
398
 
@@ -359,7 +402,7 @@ either the way your package manager installs dependencies and binaries, or by
359
402
  not running Knip from the root of the repository.
360
403
 
361
404
  **Solution**: run Knip from the project root. If needed, [lint workspaces
362
- individually][32].
405
+ individually][33].
363
406
 
364
407
  Sometimes binaries and how they're reported can be a bit confusing. See this
365
408
  example:
@@ -377,9 +420,9 @@ example:
377
420
  ```
378
421
 
379
422
  This example works fine without anything reported, as the `@commitlint/cli`
380
- package includes the `commitlint` binary. However, some script may contain
381
- `npx commitlint` and here Knip assumes `commitlint` is the name of the package.
382
- This technically works, as `commitlint` is a transitive dependency of
423
+ package includes the `commitlint` binary. However, some script may contain `npx
424
+ commitlint` and here Knip assumes `commitlint` is the name of the package. This
425
+ technically works, as `commitlint` is a transitive dependency of
383
426
  `@commitlint/cli`.
384
427
 
385
428
  **Solution**: use `npx @commitlint/cli`
@@ -395,10 +438,10 @@ or consider the binary and package(s) referenced, respectively.
395
438
  Knip may ignore or be unable to resolve an import specifier or dependency
396
439
  references. The most common causes for unresolved imports:
397
440
 
398
- - [Template strings][33]
441
+ - [Template strings][34]
399
442
  - [Extensionless imports][28]
400
- - [Unrecognized path aliases][34]
401
- - [External aliased imports][35]
443
+ - [Unrecognized path aliases][35]
444
+ - [External aliased imports][36]
402
445
 
403
446
  ### Template strings
404
447
 
@@ -430,24 +473,24 @@ The first import is resolved properly, because `.vue` is a known extension if
430
473
  the Vue plugin is enabled. The second import might not be resolved, because
431
474
  `.svg` is not a known extension.
432
475
 
433
- The recommendation is to always add the extension when importing such files,
434
- similar to how standard ES Modules specifies file extensions are necessary.
476
+ **Solution**: include the extension. Hosts supporting ES Modules (e.g. Node.js,
477
+ browsers) require a file extension for import specifiers.
435
478
 
436
479
  ### Unrecognized path aliases
437
480
 
438
- Knip considers TS config path aliases and [paths configured in knip.json][36],
481
+ Knip considers TS config path aliases and [paths configured in knip.json][37],
439
482
  but not those in e.g. Webpack or Vite configurations.
440
483
 
441
- **Solution**: configure [paths][36] or try relative imports. Otherwise, use
442
- [`ignoreUnresolved`][37] as a last resort.
484
+ **Solution**: configure [paths][37] or try relative imports. Otherwise, use
485
+ [`ignoreUnresolved`][38] as a last resort.
443
486
 
444
487
  ### External aliased imports
445
488
 
446
489
  External libraries may use aliased imports that aren't resolved by Knip.
447
490
 
448
- For instance, [unplugin-icons][10] does this to import icons from icon sets as
491
+ For instance, [unplugin-icons][39] does this to import icons from icon sets as
449
492
  components. Such imports are reported as unused. Use the [`paths` configuration
450
- option][13] to tell Knip where to find the icon types:
493
+ option][37] to tell Knip where to find the icon types:
451
494
 
452
495
  ```json title="knip.json"
453
496
  {
@@ -458,9 +501,9 @@ option][13] to tell Knip where to find the icon types:
458
501
  ```
459
502
 
460
503
  Where `[framework]` is the name of the framework you're using (see [available
461
- types][38]).
504
+ types][40]).
462
505
 
463
- **Solution**: try [--include-libs][39] or configure [paths][36].
506
+ **Solution**: try [--include-libs][41] or configure [paths][37].
464
507
 
465
508
  ## Unused exports
466
509
 
@@ -468,8 +511,8 @@ By default, Knip does not report unused exports of `entry` files.
468
511
 
469
512
  The most common causes for unused exports include:
470
513
 
471
- - [Namespace enumerations][40]
472
- - [External libraries][39]
514
+ - [Namespace enumerations][42]
515
+ - [External libraries][43]
473
516
 
474
517
  Use the `--exports` flag to [filter][15] and focus only on issues related to
475
518
  exports:
@@ -478,7 +521,7 @@ exports:
478
521
  knip --exports
479
522
  ```
480
523
 
481
- Use [includeEntryExports][41] to report unused exports of entry files as well.
524
+ Use [includeEntryExports][44] to report unused exports of entry files as well.
482
525
  This can be set per workspace.
483
526
 
484
527
  ### Namespace enumerations
@@ -490,7 +533,7 @@ are then **not** reported.
490
533
  **Solution**: if all exports on imported namespaces should be considered
491
534
  individually, include the `nsExports` issue type to disable the heuristic.
492
535
 
493
- See [namespace imports][42] to see all related patterns.
536
+ See [namespace imports][45] to see all related patterns.
494
537
 
495
538
  ### External libraries
496
539
 
@@ -526,23 +569,24 @@ Knip does not include external type definitions by default so it won't see the
526
569
  export being referenced.
527
570
 
528
571
  **Solution**: include the type definitions of external libraries with the
529
- [--include-libs][43] flag:
572
+ [--include-libs][41] flag:
530
573
 
531
574
  ```shell
532
575
  knip --include-libs
533
576
  ```
534
577
 
535
578
  This comes at a performance and memory penalty, but should give better results
536
- if you need it. This flag is implied when [classMembers][44] are included (that
579
+ if you need it. This flag is implied when [classMembers][46] are included (that
537
580
  feature comes with roughly the same performance penalty).
538
581
 
539
582
  ### Exclude exports from the report
540
583
 
541
584
  To exclude false positives from the report, there are a few options:
542
585
 
543
- - [Ignore exports used in file][45] for exports used internally.
544
- - Individual exports can be [tagged using JSDoc syntax][46].
586
+ - [Ignore exports used in file][47] for exports used internally.
587
+ - Individual exports can be [tagged using JSDoc syntax][48].
545
588
  - Have the export in an entry file:
589
+
546
590
  - Add the file to the `entry` file patterns array in the configuration.
547
591
  - Move the export(s) to an entry file.
548
592
  - Add the file to the `exports` field of `package.json`
@@ -551,7 +595,7 @@ To exclude false positives from the report, there are a few options:
551
595
  ### Missing unused exports?
552
596
 
553
597
  Did you expect certain exports in the report, but are they missing? They might
554
- be exported from an entry file. In that case, use [--include-entry-exports][41]
598
+ be exported from an entry file. In that case, use [--include-entry-exports][44]
555
599
  to make Knip also report unused exports in entry files.
556
600
 
557
601
  The exports of non-standard extensions like `.astro`, `.mdx`, `.vue` or
@@ -570,10 +614,10 @@ knip --include classMembers
570
614
  This option is also available in the Knip configuration file. Note that this
571
615
  feature comes at a cost: linting will take more time and more memory.
572
616
 
573
- Individual class members can be [tagged using JSDoc syntax][46].
617
+ Individual class members can be [tagged using JSDoc syntax][48].
574
618
 
575
619
  Classes exported from entry files are ignored, and so are their members. Use
576
- [--include-entry-exports][41] to make Knip also report members of unused exports
620
+ [--include-entry-exports][44] to make Knip also report members of unused exports
577
621
  in entry files.
578
622
 
579
623
  ### Enum members
@@ -585,16 +629,16 @@ Reporting such members can be disabled:
585
629
  knip --exclude enumMembers
586
630
  ```
587
631
 
588
- Individual enum members can be [tagged using JSDoc syntax][46].
632
+ Individual enum members can be [tagged using JSDoc syntax][48].
589
633
 
590
634
  Enums exported from entry files are ignored, and so are their members. Use
591
- [--include-entry-exports][41] to make Knip also report members of unused exports
635
+ [--include-entry-exports][44] to make Knip also report members of unused exports
592
636
  in entry files.
593
637
 
594
638
  ## Feedback or false positives?
595
639
 
596
640
  If you believe Knip incorrectly reports something as unused (i.e. there's a
597
- false positive), feel free to create a [minimal reproduction][47] and open an
641
+ false positive), feel free to create a [minimal reproduction][49] and open an
598
642
  issue on GitHub. It'll make Knip better for everyone!
599
643
 
600
644
  [1]: #unused-files
@@ -616,7 +660,7 @@ issue on GitHub. It'll make Knip better for everyone!
616
660
  [17]: ../features/source-mapping.md
617
661
  [18]: ../features/script-parser.md
618
662
  [19]: ../features/compilers.md
619
- [20]: ./writing-a-plugin.md
663
+ [20]: ../writing-a-plugin/index.md
620
664
  [21]: ../reference/plugins.md
621
665
  [22]: ../reference/configuration.md#ignoredependencies
622
666
  [23]: ../explanations/plugins.md#entry-files
@@ -626,21 +670,23 @@ issue on GitHub. It'll make Knip better for everyone!
626
670
  [27]: #missing-or-incomplete-plugin
627
671
  [28]: #unrecognized-reference
628
672
  [29]: #type-definition-packages
629
- [30]: #unlisted-binaries
630
- [31]: https://github.com/webpro-nl/knip/blob/b70958a58ea255ee7a7831e404786da807ca93d7/packages/knip/src/constants.ts#L37-L139
631
- [32]: ../features/monorepos-and-workspaces.md#lint-a-single-workspace
632
- [33]: #template-strings
633
- [34]: #unrecognized-path-aliases
634
- [35]: #external-aliased-imports
635
- [36]: ../reference/configuration.md#paths
636
- [37]: ../reference/configuration.md#ignoreunresolved
637
- [38]: #build-artifacts-and-ignored-files
638
- [39]: #external-libraries
639
- [40]: #namespace-enumerations
640
- [41]: ../reference/configuration.md#includeentryexports
641
- [42]: ../guides/namespace-imports.md
642
- [43]: ../reference/cli#--include-libs
643
- [44]: #class-members
644
- [45]: ../reference/configuration.md#ignoreexportsusedinfile
645
- [46]: ../reference/jsdoc-tsdoc-tags.md
646
- [47]: ../guides/issue-reproduction
673
+ [30]: #dependencies-named-after-nodejs-builtins
674
+ [31]: #unlisted-binaries
675
+ [32]: https://github.com/webpro-nl/knip/blob/e031018e676c47d84873cc2403251c0111ef318d/packages/knip/src/constants.ts#L39-L148
676
+ [33]: ../features/monorepos-and-workspaces.md#lint-a-single-workspace
677
+ [34]: #template-strings
678
+ [35]: #unrecognized-path-aliases
679
+ [36]: #external-aliased-imports
680
+ [37]: ../reference/configuration.md#paths
681
+ [38]: ../reference/configuration.md#ignoreunresolved
682
+ [39]: https://www.npmjs.com/package/unplugin-icons
683
+ [40]: https://github.com/unplugin/unplugin-icons/tree/main/types
684
+ [41]: ../reference/cli.md#--include-libs
685
+ [42]: #namespace-enumerations
686
+ [43]: #external-libraries
687
+ [44]: ../reference/configuration.md#includeentryexports
688
+ [45]: ../guides/namespace-imports.md
689
+ [46]: #class-members
690
+ [47]: ../reference/configuration.md#ignoreexportsusedinfile
691
+ [48]: ../reference/jsdoc-tsdoc-tags.md
692
+ [49]: ../guides/issue-reproduction.md
@@ -42,6 +42,10 @@ Before opening an issue, please make sure you:
42
42
  Please file only a single issue at a time, so each of them can be labeled and
43
43
  tracked separately.
44
44
 
45
+ There is no need to open an issue if you're going to submit a pull request to
46
+ close it right away anyway. In that case it's preferred to keep things central
47
+ in either an issue or pull request.
48
+
45
49
  ## Templates
46
50
 
47
51
  A convenient way to create a minimal reproduction is by starting with one of
@@ -23,8 +23,7 @@ Knip is intentionally strict to maximize its potential. It may initially report
23
23
  many unused files. However, getting this right will result in great reports and
24
24
  tidy codebases.
25
25
 
26
- If it doesn't come your way at the first try, remember that often only a small
27
- change go a long way towards success.
26
+ If it doesn't work out at first, a small change can go a long way.
28
27
 
29
28
  :::
30
29
 
@@ -33,9 +32,8 @@ change go a long way towards success.
33
32
  Knip reports lint issues in your codebase. See [handling issues][5] to deal with
34
33
  the reported issues.
35
34
 
36
- If Knip reports false positives and you're considering filing a GitHub issue,
37
- please do! It'll make Knip better for everyone. Please read [issue
38
- reproduction][6] first.
35
+ If you're considering filing an issue, please read [issue reproduction][6]
36
+ first.
39
37
 
40
38
  Exit code 1 indicates a successful run, but lint issues were found.
41
39
 
@@ -47,8 +45,7 @@ See [known issues][7] as it may be listed there and a workaround may be
47
45
  available. If it isn't clear what's throwing the exception, try another run with
48
46
  `--debug` to locate the cause of the issue with more details.
49
47
 
50
- If Knip throws an exception and you're considering filing a GitHub issue, please
51
- do! It'll make Knip better for everyone. Please read [issue reproduction][6]
48
+ If you're considering filing an issue, please read [issue reproduction][6]
52
49
  first.
53
50
 
54
51
  Exit code 2 indicates an exception was thrown by Knip.
@@ -31,7 +31,7 @@ import Contributors from '../../components/Contributors.astro';
31
31
 
32
32
  :::section{.badges}
33
33
 
34
- [![NPM Version][2]][1] [![NPM Downloads][3]][1] [![GitHub Repo stars][5]][4]
34
+ [![NPM Version][2]][1] [![NPM Downloads][3]][1] [![GitHub Repo stars][5]][4]
35
35
 
36
36
  :::
37
37
 
@@ -138,10 +138,10 @@ A curated selection of articles about Knip, most recent first:
138
138
  [3]: https://img.shields.io/npm/dm/knip?color=f56e0f
139
139
  [4]: https://github.com/webpro-nl/knip
140
140
  [5]: https://img.shields.io/github/stars/webpro-nl/knip?style=flat&color=f56e0f
141
- [6]: ./sponsors
141
+ [6]: /sponsors
142
142
  [7]: https://webpro.nl/hire-me
143
143
  [8]: ./reference/plugins.md
144
- [9]: ./playground
144
+ [9]: /playground
145
145
  [10]: ./guides/troubleshooting.md
146
146
  [11]: https://www.jamesshopland.com
147
147
  [12]: https://blog.val.town/gardening-dependencies
@@ -52,10 +52,9 @@ folder:
52
52
  }
53
53
  ```
54
54
 
55
- If you override the `entry` file patterns, you may also want to override
56
- `project` file patterns. The set of project files is used to determine what
57
- files are unused. The `project` patterns can also be negated to exclude files
58
- from the analysis. See [configuring project files][1] for details.
55
+ The set of `project` files determines the analysis scope. Use negated `project`
56
+ patterns to exclude files from the analysis. See [configuring project files][1]
57
+ for details.
59
58
 
60
59
  The values you set override the default values, they are not merged.
61
60
 
@@ -64,8 +63,9 @@ The values you set override the default values, they are not merged.
64
63
  Be specific with `entry` files. Minimize the number of entry files and wildcards
65
64
  for better results.
66
65
 
67
- Plugins are enabled automatically, and set entry files for you. Such as for
68
- Next.js, Astro, Remix, Vitest, Playwright and many more.
66
+ Plugins are enabled automatically, and their entry files are added
67
+ automatically. Such as for Next.js, Astro, Remix, Vitest, Playwright and many
68
+ more.
69
69
 
70
70
  :::
71
71
 
@@ -198,17 +198,23 @@ Exit with non-zero code (1) if there are any configuration hints.
198
198
 
199
199
  :::tip
200
200
 
201
- Please read [configuring project files][9] before using the `ignore` option,
202
- because in most cases you'll want to fine‑tune `entry` and `project` (or use
203
- production mode) instead.
201
+ Please read [configuring project files][9] before using the `ignore` option.
204
202
 
205
203
  :::
206
204
 
207
- Array of glob patterns to ignore issues from matching files. Example:
205
+ Avoid `ignore` patterns. There is almost always a better solution:
206
+
207
+ - Follow up on configuration hints (if there are any).
208
+ - Fine-tune `entry` and `project` patterns.
209
+ - Use [production mode][10].
210
+ - Other `ignore*` options.
211
+
212
+ **NOTE**: An exception to the rule: to _temporarily_ report only issues in files
213
+ that match the negated `ignore` pattern:
208
214
 
209
215
  ```json title="knip.json"
210
216
  {
211
- "ignore": ["src/generated.ts", "fixtures/**"]
217
+ "ignore": ["!src/dir/**"]
212
218
  }
213
219
  ```
214
220
 
@@ -271,6 +277,8 @@ export default {
271
277
 
272
278
  Suffix an item with `!` to enable it only in production mode.
273
279
 
280
+ Also see [Unused dependencies][11].
281
+
274
282
  ### `ignoreMembers`
275
283
 
276
284
  Array of class and enum members to exclude from the report. Regular expressions
@@ -399,7 +407,7 @@ files (`.js` or `.ts`), not in JSON configuration files.
399
407
 
400
408
  Override built-in compilers or add custom compilers for additional file types.
401
409
 
402
- Also see [Compilers][10].
410
+ Also see [Compilers][12].
403
411
 
404
412
  [1]: ../reference/dynamic-configuration.mdx
405
413
  [2]: ../overview/configuration.md
@@ -410,4 +418,6 @@ Also see [Compilers][10].
410
418
  [7]: ../features/rules-and-filters.md#filters
411
419
  [8]: ./jsdoc-tsdoc-tags.md
412
420
  [9]: ../guides/configuring-project-files.md
413
- [10]: ../features/compilers.md
421
+ [10]: ../features/production-mode.md
422
+ [11]: ../guides/handling-issues.mdx#unused-dependencies
423
+ [12]: ../features/compilers.md
@@ -2,31 +2,45 @@
2
2
  title: Known Issues
3
3
  ---
4
4
 
5
- This page contains a list of known issues you might run into when using Knip.
5
+ List of known issues and workarounds for exceptions thrown during a Knip run.
6
+
7
+ See [handling issues][1] to learn more about dealing with lint issues.
6
8
 
7
9
  ## Exceptions from config files
8
10
 
9
11
  An exception may be thrown when a Knip plugin loads a JavaScript or TypeScript
10
- configuration file such as `webpack.config.js` or `vite.config.ts`. Knip may
11
- load such files differently, in a different environment, or without certain
12
- environment variables set.
12
+ configuration file such as `webpack.config.js` or `vite.config.ts`:
13
13
 
14
- If it isn't clear what's throwing the exception, try another run with `--debug`
15
- to locate the cause of the issue with more details. Examples of issues when Knip
16
- loads configuration files:
14
+ ```sh
15
+ $ knip
16
+ Error loading .../vite.config.ts
17
+ ```
17
18
 
18
- - Missing environment variable
19
- - Relative path (e.g. which is sometimes not resolved from correct directory,
20
- try `import.meta.dirname` or `__dirname`)
19
+ Knip may load such files differently, in a different environment, with missing
20
+ environment variables, etcetera. Use `--debug` to locate the cause of the issue
21
+ with more details.
21
22
 
22
- As a last resort, the [plugin can be disabled][1].
23
+ Potential workarounds:
24
+
25
+ - Disable loading the file by overriding the default `config` for that plugin.
26
+ - Example: `vite: { config: [] }`
27
+ - In a monorepo, be more specific like so:
28
+ `workspaces: { "packages/lib": { vite: { config: [] } } }`
29
+ - If this helps, add the file as an `entry` file for static analysis.
30
+ - Disable the related plugin.
31
+ - Example: `eslint: false`
32
+ - In a monorepo, be more specific like so:
33
+ `workspaces: { "packages/lib": { eslint: false } }`
34
+ - If this helps, add the file as an `entry` file for static analysis.
35
+ - As a last resort, ignore the workspace: `ignoreWorkspaces: ["packages/lib"]`.
23
36
 
24
37
  ## Path aliases in config files
25
38
 
26
39
  Loading the configuration file (e.g. `cypress.config.ts`) for one of Knip's
27
40
  plugins may give an error:
28
41
 
29
- ```
42
+ ```sh
43
+ $ knip
30
44
  Analyzing workspace ....
31
45
  Error loading .../cypress.config.ts
32
46
  Reason: Cannot find module '@alias/name'
@@ -35,15 +49,13 @@ Require stack:
35
49
  ```
36
50
 
37
51
  Some tools (such as Cypress and Jest) support using TypeScript path aliases in
38
- the configuration file. Jiti does support aliases, but in a different format
39
- compared to `tsconfig.json#compilerOptions.paths` and `knip.json#paths` (e.g.
40
- the target values are not arrays).
52
+ the configuration file.
41
53
 
42
54
  Potential workarounds:
43
55
 
44
56
  - Rewrite the import in the configuration file to a relative import.
45
57
  - Use Bun with [knip-bun][2].
46
- - [Disable the plugin][1] (not recommended, try the other options first).
58
+ - See [exceptions from config files][3] for more potential workarounds.
47
59
 
48
60
  ## Nx Daemon
49
61
 
@@ -53,12 +65,13 @@ In Nx projects you might encounter this error:
53
65
  NX Daemon process terminated and closed the connection
54
66
  ```
55
67
 
56
- The solution is to [disable the Nx Daemon][3]:
68
+ The solution is to [disable the Nx Daemon][4]:
57
69
 
58
70
  ```sh
59
71
  NX_DAEMON=false knip
60
72
  ```
61
73
 
62
- [1]: ./configuration.md#plugins
74
+ [1]: ../guides/handling-issues.mdx
63
75
  [2]: ./cli.md#knip-bun
64
- [3]: https://nx.dev/concepts/nx-daemon#turning-it-off
76
+ [3]: #exceptions-from-config-files
77
+ [4]: https://nx.dev/concepts/nx-daemon#turning-it-off
@@ -6,7 +6,8 @@ sidebar:
6
6
 
7
7
  ## Enabled
8
8
 
9
- This plugin is enabled if `"@angular/cli"` is listed in `"dependencies"` or `"devDependencies"` in `package.json`.
9
+ This plugin is enabled if `"@angular/cli"` is listed in `"dependencies"` or
10
+ `"devDependencies"` in `package.json`.
10
11
 
11
12
  ## Default configuration
12
13
 
@@ -15,9 +16,7 @@ If this plugin is enabled, the following configuration is added automatically:
15
16
  ```json
16
17
  {
17
18
  "angular": {
18
- "config": [
19
- "angular.json"
20
- ]
19
+ "config": ["angular.json"]
21
20
  }
22
21
  }
23
22
  ```
@@ -26,8 +25,13 @@ Depending on local configuration, plugins may modify the defaults as shown.
26
25
 
27
26
  Custom `config` or `entry` options override default values, they are not merged.
28
27
 
29
- See [Plugins](../../explanations/plugins) for more details about plugins and their `entry` and `config` options.
28
+ See [Plugins][1] for more details about plugins and their `entry` and `config`
29
+ options.
30
30
 
31
31
  ## Generated from source
32
32
 
33
- This page was generated from the [angular plugin source code](https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/angular/index.ts).
33
+ This page was generated from the [angular plugin source code][2].
34
+
35
+ [1]: ../../explanations/plugins
36
+ [2]:
37
+ https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/angular/index.ts
@@ -6,7 +6,8 @@ sidebar:
6
6
 
7
7
  ## Enabled
8
8
 
9
- This plugin is enabled if `"@astrojs/db"` is listed in `"dependencies"` or `"devDependencies"` in `package.json`.
9
+ This plugin is enabled if `"@astrojs/db"` is listed in `"dependencies"` or
10
+ `"devDependencies"` in `package.json`.
10
11
 
11
12
  ## Default configuration
12
13
 
@@ -15,10 +16,7 @@ If this plugin is enabled, the following configuration is added automatically:
15
16
  ```json
16
17
  {
17
18
  "astro-db": {
18
- "entry": [
19
- "db/config.{js,ts}",
20
- "db/seed.{js,ts}"
21
- ]
19
+ "entry": ["db/config.{js,ts}", "db/seed.{js,ts}"]
22
20
  }
23
21
  }
24
22
  ```
@@ -27,8 +25,13 @@ Depending on local configuration, plugins may modify the defaults as shown.
27
25
 
28
26
  Custom `config` or `entry` options override default values, they are not merged.
29
27
 
30
- See [Plugins](../../explanations/plugins) for more details about plugins and their `entry` and `config` options.
28
+ See [Plugins][1] for more details about plugins and their `entry` and `config`
29
+ options.
31
30
 
32
31
  ## Generated from source
33
32
 
34
- This page was generated from the [astro-db plugin source code](https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/astro-db/index.ts).
33
+ This page was generated from the [astro-db plugin source code][2].
34
+
35
+ [1]: ../../explanations/plugins
36
+ [2]:
37
+ https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/astro-db/index.ts