Skip to content

Commit e6340b0

Browse files
committedDec 11, 2024·
Update comparison page + auto-format
1 parent dbb153d commit e6340b0

File tree

3 files changed

+66
-63
lines changed

3 files changed

+66
-63
lines changed
 

‎packages/docs/src/content/docs/explanations/comparison-and-migration.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ knip --include exports,types,nsExports,nsTypes
8686

8787
Use `knip --exports` to also include class and enum members.
8888

89-
### ts-remove-unused
89+
### tsr
9090

9191
> Remove unused code from your TypeScript Project
9292
93-
[ts-remove-unused][8] removes unused exports, and works based on a single
94-
`tsconfig.json` file (`includes` and `excludes`) and requires no configuration.
95-
It removes the `export` keyword or the whole export declaration.
93+
[tsr][8] (previously `ts-remove-unused`) removes unused exports, and works based
94+
on a single `tsconfig.json` file (`includes` and `excludes`) and requires no
95+
configuration. It removes the `export` keyword or the whole export declaration.
9696

9797
## Related projects
9898

@@ -102,8 +102,9 @@ Additional alternative and related projects include:
102102
- [DepClean][10]
103103
- [dependency-check][11]
104104
- [find-unused-exports][12]
105-
- [npm-check][13]
106-
- [renoma][14]
105+
- [next-unused][13]
106+
- [npm-check][14]
107+
- [renoma][15]
107108

108109
[1]: ./why-use-knip.md#comprehensive
109110
[2]: ../features/monorepos-and-workspaces.md
@@ -112,10 +113,11 @@ Additional alternative and related projects include:
112113
[5]: https://github.com/smeijer/unimported
113114
[6]: https://github.com/nadeesha/ts-prune
114115
[7]: https://github.com/pzavolinsky/ts-unused-exports
115-
[8]: https://github.com/line/ts-remove-unused
116+
[8]: https://github.com/line/tsr
116117
[9]: https://github.com/M-Izadmehr/deadfile
117118
[10]: https://github.com/mysteryven/depclean
118119
[11]: https://github.com/dependency-check-team/dependency-check
119120
[12]: https://github.com/jaydenseric/find-unused-exports
120-
[13]: https://github.com/dylang/npm-check
121-
[14]: https://github.com/bluwy/renoma
121+
[13]: https://github.com/pacocoursey/next-unused
122+
[14]: https://github.com/dylang/npm-check
123+
[15]: https://github.com/bluwy/renoma

‎packages/docs/src/content/docs/guides/troubleshooting.md

+24-25
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,33 @@ complicated". Knip and documentation are always a work in progress.
2121

