@knip/mcp 0.0.21 → 0.0.23

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 (172) hide show
  1. package/package.json +3 -3
  2. package/src/docs/docs/blog/brief-history.md +2 -3
  3. package/src/docs/docs/blog/for-editors-and-agents.md +2 -3
  4. package/src/docs/docs/blog/knip-v3.mdx +1 -1
  5. package/src/docs/docs/blog/knip-v4.mdx +1 -1
  6. package/src/docs/docs/blog/knip-v5.mdx +1 -1
  7. package/src/docs/docs/blog/knip-v6.md +145 -0
  8. package/src/docs/docs/blog/release-notes-v2.md +1 -1
  9. package/src/docs/docs/blog/slim-down-to-speed-up.md +1 -1
  10. package/src/docs/docs/blog/state-of-knip.md +1 -1
  11. package/src/docs/docs/blog/two-years.mdx +1 -1
  12. package/src/docs/docs/explanations/comparison-and-migration.md +2 -2
  13. package/src/docs/docs/features/auto-fix.mdx +3 -33
  14. package/src/docs/docs/features/reporters.md +16 -13
  15. package/src/docs/docs/features/rules-and-filters.md +1 -1
  16. package/src/docs/docs/guides/handling-issues.mdx +32 -48
  17. package/src/docs/docs/guides/issue-reproduction.md +4 -8
  18. package/src/docs/docs/guides/performance.md +7 -62
  19. package/src/docs/docs/guides/using-knip-in-ci.md +2 -2
  20. package/src/docs/docs/index.mdx +3 -3
  21. package/src/docs/docs/overview/configuration.md +1 -1
  22. package/src/docs/docs/overview/getting-started.mdx +1 -1
  23. package/src/docs/docs/reference/cli.md +31 -56
  24. package/src/docs/docs/reference/configuration.md +7 -7
  25. package/src/docs/docs/reference/faq.md +48 -63
  26. package/src/docs/docs/reference/integrations.md +1 -2
  27. package/src/docs/docs/reference/issue-types.md +17 -17
  28. package/src/docs/docs/reference/jsdoc-tsdoc-tags.md +1 -1
  29. package/src/docs/docs/reference/plugins/angular.md +34 -0
  30. package/src/docs/docs/reference/plugins/astro-db.md +34 -0
  31. package/src/docs/docs/reference/plugins/astro-og-canvas.md +15 -0
  32. package/src/docs/docs/reference/plugins/astro.md +44 -0
  33. package/src/docs/docs/reference/plugins/ava.md +46 -0
  34. package/src/docs/docs/reference/plugins/babel.md +41 -0
  35. package/src/docs/docs/reference/plugins/biome.md +34 -0
  36. package/src/docs/docs/reference/plugins/bumpp.md +41 -0
  37. package/src/docs/docs/reference/plugins/bun.md +34 -0
  38. package/src/docs/docs/reference/plugins/c8.md +29 -0
  39. package/src/docs/docs/reference/plugins/capacitor.md +36 -0
  40. package/src/docs/docs/reference/plugins/changelogen.md +41 -0
  41. package/src/docs/docs/reference/plugins/changelogithub.md +41 -0
  42. package/src/docs/docs/reference/plugins/changesets.md +34 -0
  43. package/src/docs/docs/reference/plugins/commitizen.md +34 -0
  44. package/src/docs/docs/reference/plugins/commitlint.md +42 -0
  45. package/src/docs/docs/reference/plugins/convex.md +34 -0
  46. package/src/docs/docs/reference/plugins/create-typescript-app.md +34 -0
  47. package/src/docs/docs/reference/plugins/cspell.md +39 -0
  48. package/src/docs/docs/reference/plugins/cucumber.md +35 -0
  49. package/src/docs/docs/reference/plugins/cypress.md +41 -0
  50. package/src/docs/docs/reference/plugins/danger.md +34 -0
  51. package/src/docs/docs/reference/plugins/dependency-cruiser.md +46 -0
  52. package/src/docs/docs/reference/plugins/docusaurus.md +40 -0
  53. package/src/docs/docs/reference/plugins/dotenv.md +32 -0
  54. package/src/docs/docs/reference/plugins/drizzle.md +34 -0
  55. package/src/docs/docs/reference/plugins/eleventy.md +35 -0
  56. package/src/docs/docs/reference/plugins/eslint.md +86 -0
  57. package/src/docs/docs/reference/plugins/execa.md +15 -0
  58. package/src/docs/docs/reference/plugins/expo.md +35 -0
  59. package/src/docs/docs/reference/plugins/expressive-code.md +40 -0
  60. package/src/docs/docs/reference/plugins/gatsby.md +49 -0
  61. package/src/docs/docs/reference/plugins/github-action.md +34 -0
  62. package/src/docs/docs/reference/plugins/github-actions.md +34 -0
  63. package/src/docs/docs/reference/plugins/glob.md +29 -0
  64. package/src/docs/docs/reference/plugins/graphql-codegen.md +46 -0
  65. package/src/docs/docs/reference/plugins/hardhat.md +34 -0
  66. package/src/docs/docs/reference/plugins/husky.md +40 -0
  67. package/src/docs/docs/reference/plugins/i18next-parser.md +46 -0
  68. package/src/docs/docs/reference/plugins/jest.md +51 -0
  69. package/src/docs/docs/reference/plugins/karma.md +39 -0
  70. package/src/docs/docs/reference/plugins/knex.md +34 -0
  71. package/src/docs/docs/reference/plugins/ladle.md +39 -0
  72. package/src/docs/docs/reference/plugins/lefthook.md +46 -0
  73. package/src/docs/docs/reference/plugins/lint-staged.md +48 -0
  74. package/src/docs/docs/reference/plugins/linthtml.md +41 -0
  75. package/src/docs/docs/reference/plugins/lockfile-lint.md +41 -0
  76. package/src/docs/docs/reference/plugins/lost-pixel.md +34 -0
  77. package/src/docs/docs/reference/plugins/markdownlint.md +34 -0
  78. package/src/docs/docs/reference/plugins/mdx.md +38 -0
  79. package/src/docs/docs/reference/plugins/mdxlint.md +38 -0
  80. package/src/docs/docs/reference/plugins/metro.md +46 -0
  81. package/src/docs/docs/reference/plugins/mocha.md +47 -0
  82. package/src/docs/docs/reference/plugins/moonrepo.md +34 -0
  83. package/src/docs/docs/reference/plugins/msw.md +35 -0
  84. package/src/docs/docs/reference/plugins/nano-staged.md +39 -0
  85. package/src/docs/docs/reference/plugins/nest.md +36 -0
  86. package/src/docs/docs/reference/plugins/netlify.md +41 -0
  87. package/src/docs/docs/reference/plugins/next-intl.md +34 -0
  88. package/src/docs/docs/reference/plugins/next-mdx.md +35 -0
  89. package/src/docs/docs/reference/plugins/next.md +52 -0
  90. package/src/docs/docs/reference/plugins/nitro.md +52 -0
  91. package/src/docs/docs/reference/plugins/node-modules-inspector.md +49 -0
  92. package/src/docs/docs/reference/plugins/node.md +50 -0
  93. package/src/docs/docs/reference/plugins/nodemon.md +30 -0
  94. package/src/docs/docs/reference/plugins/npm-package-json-lint.md +41 -0
  95. package/src/docs/docs/reference/plugins/nuxt.md +55 -0
  96. package/src/docs/docs/reference/plugins/nx.md +62 -0
  97. package/src/docs/docs/reference/plugins/nyc.md +39 -0
  98. package/src/docs/docs/reference/plugins/oclif.md +34 -0
  99. package/src/docs/docs/reference/plugins/openapi-ts.md +41 -0
  100. package/src/docs/docs/reference/plugins/oxfmt.md +46 -0
  101. package/src/docs/docs/reference/plugins/oxlint.md +46 -0
  102. package/src/docs/docs/reference/plugins/parcel.md +38 -0
  103. package/src/docs/docs/reference/plugins/payload.md +40 -0
  104. package/src/docs/docs/reference/plugins/playwright-ct.md +40 -0
  105. package/src/docs/docs/reference/plugins/playwright-test.md +29 -0
  106. package/src/docs/docs/reference/plugins/playwright.md +49 -0
  107. package/src/docs/docs/reference/plugins/plop.md +34 -0
  108. package/src/docs/docs/reference/plugins/pm2.md +37 -0
  109. package/src/docs/docs/reference/plugins/pnpm.md +34 -0
  110. package/src/docs/docs/reference/plugins/postcss.md +46 -0
  111. package/src/docs/docs/reference/plugins/preconstruct.md +34 -0
  112. package/src/docs/docs/reference/plugins/prettier.md +39 -0
  113. package/src/docs/docs/reference/plugins/prisma.md +62 -0
  114. package/src/docs/docs/reference/plugins/qwik.md +40 -0
  115. package/src/docs/docs/reference/plugins/raycast.md +34 -0
  116. package/src/docs/docs/reference/plugins/react-cosmos.md +40 -0
  117. package/src/docs/docs/reference/plugins/react-native.md +34 -0
  118. package/src/docs/docs/reference/plugins/react-router.md +37 -0
  119. package/src/docs/docs/reference/plugins/relay.md +53 -0
  120. package/src/docs/docs/reference/plugins/release-it.md +34 -0
  121. package/src/docs/docs/reference/plugins/remark.md +40 -0
  122. package/src/docs/docs/reference/plugins/remix.md +43 -0
  123. package/src/docs/docs/reference/plugins/rollup.md +49 -0
  124. package/src/docs/docs/reference/plugins/rsbuild.md +34 -0
  125. package/src/docs/docs/reference/plugins/rslib.md +34 -0
  126. package/src/docs/docs/reference/plugins/rspack.md +34 -0
  127. package/src/docs/docs/reference/plugins/rstest.md +34 -0
  128. package/src/docs/docs/reference/plugins/sanity.md +38 -0
  129. package/src/docs/docs/reference/plugins/semantic-release.md +41 -0
  130. package/src/docs/docs/reference/plugins/sentry.md +36 -0
  131. package/src/docs/docs/reference/plugins/simple-git-hooks.md +38 -0
  132. package/src/docs/docs/reference/plugins/size-limit.md +38 -0
  133. package/src/docs/docs/reference/plugins/sst.md +34 -0
  134. package/src/docs/docs/reference/plugins/starlight.md +34 -0
  135. package/src/docs/docs/reference/plugins/storybook.md +43 -0
  136. package/src/docs/docs/reference/plugins/stryker.md +34 -0
  137. package/src/docs/docs/reference/plugins/stylelint.md +41 -0
  138. package/src/docs/docs/reference/plugins/svelte.md +34 -0
  139. package/src/docs/docs/reference/plugins/sveltekit.md +34 -0
  140. package/src/docs/docs/reference/plugins/svgo.md +38 -0
  141. package/src/docs/docs/reference/plugins/svgr.md +43 -0
  142. package/src/docs/docs/reference/plugins/swc.md +34 -0
  143. package/src/docs/docs/reference/plugins/syncpack.md +41 -0
  144. package/src/docs/docs/reference/plugins/tailwind.md +34 -0
  145. package/src/docs/docs/reference/plugins/tanstack-router.md +47 -0
  146. package/src/docs/docs/reference/plugins/taskfile.md +43 -0
  147. package/src/docs/docs/reference/plugins/travis.md +34 -0
  148. package/src/docs/docs/reference/plugins/ts-node.md +30 -0
  149. package/src/docs/docs/reference/plugins/tsdown.md +46 -0
  150. package/src/docs/docs/reference/plugins/tsup.md +46 -0
  151. package/src/docs/docs/reference/plugins/tsx.md +48 -0
  152. package/src/docs/docs/reference/plugins/typedoc.md +53 -0
  153. package/src/docs/docs/reference/plugins/typescript.md +57 -0
  154. package/src/docs/docs/reference/plugins/unbuild.md +34 -0
  155. package/src/docs/docs/reference/plugins/unocss.md +39 -0
  156. package/src/docs/docs/reference/plugins/vercel-og.md +41 -0
  157. package/src/docs/docs/reference/plugins/vike.md +37 -0
  158. package/src/docs/docs/reference/plugins/vite.md +50 -0
  159. package/src/docs/docs/reference/plugins/vitepress.md +37 -0
  160. package/src/docs/docs/reference/plugins/vitest.md +72 -0
  161. package/src/docs/docs/reference/plugins/vue.md +34 -0
  162. package/src/docs/docs/reference/plugins/webdriver-io.md +34 -0
  163. package/src/docs/docs/reference/plugins/webpack.md +55 -0
  164. package/src/docs/docs/reference/plugins/wireit.md +34 -0
  165. package/src/docs/docs/reference/plugins/wrangler.md +34 -0
  166. package/src/docs/docs/reference/plugins/xo.md +40 -0
  167. package/src/docs/docs/reference/plugins/yarn.md +35 -0
  168. package/src/docs/docs/reference/plugins/yorkie.md +34 -0
  169. package/src/docs/docs/reference/plugins/zx.md +15 -0
  170. package/src/docs/docs/typescript/unused-exports.md +7 -8
  171. package/src/docs/docs/writing-a-plugin/argument-parsing.md +1 -2
  172. package/src/docs/docs/writing-a-plugin/index.md +15 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knip/mcp",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Knip MCP Server",
