@knip/mcp 0.0.2 → 0.0.3
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/docs/blog/for-editors-and-agents.md +50 -35
- package/docs/docs/blog/brief-history.md +30 -0
- package/docs/docs/blog/for-editors-and-agents.md +124 -0
- package/docs/docs/blog/knip-v3.mdx +88 -0
- package/docs/docs/blog/knip-v4.mdx +149 -0
- package/docs/docs/blog/knip-v5.mdx +190 -0
- package/docs/docs/blog/migration-to-v1.md +65 -0
- package/docs/docs/blog/release-notes-v2.md +46 -0
- package/docs/docs/blog/slim-down-to-speed-up.md +269 -0
- package/docs/docs/blog/state-of-knip.md +191 -0
- package/docs/docs/blog/two-years.mdx +107 -0
- package/docs/docs/explanations/comparison-and-migration.md +129 -0
- package/docs/docs/explanations/entry-files.md +70 -0
- package/docs/docs/explanations/plugins.md +318 -0
- package/docs/docs/explanations/why-use-knip.md +128 -0
- package/docs/docs/features/auto-fix.mdx +333 -0
- package/docs/docs/features/compilers.md +172 -0
- package/docs/docs/features/integrated-monorepos.md +52 -0
- package/docs/docs/features/monorepos-and-workspaces.md +134 -0
- package/docs/docs/features/production-mode.md +95 -0
- package/docs/docs/features/reporters.md +302 -0
- package/docs/docs/features/rules-and-filters.md +102 -0
- package/docs/docs/features/script-parser.md +156 -0
- package/docs/docs/features/source-mapping.md +100 -0
- package/docs/docs/guides/configuring-project-files.md +205 -0
- package/docs/docs/guides/contributing.md +24 -0
- package/docs/docs/guides/handling-issues.mdx +646 -0
- package/docs/docs/guides/issue-reproduction.md +94 -0
- package/docs/docs/guides/namespace-imports.md +125 -0
- package/docs/docs/guides/performance.md +97 -0
- package/docs/docs/guides/troubleshooting.md +127 -0
- package/docs/docs/guides/using-knip-in-ci.md +54 -0
- package/docs/docs/guides/working-with-commonjs.md +72 -0
- package/docs/docs/index.mdx +160 -0
- package/docs/docs/overview/configuration.md +104 -0
- package/docs/docs/overview/features.md +66 -0
- package/docs/docs/overview/getting-started.mdx +195 -0
- package/docs/docs/overview/screenshots-videos.md +42 -0
- package/docs/docs/playground.mdx +38 -0
- package/docs/docs/reference/cli.md +481 -0
- package/docs/docs/reference/configuration.md +413 -0
- package/docs/docs/reference/dynamic-configuration.mdx +72 -0
- package/docs/docs/reference/faq.md +441 -0
- package/docs/docs/reference/issue-types.md +43 -0
- package/docs/docs/reference/jsdoc-tsdoc-tags.md +122 -0
- package/docs/docs/reference/known-issues.md +64 -0
- package/docs/docs/reference/plugins/.gitkeep +0 -0
- package/docs/docs/reference/plugins.md +238 -0
- package/docs/docs/reference/related-tooling.md +46 -0
- package/docs/docs/sponsors.mdx +65 -0
- package/docs/docs/typescript/unused-dependencies.md +86 -0
- package/docs/docs/typescript/unused-exports.md +87 -0
- package/docs/docs/writing-a-plugin/argument-parsing.md +202 -0
- package/docs/docs/writing-a-plugin/index.md +376 -0
- package/docs/docs/writing-a-plugin/inputs.md +162 -0
- package/package.json +8 -6
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Knip for Editors & Agents
|
|
3
|
-
date: 2025-12-
|
|
3
|
+
date: 2025-12-17
|
|
4
4
|
sidebar:
|
|
5
5
|
order: 1
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
_Published: 2025-12-
|
|
8
|
+
_Published: 2025-12-17_
|
|
9
|
+
|
|
10
|
+
Three years in, Knip has founds its place in [over 10.000 projects][1] and is
|
|
11
|
+
downloaded [over 18M times/month][2]. A long period of steady growth in usage
|
|
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 VS Code Extension **and** MCP
|
|
14
|
+
Server. For humans and coding agents alike, Knip will help keep your codebases
|
|
15
|
+
tidy.
|
|
16
|
+
|
|
17
|
+
Don't forget... Knip it before you ship it!
|
|
9
18
|
|
|
10
19
|
## VS Code Extension
|
|
11
20
|
|
|
12
21
|
This one is for you.
|
|
13
22
|
|
|
14
|
-
[The usual suspects][
|
|
23
|
+
[The usual suspects][3] like red squiggles for unused exports are there. What
|
|
15
24
|
really moves the needle for DX with Knip's module graph is **navigation**. A
|
|
16
25
|
completely unique way to view & fly through codebases for developers who care.
|
|
17
26
|
Connect the dots during development and refactors, while keeping things in
|
|
18
|
-
check. We're starting out with [3 key features][
|
|
27
|
+
check. We're starting out with [3 key features][4]:
|
|
19
28
|
|
|
20
29
|
1. **Hover over Export** for import & usage locations
|
|
21
30
|
2. **Imports Tree View** for direct links to implementations
|
|
22
31
|
3. **Exports Tree View** for direct links to import & usage locations
|
|
23
32
|
|
|
33
|
+
Find [Knip on the VS Code Marketplace][5].
|
|
34
|
+
|
|
24
35
|
## MCP Server
|
|
25
36
|
|
|
26
37
|
Configuring Knip has always been a major headache to many. No more. Tell your
|
|
@@ -28,7 +39,7 @@ coding agent to "configure knip" and it will RTFM so you don't have to. Using a
|
|
|
28
39
|
newer model like Opus 4.5 or GPT 5.2 results in an optimized `knip.json` file
|
|
29
40
|
and an uncluttered codebase.
|
|
30
41
|
|
|
31
|
-
The [MCP Server is available][
|
|
42
|
+
The [MCP Server is available][6] separately and built into the VS Code
|
|
32
43
|
Extension.
|
|
33
44
|
|
|
34
45
|
## Language Server
|
|
@@ -40,25 +51,25 @@ information. Queries like "where is an export imported" or "is this import part
|
|
|
40
51
|
of a circular dependency" are just scratching the surface here.
|
|
41
52
|
|
|
42
53
|
Extensions for other IDEs can be built on top. See
|
|
43
|
-
[language-server/README.md][
|
|
54
|
+
[language-server/README.md][7]
|
|
44
55
|
|
|
45
56
|
## Screenshots
|
|
46
57
|
|
|
47
|
-
- [Lint Findings][
|
|
48
|
-
- [Imports & Exports][
|
|
49
|
-
- [Contention][
|
|
50
|
-
- [Circular Dependencies][
|
|
51
|
-
- [Conflicts][
|
|
52
|
-
- [Branching][
|
|
53
|
-
- [VS Code Extension Settings][
|
|
58
|
+
- [Lint Findings][3]
|
|
59
|
+
- [Imports & Exports][4]
|
|
60
|
+
- [Contention][8]
|
|
61
|
+
- [Circular Dependencies][9]
|
|
62
|
+
- [Conflicts][10]
|
|
63
|
+
- [Branching][11]
|
|
64
|
+
- [VS Code Extension Settings][12]
|
|
54
65
|
|
|
55
66
|
### Lint Findings
|
|
56
67
|
|
|
57
|
-
![Lint Findings][
|
|
68
|
+
![Lint Findings][13]
|
|
58
69
|
|
|
59
70
|
### Imports & Exports
|
|
60
71
|
|
|
61
|
-
![hover][
|
|
72
|
+
![hover][14]
|
|
62
73
|
|
|
63
74
|
### Contention
|
|
64
75
|
|
|
@@ -70,7 +81,7 @@ branched/diamond-shaped import chains.
|
|
|
70
81
|
|
|
71
82
|
If an import is part of a circular dependency, Knip will display:
|
|
72
83
|
|
|
73
|
-
![Circular Dependencies][
|
|
84
|
+
![Circular Dependencies][15]
|
|
74
85
|
|
|
75
86
|
#### Conflicts
|
|
76
87
|
|
|
@@ -78,7 +89,7 @@ TypeScript shows direct conflicts when importing or re-exporting the same named
|
|
|
78
89
|
export from different files. Except when the problem is more subtle and the
|
|
79
90
|
chain spans more than one file. Knip warns:
|
|
80
91
|
|
|
81
|
-
![Conflicts][
|
|
92
|
+
![Conflicts][16]
|
|
82
93
|
|
|
83
94
|
#### Branching
|
|
84
95
|
|
|
@@ -86,24 +97,28 @@ Branched or diamond-shaped imports chains indicate unnecessary re-exports and
|
|
|
86
97
|
complexity. They help to untangle large codebases and shrink or get rid of
|
|
87
98
|
barrel files. Knip warns:
|
|
88
99
|
|
|
89
|
-
![Branching][
|
|
100
|
+
![Branching][17]
|
|
90
101
|
|
|
91
102
|
### VS Code Extension Settings
|
|
92
103
|
|
|
93
|
-
![VS Code Extension Settings][
|
|
94
|
-
|
|
95
|
-
[1]:
|
|
96
|
-
[2]:
|
|
97
|
-
[3]:
|
|
98
|
-
[4]:
|
|
99
|
-
[5]:
|
|
100
|
-
[6]:
|
|
101
|
-
[7]:
|
|
102
|
-
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
104
|
+
![VS Code Extension Settings][18]
|
|
105
|
+
|
|
106
|
+
[1]: https://github.com/webpro-nl/knip/network/dependents
|
|
107
|
+
[2]: https://www.npmjs.com/package/knip
|
|
108
|
+
[3]: #lint-findings
|
|
109
|
+
[4]: #imports--exports
|
|
110
|
+
[5]: https://marketplace.visualstudio.com/items?itemName=webpro.vscode-knip
|
|
111
|
+
[6]: https://www.npmjs.com/package/@knip/mcp
|
|
112
|
+
[7]:
|
|
113
|
+
https://github.com/webpro-nl/knip/blob/main/packages/language-server/README.md
|
|
114
|
+
[8]: #contention
|
|
115
|
+
[9]: #circular-dependencies
|
|
116
|
+
[10]: #conflicts
|
|
117
|
+
[11]: #branching
|
|
118
|
+
[12]: #vs-code-extension-settings
|
|
119
|
+
[13]: /screenshots/editors-and-agents/diagnostics.webp
|
|
120
|
+
[14]: /screenshots/editors-and-agents/imports-exports.webp
|
|
121
|
+
[15]: /screenshots/editors-and-agents/circular-dependency.webp
|
|
122
|
+
[16]: /screenshots/editors-and-agents/conflict.webp
|
|
123
|
+
[17]: /screenshots/editors-and-agents/branch.webp
|
|
124
|
+
[18]: /screenshots/editors-and-agents/vscode-extension-settings.webp
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: A Brief History Of Knip
|
|
3
|
+
date: 2023-10-15
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 7
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
_Published: 2023-10-15_
|
|
9
|
+
|
|
10
|
+
If you are fond of short lists and brief histories, then this page was written
|
|
11
|
+
just for you!
|
|
12
|
+
|
|
13
|
+
- 2022-10-04: The [initial commit][1]. Still so tiny at that point, but the seed
|
|
14
|
+
was planted. Starting out with finding unused files and exports, the name was
|
|
15
|
+
Exportman! 🦸
|
|
16
|
+
- 2022-10-09: Big plans and a rename 5 days later, the first published version
|
|
17
|
+
of Knip was [v0.1.2][2].
|
|
18
|
+
- 2022-11-22: Unused dependencies and support for workspaces and plugins in the
|
|
19
|
+
[first alpha of v1][3].
|
|
20
|
+
- 2023-01-10: Lots of testing and fixes led to [Knip v1][4].
|
|
21
|
+
- 2023-03-22: [Knip v2][5] saw a full rewrite of the TypeScript backend.
|
|
22
|
+
- 2023-10-15: [Introduction of Knip v3][6].
|
|
23
|
+
|
|
24
|
+
[1]:
|
|
25
|
+
https://github.com/webpro-nl/knip/commit/9589dfe22608da7d89f2613383da6db5826226d2
|
|
26
|
+
[2]: https://github.com/webpro-nl/knip/tree/0.1.2
|
|
27
|
+
[3]: https://github.com/webpro-nl/knip/releases/tag/1.0.0-alpha.0
|
|
28
|
+
[4]: https://github.com/webpro-nl/knip/tree/1.0.0
|
|
29
|
+
[5]: https://github.com/webpro-nl/knip/issues/73
|
|
30
|
+
[6]: ./knip-v3.mdx
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Knip for Editors & Agents
|
|
3
|
+
date: 2025-12-17
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
_Published: 2025-12-17_
|
|
9
|
+
|
|
10
|
+
Three years in, Knip has founds its place in [over 10.000 projects][1] and is
|
|
11
|
+
downloaded [over 18M times/month][2]. A long period of steady growth in usage
|
|
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 VS Code Extension **and** MCP
|
|
14
|
+
Server. For humans and coding agents alike, Knip will help keep your codebases
|
|
15
|
+
tidy.
|
|
16
|
+
|
|
17
|
+
Don't forget... Knip it before you ship it!
|
|
18
|
+
|
|
19
|
+
## VS Code Extension
|
|
20
|
+
|
|
21
|
+
This one is for you.
|
|
22
|
+
|
|
23
|
+
[The usual suspects][3] like red squiggles for unused exports are there. What
|
|
24
|
+
really moves the needle for DX with Knip's module graph is **navigation**. A
|
|
25
|
+
completely unique way to view & fly through codebases for developers who care.
|
|
26
|
+
Connect the dots during development and refactors, while keeping things in
|
|
27
|
+
check. We're starting out with [3 key features][4]:
|
|
28
|
+
|
|
29
|
+
1. **Hover over Export** for import & usage locations
|
|
30
|
+
2. **Imports Tree View** for direct links to implementations
|
|
31
|
+
3. **Exports Tree View** for direct links to import & usage locations
|
|
32
|
+
|
|
33
|
+
Find [Knip on the VS Code Marketplace][5].
|
|
34
|
+
|
|
35
|
+
## MCP Server
|
|
36
|
+
|
|
37
|
+
Configuring Knip has always been a major headache to many. No more. Tell your
|
|
38
|
+
coding agent to "configure knip" and it will RTFM so you don't have to. Using a
|
|
39
|
+
newer model like Opus 4.5 or GPT 5.2 results in an optimized `knip.json` file
|
|
40
|
+
and an uncluttered codebase.
|
|
41
|
+
|
|
42
|
+
The [MCP Server is available][6] separately and built into the VS Code
|
|
43
|
+
Extension.
|
|
44
|
+
|
|
45
|
+
## Language Server
|
|
46
|
+
|
|
47
|
+
The VS Code Extension and the MCP Server are powered by the new Language Server.
|
|
48
|
+
It's a custom server that builds the full module graph of your project, and
|
|
49
|
+
provides a session with a graph explorer to request all sorts of interesting
|
|
50
|
+
information. Queries like "where is an export imported" or "is this import part
|
|
51
|
+
of a circular dependency" are just scratching the surface here.
|
|
52
|
+
|
|
53
|
+
Extensions for other IDEs can be built on top. See
|
|
54
|
+
[language-server/README.md][7]
|
|
55
|
+
|
|
56
|
+
## Screenshots
|
|
57
|
+
|
|
58
|
+
- [Lint Findings][3]
|
|
59
|
+
- [Imports & Exports][4]
|
|
60
|
+
- [Contention][8]
|
|
61
|
+
- [Circular Dependencies][9]
|
|
62
|
+
- [Conflicts][10]
|
|
63
|
+
- [Branching][11]
|
|
64
|
+
- [VS Code Extension Settings][12]
|
|
65
|
+
|
|
66
|
+
### Lint Findings
|
|
67
|
+
|
|
68
|
+
![Lint Findings][13]
|
|
69
|
+
|
|
70
|
+
### Imports & Exports
|
|
71
|
+
|
|
72
|
+
![hover][14]
|
|
73
|
+
|
|
74
|
+
### Contention
|
|
75
|
+
|
|
76
|
+
The IDE extension shows extra issues in the tree views like circular
|
|
77
|
+
dependencies. We're starting out with some extra novelties like conflicting and
|
|
78
|
+
branched/diamond-shaped import chains.
|
|
79
|
+
|
|
80
|
+
#### Circular Dependencies
|
|
81
|
+
|
|
82
|
+
If an import is part of a circular dependency, Knip will display:
|
|
83
|
+
|
|
84
|
+
![Circular Dependencies][15]
|
|
85
|
+
|
|
86
|
+
#### Conflicts
|
|
87
|
+
|
|
88
|
+
TypeScript shows direct conflicts when importing or re-exporting the same named
|
|
89
|
+
export from different files. Except when the problem is more subtle and the
|
|
90
|
+
chain spans more than one file. Knip warns:
|
|
91
|
+
|
|
92
|
+
![Conflicts][16]
|
|
93
|
+
|
|
94
|
+
#### Branching
|
|
95
|
+
|
|
96
|
+
Branched or diamond-shaped imports chains indicate unnecessary re-exports and
|
|
97
|
+
complexity. They help to untangle large codebases and shrink or get rid of
|
|
98
|
+
barrel files. Knip warns:
|
|
99
|
+
|
|
100
|
+
![Branching][17]
|
|
101
|
+
|
|
102
|
+
### VS Code Extension Settings
|
|
103
|
+
|
|
104
|
+
![VS Code Extension Settings][18]
|
|
105
|
+
|
|
106
|
+
[1]: https://github.com/webpro-nl/knip/network/dependents
|
|
107
|
+
[2]: https://www.npmjs.com/package/knip
|
|
108
|
+
[3]: #lint-findings
|
|
109
|
+
[4]: #imports--exports
|
|
110
|
+
[5]: https://marketplace.visualstudio.com/items?itemName=webpro.vscode-knip
|
|
111
|
+
[6]: https://www.npmjs.com/package/@knip/mcp
|
|
112
|
+
[7]:
|
|
113
|
+
https://github.com/webpro-nl/knip/blob/main/packages/language-server/README.md
|
|
114
|
+
[8]: #contention
|
|
115
|
+
[9]: #circular-dependencies
|
|
116
|
+
[10]: #conflicts
|
|
117
|
+
[11]: #branching
|
|
118
|
+
[12]: #vs-code-extension-settings
|
|
119
|
+
[13]: /screenshots/editors-and-agents/diagnostics.webp
|
|
120
|
+
[14]: /screenshots/editors-and-agents/imports-exports.webp
|
|
121
|
+
[15]: /screenshots/editors-and-agents/circular-dependency.webp
|
|
122
|
+
[16]: /screenshots/editors-and-agents/conflict.webp
|
|
123
|
+
[17]: /screenshots/editors-and-agents/branch.webp
|
|
124
|
+
[18]: /screenshots/editors-and-agents/vscode-extension-settings.webp
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Announcing Knip v3
|
|
3
|
+
date: 2023-10-15
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 8
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
9
|
+
|
|
10
|
+
_Published: 2023-10-15_
|
|
11
|
+
|
|
12
|
+
Lots of new users got introduced to Knip, coming with clear bug reports, helpful
|
|
13
|
+
insights, superb reproductions and great suggestions this year. You're all a
|
|
14
|
+
friendly and helpful bunch! Recently I've opened a Discord channel where more
|
|
15
|
+
communication, collaboration, ideas and updates are happening: feel free to join
|
|
16
|
+
[The Knip Barn][1]!
|
|
17
|
+
|
|
18
|
+
Today, Knip has [over 140k weekly downloads on npm][2], [almost 4000 stars on
|
|
19
|
+
GitHub][3], and [over 500 repositories][4] using it. While numbers are just
|
|
20
|
+
numbers, they do add to the positive feedback I'm receiving daily. Everything
|
|
21
|
+
combined makes me think I'm on the right track which is very motivating to keep
|
|
22
|
+
working on Knip.
|
|
23
|
+
|
|
24
|
+
## So... What's Been Cooking Lately?
|
|
25
|
+
|
|
26
|
+
- Migration to a monorepo setup
|
|
27
|
+
- This very website built with Starlight 🌟
|
|
28
|
+
- Extended documentation for just about everything
|
|
29
|
+
- Improved JSON reporter for external integrations (e.g. [GitHub Action][5])
|
|
30
|
+
- Some breaking changes, but you probably don't need to make any changes
|
|
31
|
+
|
|
32
|
+
## Breaking Changes
|
|
33
|
+
|
|
34
|
+
A major bump comes with breaking changes, but most likely no changes necessary
|
|
35
|
+
on your end:
|
|
36
|
+
|
|
37
|
+
- Removed support for Node.js v16, Knip v3 requires at least Node.js v18.6
|
|
38
|
+
- Simplified [exit codes][6]
|
|
39
|
+
- [Production mode][7] now includes types by default (add `--exclude types` for
|
|
40
|
+
previous behavior)
|
|
41
|
+
- Removed `--ignore-internal` flag; [`@internal`][8] exports ignored in
|
|
42
|
+
production mode now
|
|
43
|
+
- The `--debug-file-filter` flag is removed
|
|
44
|
+
- The `jsonExt` reporter is now the default [JSON reporter][9] (the previous one
|
|
45
|
+
is gone)
|
|
46
|
+
- Moved `typescript` to `peerDependencies` (requires `>=5.0.4`)
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
Try out the latest Knip v3 release today!
|
|
51
|
+
|
|
52
|
+
<Tabs syncKey="pm">
|
|
53
|
+
<TabItem label="npm">
|
|
54
|
+
```shell
|
|
55
|
+
npm install -D knip
|
|
56
|
+
```
|
|
57
|
+
</TabItem>
|
|
58
|
+
|
|
59
|
+
<TabItem label="pnpm">
|
|
60
|
+
```shell
|
|
61
|
+
pnpm add -D knip
|
|
62
|
+
```
|
|
63
|
+
</TabItem>
|
|
64
|
+
|
|
65
|
+
<TabItem label="bun">
|
|
66
|
+
```shell
|
|
67
|
+
bun add -D knip
|
|
68
|
+
```
|
|
69
|
+
</TabItem>
|
|
70
|
+
|
|
71
|
+
<TabItem label="yarn">
|
|
72
|
+
```shell
|
|
73
|
+
yarn add -D knip
|
|
74
|
+
```
|
|
75
|
+
</TabItem>
|
|
76
|
+
</Tabs>
|
|
77
|
+
|
|
78
|
+
Remember, Knip it before you ship it! Have a great day ☀️
|
|
79
|
+
|
|
80
|
+
[1]: https://discord.gg/r5uXTtbTpc
|
|
81
|
+
[2]: https://www.npmjs.com/package/knip
|
|
82
|
+
[3]: https://github.com/webpro-nl/knip/stargazers
|
|
83
|
+
[4]: https://github.com/webpro-nl/knip/network/dependents
|
|
84
|
+
[5]: https://github.com/marketplace/actions/knip-reporter
|
|
85
|
+
[6]: ../reference/cli.md#exit-code
|
|
86
|
+
[7]: ../features/production-mode.md
|
|
87
|
+
[8]: ../reference/jsdoc-tsdoc-tags.md#internal
|
|
88
|
+
[9]: ../features/reporters.md#json
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Announcing Knip v4
|
|
3
|
+
date: 2024-01-16
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
9
|
+
|
|
10
|
+
_Published: 2024-01-16_
|
|
11
|
+
|
|
12
|
+
I'm happy to announce that Knip v4 is available!
|
|
13
|
+
|
|
14
|
+
The work took over a month and the process of [slimming down to speed up][1]
|
|
15
|
+
ended up really well: significant faster runs and reduced memory usage. In the
|
|
16
|
+
meantime, v3 continued to receive more contributions, plugins and bug fixes.
|
|
17
|
+
|
|
18
|
+
## Highlights
|
|
19
|
+
|
|
20
|
+
Compared to v3, here are the highlights:
|
|
21
|
+
|
|
22
|
+
- Performance: significant speed bump (up to 80%!)
|
|
23
|
+
- Performance: globbing in combo with `.gitignore` is a lot more efficient
|
|
24
|
+
- Configuration: [built-in compilers][2] (for Astro, MDX, Svelte & Vue)
|
|
25
|
+
- The `ignore` option has been improved
|
|
26
|
+
- Internal refactoring to serialize data for future improvements like caching.
|
|
27
|
+
|
|
28
|
+
The actual performance win in your projects depends on various factors like size
|
|
29
|
+
and complexity.
|
|
30
|
+
|
|
31
|
+
## Major Changes
|
|
32
|
+
|
|
33
|
+
The changes have been tested against various repositories, but it's possible
|
|
34
|
+
that you will encounter false positives caused by the major refactoring that has
|
|
35
|
+
been done. If you do, [please report][3]!
|
|
36
|
+
|
|
37
|
+
### Unused Class Members
|
|
38
|
+
|
|
39
|
+
Finding unused class members is no longer enabled by default. Here's why it's
|
|
40
|
+
now opt-in:
|
|
41
|
+
|
|
42
|
+
- When using Knip for the first time on a large repository it can crash after a
|
|
43
|
+
while with an out of memory error. This is a terrible experience.
|
|
44
|
+
- Plenty of codebases don't use classes at all, keeping TS programs in memory is
|
|
45
|
+
a waste of resources.
|
|
46
|
+
- Many configurations already exclude `classMembers` from the output.
|
|
47
|
+
|
|
48
|
+
Enable unused class members by using the CLI argument or the configuration
|
|
49
|
+
option:
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
knip --include classMembers
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"include": ["classMembers"]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Now that unused class members is opt-in and better organized within Knip, it
|
|
62
|
+
might be interesting to start looking at opt-ins for other unused members, such
|
|
63
|
+
as those of types and interfaces.
|
|
64
|
+
|
|
65
|
+
By the way, enum members are "cheap" with the v4 refactor, so those are still
|
|
66
|
+
included by default.
|
|
67
|
+
|
|
68
|
+
### Compilers
|
|
69
|
+
|
|
70
|
+
You can remove the `compilers` option from your configuration. Since you can
|
|
71
|
+
override them, your custom compilers can stay where they are. This also means
|
|
72
|
+
that you can go back from `knip.ts` to `knip.json` if you prefer.
|
|
73
|
+
|
|
74
|
+
### Ignore Files
|
|
75
|
+
|
|
76
|
+
The `ignore` option accepted patterns like `examples/`, but if you want to
|
|
77
|
+
ignore the files inside this folder you should update to globs like
|
|
78
|
+
`examples/**`.
|
|
79
|
+
|
|
80
|
+
## What's Next?
|
|
81
|
+
|
|
82
|
+
The refactoring for this release opens the door to more optimizations, such as
|
|
83
|
+
caching. I'm also very excited to see how deeper integrations such as in GitHub
|
|
84
|
+
Actions or IDEs like VS Code or WebStorm may further develop.
|
|
85
|
+
|
|
86
|
+
Remember, if you are you using Knip at work your company can [sponsor me][4]!
|
|
87
|
+
|
|
88
|
+
## One More Thing...
|
|
89
|
+
|
|
90
|
+
An idea I've been toying with is "tagged exports". The idea is that you can tag
|
|
91
|
+
exports in a JSDoc comment. The tag does not need to be part of the JSDoc or
|
|
92
|
+
TSDoc spec. For example:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
/** @custom */
|
|
96
|
+
export const myExport = 1;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then, include or exclude such tagged exports from the report like so:
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
knip --experimental-tags=+custom
|
|
103
|
+
knip --experimental-tags=-custom,-internal
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This way, you can either focus on or ignore specific tagged exports with tags
|
|
107
|
+
you define yourself. This also works for individual class or enum members.
|
|
108
|
+
|
|
109
|
+
Once this feature is intuitive and stable, the `experimental` flag will be
|
|
110
|
+
removed and option(s) added to the Knip configuration file. The docs are in the
|
|
111
|
+
[CLI reference][5].
|
|
112
|
+
|
|
113
|
+
## Let's Go!
|
|
114
|
+
|
|
115
|
+
What are you waiting for? Start using Knip v4 today!
|
|
116
|
+
|
|
117
|
+
<Tabs syncKey="pm">
|
|
118
|
+
<TabItem label="npm">
|
|
119
|
+
```shell
|
|
120
|
+
npm install -D knip
|
|
121
|
+
```
|
|
122
|
+
</TabItem>
|
|
123
|
+
|
|
124
|
+
<TabItem label="pnpm">
|
|
125
|
+
```shell
|
|
126
|
+
pnpm add -D knip
|
|
127
|
+
```
|
|
128
|
+
</TabItem>
|
|
129
|
+
|
|
130
|
+
<TabItem label="bun">
|
|
131
|
+
```shell
|
|
132
|
+
bun add -D knip
|
|
133
|
+
```
|
|
134
|
+
</TabItem>
|
|
135
|
+
|
|
136
|
+
<TabItem label="yarn">
|
|
137
|
+
```shell
|
|
138
|
+
yarn add -D knip
|
|
139
|
+
```
|
|
140
|
+
</TabItem>
|
|
141
|
+
</Tabs>
|
|
142
|
+
|
|
143
|
+
Remember, Knip it before you ship it! Have a great day ☀️
|
|
144
|
+
|
|
145
|
+
[1]: ./slim-down-to-speed-up.md
|
|
146
|
+
[2]: ../features/compilers.md
|
|
147
|
+
[3]: ../guides/issue-reproduction
|
|
148
|
+
[4]: https://github.com/sponsors/webpro
|
|
149
|
+
[5]: ../reference/cli#--experimental-tags
|