@knip/mcp 0.0.13 → 0.0.15
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.
- package/package.json +2 -2
- package/src/docs/docs/blog/for-editors-and-agents.md +47 -43
- package/src/docs/docs/blog/knip-v4.mdx +2 -2
- package/src/docs/docs/blog/two-years.mdx +1 -1
- package/src/docs/docs/explanations/plugins.md +10 -7
- package/src/docs/docs/guides/configuring-project-files.md +3 -3
- package/src/docs/docs/guides/contributing.md +1 -1
- package/src/docs/docs/guides/handling-issues.mdx +44 -45
- package/src/docs/docs/guides/issue-reproduction.md +4 -0
- package/src/docs/docs/guides/troubleshooting.md +1 -1
- package/src/docs/docs/index.mdx +3 -3
- package/src/docs/docs/overview/features.md +2 -2
- package/src/docs/docs/overview/getting-started.mdx +16 -5
- package/src/docs/docs/reference/configuration.md +7 -0
- package/src/docs/docs/reference/faq.md +1 -2
- package/src/docs/docs/reference/known-issues.md +13 -8
- package/src/docs/docs/reference/plugins/angular.md +10 -6
- package/src/docs/docs/reference/plugins/astro-db.md +10 -7
- package/src/docs/docs/reference/plugins/astro.md +10 -6
- package/src/docs/docs/reference/plugins/ava.md +10 -7
- package/src/docs/docs/reference/plugins/babel.md +9 -3
- package/src/docs/docs/reference/plugins/biome.md +10 -7
- package/src/docs/docs/reference/plugins/bumpp.md +9 -3
- package/src/docs/docs/reference/plugins/bun.md +6 -2
- package/src/docs/docs/reference/plugins/c8.md +7 -4
- package/src/docs/docs/reference/plugins/capacitor.md +10 -6
- package/src/docs/docs/reference/plugins/changelogen.md +9 -3
- package/src/docs/docs/reference/plugins/changelogithub.md +9 -3
- package/src/docs/docs/reference/plugins/changesets.md +10 -6
- package/src/docs/docs/reference/plugins/commitizen.md +10 -8
- package/src/docs/docs/reference/plugins/commitlint.md +9 -3
- package/src/docs/docs/reference/plugins/convex.md +10 -7
- package/src/docs/docs/reference/plugins/create-typescript-app.md +10 -6
- package/src/docs/docs/reference/plugins/cspell.md +9 -3
- package/src/docs/docs/reference/plugins/cucumber.md +11 -9
- package/src/docs/docs/reference/plugins/cypress.md +10 -6
- package/src/docs/docs/reference/plugins/danger.md +10 -6
- package/src/docs/docs/reference/plugins/dependency-cruiser.md +14 -9
- package/src/docs/docs/reference/plugins/docusaurus.md +10 -6
- package/src/docs/docs/reference/plugins/dotenv.md +8 -4
- package/src/docs/docs/reference/plugins/drizzle.md +10 -6
- package/src/docs/docs/reference/plugins/eleventy.md +11 -11
- package/src/docs/docs/reference/plugins/eslint.md +22 -10
- package/src/docs/docs/reference/plugins/expo.md +11 -11
- package/src/docs/docs/reference/plugins/gatsby.md +9 -3
- package/src/docs/docs/reference/plugins/github-action.md +10 -6
- package/src/docs/docs/reference/plugins/github-actions.md +10 -7
- package/src/docs/docs/reference/plugins/glob.md +8 -4
- package/src/docs/docs/reference/plugins/graphql-codegen.md +9 -3
- package/src/docs/docs/reference/plugins/hardhat.md +10 -6
- package/src/docs/docs/reference/plugins/husky.md +9 -3
- package/src/docs/docs/reference/plugins/i18next-parser.md +14 -9
- package/src/docs/docs/reference/plugins/jest.md +14 -10
- package/src/docs/docs/reference/plugins/karma.md +9 -3
- package/src/docs/docs/reference/plugins/knex.md +37 -0
- package/src/docs/docs/reference/plugins/ladle.md +11 -9
- package/src/docs/docs/reference/plugins/lefthook.md +9 -3
- package/src/docs/docs/reference/plugins/lint-staged.md +9 -3
- package/src/docs/docs/reference/plugins/linthtml.md +9 -3
- package/src/docs/docs/reference/plugins/lockfile-lint.md +9 -3
- package/src/docs/docs/reference/plugins/lost-pixel.md +10 -6
- package/src/docs/docs/reference/plugins/markdownlint.md +10 -7
- package/src/docs/docs/reference/plugins/mdx.md +10 -6
- package/src/docs/docs/reference/plugins/mdxlint.md +9 -3
- package/src/docs/docs/reference/plugins/metro.md +12 -9
- package/src/docs/docs/reference/plugins/mocha.md +15 -13
- package/src/docs/docs/reference/plugins/moonrepo.md +10 -8
- package/src/docs/docs/reference/plugins/msw.md +11 -9
- package/src/docs/docs/reference/plugins/nano-staged.md +9 -3
- package/src/docs/docs/reference/plugins/nest.md +10 -9
- package/src/docs/docs/reference/plugins/netlify.md +11 -9
- package/src/docs/docs/reference/plugins/next-intl.md +10 -6
- package/src/docs/docs/reference/plugins/next-mdx.md +11 -9
- package/src/docs/docs/reference/plugins/next.md +10 -6
- package/src/docs/docs/reference/plugins/node-modules-inspector.md +11 -4
- package/src/docs/docs/reference/plugins/node.md +12 -8
- package/src/docs/docs/reference/plugins/nodemon.md +8 -4
- package/src/docs/docs/reference/plugins/npm-package-json-lint.md +9 -3
- package/src/docs/docs/reference/plugins/nuxt.md +14 -8
- package/src/docs/docs/reference/plugins/nx.md +15 -7
- package/src/docs/docs/reference/plugins/nyc.md +9 -3
- package/src/docs/docs/reference/plugins/oclif.md +10 -6
- package/src/docs/docs/reference/plugins/oxlint.md +14 -9
- package/src/docs/docs/reference/plugins/parcel.md +41 -0
- package/src/docs/docs/reference/plugins/playwright-ct.md +10 -6
- package/src/docs/docs/reference/plugins/playwright-test.md +10 -5
- package/src/docs/docs/reference/plugins/playwright.md +15 -12
- package/src/docs/docs/reference/plugins/plop.md +10 -6
- package/src/docs/docs/reference/plugins/pnpm.md +8 -5
- package/src/docs/docs/reference/plugins/postcss.md +9 -3
- package/src/docs/docs/reference/plugins/preconstruct.md +10 -6
- package/src/docs/docs/reference/plugins/prettier.md +9 -3
- package/src/docs/docs/reference/plugins/prisma.md +14 -10
- package/src/docs/docs/reference/plugins/react-cosmos.md +10 -6
- package/src/docs/docs/reference/plugins/react-router.md +9 -3
- package/src/docs/docs/reference/plugins/relay.md +14 -10
- package/src/docs/docs/reference/plugins/release-it.md +10 -7
- package/src/docs/docs/reference/plugins/remark.md +9 -3
- package/src/docs/docs/reference/plugins/remix.md +9 -3
- package/src/docs/docs/reference/plugins/rollup.md +14 -9
- package/src/docs/docs/reference/plugins/rsbuild.md +10 -6
- package/src/docs/docs/reference/plugins/rslib.md +10 -6
- package/src/docs/docs/reference/plugins/rspack.md +10 -6
- package/src/docs/docs/reference/plugins/rstest.md +10 -6
- package/src/docs/docs/reference/plugins/semantic-release.md +9 -3
- package/src/docs/docs/reference/plugins/sentry.md +10 -6
- package/src/docs/docs/reference/plugins/simple-git-hooks.md +9 -3
- package/src/docs/docs/reference/plugins/size-limit.md +9 -3
- package/src/docs/docs/reference/plugins/sst.md +10 -6
- package/src/docs/docs/reference/plugins/starlight.md +10 -6
- package/src/docs/docs/reference/plugins/storybook.md +11 -9
- package/src/docs/docs/reference/plugins/stryker.md +10 -6
- package/src/docs/docs/reference/plugins/stylelint.md +9 -3
- package/src/docs/docs/reference/plugins/svelte.md +9 -3
- package/src/docs/docs/reference/plugins/svgo.md +10 -6
- package/src/docs/docs/reference/plugins/svgr.md +9 -3
- package/src/docs/docs/reference/plugins/swc.md +10 -6
- package/src/docs/docs/reference/plugins/syncpack.md +9 -3
- package/src/docs/docs/reference/plugins/tailwind.md +10 -6
- package/src/docs/docs/reference/plugins/tanstack-router.md +49 -0
- package/src/docs/docs/reference/plugins/taskfile.md +10 -7
- package/src/docs/docs/reference/plugins/travis.md +8 -5
- package/src/docs/docs/reference/plugins/ts-node.md +8 -4
- package/src/docs/docs/reference/plugins/tsdown.md +14 -10
- package/src/docs/docs/reference/plugins/tsup.md +14 -10
- package/src/docs/docs/reference/plugins/tsx.md +12 -8
- package/src/docs/docs/reference/plugins/typedoc.md +13 -6
- package/src/docs/docs/reference/plugins/typescript.md +17 -10
- package/src/docs/docs/reference/plugins/unbuild.md +10 -6
- package/src/docs/docs/reference/plugins/unocss.md +9 -3
- package/src/docs/docs/reference/plugins/vercel-og.md +9 -3
- package/src/docs/docs/reference/plugins/vike.md +9 -3
- package/src/docs/docs/reference/plugins/vite.md +14 -9
- package/src/docs/docs/reference/plugins/vitepress.md +9 -3
- package/src/docs/docs/reference/plugins/vitest.md +13 -6
- package/src/docs/docs/reference/plugins/vue.md +10 -6
- package/src/docs/docs/reference/plugins/webdriver-io.md +10 -6
- package/src/docs/docs/reference/plugins/webpack.md +14 -9
- package/src/docs/docs/reference/plugins/wireit.md +10 -6
- package/src/docs/docs/reference/plugins/wrangler.md +10 -6
- package/src/docs/docs/reference/plugins/xo.md +10 -7
- package/src/docs/docs/reference/plugins/yarn.md +8 -5
- package/src/docs/docs/reference/plugins/yorkie.md +10 -6
- package/src/docs/docs/reference/plugins.md +5 -1
- package/src/docs/docs/writing-a-plugin/index.md +16 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Knip MCP Server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
30
30
|
"zod": "^4.1.11",
|
|
31
|
-
"knip": "^5.
|
|
31
|
+
"knip": "^5.80.1"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18.18.0"
|
|
@@ -7,32 +7,34 @@ sidebar:
|
|
|
7
7
|
|
|
8
8
|
_Published: 2025-12-17_
|
|
9
9
|
|
|
10
|
-
Three years in, Knip has
|
|
10
|
+
Three years in, Knip has found its place in [over 10.000 projects][1] and is
|
|
11
11
|
downloaded [over 18M times/month][2]. A long period of steady growth in usage
|
|
12
12
|
and stability allows Knip to become more accessible to more people. That's why
|
|
13
|
-
I'm excited and proud to introduce the brand new
|
|
14
|
-
Server. For humans and coding agents alike, Knip will help keep your
|
|
15
|
-
tidy.
|
|
13
|
+
I'm excited and proud to introduce the brand new [Editor Extension][3] **and**
|
|
14
|
+
MCP Server. For humans and coding agents alike, Knip will help keep your
|
|
15
|
+
codebases tidy.
|
|
16
16
|
|
|
17
17
|
Don't forget... Knip it before you ship it!
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Editor Extension
|
|
20
20
|
|
|
21
21
|
This one is for you.
|
|
22
22
|
|
|
23
|
-
[The usual suspects][
|
|
23
|
+
[The usual suspects][4] like red squiggles for unused exports are there. What
|
|
24
24
|
really moves the needle for DX with Knip's module graph is **navigation**. A
|
|
25
|
-
completely unique way to view & fly through codebases
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
completely unique way to view & fly through codebases. Connect the dots during
|
|
26
|
+
development and refactors, while keeping things in check. We're starting out
|
|
27
|
+
with [3 key features][5]:
|
|
28
28
|
|
|
29
29
|
1. **Hover over Export** for import & usage locations
|
|
30
30
|
2. **Imports Tree View** for direct links to implementations
|
|
31
31
|
3. **Exports Tree View** for direct links to import & usage locations
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The extension has a [built-in MCP Server][6] with a command and resources to
|
|
34
|
+
configure Knip for you, _completely automated_.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
Find [Knip on the VS Code Marketplace][7] and find [Knip in the Open VSX
|
|
37
|
+
Registry][8].
|
|
36
38
|
|
|
37
39
|
## MCP Server
|
|
38
40
|
|
|
@@ -41,7 +43,7 @@ coding agent to "configure knip" and it will RTFM so you don't have to. Using a
|
|
|
41
43
|
newer model like Opus 4.5 or GPT 5.2 results in an optimized `knip.json` file
|
|
42
44
|
and an uncluttered codebase.
|
|
43
45
|
|
|
44
|
-
The [MCP Server is available][
|
|
46
|
+
The [MCP Server is available][9] separately and built into the VS Code
|
|
45
47
|
Extension.
|
|
46
48
|
|
|
47
49
|
## Language Server
|
|
@@ -53,25 +55,25 @@ information. Queries like "where is an export imported" or "is this import part
|
|
|
53
55
|
of a circular dependency" are just scratching the surface here.
|
|
54
56
|
|
|
55
57
|
Extensions for other IDEs can be built on top. See
|
|
56
|
-
[language-server/README.md][
|
|
58
|
+
[language-server/README.md][10]
|
|
57
59
|
|
|
58
60
|
## Screenshots
|
|
59
61
|
|
|
60
|
-
- [Lint Findings][
|
|
61
|
-
- [Imports & Exports][
|
|
62
|
-
- [Contention][
|
|
63
|
-
- [Circular Dependencies][
|
|
64
|
-
- [Conflicts][
|
|
65
|
-
- [Branching][
|
|
66
|
-
- [VS Code Extension Settings][
|
|
62
|
+
- [Lint Findings][4]
|
|
63
|
+
- [Imports & Exports][5]
|
|
64
|
+
- [Contention][11]
|
|
65
|
+
- [Circular Dependencies][12]
|
|
66
|
+
- [Conflicts][13]
|
|
67
|
+
- [Branching][14]
|
|
68
|
+
- [VS Code Extension Settings][15]
|
|
67
69
|
|
|
68
70
|
### Lint Findings
|
|
69
71
|
|
|
70
|
-
![Lint Findings][
|
|
72
|
+
![Lint Findings][16]
|
|
71
73
|
|
|
72
74
|
### Imports & Exports
|
|
73
75
|
|
|
74
|
-
![hover][
|
|
76
|
+
![hover][17]
|
|
75
77
|
|
|
76
78
|
### Contention
|
|
77
79
|
|
|
@@ -83,7 +85,7 @@ branched/diamond-shaped import chains.
|
|
|
83
85
|
|
|
84
86
|
If an import is part of a circular dependency, Knip will display:
|
|
85
87
|
|
|
86
|
-
![Circular Dependencies][
|
|
88
|
+
![Circular Dependencies][18]
|
|
87
89
|
|
|
88
90
|
#### Conflicts
|
|
89
91
|
|
|
@@ -91,7 +93,7 @@ TypeScript shows direct conflicts when importing or re-exporting the same named
|
|
|
91
93
|
export from different files. Except when the problem is more subtle and the
|
|
92
94
|
chain spans more than one file. Knip warns:
|
|
93
95
|
|
|
94
|
-
![Conflicts][
|
|
96
|
+
![Conflicts][19]
|
|
95
97
|
|
|
96
98
|
#### Branching
|
|
97
99
|
|
|
@@ -99,29 +101,31 @@ Branched or diamond-shaped imports chains indicate unnecessary re-exports and
|
|
|
99
101
|
complexity. They help to untangle large codebases and shrink or get rid of
|
|
100
102
|
barrel files. Knip warns:
|
|
101
103
|
|
|
102
|
-
![Branching][
|
|
104
|
+
![Branching][20]
|
|
103
105
|
|
|
104
106
|
### VS Code Extension Settings
|
|
105
107
|
|
|
106
|
-
![VS Code Extension Settings][
|
|
108
|
+
![VS Code Extension Settings][21]
|
|
107
109
|
|
|
108
110
|
[1]: https://github.com/webpro-nl/knip/network/dependents
|
|
109
111
|
[2]: https://www.npmjs.com/package/knip
|
|
110
|
-
[3]: #
|
|
111
|
-
[4]: #
|
|
112
|
-
[5]:
|
|
113
|
-
[6]:
|
|
114
|
-
[7]: https://
|
|
115
|
-
[8]:
|
|
112
|
+
[3]: #editor-extension
|
|
113
|
+
[4]: #lint-findings
|
|
114
|
+
[5]: #imports--exports
|
|
115
|
+
[6]: #mcp-server
|
|
116
|
+
[7]: https://marketplace.visualstudio.com/items?itemName=webpro.vscode-knip
|
|
117
|
+
[8]: https://open-vsx.org/extension/webpro/vscode-knip
|
|
118
|
+
[9]: https://www.npmjs.com/package/@knip/mcp
|
|
119
|
+
[10]:
|
|
116
120
|
https://github.com/webpro-nl/knip/blob/main/packages/language-server/README.md
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
[
|
|
122
|
-
[
|
|
123
|
-
[
|
|
124
|
-
[
|
|
125
|
-
[
|
|
126
|
-
[
|
|
127
|
-
[
|
|
121
|
+
[11]: #contention
|
|
122
|
+
[12]: #circular-dependencies
|
|
123
|
+
[13]: #conflicts
|
|
124
|
+
[14]: #branching
|
|
125
|
+
[15]: #vs-code-extension-settings
|
|
126
|
+
[16]: /screenshots/editors-and-agents/diagnostics.webp
|
|
127
|
+
[17]: /screenshots/editors-and-agents/imports-exports.webp
|
|
128
|
+
[18]: /screenshots/editors-and-agents/circular-dependency.webp
|
|
129
|
+
[19]: /screenshots/editors-and-agents/conflict.webp
|
|
130
|
+
[20]: /screenshots/editors-and-agents/branch.webp
|
|
131
|
+
[21]: /screenshots/editors-and-agents/vscode-extension-settings.webp
|
|
@@ -144,6 +144,6 @@ Remember, Knip it before you ship it! Have a great day ☀️
|
|
|
144
144
|
|
|
145
145
|
[1]: ./slim-down-to-speed-up.md
|
|
146
146
|
[2]: ../features/compilers.md
|
|
147
|
-
[3]: ../guides/issue-reproduction
|
|
147
|
+
[3]: ../guides/issue-reproduction.md
|
|
148
148
|
[4]: https://github.com/sponsors/webpro
|
|
149
|
-
[5]: ../reference/cli#--experimental-tags
|
|
149
|
+
[5]: ../reference/cli.md#--experimental-tags
|
|
@@ -101,7 +101,7 @@ Thanks to Joshua Goldberg for [emoji-blast][7]! 🎉
|
|
|
101
101
|
[1]: https://www.npmjs.com/package/exportman/v/0.0.1
|
|
102
102
|
[2]: /cow-with-orange-scissors-van-gogh-style.webp
|
|
103
103
|
[3]: https://github.com/webpro-nl/knip/releases/tag/5.31.0
|
|
104
|
-
[4]: ../features/auto-fix.
|
|
104
|
+
[4]: ../features/auto-fix.mdx
|
|
105
105
|
[5]: https://github.com/unjs/jiti
|
|
106
106
|
[6]: /sponsors
|
|
107
107
|
[7]: https://www.emojiblast.dev
|
|
@@ -108,7 +108,7 @@ configured.
|
|
|
108
108
|
|
|
109
109
|
:::tip[Plugins result in less configuration]
|
|
110
110
|
|
|
111
|
-
Plugins uses entry file patterns as defined in
|
|
111
|
+
Plugins uses entry file patterns as defined in your configuration file of these
|
|
112
112
|
tools. So you don't need to repeat this in your Knip configuration.
|
|
113
113
|
|
|
114
114
|
:::
|
|
@@ -242,7 +242,8 @@ dependency.
|
|
|
242
242
|
|
|
243
243
|
:::tip[Summary]
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
In your config files, plugins can find additional entry files and also other
|
|
246
|
+
config files recursively.
|
|
246
247
|
|
|
247
248
|
:::
|
|
248
249
|
|
|
@@ -285,7 +286,9 @@ Additionally, `./setup-tests.ts` will be added as an `entry` file.
|
|
|
285
286
|
|
|
286
287
|
:::note
|
|
287
288
|
|
|
288
|
-
When plugins dynamically load configuration files, conditional dependencies may
|
|
289
|
+
When plugins dynamically load configuration files, conditional dependencies may
|
|
290
|
+
not be detected if the condition evaluates differently during analysis. See
|
|
291
|
+
[conditional or dynamic dependencies][9] for details and workarounds.
|
|
289
292
|
|
|
290
293
|
:::
|
|
291
294
|
|
|
@@ -299,7 +302,7 @@ node --loader tsx scripts/deploy.ts
|
|
|
299
302
|
playwright test -c playwright.web.config.ts
|
|
300
303
|
```
|
|
301
304
|
|
|
302
|
-
Please see [script parser][
|
|
305
|
+
Please see [script parser][10] for more details.
|
|
303
306
|
|
|
304
307
|
## Summary
|
|
305
308
|
|
|
@@ -315,12 +318,12 @@ Plugins are configured with two distinct types of files:
|
|
|
315
318
|
:::
|
|
316
319
|
|
|
317
320
|
[1]: ../reference/plugins.md
|
|
318
|
-
[2]: ../
|
|
321
|
+
[2]: ../writing-a-plugin/index.md
|
|
319
322
|
[3]: #configuration-files
|
|
320
323
|
[4]: #entry-files
|
|
321
324
|
[5]: #command-line-arguments
|
|
322
325
|
[6]: ./entry-files.md
|
|
323
326
|
[7]: ../reference/plugins/eslint.md
|
|
324
327
|
[8]: ../reference/plugins/vitest.md
|
|
325
|
-
[9]: ../
|
|
326
|
-
[10]: ../
|
|
328
|
+
[9]: ../guides/handling-issues.mdx#conditional-or-dynamic-dependencies
|
|
329
|
+
[10]: ../features/script-parser.md
|
|
@@ -41,8 +41,8 @@ and adjust `project` to fit your codebase.
|
|
|
41
41
|
Use negated `project` patterns to precisely include/exclude files for unused
|
|
42
42
|
files detection.
|
|
43
43
|
|
|
44
|
-
Use `ignore
|
|
45
|
-
from analysis.
|
|
44
|
+
Use `ignore*` to suppress specific issues in matching files; it does not exclude
|
|
45
|
+
files from analysis.
|
|
46
46
|
|
|
47
47
|
:::
|
|
48
48
|
|
|
@@ -200,6 +200,6 @@ automatically added as well.
|
|
|
200
200
|
|
|
201
201
|
[1]: ../typescript/unused-exports.md
|
|
202
202
|
[2]: ../explanations/entry-files.md
|
|
203
|
-
[3]: ../reference/configuration#ignoreexportsusedinfile
|
|
203
|
+
[3]: ../reference/configuration.md#ignoreexportsusedinfile
|
|
204
204
|
[4]: ../features/production-mode.md
|
|
205
205
|
[5]: ../explanations/plugins.md#entry-files
|
|
@@ -20,5 +20,5 @@ contributes to that goal is welcome!
|
|
|
20
20
|
[1]: https://github.com/webpro-nl/knip
|
|
21
21
|
[2]: ./issue-reproduction.md
|
|
22
22
|
[3]: https://github.com/webpro-nl/knip/blob/main/.github/CONTRIBUTING.md
|
|
23
|
-
[4]:
|
|
23
|
+
[4]: ../writing-a-plugin/index.md
|
|
24
24
|
[5]: https://github.com/webpro-nl/knip/blob/main/.github/DEVELOPMENT.md
|
|
@@ -294,7 +294,7 @@ Some packages have the same name as a Node.js builtin (for instance `buffer` or
|
|
|
294
294
|
**Solution**: if Knip reports such a dependency as unused, add it to
|
|
295
295
|
[ignoreDependencies][22].
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
### Conditional or dynamic dependencies
|
|
298
298
|
|
|
299
299
|
Dependencies added conditionally in configuration files may not be detected by
|
|
300
300
|
Knip. This happens because Knip loads and executes config files, and conditional
|
|
@@ -319,11 +319,11 @@ If `process.env.REPORT_PORTAL_ENABLED` evaluates to `false` when Knip runs, the
|
|
|
319
319
|
`@reportportal/agent-js-playwright` dependency won't be detected and may be
|
|
320
320
|
reported as unused.
|
|
321
321
|
|
|
322
|
-
This limitation exists because Knip executes configuration files to parse their
|
|
323
|
-
While Knip can parse configuration files statically using AST
|
|
324
|
-
Syntax Tree) analysis, this approach becomes complex very quickly and
|
|
325
|
-
the time it is easier to use the [`ignoreDependencies`][22]
|
|
326
|
-
for conditionals.
|
|
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
327
|
|
|
328
328
|
```json title="knip.json"
|
|
329
329
|
{
|
|
@@ -420,9 +420,9 @@ example:
|
|
|
420
420
|
```
|
|
421
421
|
|
|
422
422
|
This example works fine without anything reported, as the `@commitlint/cli`
|
|
423
|
-
package includes the `commitlint` binary. However, some script may contain
|
|
424
|
-
|
|
425
|
-
|
|
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
|
|
426
426
|
`@commitlint/cli`.
|
|
427
427
|
|
|
428
428
|
**Solution**: use `npx @commitlint/cli`
|
|
@@ -473,8 +473,8 @@ The first import is resolved properly, because `.vue` is a known extension if
|
|
|
473
473
|
the Vue plugin is enabled. The second import might not be resolved, because
|
|
474
474
|
`.svg` is not a known extension.
|
|
475
475
|
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
**Solution**: include the extension. Hosts supporting ES Modules (e.g. Node.js,
|
|
477
|
+
browsers) require a file extension for import specifiers.
|
|
478
478
|
|
|
479
479
|
### Unrecognized path aliases
|
|
480
480
|
|
|
@@ -488,9 +488,9 @@ but not those in e.g. Webpack or Vite configurations.
|
|
|
488
488
|
|
|
489
489
|
External libraries may use aliased imports that aren't resolved by Knip.
|
|
490
490
|
|
|
491
|
-
For instance, [unplugin-icons][
|
|
491
|
+
For instance, [unplugin-icons][39] does this to import icons from icon sets as
|
|
492
492
|
components. Such imports are reported as unused. Use the [`paths` configuration
|
|
493
|
-
option][
|
|
493
|
+
option][37] to tell Knip where to find the icon types:
|
|
494
494
|
|
|
495
495
|
```json title="knip.json"
|
|
496
496
|
{
|
|
@@ -501,9 +501,9 @@ option][13] to tell Knip where to find the icon types:
|
|
|
501
501
|
```
|
|
502
502
|
|
|
503
503
|
Where `[framework]` is the name of the framework you're using (see [available
|
|
504
|
-
types][
|
|
504
|
+
types][40]).
|
|
505
505
|
|
|
506
|
-
**Solution**: try [--include-libs][
|
|
506
|
+
**Solution**: try [--include-libs][41] or configure [paths][37].
|
|
507
507
|
|
|
508
508
|
## Unused exports
|
|
509
509
|
|
|
@@ -511,8 +511,8 @@ By default, Knip does not report unused exports of `entry` files.
|
|
|
511
511
|
|
|
512
512
|
The most common causes for unused exports include:
|
|
513
513
|
|
|
514
|
-
- [Namespace enumerations][
|
|
515
|
-
- [External libraries][
|
|
514
|
+
- [Namespace enumerations][42]
|
|
515
|
+
- [External libraries][43]
|
|
516
516
|
|
|
517
517
|
Use the `--exports` flag to [filter][15] and focus only on issues related to
|
|
518
518
|
exports:
|
|
@@ -521,7 +521,7 @@ exports:
|
|
|
521
521
|
knip --exports
|
|
522
522
|
```
|
|
523
523
|
|
|
524
|
-
Use [includeEntryExports][
|
|
524
|
+
Use [includeEntryExports][44] to report unused exports of entry files as well.
|
|
525
525
|
This can be set per workspace.
|
|
526
526
|
|
|
527
527
|
### Namespace enumerations
|
|
@@ -533,7 +533,7 @@ are then **not** reported.
|
|
|
533
533
|
**Solution**: if all exports on imported namespaces should be considered
|
|
534
534
|
individually, include the `nsExports` issue type to disable the heuristic.
|
|
535
535
|
|
|
536
|
-
See [namespace imports][
|
|
536
|
+
See [namespace imports][45] to see all related patterns.
|
|
537
537
|
|
|
538
538
|
### External libraries
|
|
539
539
|
|
|
@@ -553,7 +553,6 @@ non-standard consumption of your exports? Here's an example:
|
|
|
553
553
|
resolveComponent: components => components.Orange,
|
|
554
554
|
});
|
|
555
555
|
```
|
|
556
|
-
|
|
557
556
|
</TabItem>
|
|
558
557
|
|
|
559
558
|
<TabItem label="components.js">
|
|
@@ -570,23 +569,24 @@ Knip does not include external type definitions by default so it won't see the
|
|
|
570
569
|
export being referenced.
|
|
571
570
|
|
|
572
571
|
**Solution**: include the type definitions of external libraries with the
|
|
573
|
-
[--include-libs][
|
|
572
|
+
[--include-libs][41] flag:
|
|
574
573
|
|
|
575
574
|
```shell
|
|
576
575
|
knip --include-libs
|
|
577
576
|
```
|
|
578
577
|
|
|
579
578
|
This comes at a performance and memory penalty, but should give better results
|
|
580
|
-
if you need it. This flag is implied when [classMembers][
|
|
579
|
+
if you need it. This flag is implied when [classMembers][46] are included (that
|
|
581
580
|
feature comes with roughly the same performance penalty).
|
|
582
581
|
|
|
583
582
|
### Exclude exports from the report
|
|
584
583
|
|
|
585
584
|
To exclude false positives from the report, there are a few options:
|
|
586
585
|
|
|
587
|
-
- [Ignore exports used in file][
|
|
588
|
-
- Individual exports can be [tagged using JSDoc syntax][
|
|
586
|
+
- [Ignore exports used in file][47] for exports used internally.
|
|
587
|
+
- Individual exports can be [tagged using JSDoc syntax][48].
|
|
589
588
|
- Have the export in an entry file:
|
|
589
|
+
|
|
590
590
|
- Add the file to the `entry` file patterns array in the configuration.
|
|
591
591
|
- Move the export(s) to an entry file.
|
|
592
592
|
- Add the file to the `exports` field of `package.json`
|
|
@@ -595,7 +595,7 @@ To exclude false positives from the report, there are a few options:
|
|
|
595
595
|
### Missing unused exports?
|
|
596
596
|
|
|
597
597
|
Did you expect certain exports in the report, but are they missing? They might
|
|
598
|
-
be exported from an entry file. In that case, use [--include-entry-exports][
|
|
598
|
+
be exported from an entry file. In that case, use [--include-entry-exports][44]
|
|
599
599
|
to make Knip also report unused exports in entry files.
|
|
600
600
|
|
|
601
601
|
The exports of non-standard extensions like `.astro`, `.mdx`, `.vue` or
|
|
@@ -614,10 +614,10 @@ knip --include classMembers
|
|
|
614
614
|
This option is also available in the Knip configuration file. Note that this
|
|
615
615
|
feature comes at a cost: linting will take more time and more memory.
|
|
616
616
|
|
|
617
|
-
Individual class members can be [tagged using JSDoc syntax][
|
|
617
|
+
Individual class members can be [tagged using JSDoc syntax][48].
|
|
618
618
|
|
|
619
619
|
Classes exported from entry files are ignored, and so are their members. Use
|
|
620
|
-
[--include-entry-exports][
|
|
620
|
+
[--include-entry-exports][44] to make Knip also report members of unused exports
|
|
621
621
|
in entry files.
|
|
622
622
|
|
|
623
623
|
### Enum members
|
|
@@ -629,16 +629,16 @@ Reporting such members can be disabled:
|
|
|
629
629
|
knip --exclude enumMembers
|
|
630
630
|
```
|
|
631
631
|
|
|
632
|
-
Individual enum members can be [tagged using JSDoc syntax][
|
|
632
|
+
Individual enum members can be [tagged using JSDoc syntax][48].
|
|
633
633
|
|
|
634
634
|
Enums exported from entry files are ignored, and so are their members. Use
|
|
635
|
-
[--include-entry-exports][
|
|
635
|
+
[--include-entry-exports][44] to make Knip also report members of unused exports
|
|
636
636
|
in entry files.
|
|
637
637
|
|
|
638
638
|
## Feedback or false positives?
|
|
639
639
|
|
|
640
640
|
If you believe Knip incorrectly reports something as unused (i.e. there's a
|
|
641
|
-
false positive), feel free to create a [minimal reproduction][
|
|
641
|
+
false positive), feel free to create a [minimal reproduction][49] and open an
|
|
642
642
|
issue on GitHub. It'll make Knip better for everyone!
|
|
643
643
|
|
|
644
644
|
[1]: #unused-files
|
|
@@ -660,34 +660,33 @@ issue on GitHub. It'll make Knip better for everyone!
|
|
|
660
660
|
[17]: ../features/source-mapping.md
|
|
661
661
|
[18]: ../features/script-parser.md
|
|
662
662
|
[19]: ../features/compilers.md
|
|
663
|
-
[20]:
|
|
663
|
+
[20]: ../writing-a-plugin/index.md
|
|
664
664
|
[21]: ../reference/plugins.md
|
|
665
665
|
[22]: ../reference/configuration.md#ignoredependencies
|
|
666
666
|
[23]: ../explanations/plugins.md#entry-files
|
|
667
667
|
[24]: ../explanations/entry-files.md#plugins
|
|
668
|
-
[25]:
|
|
669
|
-
../reference/faq.md#why-cant-i-use-path-aliases-to-reference-other-workspaces
|
|
668
|
+
[25]: ../reference/faq.md#why-cant-i-use-path-aliases-to-reference-other-workspaces
|
|
670
669
|
[26]: ../features/integrated-monorepos.md
|
|
671
670
|
[27]: #missing-or-incomplete-plugin
|
|
672
671
|
[28]: #unrecognized-reference
|
|
673
672
|
[29]: #type-definition-packages
|
|
674
673
|
[30]: #dependencies-named-after-nodejs-builtins
|
|
675
674
|
[31]: #unlisted-binaries
|
|
676
|
-
[32]:
|
|
677
|
-
https://github.com/webpro-nl/knip/blob/b70958a58ea255ee7a7831e404786da807ca93d7/packages/knip/src/constants.ts#L37-L139
|
|
675
|
+
[32]: https://github.com/webpro-nl/knip/blob/e031018e676c47d84873cc2403251c0111ef318d/packages/knip/src/constants.ts#L39-L148
|
|
678
676
|
[33]: ../features/monorepos-and-workspaces.md#lint-a-single-workspace
|
|
679
677
|
[34]: #template-strings
|
|
680
678
|
[35]: #unrecognized-path-aliases
|
|
681
679
|
[36]: #external-aliased-imports
|
|
682
680
|
[37]: ../reference/configuration.md#paths
|
|
683
681
|
[38]: ../reference/configuration.md#ignoreunresolved
|
|
684
|
-
[39]:
|
|
685
|
-
[40]:
|
|
686
|
-
[41]:
|
|
687
|
-
[42]:
|
|
688
|
-
[43]:
|
|
689
|
-
[44]: ../reference/
|
|
690
|
-
[45]:
|
|
691
|
-
[46]:
|
|
692
|
-
[47]: ../reference/
|
|
693
|
-
[48]: ../
|
|
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
|
|
@@ -121,7 +121,7 @@ to [open an issue on GitHub][14].
|
|
|
121
121
|
[2]: #exceptions-thrown-by-knip
|
|
122
122
|
[3]: #debug
|
|
123
123
|
[4]: #trace
|
|
124
|
-
[5]: ../guides/handling-issues.
|
|
124
|
+
[5]: ../guides/handling-issues.mdx
|
|
125
125
|
[6]: ./issue-reproduction.md
|
|
126
126
|
[7]: ../reference/known-issues.md
|
|
127
127
|
[8]: ../reference/cli.md#--workspace-dir
|
package/src/docs/docs/index.mdx
CHANGED
|
@@ -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
|
|
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]:
|
|
141
|
+
[6]: /sponsors
|
|
142
142
|
[7]: https://webpro.nl/hire-me
|
|
143
143
|
[8]: ./reference/plugins.md
|
|
144
|
-
[9]:
|
|
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
|
|
@@ -44,7 +44,7 @@ Also see [related tooling][2].
|
|
|
44
44
|
[4]: ../reference/cli.md#--cache
|
|
45
45
|
[5]: ../guides/working-with-commonjs.md
|
|
46
46
|
[6]: ../features/compilers.md
|
|
47
|
-
[7]: ../guides/troubleshooting.md#
|
|
47
|
+
[7]: ../guides/troubleshooting.md#debug
|
|
48
48
|
[8]: ../features/rules-and-filters.md#filters
|
|
49
49
|
[9]: ../features/auto-fix.mdx#format
|
|
50
50
|
[10]: ../reference/jsdoc-tsdoc-tags.md
|
|
@@ -63,4 +63,4 @@ Also see [related tooling][2].
|
|
|
63
63
|
[23]: ../features/production-mode.md#strict-mode
|
|
64
64
|
[24]: ../guides/troubleshooting.md#trace
|
|
65
65
|
[25]: ../reference/cli.md#--watch
|
|
66
|
-
[26]: ../features/monorepos-and-workspaces#lint-a-single-workspace
|
|
66
|
+
[26]: ../features/monorepos-and-workspaces.md#lint-a-single-workspace
|
|
@@ -77,7 +77,17 @@ If the output makes sense to you, feel free to go to the next page:
|
|
|
77
77
|
|
|
78
78
|
## Too Much?
|
|
79
79
|
|
|
80
|
-
In large or complex codebases the output might be overwhelming.
|
|
80
|
+
In large or complex codebases the output might be overwhelming.
|
|
81
|
+
|
|
82
|
+
:::tip[NEW]
|
|
83
|
+
|
|
84
|
+
Use the new [Knip Editor Extension][3] and let your coding agent configure Knip
|
|
85
|
+
for you. The built-in MCP Server will intelligently craft a custom `knip.json`
|
|
86
|
+
based on the documentation and configuration hints.
|
|
87
|
+
|
|
88
|
+
:::
|
|
89
|
+
|
|
90
|
+
Start by
|
|
81
91
|
limiting the number of shown issues per type:
|
|
82
92
|
|
|
83
93
|
<Tabs syncKey="pm">
|
|
@@ -108,12 +118,12 @@ limiting the number of shown issues per type:
|
|
|
108
118
|
|
|
109
119
|
The output is easier to digest and may include some configuration hints to get
|
|
110
120
|
an idea of what's left to configure. Many unused files? Go to [configuration][2]
|
|
111
|
-
and follow up with [troubleshooting][
|
|
121
|
+
and follow up with [troubleshooting][4] if needed.
|
|
112
122
|
|
|
113
123
|
:::tip
|
|
114
124
|
|
|
115
125
|
Do not use the `ignore` option just to get rid of unwanted output. Read
|
|
116
|
-
[Configuring Project Files][
|
|
126
|
+
[Configuring Project Files][5] to get the most out of Knip.
|
|
117
127
|
|
|
118
128
|
:::
|
|
119
129
|
|
|
@@ -191,5 +201,6 @@ already.
|
|
|
191
201
|
|
|
192
202
|
[1]: /playground
|
|
193
203
|
[2]: ./configuration.md
|
|
194
|
-
[3]: ../
|
|
195
|
-
[4]: ../guides/
|
|
204
|
+
[3]: ../blog/for-editors-and-agents.md
|
|
205
|
+
[4]: ../guides/troubleshooting.md
|
|
206
|
+
[5]: ../guides/configuring-project-files.md
|
|
@@ -180,6 +180,13 @@ notation below is valid and will report only exports tagged `@lintignore` or
|
|
|
180
180
|
}
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
+
:::caution
|
|
184
|
+
|
|
185
|
+
Tags must not contain hyphens or plus symbols, so it is recommended to stick to
|
|
186
|
+
letters and avoid snake-case.
|
|
187
|
+
|
|
188
|
+
:::
|
|
189
|
+
|
|
183
190
|
Also see [JSDoc & TSDoc Tags][8].
|
|
184
191
|
|
|
185
192
|
### `treatConfigHintsAsErrors`
|
|
@@ -408,7 +408,6 @@ Examples of features that have been requested include:
|
|
|
408
408
|
- Unused object members (and e.g. React component props)
|
|
409
409
|
- Unused object props in function return values
|
|
410
410
|
- Analyze workspaces in parallel
|
|
411
|
-
- Plugins for editors like VS Code and WebStorm (LSP-based?)
|
|
412
411
|
- Support Deno
|
|
413
412
|
- Improve internal code structures and accessibility to support contributions
|
|
414
413
|
- One-shot dead code removal (more comprehensive removal of unused variables,
|
|
@@ -427,7 +426,7 @@ require more development efforts and maintenance. Time is limited and
|
|
|
427
426
|
[5]: ../explanations/why-use-knip.md#comprehensive
|
|
428
427
|
[6]: #module-resolution
|
|
429
428
|
[7]: ../features/script-parser.md
|
|
430
|
-
[8]: ../guides/handling-issues.mdx#
|
|
429
|
+
[8]: ../guides/handling-issues.mdx#type-definition-packages
|
|
431
430
|
[9]: https://oxc.rs/docs/guide/usage/resolver.html
|
|
432
431
|
[10]: ../guides/performance.md#workspace-sharing
|
|
433
432
|
[11]: #whats-the-difference-between-workspaces-projects-and-programs
|