5
5
  "keywords": [
6
6
  "knip",
@@ -28,10 +28,10 @@
28
28
  "dependencies": {
29
29
  "@modelcontextprotocol/sdk": "^1.27.1",
30
30
  "zod": "^4.1.11",
31
- "knip": "^5.87.0"
31
+ "knip": "^6.0.0"
32
32
  },
33
33
  "engines": {
34
- "node": ">=18.18.0"
34
+ "node": "^20.19.0 || >=22.12.0"
35
35
  },
36
36
  "scripts": {
37
37
  "release": "release-it -c ../../.release-it.json"
@@ -2,7 +2,7 @@
2
2
  title: A Brief History Of Knip
3
3
  date: 2023-10-15
4
4
  sidebar:
5
- order: 7
5
+ order: 8
6
6
  ---
7
7
 
8
8
  _Published: 2023-10-15_
@@ -21,8 +21,7 @@ just for you!
21
21
  - 2023-03-22: [Knip v2][5] saw a full rewrite of the TypeScript backend.
22
22
  - 2023-10-15: [Introduction of Knip v3][6].
23
23
 
24
- [1]:
25
- https://github.com/webpro-nl/knip/commit/9589dfe22608da7d89f2613383da6db5826226d2
24
+ [1]: https://github.com/webpro-nl/knip/commit/9589dfe22608da7d89f2613383da6db5826226d2
26
25
  [2]: https://github.com/webpro-nl/knip/tree/0.1.2
27
26
  [3]: https://github.com/webpro-nl/knip/releases/tag/1.0.0-alpha.0
28
27
  [4]: https://github.com/webpro-nl/knip/tree/1.0.0
@@ -2,7 +2,7 @@
2
2
  title: Knip for Editors & Agents
3
3
  date: 2025-12-17
4
4
  sidebar:
5
- order: 1
5
+ order: 2
6
6
  ---
7
7
 
8
8
  _Published: 2025-12-17_
@@ -116,8 +116,7 @@ barrel files. Knip warns:
116
116
  [7]: https://marketplace.visualstudio.com/items?itemName=webpro.vscode-knip
117
117
  [8]: https://open-vsx.org/extension/webpro/vscode-knip
118
118
  [9]: https://www.npmjs.com/package/@knip/mcp
119
- [10]:
120
- https://github.com/webpro-nl/knip/blob/main/packages/language-server/README.md
119
+ [10]: https://github.com/webpro-nl/knip/blob/main/packages/language-server/README.md
121
120
  [11]: #contention
122
121
  [12]: #circular-dependencies
123
122
  [13]: #conflicts
@@ -2,7 +2,7 @@
2
2
  title: Announcing Knip v3
3
3
  date: 2023-10-15
4
4
  sidebar:
5
- order: 8
5
+ order: 9
6
6
  ---
7
7
 
8
8
  import { Tabs, TabItem } from '@astrojs/starlight/components';
@@ -2,7 +2,7 @@
2
2
  title: Announcing Knip v4
3
3
  date: 2024-01-16
4
4
  sidebar:
5
- order: 5
5
+ order: 6
6
6
  ---
7
7
 
8
8
  import { Tabs, TabItem } from '@astrojs/starlight/components';
@@ -2,7 +2,7 @@
2
2
  title: Announcing Knip v5
3
3
  date: 2024-02-10
4
4
  sidebar:
5
- order: 4
5
+ order: 5
6
6
  ---
7
7
 
8
8
  import { Tabs, TabItem } from '@astrojs/starlight/components';
@@ -0,0 +1,145 @@
1
+ ---
2
+ title: Announcing Knip v6
3
+ date: 2026-03-20
4
+ sidebar:
5
+ order: 1
6
+ ---
7
+
8
+ _Published: 2026-03-20_
9
+
10
+ ## Knip v6 is out!
11
+
12
+ This release is all about replacing the TypeScript backend entirely with
13
+ `oxc-parser` and `oxc-resolver`, and making Knip a whole lot faster!
14
+
15
+ ## From TypeScript to oxc
16
+
17
+ Two years ago, the ["slim down to speed up"][1] and [Knip v4][2] work removed a
18
+ lot of overhead around TypeScript programs, made serialization and caching
19
+ practical, and improved memory efficiency a lot. But there was still a ceiling:
20
+ parsing and module resolution still depended on TypeScript APIs designed for
21
+ IDEs and language servers — not for the kind of single-pass static analysis Knip
22
+ does.
23
+
24
+ Starting today, Knip v6 parses your source files with [oxc-parser][3]. This is
25
+ more than just a parser swap for the sake of using the latest 'n greatest.
26
+
27
+ Knip has always been designed to parse each file only once, but the TypeScript
28
+ backend carried the overhead of wiring up an entire program along with the
29
+ typechecker. That's useful for IDEs keeping symbols connected, but much less so
30
+ when you only need to traverse an AST once to collect imports and exports.
31
+ The TypeScript backend made the setup as a whole harder and slower than it
32
+ needed to be, especially to keep large monorepos in check.
33
+
34
+ Now with TypeScript itself Go-ing places, replacing that backend was only a
35
+ matter of time.
36
+
37
+ Unsurprisingly, the search didn't take long: `oxc-parser` offers everything we
38
+ need and its (experimental) raw transfer is crazy fast. Massive props to
39
+ [overlookmotel][4], [Boshen][5] and all contributors for all the work on
40
+ [the oxc suite][6]!
41
+
42
+ ## Performance tuning
43
+
44
+ Next to this major refactor, I've been having a ball tuning Knip's performance
45
+ further. One thing to highlight here is that a few more plugins have been
46
+ refactored to statically analyze configuration files directly, as opposed to
47
+ actually importing them (including transitive dependencies...). This includes
48
+ the ESLint ("flat config"), tsdown and tsup plugins.
49
+
50
+ ## The numbers
51
+
52
+ Comparing v5 and v6 in some projects using Knip, all boosts are in the **2-4x** range:
53
+
54
+ [![venz-chart][8]][7]
55
+
56
+ Trust me, I could look at this chart all day long! The same numbers in a table:
57
+
58
+ | Project | v5.88.0 | v6.0.0 |
59
+ | ---------------- | ------: | -----: |
60
+ | [astro][9] | 4.0s | 2.0s |
61
+ | [query][10] | 3.8s | 1.7s |
62
+ | [rolldown][11] | 3.7s | 1.7s |
63
+ | [sentry][12] | 11.0s | 4.0s |
64
+ | [TypeScript][13] | 3.7s | 0.9s |
65
+
66
+ ## What's new
67
+
68
+ - Did I already mention Knip got 2-4x faster?
69
+ - Support for TS namespaces (and modules), new issue type `namespaceMembers`:
70
+
71
+ ```ts
72
+ export namespace MyNamespace {
73
+ export const myName = 'knip'; // we were ignored in v5,
74
+ export type MyType = string; // yet in v6 we are included
75
+ }
76
+ ```
77
+
78
+ ## Breaking changes
79
+
80
+ Granted, most of you won't even notice. Here's the list:
81
+
82
+ - Dropped support for Node.js v18 → Knip v6 requires Node.js v20.19.0 or newer
83
+ - Dropped issue type `classMembers`
84
+ - Dropped `--include-libs` → this is now the default and only behavior
85
+ - Dropped `--isolate-workspaces` → this is now the default and only behavior
86
+ - Dropped `--experimental-tags` → use [`--tags`][14]
87
+ - In [reporter functions][15], `issues.files` is consistent with other issue shapes. Removed `issues._files`.
88
+ - In the [JSON reporter][16], issues are consistently arrays for any issue type. Removed root `files`.
89
+
90
+ ## Editor Extensions
91
+
92
+ [Editor extensions][17] benefit from the core upgrades, for being faster and more
93
+ memory-efficient. Regardless of new extension releases, the local version of
94
+ Knip will be detected and used. Upgrade `knip` in your dependencies when you're
95
+ ready.
96
+
97
+ ## What about classMembers?
98
+
99
+ I feel you. Even Knip itself was using it. Until today.
100
+
101
+ The problem is that the implementation relies on the JS-based `ts.LanguageService`
102
+ API that exposes the `findReferences` method. TypeScript v6 is the last JS-based
103
+ release, and TypeScript v7 is a full rewrite in Go. I am left wondering if it
104
+ ever will be feasible and practical to build such features using primitives
105
+ (i.e. not via LSP) in a JS-based CLI (references: [microsoft/typescript-go#455][18],
106
+ [@typescript/api][19]). Knip was already pretty unique for even trying this in
107
+ a CLI tool.
108
+
109
+ Not that many projects seem to be using it either:
110
+ [github.com search for "classMembers path\:knip.json"][20].
111
+
112
+ If your project relies on it, feel free to open an issue on GitHub or contact me
113
+ and maybe we can work something out. Maybe a separate dedicated tool could work,
114
+ or extended support for Knip v5.
115
+
116
+ ## Upgrade today
117
+
118
+ ```sh
119
+ npm install -D knip@latest
120
+ ```
121
+
122
+ ## Deep closing thoughts...
123
+
124
+ Remember, Knip it before you ship it! Have a great day ☀️
125
+
126
+ [1]: ./slim-down-to-speed-up.md
127
+ [2]: ./knip-v4.mdx
128
+ [3]: https://oxc.rs/docs/guide/usage/parser
129
+ [4]: https://github.com/overlookmotel
130
+ [5]: https://github.com/Boshen
131
+ [6]: https://oxc.rs
132
+ [7]: https://try.venz.dev/?type=bar&labelX=Knip&labelY=duration+(s)&label=astro&label=query&label=rolldown&label=sentry&label=typescript&l=v5.88.0&l=v6.0.0&data=4*2&data=3.8*1.7&data=3.7*1.7&data=11*4&data=3.7*0.9
133
+ [8]: https://cdn.venz.dev/i/chart.svg?pad=0&type=bar&labelX=Knip&labelY=duration+(s)&label=astro&label=query&label=rolldown&label=sentry&label=typescript&l=v5.88.0&l=v6.0.0&data=4*2&data=3.8*1.7&data=3.7*1.7&data=11*4&data=3.7*0.9&theme=dark
134
+ [9]: https://github.com/withastro/astro
135
+ [10]: https://github.com/TanStack/query
136
+ [11]: https://github.com/rolldown/rolldown
137
+ [12]: https://github.com/getsentry/sentry
138
+ [13]: https://github.com/microsoft/TypeScript
139
+ [14]: ../reference/configuration.md#tags
140
+ [15]: ../features/reporters.md#custom-reporters
141
+ [16]: ../features/reporters.md#json
142
+ [17]: ../reference/integrations.md
143
+ [18]: https://github.com/microsoft/typescript-go/discussions/455
144
+ [19]: https://github.com/microsoft/typescript-go/tree/main/_packages/api
145
+ [20]: https://github.com/search?q=classMembers%20path%3Aknip.json&type=code
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Release Notes v2
3
3
  sidebar:
4
- order: 9
4
+ order: 10
5
5
  ---
6
6
 
7
7
  _2023-03-22_
@@ -2,7 +2,7 @@
2
2
  title: Slim down to speed up
3
3
  date: 2023-12-14
4
4
  sidebar:
5
- order: 6
5
+ order: 7
6
6
  ---
7
7
 
8
8
  _Published: 2023-12-14_
@@ -2,7 +2,7 @@
2
2
  title: The State of Knip
3
3
  date: 2025-02-28
4
4
  sidebar:
5
- order: 2
5
+ order: 3
6
6
  ---
7
7
 
8
8
  _Published: 2025-02-28_
@@ -2,7 +2,7 @@
2
2
  title: Two Years
3
3
  date: 2024-10-04
4
4
  sidebar:
5
- order: 3
5
+ order: 4
6
6
  ---
7
7
 
8
8
  _Published: 2024-10-04_
@@ -71,7 +71,7 @@ ts-prune
71
71
  knip --include exports,types,nsExports,nsTypes
72
72
  ```
73
73
 
74
- Use `knip --exports` to also include class and enum members.
74
+ Use `knip --exports` to also include enum and namespace members.
75
75
 
76
76
  **Project status**: The project is archived and recommends Knip.
77
77
 
@@ -87,7 +87,7 @@ ts-unused-exports
87
87
  knip --include exports,types,nsExports,nsTypes
88
88
  ```
89
89
 
90
- Use `knip --exports` to also include class and enum members.
90
+ Use `knip --exports` to also include enum and namespace members.
91
91
 
92
92
  ### tsr
93
93
 
@@ -11,8 +11,7 @@ following [issue types][1]:
11
11
 
12
12
  - Remove `export` keyword for unused exports, re-exports, and exported types
13
13
  - Remove `export default` keywords for unused default exports
14
- - Remove unused enum members
15
- - Remove unused class members (disabled by default)
14
+ - Remove unused enum and namespace members
16
15
  - Remove unused `dependencies` and `devDependencies` from `package.json`
17
16
  - Remove unused files
18
17
  - Remove unused catalog entries
@@ -288,37 +287,9 @@ Unused dependencies are removed from `package.json`:
288
287
  }
289
288
  ```
290
289
 
291
- ### Class members   <Badge text="experimental" variant="caution" />
292
-
293
- Unused members of classes can be removed:
294
-
295
- ```diff title="file.ts"
296
- export class Rectangle {
297
- constructor(public width: number, public height: number) {}
298
-
299
- - static Key = 1;
300
- +
301
-
302
- area() {
303
- return this.width * this.height;
304
- }
305
-
306
- - public get unusedGetter(): string {
307
- - return 'unusedGetter';
308
- - }
309
- }
310
- ```
311
-
312
- Currently Knip might be too eager removing class members when they're not
313
- referenced internally but meant to be called by an external library. For
314
- instance, Knip might think `componentDidMount` and `render` in React class
315
- component are unused and will remove those.
316
-
317
- Note that [`classMembers` aren't included by default][4].
318
-
319
290
  ### Catalog entries
320
291
 
321
- Unused [catalog][5] entries are removed from `pnpm-workspace.yaml`:
292
+ Unused [catalog][4] entries are removed from `pnpm-workspace.yaml`:
322
293
 
323
294
  ```diff title="pnpm-workspace.yaml"
324
295
  packages:
@@ -344,5 +315,4 @@ Operations that auto-fix does not (yet) perform and why:
344
315
  [1]: ../reference/issue-types.md
345
316
  [2]: https://github.com/JoshuaKGoldberg/formatly
346
317
  [3]: https://github.com/webpro-nl/remove-unused-vars
347
- [4]: ../guides/handling-issues.mdx#class-members
348
- [5]: https://pnpm.io/catalogs
318
+ [4]: https://pnpm.io/catalogs
@@ -29,7 +29,6 @@ object per file structured like this:
29
29
 
30
30
  ```json
31
31
  {
32
- "files": ["src/unused.ts"],
33
32
  "issues": [
34
33
  {
35
34
  "file": "package.json",
@@ -55,18 +54,22 @@ object per file structured like this:
55
54
  { "name": "unusedEnum", "line": 3, "col": 13, "pos": 71 },
56
55
  { "name": "unusedType", "line": 8, "col": 14, "pos": 145 }
57
56
  ],
58
- "enumMembers": {
59
- "MyEnum": [
60
- { "name": "unusedMember", "line": 13, "col": 3, "pos": 167 },
61
- { "name": "unusedKey", "line": 15, "col": 3, "pos": 205 }
62
- ]
63
- },
64
- "classMembers": {
65
- "MyClass": [
66
- { "name": "unusedMember", "line": 40, "col": 3, "pos": 687 },
67
- { "name": "unusedSetter", "line": 61, "col": 14, "pos": 1071 }
68
- ]
69
- },
57
+ "enumMembers": [
58
+ {
59
+ "namespace": "MyEnum",
60
+ "name": "unusedMember",
61
+ "line": 13,
62
+ "col": 3,
63
+ "pos": 167
64
+ },
65
+ {
66
+ "namespace": "MyEnum",
67
+ "name": "unusedKey",
68
+ "line": 15,
69
+ "col": 3,
70
+ "pos": 205
71
+ }
72
+ ],
70
73
  "duplicates": ["Registration", "default"]
71
74
  }
72
75
  ]
@@ -52,6 +52,7 @@ Knip has shortcuts to include only specific issue types.
52
52
  - `exports`
53
53
  - `types`
54
54
  - `enumMembers`
55
+ - `namespaceMembers`
55
56
  - `duplicates`
56
57
 
57
58
  3. The `--files` flag is a shortcut for `--include files`
@@ -73,7 +74,6 @@ Example:
73
74
  {
74
75
  "rules": {
75
76
  "files": "warn",
76
- "classMembers": "off",
77
77
  "duplicates": "off"
78
78
  }
79
79
  }
@@ -517,7 +517,7 @@ option][39] to tell Knip where to find the icon types:
517
517
  Where `[framework]` is the name of the framework you're using (see [available
518
518
  types][42]).
519
519
 
520
- **Solution**: try [--include-libs][43] or configure [paths][39].
520
+ **Solution**: configure [paths][39].
521
521
 
522
522
  ## Unused exports
523
523
 
@@ -525,8 +525,8 @@ By default, Knip does not report unused exports of `entry` files.
525
525
 
526
526
  The most common causes for unused exports include:
527
527
 
528
- - [Namespace enumerations][44]
529
- - [External libraries][45]
528
+ - [Namespace enumerations][43]
529
+ - [External libraries][44]
530
530
 
531
531
  Use the `--exports` flag to [filter][17] and focus only on issues related to
532
532
  exports:
@@ -535,7 +535,7 @@ exports:
535
535
  knip --exports
536
536
  ```
537
537
 
538
- Use [includeEntryExports][46] to report unused exports of entry files as well.
538
+ Use [includeEntryExports][45] to report unused exports of entry files as well.
539
539
  This can be set per workspace.
540
540
 
541
541
  ### Namespace enumerations
@@ -547,7 +547,7 @@ are then **not** reported.
547
547
  **Solution**: if all exports on imported namespaces should be considered
548
548
  individually, include the `nsExports` issue type to disable the heuristic.
549
549
 
550
- See [namespace imports][47] to see all related patterns.
550
+ See [namespace imports][46] to see all related patterns.
551
551
 
552
552
  ### External libraries
553
553
 
@@ -578,27 +578,16 @@ non-standard consumption of your exports? Here's an example:
578
578
  </Tabs>
579
579
 
580
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).
581
+ referenced through a function of an external library. Knip includes external
582
+ type definitions to trace such usage, but in some cases it may not be able to
583
+ follow the reference through the library's API.
595
584
 
596
585
  ### Exclude exports from the report
597
586
 
598
587
  To exclude false positives from the report, there are a few options:
599
588
 
600
- - [Ignore exports used in file][49] for exports used internally.
601
- - Individual exports can be [tagged using JSDoc syntax][50].
589
+ - [Ignore exports used in file][47] for exports used internally.
590
+ - Individual exports can be [tagged using JSDoc syntax][48].
602
591
  - Have the export in an entry file:
603
592
 
604
593
  - Add the file to the `entry` file patterns array in the configuration.
@@ -609,50 +598,47 @@ To exclude false positives from the report, there are a few options:
609
598
  ### Missing unused exports?
610
599
 
611
600
  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]
