Skip to content

Commit 50b5aa3

Browse files
committedOct 10, 2023
Edit docs
1 parent 40a91da commit 50b5aa3

File tree

1 file changed

+61
-56
lines changed

1 file changed

+61
-56
lines changed
 

‎README.md

+61-56
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,47 @@ The dots don't connect themselves. This is where Knip comes in:
2323
- [x] Finds binaries and dependencies in npm scripts, and a lot more locations
2424
- [x] Finds unused members of classes and enums
2525
- [x] Finds duplicate exports
26+
- [x] Use [production and strict mode][4] to focus on isolated production code
2627
- [x] Supports any combination of JavaScript and TypeScript
27-
- [x] Multiple built-in [reporters][4] (or use [custom reporters][5] and [preprocessors][6])
28-
- [x] Understands [JSDoc/TSDoc tags][7] (e.g. `@public` and `@internal`)
28+
- [x] Multiple built-in [reporters][5] (or use [custom reporters][6] and [preprocessors][7])
29+
- [x] Understands [JSDoc/TSDoc tags][8] (e.g. `@public` and `@internal`)
2930
- [x] Run Knip as part of your CI environment to detect issues and prevent regressions
3031

3132
Knip shines in both small and large projects. It's a fresh take on keeping your projects clean & tidy!
3233

33-
[![An orange cow with scissors, Van Gogh style][9]][8] <sup>_“An orange cow with scissors, Van Gogh style” - generated
34+
[![An orange cow with scissors, Van Gogh style][10]][9] <sup>_“An orange cow with scissors, Van Gogh style” - generated
3435
with OpenAI_</sup>
3536

36-
For updates or questions, come hang out in [The Knip Barn (Discord)][10], or follow [@webprolific (Twitter)][11] or
37-
[@webpro (fosstodon.org)][12]. Please use GitHub to [report issues][13].
37+
For updates or questions, come hang out in [The Knip Barn (Discord)][11], or follow [@webprolific (Twitter)][12] or
38+
[@webpro (fosstodon.org)][13]. Please use GitHub to [report issues][14].
3839

3940
## Contents
4041