2222
If it doesn't come your way at the first try, please understand this also shows
2323
the dynamic and innovative nature of the ecosystem. Often only small changes go
24-
a long way towards success. Consider
25-
[opening an issue](https://github.com/webpro-nl/knip/issues/new/choose) and/or
26-
[ask away on Discord](https://discord.gg/r5uXTtbTpc). With the help of the
27-
community (that's you!) we can improve Knip for everyone and make project
28-
maintenance easier and more fun!
24+
a long way towards success. Consider [opening an issue][5] and/or [ask away on
25+
Discord][6]. With the help of the community (that's you!) we can improve Knip
26+
for everyone and make project maintenance easier and more fun!
2927

3028
:::
3129

3230
## Lint issues reported by Knip
3331

34-
Knip reports lint issues in your codebase. See [handling issues][5] to deal with
32+
Knip reports lint issues in your codebase. See [handling issues][7] to deal with
3533
the reported issues.
3634

3735
If Knip reports false positives and you're considering filing a GitHub issue,
3836
please do! It'll make Knip better for everyone. Please read [issue
39-
reproduction][6] first.
37+
reproduction][8] first.
4038

4139
Exit code 1 indicates a successful run, but lint issues were found.
4240

4341
## Exceptions thrown by Knip
4442

4543
Knip may throw an exception, resulting in an unsuccessful run.
4644

47-
See [known issues][7] as it may be listed there and a workaround may be
45+
See [known issues][9] as it may be listed there and a workaround may be
4846
available. If it isn't clear what's throwing the exception, try another run with
4947
`--debug` to locate the cause of the issue with more details.
5048

5149
If Knip throws an exception and you're considering filing a GitHub issue, please
52-
do! It'll make Knip better for everyone. Please read [issue reproduction][6]
50+
do! It'll make Knip better for everyone. Please read [issue reproduction][8]
5351
first.
5452

5553
Exit code 2 indicates an exception was thrown by Knip.
@@ -97,32 +95,33 @@ the opposite direction and shows where exports are imported.
9795

9896
## Opening an issue
9997

100-
If you want to open an issue, please see [issue reproduction][6].
98+
If you want to open an issue, please see [issue reproduction][8].
10199

102100
## Understanding Knip
103101

104-
Looking to better understand how Knip works? The [entry files][8] and
105-
[plugins][9] explanations cover two core concepts. After this you might want to
106-
check out features like [production mode][10] and [monorepos & workspaces][11].
102+
Looking to better understand how Knip works? The [entry files][10] and
103+
[plugins][11] explanations cover two core concepts. After this you might want to
104+
check out features like [production mode][12] and [monorepos & workspaces][13].
107105

108-
In a more general sense, [Why use Knip?][12] explains what Knip can do for you.
106+
In a more general sense, [Why use Knip?][14] explains what Knip can do for you.
109107

110108
## Asking for help
111109

112110
If you can't find your answer in any of the aforementioned resources, feel free
113-
to [open an issue on GitHub][13] or discuss it in [the Discord channel][14].
111+
to [open an issue on GitHub][15] or discuss it in [the Discord channel][6].
114112

115113
[1]: #lint-issues-reported-by-knip
116114
[2]: #exceptions-thrown-by-knip
117115
[3]: #debug
118116
[4]: #trace
119-
[5]: ../guides/handling-issues.md
120-
[6]: ./issue-reproduction.md
121-
[7]: ../reference/known-issues.md
122-
[8]: ../explanations/entry-files.md
123-
[9]: ../explanations/plugins.md
124-
[10]: ../features/production-mode.md
125-
[11]: ../features/monorepos-and-workspaces.md
126-
[12]: ../explanations/why-use-knip.md
127-
[13]: https://github.com/webpro-nl/knip/issues
128-
[14]: https://discord.gg/r5uXTtbTpc
117+
[5]: https://github.com/webpro-nl/knip/issues/new/choose
118+
[6]: https://discord.gg/r5uXTtbTpc
119+
[7]: ../guides/handling-issues.md
120+
[8]: ./issue-reproduction.md
121+
[9]: ../reference/known-issues.md
122+
[10]: ../explanations/entry-files.md
123+
[11]: ../explanations/plugins.md
124+
[12]: ../features/production-mode.md
125+
[13]: ../features/monorepos-and-workspaces.md
126+
[14]: ../explanations/why-use-knip.md
127+
[15]: https://github.com/webpro-nl/knip/issues

‎packages/docs/src/content/docs/reference/faq.md

+31-29
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ hands".
4848

4949
On the other hand, Knip is a project linter that should be part of QA. It lints,
5050
reports and fixes only your own source code. A linter reporting issues hands
51-
control back to you (unless you [auto-fix](../features/auto-fix.mdx)
52-
everything).
51+
control back to you (unless you [auto-fix][1] everything).
5352

5453
Besides those differences, Knip has a broader scope:
5554

56-
- Improve DX (see [less is more](../explanations/why-use-knip.md#less-is-more)).
55+
- Improve DX (see [less is more][2]).
5756
- Include non-production code and dependencies in the process by default.
58-
- Report more [issue types](./issue-types.md) (such as unlisted dependencies).
57+
- Report more [issue types][3] (such as unlisted dependencies).
5958

6059
## Synergy
6160

@@ -88,13 +87,13 @@ Building up the module and dependency graph requires non-standard module
8887
resolution and not only static but also dynamic analysis (i.e. actually load and
8988
execute modules), such as for parsers of plugins to receive the exported value
9089
of dynamic tooling configuration files. Additionally, [exports consumed by
91-
external libraries][1] require type information, as supported by the TypeScript
90+
external libraries][4] require type information, as supported by the TypeScript
9291
backend. Last but not least, shell script parsing is required to find the right
9392
entry files, configuration files and dependencies accurately.
9493

9594
The rippling effect of plugins and recursively adding entry files and
9695
dependencies to build up the graph is also exactly what's meant by
97-
["comprehensive" here][2].
96+
["comprehensive" here][5].
9897

9998
## Building the graph
10099

@@ -136,9 +135,8 @@ files (`config/vitest.config.ts` and `playwright.e2e.config.ts` in the examples
136135
above). They're recognized as configuration files and passed to their respective
137136
plugins, and may contain additional entry files.
138137

139-
Entry files are added to the module graph.
140-
[Module resolution](#module-resolution) might result in additional entry files
141-
recursively until no more entry files are found.
138+
Entry files are added to the module graph. [Module resolution][6] might result
139+
in additional entry files recursively until no more entry files are found.
142140

143141
### What does Knip look for in source files?
144142

@@ -150,7 +148,7 @@ all nodes of the generated AST to find:
150148
- Accessed properties on namespace imports and re-exports to track individual
151149
export usage
152150
- Calls to `require.resolve` and `import.meta.resolve`
153-
- Scripts in template strings (passed to [script parser][3])
151+
- Scripts in template strings (passed to [script parser][7])
154152

155153
### What's in the graph?
156154

@@ -188,7 +186,7 @@ there are a few issues with this approach:
188186

189187
- It requires lockfile parsing for each lockfile format and version of each
190188
package manager.
191-
- The lockfile doesn't contain whether the package [has types included][4].
189+
- The lockfile doesn't contain whether the package [has types included][8].
192190

193191
## Module Resolution
194192

@@ -209,12 +207,12 @@ seem to meet all requirements to be usable on its own by Knip:
209207
`module.js`
210208

211209
A few strategies have been tried and tweaked, and Knip currently uses a
212-
combination of [enhanced-resolve][5], the TypeScript module resolver and a few
210+
combination of [enhanced-resolve][9], the TypeScript module resolver and a few
213211
customizations. This single custom module resolver function is hooked into the
214212
TypeScript compiler and language service hosts.
215213

216214
Everything else outside the dependency graph is handled by `enhanced-resolve`
217-
when doing things like [script parsing][3] and resolving references to files in
215+
when doing things like [script parsing][7] and resolving references to files in
218216
other workspaces.
219217

220218
### How does Knip handle non-standard import syntax?
@@ -245,7 +243,7 @@ file. They're not a concept in Knip.
245243

246244
A TypeScript program has a 1-to-1 relationship with workspaces if they're
247245
analyzed in isolation. However, by default Knip optimizes for performance and
248-
utilizes [workspace sharing][6]. That's why debug output contains messages like
246+
utilizes [workspace sharing][10]. That's why debug output contains messages like
249247
"Installed 2 programs for 29 workspaces".
250248

251249
### Why doesn't Knip match my TypeScript project structure?
@@ -277,7 +275,7 @@ Knip shares the files of multiple workspaces in a single program if their
277275
configuration allows it. This optimization is enabled by default, while it also
278276
allows the module resolver (one per program) to do some more caching.
279277

280-
Also see [workspace sharing][6].
278+
Also see [workspace sharing][10].
281279

282280
### Why doesn't Knip just use `ts.findReferences`?
283281

@@ -293,7 +291,7 @@ comprehensive graph include:
293291
Without sacrificing these benefits, Knip does use `ts.findReferences` to find
294292
references to class members (i.e. when the issue type `classMembers` is
295293
included). In case analysis of exports requires type information of external
296-
dependencies, the [`--include-libs ` flag][1] will trigger the same.
294+
dependencies, the [`--include-libs ` flag][4] will trigger the same.
297295

298296
### Why can't I use path aliases to reference other workspaces?
299297

@@ -359,7 +357,7 @@ other file types.
359357
Knip comes with basic "compilers" for a few common non-standard file types.
360358
They're not actual compilers, they're regular expressions only to extract import
361359
statements. Override the built-in Vue "compiler" with the real one in your
362-
project. Also see the answer to the previous question and [Compilers][7].
360+
project. Also see the answer to the previous question and [Compilers][11].
363361

364362
## Miscellaneous
365363

@@ -379,7 +377,7 @@ Which mode should've been the default? They both have their merits:
379377
tooling, including most issues found in production mode. This mode has the
380378
most impact on DX, for the same reason.
381379

382-
Also see [production mode][8].
380+
Also see [production mode][12].
383381

384382
### Why doesn't Knip have...?
385383

@@ -403,14 +401,18 @@ Examples of features that have been requested include:
403401

404402
These are all interesting ideas, but most increase the API surface area, and all
405403
require more development efforts and maintenance. Time is limited and
406-
[sponsorships][9] currently don't cover - this can change though!
407-
408-
[1]: ../guides/handling-issues.mdx#external-libraries
409-
[2]: ../explanations/why-use-knip.md#comprehensive
410-
[3]: ../features/script-parser.md
411-
[4]: ../guides/handling-issues.mdx#types-packages
412-
[5]: https://www.npmjs.com/package/enhanced-resolve
413-
[6]: ../guides/performance.md#workspace-sharing
414-
[7]: ../features/compilers.md
415-
[8]: ../features/production-mode.md
416-
[9]: /sponsors
404+
[sponsorships][13] currently don't cover - this can change though!
405+
406+
[1]: ../features/auto-fix.mdx
407+
[2]: ../explanations/why-use-knip.md#less-is-more
408+
[3]: ./issue-types.md
409+
[4]: ../guides/handling-issues.mdx#external-libraries
410+
[5]: ../explanations/why-use-knip.md#comprehensive
411+
[6]: #module-resolution
412+
[7]: ../features/script-parser.md
413+
[8]: ../guides/handling-issues.mdx#types-packages
414+
[9]: https://www.npmjs.com/package/enhanced-resolve
415+
[10]: ../guides/performance.md#workspace-sharing
416+
[11]: ../features/compilers.md
417+
[12]: ../features/production-mode.md
418+
[13]: /sponsors

0 commit comments

Comments
 (0)
Please sign in to comment.