601
+ be exported from an entry file. In that case, use [--include-entry-exports][45]
613
602
  to make Knip also report unused exports in entry files.
614
603
 
615
604
  The exports of non-standard extensions like `.astro`, `.mdx`, `.vue` or
616
605
  `.svelte` are not available by default. See [compilers][21] for more details on
617
606
  how to include them.
618
607
 
619
- ### Class members
608
+ ### Enum members
620
609
 
621
- Unused members of exported classes are not reported by default, here's how to
622
- enable them:
610
+ Unused enums and unused members of exported enums are reported by default.
611
+ Reporting such members can be disabled:
623
612
 
624
613
  ```sh
625
- knip --include classMembers
614
+ knip --exclude enumMembers
626
615
  ```
627
616
 
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].
617
+ Individual enum members can be [tagged using JSDoc syntax][48].
632
618
 
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
619
+ Enums exported from entry files are ignored, and so are their members. Use
620
+ [--include-entry-exports][45] to make Knip also report members of unused exports
635
621
  in entry files.
636
622
 
637
- ### Enum members
623
+ ### Namespace members
638
624
 
639
- Unused enums and unused members of exported enums are reported by default.
625
+ Unused members of exported TypeScript namespaces are reported by default.
640
626
  Reporting such members can be disabled:
