1
1
# ✂️ Knip
2
2
3
- Knip scans your JavaScript and TypeScript projects for ** unused files, dependencies and exports** . Things that should be
4
- eliminated. Less code means better performance and less to maintain, important for both UX and DX!
3
+ Knip scans your JavaScript and TypeScript projects for ** unused files, dependencies and exports** : things that can be
4
+ removed! Less code means better performance and less to maintain, important for both UX and DX!
5
5
6
6
For comparison, ESLint finds unused variables inside files in isolation, but this will not be flagged:
7
7
@@ -142,7 +142,7 @@ As always, make sure to backup files or use Git before deleting files or making
142
142
143
143
The default configuration for Knip is very strict and targets production code. For best results, it is recommended to
144
144
exclude files such as tests from the project files. Here's why: when including tests and other non-production files,
145
- they may prevent production files from being reported as unused.
145
+ they may import production files, which will prevent them from being reported as unused.
146
146
147
147
Excluding non-production files from the ` projectFiles ` allows Knip to understand what production code can be removed
148
148
(including dependent files!).
@@ -162,8 +162,7 @@ and add `dev: true` to a file named such as `knip.dev.json`:
162
162
}
163
163
```
164
164
165
- Use ` -c knip.dev.json ` and unused files and exports for the combined set of files as configured in ` entryFiles ` will be
166
- reported.
165
+ Now use ` -c knip.dev.json ` to find unused files and exports for the combined set of files as configured in ` entryFiles ` .
167
166
168
167
An alternative way to store ` dev ` configuration is in this example ` package.json ` :
169
168
@@ -192,7 +191,7 @@ This way, the `--dev` flag will use the `dev` options (and also add `devDependen
192
191
193
192
#### Separate packages
194
193
195
- In repos with multiple (published) packages, the ` --cwd ` option comes in handy. With similar package structures, the
194
+ In repos with multiple (published) packages, the ` --dir ` option comes in handy. With similar package structures, the
196
195
packages can be configured using globs:
197
196
198
197
``` json
@@ -209,8 +208,8 @@ Packages can also be explicitly configured per package directory.
209
208
To scan the packages separately, using the first match from the configuration file:
210
209
211
210
```
212
- knip --cwd packages/client
213
- knip --cwd packages/services
211
+ knip --dir packages/client
212
+ knip --dir packages/services
214
213
```
215
214
216
215
#### Connected projects
0 commit comments