@knip/mcp 0.0.1 → 0.0.2
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/brief-history.md +1 -1
- package/docs/blog/knip-v3.mdx +1 -1
- package/docs/blog/knip-v4.mdx +1 -1
- package/docs/blog/knip-v5.mdx +1 -1
- package/docs/blog/release-notes-v2.md +1 -1
- package/docs/blog/slim-down-to-speed-up.md +1 -1
- package/docs/blog/state-of-knip.md +1 -1
- package/docs/blog/two-years.mdx +1 -1
- package/docs/index.mdx +4 -0
- package/package.json +2 -2
- package/docs/docs/blog/brief-history.md +0 -30
- package/docs/docs/blog/knip-v3.mdx +0 -88
- package/docs/docs/blog/knip-v4.mdx +0 -149
- package/docs/docs/blog/knip-v5.mdx +0 -190
- package/docs/docs/blog/migration-to-v1.md +0 -65
- package/docs/docs/blog/release-notes-v2.md +0 -46
- package/docs/docs/blog/slim-down-to-speed-up.md +0 -269
- package/docs/docs/blog/state-of-knip.md +0 -191
- package/docs/docs/blog/two-years.mdx +0 -107
- package/docs/docs/explanations/comparison-and-migration.md +0 -129
- package/docs/docs/explanations/entry-files.md +0 -70
- package/docs/docs/explanations/plugins.md +0 -318
- package/docs/docs/explanations/why-use-knip.md +0 -128
- package/docs/docs/features/auto-fix.mdx +0 -333
- package/docs/docs/features/compilers.md +0 -172
- package/docs/docs/features/integrated-monorepos.md +0 -52
- package/docs/docs/features/monorepos-and-workspaces.md +0 -134
- package/docs/docs/features/production-mode.md +0 -95
- package/docs/docs/features/reporters.md +0 -302
- package/docs/docs/features/rules-and-filters.md +0 -102
- package/docs/docs/features/script-parser.md +0 -156
- package/docs/docs/features/source-mapping.md +0 -100
- package/docs/docs/guides/configuring-project-files.md +0 -205
- package/docs/docs/guides/contributing.md +0 -24
- package/docs/docs/guides/handling-issues.mdx +0 -646
- package/docs/docs/guides/issue-reproduction.md +0 -94
- package/docs/docs/guides/namespace-imports.md +0 -125
- package/docs/docs/guides/performance.md +0 -97
- package/docs/docs/guides/troubleshooting.md +0 -127
- package/docs/docs/guides/using-knip-in-ci.md +0 -54
- package/docs/docs/guides/working-with-commonjs.md +0 -72
- package/docs/docs/index.mdx +0 -160
- package/docs/docs/overview/configuration.md +0 -104
- package/docs/docs/overview/features.md +0 -66
- package/docs/docs/overview/getting-started.mdx +0 -195
- package/docs/docs/overview/screenshots-videos.md +0 -42
- package/docs/docs/playground.mdx +0 -38
- package/docs/docs/reference/cli.md +0 -481
- package/docs/docs/reference/configuration.md +0 -413
- package/docs/docs/reference/dynamic-configuration.mdx +0 -72
- package/docs/docs/reference/faq.md +0 -441
- package/docs/docs/reference/issue-types.md +0 -43
- package/docs/docs/reference/jsdoc-tsdoc-tags.md +0 -122
- package/docs/docs/reference/known-issues.md +0 -64
- package/docs/docs/reference/plugins/.gitkeep +0 -0
- package/docs/docs/reference/plugins.md +0 -238
- package/docs/docs/reference/related-tooling.md +0 -46
- package/docs/docs/sponsors.mdx +0 -65
- package/docs/docs/typescript/unused-dependencies.md +0 -86
- package/docs/docs/typescript/unused-exports.md +0 -87
- package/docs/docs/writing-a-plugin/argument-parsing.md +0 -202
- package/docs/docs/writing-a-plugin/index.md +0 -376
- package/docs/docs/writing-a-plugin/inputs.md +0 -162
- /package/docs/{docs/blog → blog}/for-editors-and-agents.md +0 -0
package/docs/blog/knip-v3.mdx
CHANGED
package/docs/blog/knip-v4.mdx
CHANGED
package/docs/blog/knip-v5.mdx
CHANGED
package/docs/blog/two-years.mdx
CHANGED
package/docs/index.mdx
CHANGED
|
@@ -12,6 +12,10 @@ hero:
|
|
|
12
12
|
link: ./overview/getting-started
|
|
13
13
|
icon: right-arrow
|
|
14
14
|
variant: primary
|
|
15
|
+
- text: 'NEW: Knip for Editors & Agents'
|
|
16
|
+
link: /blog/for-editors-and-agents
|
|
17
|
+
icon: rocket
|
|
18
|
+
variant: secondary
|
|
15
19
|
- text: View on GitHub
|
|
16
20
|
link: https://github.com/webpro-nl/knip
|
|
17
21
|
icon: external
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Knip MCP Server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
31
31
|
"zod": "^4.1.11",
|
|
32
|
-
"knip": "5.75.
|
|
32
|
+
"knip": "5.75.1"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18.18.0"
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
|
@@ -1,149 +0,0 @@
|
|
|
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
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Announcing Knip v5
|
|
3
|
-
date: 2024-02-10
|
|
4
|
-
sidebar:
|
|
5
|
-
order: 4
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
9
|
-
|
|
10
|
-
_Published: 2024-02-10_
|
|
11
|
-
|
|
12
|
-
Today brings the smallest major release so far. Tiny yet mighty!
|
|
13
|
-
|
|
14
|
-
Below are two cases to demonstrate the change in how unused exports are
|
|
15
|
-
reported.
|
|
16
|
-
|
|
17
|
-
## Case 1
|
|
18
|
-
|
|
19
|
-
The first case shows two exports with a namespaced import that references one of
|
|
20
|
-
those exports explicitly:
|
|
21
|
-
|
|
22
|
-
```ts title="knip.js"
|
|
23
|
-
export const version = 'v5';
|
|
24
|
-
export const getRocket = () => '🚀';
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```ts title="index.js"
|
|
28
|
-
import * as NS from './knip.js';
|
|
29
|
-
|
|
30
|
-
console.log(NS.version);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
In this case we see that `getRocket` is an unused export.
|
|
34
|
-
|
|
35
|
-
Previously it would go into the "Unused exports in namespaces" category
|
|
36
|
-
(`nsExports`). This issue has been moved to the "Unused exports" category
|
|
37
|
-
(`exports`).
|
|
38
|
-
|
|
39
|
-
## Case 2
|
|
40
|
-
|
|
41
|
-
The second case is similar, but only the imported namespace itself is
|
|
42
|
-
referenced. None of the individual exports is referenced:
|
|
43
|
-
|
|
44
|
-
```ts title="index.js"
|
|
45
|
-
import * as NS from './knip.js';
|
|
46
|
-
import send from 'stats';
|
|
47
|
-
|
|
48
|
-
send(NS);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Are the `version` and `getRocket` exports used? We can't know. The same is true
|
|
52
|
-
for the spread object pattern:
|
|
53
|
-
|
|
54
|
-
```ts title="index.js"
|
|
55
|
-
import * as NS from './knip.js';
|
|
56
|
-
|
|
57
|
-
const Spread = { ...NS };
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Previously those exports would go into the "Unused exports in namespaces"
|
|
61
|
-
category. This is still the case, but this category is no longer enabled by
|
|
62
|
-
default.
|
|
63
|
-
|
|
64
|
-
## Include unused exports in namespaces
|
|
65
|
-
|
|
66
|
-
To enable this type of issues in Knip v5, add this argument to the command:
|
|
67
|
-
|
|
68
|
-
```shell
|
|
69
|
-
knip --include nsExports
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Or in your configuration file:
|
|
73
|
-
|
|
74
|
-
```json title="knip.json"
|
|
75
|
-
{
|
|
76
|
-
"include": ["nsExports", "nsTypes"]
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Now `version` and `getRocket` will be reported as "Unused exports in
|
|
81
|
-
namespaces".
|
|
82
|
-
|
|
83
|
-
Note that `nsExports` and `nsTypes` are split for more granular control.
|
|
84
|
-
|
|
85
|
-
## Handling exports in namespaced imports
|
|
86
|
-
|
|
87
|
-
You have a few options to handle namespaced imports when it comes to unused
|
|
88
|
-
exports.
|
|
89
|
-
|
|
90
|
-
### 1. Use named imports
|
|
91
|
-
|
|
92
|
-
Regardless of whether `nsExports` is enabled or not, it's often good practice to
|
|
93
|
-
replace the namespaced imports with named imports:
|
|
94
|
-
|
|
95
|
-
```ts title="index.js"
|
|
96
|
-
import { version, getRocket } from './knip.js';
|
|
97
|
-
|
|
98
|
-
send({ version, getRocket });
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Whenever possible, explicit over implicit is often the better choice.
|
|
102
|
-
|
|
103
|
-
### 2. Standardized JSDoc tags
|
|
104
|
-
|
|
105
|
-
Using one of the available JSDoc tags like `@public` or `@internal`:
|
|
106
|
-
|
|
107
|
-
```ts title="knip.js"
|
|
108
|
-
export const version = 'v5';
|
|
109
|
-
/** @public */
|
|
110
|
-
export const getRocket = () => '🚀';
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Assuming only imported using a namespace (like in the example cases above), this
|
|
114
|
-
will exclude the `getRocket` export from the report, even though it isn't
|
|
115
|
-
explicitly referenced.
|
|
116
|
-
|
|
117
|
-
### 3. Arbitrary JSDoc tags
|
|
118
|
-
|
|
119
|
-
Another solution is to tag individual exports arbitrarily:
|
|
120
|
-
|
|
121
|
-
```ts title="knip.js"
|
|
122
|
-
export const version = 'v5';
|
|
123
|
-
/** @launch */
|
|
124
|
-
export const getRocket = () => '🚀';
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
And then exclude the tag like so:
|
|
128
|
-
|
|
129
|
-
```shell
|
|
130
|
-
$ knip --experimental-tags=-launch
|
|
131
|
-
Exports in used namespace (1)
|
|
132
|
-
version NS unknown knip.js:1:1
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Assuming only imported using a namespace (like in the example cases above), this
|
|
136
|
-
will exclude the `getRocket` export from the report, even though it isn't
|
|
137
|
-
explicitly referenced.
|
|
138
|
-
|
|
139
|
-
## A better default
|
|
140
|
-
|
|
141
|
-
I believe this behavior in v5 is the better default: have all exports you want
|
|
142
|
-
to know about in a single category, and those you probably want to ignore in
|
|
143
|
-
another that's disabled by default.
|
|
144
|
-
|
|
145
|
-
Before the [v4 refactoring][1], this would be a lot harder to implement. That
|
|
146
|
-
refactoring turns out to be a better investment than expected. Combined with a
|
|
147
|
-
better understanding of how people write code and use Knip, this change is a
|
|
148
|
-
natural iteration.
|
|
149
|
-
|
|
150
|
-
Why the major bump? It's not breaking for the large majority of users, but for
|
|
151
|
-
some it may be breaking. For instance when relying on the [JSON reporter][2],
|
|
152
|
-
other reporter output, or custom [preprocessing][3]. It's not a bug fix, it's
|
|
153
|
-
not a new feature, but since semver is all about setting expectations I feel the
|
|
154
|
-
change is large enough to warrant a major bump.
|
|
155
|
-
|
|
156
|
-
## Let's Go!
|
|
157
|
-
|
|
158
|
-
What are you waiting for? Start using Knip v5 today!
|
|
159
|
-
|
|
160
|
-
<Tabs syncKey="pm">
|
|
161
|
-
<TabItem label="npm">
|
|
162
|
-
```shell
|
|
163
|
-
npm install -D knip
|
|
164
|
-
```
|
|
165
|
-
</TabItem>
|
|
166
|
-
|
|
167
|
-
<TabItem label="pnpm">
|
|
168
|
-
```shell
|
|
169
|
-
pnpm add -D knip
|
|
170
|
-
```
|
|
171
|
-
</TabItem>
|
|
172
|
-
|
|
173
|
-
<TabItem label="bun">
|
|
174
|
-
```shell
|
|
175
|
-
bun add -D knip
|
|
176
|
-
```
|
|
177
|
-
</TabItem>
|
|
178
|
-
|
|
179
|
-
<TabItem label="yarn">
|
|
180
|
-
```shell
|
|
181
|
-
yarn add -D knip
|
|
182
|
-
```
|
|
183
|
-
</TabItem>
|
|
184
|
-
</Tabs>
|
|
185
|
-
|
|
186
|
-
Remember, Knip it before you ship it! Have a great day ☀️
|
|
187
|
-
|
|
188
|
-
[1]: ../blog/slim-down-to-speed-up.md
|
|
189
|
-
[2]: ../features/reporters.md#json
|
|
190
|
-
[3]: ../features/reporters.md#preprocessors
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Migration to v1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
_2023-01-04_
|
|
6
|
-
|
|
7
|
-
When coming from version v0.13.3 or before, there are some breaking changes:
|
|
8
|
-
|
|
9
|
-
- The `entryFiles` and `projectFiles` options have been renamed to `entry` and
|
|
10
|
-
`project`.
|
|
11
|
-
- The `--dev` argument and `dev: true` option are gone, this is now the default
|
|
12
|
-
mode (see [production mode][1]).
|
|
13
|
-
- Workspaces have been moved from the root of the config to the `workspaces` key
|
|
14
|
-
(see [workspaces][2]).
|
|
15
|
-
- The `--dir` argument has been renamed to `--workspace`.
|
|
16
|
-
|
|
17
|
-
## Example
|
|
18
|
-
|
|
19
|
-
A configuration like this in v0.13.3 or before...
|
|
20
|
-
|
|
21
|
-
```json
|
|
22
|
-
{
|
|
23
|
-
"entryFiles": ["src/index.ts"],
|
|
24
|
-
"projectFiles": ["src/**/*.ts", "!**/*.spec.ts"],
|
|
25
|
-
"dev": {
|
|
26
|
-
"entryFiles": ["src/index.ts", "src/**/*.spec.ts", "src/**/*.e2e.ts"],
|
|
27
|
-
"projectFiles": ["src/**/*.ts"]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
...should become this for v1...
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"entry": ["src/index.ts!"],
|
|
37
|
-
"project": ["src/**/*.ts!"]
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Much cleaner, right? For some more details:
|
|
42
|
-
|
|
43
|
-
- The `dev` property for the `--dev` flag is now the default mode.
|
|
44
|
-
- Use `--production` to analyze only the `entry` and `project` files suffixed
|
|
45
|
-
with `!`.
|
|
46
|
-
- The glob patterns for both types of test files (`*.spec.ts` and `*.e2e.ts`)
|
|
47
|
-
are no longer needed:
|
|
48
|
-
- Regular test files like `*.test.js` and `*.spec.ts` etc. are automatically
|
|
49
|
-
handled by Knip.
|
|
50
|
-
- The `*.e2e.ts` files is configured with the Cypress or other plugin. Note
|
|
51
|
-
that Cypress uses `*.cy.ts` for spec files, but this could be overridden
|
|
52
|
-
like so:
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
{
|
|
56
|
-
"entry": "src/index.ts!",
|
|
57
|
-
"project": "src/**/*.ts!",
|
|
58
|
-
"cypress": {
|
|
59
|
-
"entry": "src/**/*.e2e.ts"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
[1]: ../features/production-mode.md
|
|
65
|
-
[2]: ../features/monorepos-and-workspaces.md
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Release Notes v2
|
|
3
|
-
sidebar:
|
|
4
|
-
order: 9
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
_2023-03-22_
|
|
8
|
-
|
|
9
|
-
## Breaking changes
|
|
10
|
-
|
|
11
|
-
When coming from v1, there are no breaking changes in terms of configuration.
|
|
12
|
-
|
|
13
|
-
## Changes
|
|
14
|
-
|
|
15
|
-
There are some changes regarding CLI arguments and output:
|
|
16
|
-
|
|
17
|
-
- Knip now runs on every \[workspace]\[1] automatically (except for the ones in
|
|
18
|
-
`ignoreWorkspaces: []`).
|
|
19
|
-
- The "Unlisted or unresolved dependencies" is split in "Unlisted dependencies"
|
|
20
|
-
and "Unresolved imports".
|
|
21
|
-
- Bug fixes and increased correctness impact output (potentially causing CI to
|
|
22
|
-
now succeed or fail).
|
|
23
|
-
|
|
24
|
-
## New features
|
|
25
|
-
|
|
26
|
-
Rewriting a major part of Knip's core from scratch allows for some new exciting
|
|
27
|
-
features:
|
|
28
|
-
|
|
29
|
-
- **Performance**. Files are read only once, and their ASTs are traversed only
|
|
30
|
-
once. Projects of any size will notice the difference. Total running time for
|
|
31
|
-
some projects decreases with 90%.
|
|
32
|
-
- **Compilers**. You can now include other file types such as `.mdx`, `.vue` and
|
|
33
|
-
`.svelte` in the analysis.
|
|
34
|
-
|
|
35
|
-
Internally, the `ts-morph` dependency is replaced by `typescript` itself.
|
|
36
|
-
|
|
37
|
-
## Other improvements
|
|
38
|
-
|
|
39
|
-
- Improved support for workspaces.
|
|
40
|
-
- Improved module resolutions, self-referencing imports, and other things you
|
|
41
|
-
don't want to worry about.
|
|
42
|
-
- Configure `ignoreDependencies` and `ignoreBinaries` at the workspace level.
|
|
43
|
-
- Simplified plugins model: plugin dependency finder may now return any type of
|
|
44
|
-
dependency in a single array: npm packages, local workspace packages, local
|
|
45
|
-
files, etc. (module and path resolution are handled outside the plugin).
|
|
46
|
-
- Many bugfixes.
|