41-
- [Getting Started][14]
42-
- [Installation][15]
43-
- [Default Configuration][16]
44-
- [Let's Go!][17]
45-
- [Configuration][18]
46-
- [Entry Files][19]
42+
- [Getting Started][15]
43+
- [Installation][16]
44+
- [Default Configuration][17]
45+
- [Let's Go!][18]
46+
- [Configuration][19]
47+
- [Entry Files][20]
4748
- [Workspaces][1]
4849
- [Plugins][2]
4950
- [Compilers][3]
50-
- [Ignore files, binaries, dependencies and workspaces][20]
51-
- [Public exports][21]
52-
- [Ignore exports used in file][22]
53-
- [Include exports in entry files][23]
54-
- [Paths][24]
55-
- [Production Mode][25]
51+
- [Ignore files, binaries, dependencies and workspaces][21]
52+
- [Public exports][22]
53+
- [Ignore exports used in file][23]
54+
- [Include exports in entry files][24]
55+
- [Paths][25]
56+
- [Production Mode][4]
5657
- [Strict][26]
5758
- [Ignore `@internal` exports][27]
5859
- [Plugins][28]
5960
- [Output][29]
6061
- [Screenshots][30]
6162
- [Reading the report][31]
6263
- [Rules & Filters][32]
63-
- [Reporters][4]
64+
- [Reporters][5]
6465
- [Fixing Issues][33]
65-
- [JSDoc tags][7]
66+
- [JSDoc tags][8]
6667
- [Command Line Options][34]
6768
- [Potential boost with `--no-gitignore`][35]
6869
- [Comparison & Migration][36]
@@ -88,7 +89,7 @@ Knip supports LTS versions of Node.js, and currently requires at least Node.js v
8889

8990
### Default Configuration
9091

91-
Knip has good defaults and you can run it without any configuration. The (simplified) default config:
92+
Knip has good defaults and aims for no or little configuration. The (simplified) default config:
9293

9394
```json
9495
{
@@ -97,9 +98,9 @@ Knip has good defaults and you can run it without any configuration. The (simpli
9798
}
9899
```
99100

100-
There's more, jump to [Entry Files][19] for details.
101+
There's more, jump to [Entry Files][20] for details.
101102

102-
Places where Knip looks for configuration (ordered by priority):
103+
Knip looks for this configuration file (ordered by priority):
103104

104105
- `knip.json`
105106
- `knip.jsonc`
@@ -122,7 +123,7 @@ const config: KnipConfig = {
122123
export default config;
123124
```
124125

125-
Use `--config path/to/knip.json` to use a different location.
126+
Use `--config path/to/knip.config.json` for a different path.
126127

127128
### Let's Go!
128129

@@ -136,8 +137,9 @@ Run the checks with `npx knip`. Or first add this script to `package.json`:
136137
}
137138
```
138139

139-
Then use `npm run knip` to analyze the project and output unused files, dependencies and exports. Knip works just fine
140-
with `yarn` or `pnpm` as well.
140+
Then use `npm run knip` to analyze the project and output unused files, dependencies and exports.
141+
142+
Knip works just fine with `yarn` or `pnpm` or `bun`.
141143

142144
See [Command Line Options][34] for an overview of available CLI options.
143145

@@ -150,15 +152,15 @@ In addition to `index.js`, the following file names and extensions are also cons
150152
- `index`, `main` and `cli`
151153
- `js`, `mjs`, `cjs`, `jsx`, `ts`, `mts`, `cts` and `tsx`
152154

153-
This means files like `main.cjs` and `src/cli.ts` are automatically added as entry files. Knip looks for entry files at
154-
those default locations, but also in other places:
155+
This means files like `main.cjs` and `src/cli.ts` are automatically added as entry files. Knip also looks for `entry`
156+
files in other places:
155157

156158
- The `main`, `bin` and `exports` fields of `package.json`.
157-
- [Plugins][2] such as for Next.js, Remix, Gatsby or Svelte add entry files.
158-
- The `scripts` in package.json or other scripts may provide entry files.
159+
- [Plugins][2] such as for Jest, Next.js, Svelte or Vitest etc. add entry files.
160+
- The `scripts` in package.json and other scripts may provide entry files.
159161

160-
Knip does this for each [workspace][1] it finds, trying to minimize the configuration to suit your project. In a
161-
perfectly boring world where everything is according to defaults you wouldn't even need a `knip.json` file at all.
162+
Knip does this for each [workspace][1] it finds. In a perfectly boring world where everything is according to defaults
163+
you wouldn't even need a `knip.json` file at all.
162164

163165
Larger projects tend to have more things customized, and therefore probably get more out of Knip with a configuration
164166
file. Let's say you are using `.ts` files exclusively and have all source files only in the `src` directory:
@@ -202,7 +204,7 @@ Here's an example `knip.json` configuration with some custom `entry` and `projec
202204
```
203205

204206
It might be useful to run Knip first with no or little configuration to see where it needs custom `entry` and/or
205-
`project` files. Each workspace has the same [default configuration][18].
207+
`project` files. Each workspace has the same [default configuration][19].
206208

207209
The root workspace is named `"."` under `workspaces` (like in the example).
208210

@@ -540,6 +542,9 @@ The report contains the following types of issues:
540542
| Unused exported class members | unable to find references to this class member | `classMembers` |
541543
| Duplicate exports | the same thing is exported more than once | `duplicates` |
542544

545+
Note that `devDependencies` is covered within a single key for all `dependencies`. In [strict production mode][4],
546+
`devDependencies` are not included.
547+
543548
When an issue type has zero issues, it is not shown.
544549

545550
Getting too many reported issues and false positives? Read more about [handling issues][49].
@@ -753,7 +758,7 @@ unimported
753758
knip --production --dependencies --include files
754759
```
755760

756-
Also see [production mode][25].
761+
Also see [production mode][4].
757762

758763
### ts-unused-exports
759764

@@ -793,7 +798,7 @@ Many thanks to some of the early adopters of Knip:
793798

794799
## Articles, etc.
795800

796-
- Discord: hang out in [The Knip Barn][10]
801+
- Discord: hang out in [The Knip Barn][11]
797802
- Ask your questions in the [Knip knowledge base][67] (powered by OpenAI and [7-docs][68], experimental!)
798803
- Smashing Magazine: [Knip: An Automated Tool For Finding Unused Files, Exports, And Dependencies][69]
799804
- Effective TypeScript: [Recommendation Update: ✂️ Use knip to detect dead code and types][70]
@@ -820,28 +825,28 @@ Special thanks to the wonderful people who have contributed to this project:
820825
[1]: #workspaces
821826
[2]: #plugins
822827
[3]: #compilers
823-
[4]: #reporters
824-
[5]: #custom-reporters
825-
[6]: #preprocessers
826-
[7]: #jsdoc-tags
827-
[8]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
828-
[9]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
829-
[10]: https://discord.gg/r5uXTtbTpc
830-
[11]: https://twitter.com/webprolific
831-
[12]: https://fosstodon.org/@webpro
832-
[13]: https://github.com/webpro/knip/issues
833-
[14]: #getting-started
834-
[15]: #installation
835-
[16]: #default-configuration
836-
[17]: #lets-go
837-
[18]: #configuration
838-
[19]: #entry-files
839-
[20]: #ignore-files-binaries-dependencies-and-workspaces
840-
[21]: #public-exports
841-
[22]: #ignore-exports-used-in-file
842-
[23]: #include-exports-in-entry-files
843-
[24]: #paths
844-
[25]: #production-mode
828+
[4]: #production-mode
829+
[5]: #reporters
830+
[6]: #custom-reporters
831+
[7]: #preprocessers
832+
[8]: #jsdoc-tags
833+
[9]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
834+
[10]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
835+
[11]: https://discord.gg/r5uXTtbTpc
836+
[12]: https://twitter.com/webprolific
837+
[13]: https://fosstodon.org/@webpro
838+
[14]: https://github.com/webpro/knip/issues
839+
[15]: #getting-started
840+
[16]: #installation
841+
[17]: #default-configuration
842+
[18]: #lets-go
843+
[19]: #configuration
844+
[20]: #entry-files
845+
[21]: #ignore-files-binaries-dependencies-and-workspaces
846+
[22]: #public-exports
847+
[23]: #ignore-exports-used-in-file
848+
[24]: #include-exports-in-entry-files
849+
[25]: #paths
845850
[26]: #strict
846851
[27]: #ignore-internal-exports
847852
[28]: #plugins-1

0 commit comments

Comments
 (0)
Please sign in to comment.