641
627
 
642
628
  ```sh
643
- knip --exclude enumMembers
629
+ knip --exclude namespaceMembers
644
630
  ```
645
631
 
646
- Individual enum members can be [tagged using JSDoc syntax][50].
632
+ Individual namespace members can be [tagged using JSDoc syntax][48].
647
633
 
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
634
+ Namespaces exported from entry files are ignored, and so are their members. Use
635
+ [--include-entry-exports][45] to make Knip also report members of unused exports
650
636
  in entry files.
651
637
 
652
638
  ## Feedback or false positives?
653
639
 
654
640
  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
641
+ false positive), feel free to create a [minimal reproduction][49] and open an
656
642
  issue on GitHub. It'll make Knip better for everyone!
657
643
 
658
644
  [1]: #unused-files
@@ -697,12 +683,10 @@ issue on GitHub. It'll make Knip better for everyone!
697
683
  [40]: ../reference/configuration.md#ignoreunresolved
698
684
  [41]: https://www.npmjs.com/package/unplugin-icons
699
685
  [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
686
+ [43]: #namespace-enumerations
687
+ [44]: #external-libraries
688
+ [45]: ../reference/configuration.md#includeentryexports
689
+ [46]: ../guides/namespace-imports.md
690
+ [47]: ../reference/configuration.md#ignoreexportsusedinfile
691
+ [48]: ../reference/jsdoc-tsdoc-tags.md
692
+ [49]: ../guides/issue-reproduction.md
@@ -87,14 +87,10 @@ development][12].
87
87
 
88
88
  [1]: https://github.com/webpro-nl/knip/issues?q=is%3Aissue
89
89
  [2]: https://knip.dev/reference/known-issues
90
- [3]:
91
- https://codesandbox.io/p/devbox/github/webpro-nl/knip/main/templates/issue-reproduction/basic
92
- [4]:
93
- https://stackblitz.com/github/webpro-nl/knip/tree/main/templates/issue-reproduction/basic
94
- [5]:
95
- https://codesandbox.io/p/devbox/github/webpro-nl/knip/main/templates/issue-reproduction/monorepo
96
- [6]:
97
- https://stackblitz.com/github/webpro-nl/knip/tree/main/templates/issue-reproduction/monorepo
90
+ [3]: https://codesandbox.io/p/devbox/github/webpro-nl/knip/main/templates/issue-reproduction/basic
91
+ [4]: https://stackblitz.com/github/webpro-nl/knip/tree/main/templates/issue-reproduction/basic
92
+ [5]: https://codesandbox.io/p/devbox/github/webpro-nl/knip/main/templates/issue-reproduction/monorepo
93
+ [6]: https://stackblitz.com/github/webpro-nl/knip/tree/main/templates/issue-reproduction/monorepo
98
94
  [7]: https://codesandbox.io
99
95
  [8]: https://stackblitz.com
100
96
  [9]: https://github.com/webpro-nl/knip/blob/main/.github/DEVELOPMENT.md#tests