knip 0.7.2 → 0.7.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/README.md CHANGED
@@ -1,22 +1,20 @@
1
1
  # ✂️ Knip
2
2
 
3
- Knip scans your JavaScript and TypeScript projects for **unused files, dependencies and exports**: things that can be
4
- removed! Less code leads to improved performance, less maintenance, easier refactorings.
3
+ Knip finds **unused files, dependencies and exports** in your JavaScript and TypeScript projects. Less code leads to
4
+ improved performance, less maintenance and easier refactorings.
5
5
 
6
6
  ```ts
7
7
  export const myVar = true;
8
8
  ```
9
9
 
10
10
  ESLint handles files in isolation, so the `export` keyword "blocks" further analysis. Unused files and dependencies will
11
- also not be detected. You could think of Knip as going (far!) beyond the "unused variable" rule of ESLint. Knip lints
12
- the project as a whole, or parts of it.
11
+ also not be detected. You could think of Knip as going (far!) beyond the `no-unused-vars` rule of ESLint. Knip lints the
12
+ project as a whole (or parts of it).
13
13
 
14
- It's only human to forget to delete files or dependencies that you no longer use. How to keep track of how many times
15
- something is actually used in a codebase? How to find out this number just dropped to zero for anything? Where to even
16
- start finding things that can be removed during maintenance and refactorings? Especially in larger projects all of this
17
- can be tedious. This is where Knip comes in.
14
+ It's only human to forget removing things that you no longer use. But how do you find out? Where to even start finding
15
+ things that can be removed?
18
16
 
19
- Boring stuff should be automated! Just let Knip have a crack at it:
17
+ The dots don't connect themselves. This is where Knip comes in:
20
18
 
21
19
  - [x] Finds **unused files, dependencies and exports**.
22
20
  - [x] Finds dependencies not listed in `package.json`.
@@ -24,24 +22,21 @@ Boring stuff should be automated! Just let Knip have a crack at it:
24
22
  - [x] Supports JavaScript inside TypeScript projects (`"allowJs": true`).
25
23
  - [x] Finds duplicate exports of the same symbol.
26
24
  - [x] Supports JavaScript ES Module-based projects without a `tsconfig.json`.
27
- - [x] Features multiple [reporters](#reporters) and supports [custom reporters](#custom-reporters).
25
+ - [x] Features multiple [reporters][1] and supports [custom reporters][2].
28
26
 
29
27
  Knip really shines in larger projects. A little bit of configuration will pay off, I promise. A comparison with similar
30
- tools answers the question
31
- [why another unused file/dependency/export finder?](#why-yet-another-unused-filedependencyexport-finder)
28
+ tools answers the question [why another unused file/dependency/export finder?][3]
32
29
 
33
30
  Knip is a fresh take on keeping your projects clean & tidy!
34
31
 
35
- [![An orange cow with scissors, Van Gogh style](./assets/cow-with-orange-scissors-van-gogh-style.webp)](https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC)
36
- <sup>_“An orange cow with scissors, Van Gogh style” - generated with OpenAI_</sup>
32
+ [![An orange cow with scissors, Van Gogh style][5]][4] <sup>_“An orange cow with scissors, Van Gogh style” - generated
33
+ with OpenAI_</sup>
37
34
 
38
35
  ## Installation
39
36
 
40
- ```
41
- npm install -D knip
42
- ```
37
+ npm install -D knip
43
38
 
44
- Knip requires least Node.js v16.17 or v18 is required. Knip is _cutting edge!_
39
+ Knip requires at least Node.js v16.17 or v18. Knip is _cutting edge!_
45
40
 
46
41
  ## Usage
47
42
 
@@ -59,67 +54,67 @@ all files it should match them against, including potentially unused files.
59
54
 
60
55
  Then run the checks:
61
56
 
62
- ```
63
- npx knip
64
- ```
57
+ npx knip
65
58
 
66
59
  This will analyze the project and output unused files, exports, types and duplicate exports.
67
60
 
68
- Use `--include files` when configuring knip the first time for faster initial results.
69
-
70
61
  ## How It Works
71
62
 
72
63
  Knip works by creating two sets of files:
73
64
 
74
- 1. Production code is the set of files resolved from the `entryFiles`.
75
- 2. They are matched against the set of `projectFiles`.
76
- 3. The subset of project files that is not production code will be reported as unused files (in red).
77
- 4. Then the production code (in blue) will be scanned for unused exports.
65
+ 1. Production code is the set of files resolved from the `entryFiles`.
66
+ 2. They are matched against the set of `projectFiles`.
67
+ 3. The subset of project files that is not production code will be reported as unused files (in red).
68
+ 4. Then the production code (in blue) will be analyzed for unused exports.
78
69
 
79
- ![How it works](./assets/how-it-works.drawio.svg)
70
+ ![How it works][6]
80
71
 
81
72
  ## Options
82
73
 
83
- ```
84
- npx knip
85
- knip [options]
86
-
87
- Options:
88
- -c/--config [file] Configuration file path (default: ./knip.json or package.json#knip)
89
- -t/--tsConfig [file] TypeScript configuration path (default: ./tsconfig.json)
90
- --dir Working directory (default: current working directory)
91
- --include Report only listed issue group(s) (see below)
92
- --exclude Exclude issue group(s) from report (see below)
93
- --ignore Ignore files matching this glob pattern (can be set multiple times)
94
- --no-gitignore Don't use .gitignore
95
- --dev Include `devDependencies` in report(s)
96
- --no-progress Don't show dynamic progress updates
97
- --max-issues Maximum number of issues before non-zero exit code (default: 0)
98
- --reporter Select reporter: symbols, compact, codeowners (default: symbols)
99
- --reporter-options Pass extra options to the reporter (as JSON string, see example)
100
- --jsdoc Enable JSDoc parsing, with options: public
101
- --debug Show debug output
102
- --debug-level Set verbosity of debug output (default: 1, max: 2)
103
-
104
- Issue groups: files, dependencies, unlisted, exports, nsExports, types, nsTypes, duplicates
105
-
106
- Examples:
107
-
108
- $ knip
109
- $ knip --dir packages/client --include files
110
- $ knip -c ./knip.js --reporter compact --jsdoc public
111
- $ knip --ignore 'lib/**/*.ts' --ignore build
112
- $ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
113
-
114
- More info: https://github.com/webpro/knip
115
- ```
74
+ ❯ npx knip
75
+ knip [options]
76
+
77
+ Options:
78
+ -c/--config [file] Configuration file path (default: ./knip.json or package.json#knip)
79
+ -t/--tsConfig [file] TypeScript configuration path (default: ./tsconfig.json)
80
+ --dir Working directory (default: current working directory)
81
+ --include Report only listed issue type(s) (see below)
82
+ --exclude Exclude issue type(s) from report (see below)
83
+ --ignore Ignore files matching this glob pattern (can be set multiple times)
84
+ --no-gitignore Don't use .gitignore
85
+ --dev Include `devDependencies` in report(s)
86
+ --no-progress Don't show dynamic progress updates
87
+ --max-issues Maximum number of issues before non-zero exit code (default: 0)
88
+ --reporter Select reporter: symbols, compact, codeowners (default: symbols)
89
+ --reporter-options Pass extra options to the reporter (as JSON string, see example)
90
+ --jsdoc Enable JSDoc parsing, with options: public
91
+ --debug Show debug output
92
+ --debug-level Set verbosity of debug output (default: 1, max: 2)
93
+
94
+ Issue types: files, dependencies, unlisted, exports, nsExports, types, nsTypes, duplicates
95
+
96
+ Examples:
97
+
98
+ $ knip
99
+ $ knip --dir packages/client --include files
100
+ $ knip -c ./knip.js --reporter compact --jsdoc public
101
+ $ knip --ignore 'lib/**/*.ts' --ignore build
102
+ $ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
103
+
104
+ More info: https://github.com/webpro/knip
116
105
 
117
- 🚀 Knip is considerably faster when only the `files` and/or `duplicates` groups are included.
106
+ ## Performance
107
+
108
+ 🚀 Knip is considerably faster when only the `files` and/or `duplicates` types are included. Finding unused exports
109
+ requires deeper analysis (`exports`, `nsExports`, `types`, `nsTypes`). The following example commands do the same:
110
+
111
+ knip --include files --include duplicates
112
+ knip --include files,duplicates
118
113
 
119
114
  ## Reading the report
120
115
 
121
116
  After analyzing all the files resolved from the `entryFiles` against the `projectFiles`, the report contains the
122
- following groups of issues:
117
+ following types of issues:
123
118
 
124
119
  - `files` - Unused files: did not find references to this file
125
120
  - `dependencies` - Unused dependencies: did not find references to this dependency
@@ -130,25 +125,26 @@ following groups of issues:
130
125
  - `nsTypes` - Unused types in namespaces: did not find direct references to this exported variable (2)
131
126
  - `duplicates` - Duplicate exports: the same thing is exported more than once with different names from the same file
132
127
 
133
- Each group type can be an `--include` or `--exclude` to slice & dice the report to your needs.
128
+ 1. This may also include dependencies that could not be resolved properly (such as non-relative `local/dir/file.ts` not
129
+ and `local` not being in `node_modules`).
130
+ 2. The variable or type is not referenced directly, and has become a member of a namespace. That's why Knip is not sure
131
+ whether this export can be removed, so please look into it:
134
132
 
135
- 1. This may also include dependencies that could not be resolved properly (such as non-relative `local/dir/file.ts` not
136
- and `local` not being in `node_modules`).
137
- 2. The variable or type is not referenced directly, and has become a member of a namespace. That's why Knip is not sure
138
- whether this export can be removed, so please look into it:
133
+ You can `--include` or `--exclude` any of the types to slice & dice the report to your needs. Alternatively, they can be
134
+ added to the configuration (e.g. `"exclude": ["dependencies"]`).
139
135
 
140
136
  ## Now what?
141
137
 
142
138
  As always, make sure to backup files or use Git before deleting files or making changes. Run tests to verify results.
143
139
 
144
- - Unused files can be deleted.
140
+ - Unused files can be removed.
145
141
  - Unused dependencies can be removed from `package.json`.
146
142
  - Unlisted dependencies should be added to `package.json`.
147
143
  - Unused exports and types: remove the `export` keyword in front of unused exports. Then you (or tools such as the
148
144
  TypeScript language server in VS Code and/or ESLint) can see whether the variable or type is used within the same
149
145
  file. If this is not the case, it can be removed.
150
146
 
151
- 🔁 Repeat the process to reveal new unused files and exports. Sometimes it's so liberating to delete things!
147
+ 🔁 Repeat the process to reveal new unused files and exports. Sometimes it's so liberating to remove things!
152
148
 
153
149
  ## Production versus non-production code
154
150
 
@@ -157,12 +153,12 @@ Feels like you're getting too many false positives? Let's talk about `entryFiles
157
153
  ### Production code
158
154
 
159
155
  The default configuration for Knip is very strict and targets production code. Non-production files such as tests should
160
- not be part of the `entryFiles`. Here's why: test and other non-production files often import production files, which
161
- will prevent the production files from being reported as unused. For best results:
156
+ not be part of the `entryFiles` and `projectFiles`. Here's why: test and other non-production files often import
157
+ production files, which will prevent the production files from being reported as unused. For best results:
162
158
 
163
159
  - Include only production entry files to the `entryFiles`.
164
160
  - Include only and all production files to the `projectFiles`.
165
- - If necessary, exclude non-production files from the `projectFiles` (using negation patterns).
161
+ - If necessary, add globs to exclude non-production files from the `projectFiles` (using negation pattern).
166
162
 
167
163
  This will ensure Knip understands what production code can be removed.
168
164
 
@@ -175,8 +171,8 @@ To analyze the project as a whole:
175
171
 
176
172
  - Include both production entry files and test files to the `entryFiles`.
177
173
  - Include all production files to the `projectFiles`.
178
- - Include non-production files from the `projectFiles`.
179
- - To include `devDependencies`, set `dev: true` in the configuration or add `--dev` as a command line flag.
174
+ - If necessary, add globs for non-production files to the `projectFiles`.
175
+ - Set `dev: true` in the configuration or add `--dev` as a command line flag (to add `devDependencies`).
180
176
 
181
177
  Here's an example:
182
178
 
@@ -233,18 +229,18 @@ packages can be configured using globs:
233
229
 
234
230
  Packages can also be explicitly configured per package directory.
235
231
 
236
- To scan the packages separately, using the matching pattern from the configuration file:
232
+ To analyze the packages separately, using the matching pattern from the configuration file:
237
233
 
238
- ```
239
- knip --dir packages/client
240
- knip --dir packages/services
241
- ```
234
+ knip --dir packages/client
235
+ knip --dir packages/services
242
236
 
243
237
  #### Connected projects
244
238
 
245
- A good example of a large project setup is a monorepo, such as created with Nx. Let's take an example project
246
- configuration for an Nx project using Next.js, Jest and Storybook. This configuration file can also be a JavaScript
247
- file, which allows to add logic and/or comments (e.g. `knip.js`):
239
+ A good example of a large project setup is a monorepo. Let's take an example (Nx) project configuration using Next.js,
240
+ Jest and Storybook, which has multiple apps and libs. They are not published separately and don't have their own
241
+ `package.json`.
242
+
243
+ This configuration file can also be a JavaScript file, which allows to add logic and/or comments (e.g. `knip.js`):
248
244
 
249
245
  ```js
250
246
  const entryFiles = ['apps/**/pages/**/*.{js,ts,tsx}'];
@@ -266,8 +262,8 @@ const projectFiles = [
266
262
  module.exports = { entryFiles, projectFiles };
267
263
  ```
268
264
 
269
- This should give good results about unused files and exports for the monorepo. After the first run, the configuration
270
- can be tweaked further to the project structure.
265
+ This should give good results about unused files, dependencies and exports for the monorepo. After the first run, the
266
+ configuration can be tweaked further to the project structure.
271
267
 
272
268
  ## Reporters
273
269
 
@@ -302,84 +298,78 @@ The data can then be used to write issues to `stdout`, a JSON or CSV file, or se
302
298
 
303
299
  The default reporter shows the sorted symbols first:
304
300
 
305
- ```
306
- $ knip
307
- --- UNUSED FILES (2)
308
- src/chat/helpers.ts
309
- src/components/SideBar.tsx
310
- --- UNUSED DEPENDENCIES (1)
311
- moment
312
- --- UNLISTED DEPENDENCIES (1)
313
- react
314
- --- UNUSED EXPORTS (5)
315
- lowercaseFirstLetter src/common/src/string/index.ts
316
- RegistrationBox src/components/Registration.tsx
317
- clamp src/css.ts
318
- restoreSession src/services/authentication.ts
319
- PREFIX src/services/authentication.ts
320
- --- UNUSED TYPES (4)
321
- enum RegistrationServices src/components/Registration/registrationMachine.ts
322
- type RegistrationAction src/components/Registration/registrationMachine.ts
323
- type ComponentProps src/components/Registration.tsx
324
- interface ProductDetail src/types/Product.ts
325
- --- DUPLICATE EXPORTS (2)
326
- Registration, default src/components/Registration.tsx
327
- ProductsList, default src/components/Products.tsx
328
- ```
301
+ $ knip
302
+ --- UNUSED FILES (2)
303
+ src/chat/helpers.ts
304
+ src/components/SideBar.tsx
305
+ --- UNUSED DEPENDENCIES (1)
306
+ moment
307
+ --- UNLISTED DEPENDENCIES (1)
308
+ react
309
+ --- UNUSED EXPORTS (5)
310
+ lowercaseFirstLetter src/common/src/string/index.ts
311
+ RegistrationBox src/components/Registration.tsx
312
+ clamp src/css.ts
313
+ restoreSession src/services/authentication.ts
314
+ PREFIX src/services/authentication.ts
315
+ --- UNUSED TYPES (4)
316
+ enum RegistrationServices src/components/Registration/registrationMachine.ts
317
+ type RegistrationAction src/components/Registration/registrationMachine.ts
318
+ type ComponentProps src/components/Registration.tsx
319
+ interface ProductDetail src/types/Product.ts
320
+ --- DUPLICATE EXPORTS (2)
321
+ Registration, default src/components/Registration.tsx
322
+ ProductsList, default src/components/Products.tsx
329
323
 
330
324
  #### Compact
331
325
 
332
326
  The compact reporter shows the sorted files first, and then a list of symbols:
333
327
 
334
- ```
335
- $ knip --reporter compact
336
- --- UNUSED FILES (2)
337
- src/chat/helpers.ts
338
- src/components/SideBar.tsx
339
- --- UNUSED DEPENDENCIES (1)
340
- moment
341
- --- UNLISTED DEPENDENCIES (1)
342
- react
343
- --- UNUSED EXPORTS (4)
344
- src/common/src/string/index.ts: lowercaseFirstLetter
345
- src/components/Registration.tsx: RegistrationBox
346
- src/css.ts: clamp
347
- src/services/authentication.ts: restoreSession, PREFIX
348
- --- UNUSED TYPES (3)
349
- src/components/Registration/registrationMachine.ts: RegistrationServices, RegistrationAction
350
- src/components/Registration.tsx: ComponentProps
351
- src/types/Product.ts: ProductDetail
352
- --- DUPLICATE EXPORTS (2)
353
- src/components/Registration.tsx: Registration, default
354
- src/components/Products.tsx: ProductsList, default
355
- ```
328
+ $ knip --reporter compact
329
+ --- UNUSED FILES (2)
330
+ src/chat/helpers.ts
331
+ src/components/SideBar.tsx
332
+ --- UNUSED DEPENDENCIES (1)
333
+ moment
334
+ --- UNLISTED DEPENDENCIES (1)
335
+ react
336
+ --- UNUSED EXPORTS (4)
337
+ src/common/src/string/index.ts: lowercaseFirstLetter
338
+ src/components/Registration.tsx: RegistrationBox
339
+ src/css.ts: clamp
340
+ src/services/authentication.ts: restoreSession, PREFIX
341
+ --- UNUSED TYPES (3)
342
+ src/components/Registration/registrationMachine.ts: RegistrationServices, RegistrationAction
343
+ src/components/Registration.tsx: ComponentProps
344
+ src/types/Product.ts: ProductDetail
345
+ --- DUPLICATE EXPORTS (2)
346
+ src/components/Registration.tsx: Registration, default
347
+ src/components/Products.tsx: ProductsList, default
356
348
 
357
349
  #### Code Owners
358
350
 
359
351
  The `codeowners` reporter is like `compact`, but shows the sorted code owners (according to `.github/CODEOWNERS`) first:
360
352
 
361
- ```
362
- $ knip --reporter codeowners
363
- --- UNUSED FILES (2)
364
- @org/team src/chat/helpers.ts
365
- @org/owner src/components/SideBar.tsx
366
- --- UNUSED DEPENDENCIES (1)
367
- @org/admin moment
368
- --- UNLISTED DEPENDENCIES (1)
369
- @org/owner src/components/Registration.tsx react
370
- --- UNUSED EXPORTS (4)
371
- @org/team src/common/src/string/index.ts: lowercaseFirstLetter
372
- @org/owner src/components/Registration.tsx: RegistrationBox
373
- @org/owner src/css.ts: clamp
374
- @org/owner src/services/authentication.ts: restoreSession, PREFIX
375
- --- UNUSED TYPES (3)
376
- @org/owner src/components/Registration/registrationMachine.ts: RegistrationServices, RegistrationAction
377
- @org/owner src/components/Registration.tsx: ComponentProps
378
- @org/owner src/types/Product.ts: ProductDetail
379
- --- DUPLICATE EXPORTS (2)
380
- @org/owner src/components/Registration.tsx: Registration, default
381
- @org/owner src/components/Products.tsx: ProductsList, default
382
- ```
353
+ $ knip --reporter codeowners
354
+ --- UNUSED FILES (2)
355
+ @org/team src/chat/helpers.ts
356
+ @org/owner src/components/SideBar.tsx
357
+ --- UNUSED DEPENDENCIES (1)
358
+ @org/admin moment
359
+ --- UNLISTED DEPENDENCIES (1)
360
+ @org/owner src/components/Registration.tsx react
361
+ --- UNUSED EXPORTS (4)
362
+ @org/team src/common/src/string/index.ts: lowercaseFirstLetter
363
+ @org/owner src/components/Registration.tsx: RegistrationBox
364
+ @org/owner src/css.ts: clamp
365
+ @org/owner src/services/authentication.ts: restoreSession, PREFIX
366
+ --- UNUSED TYPES (3)
367
+ @org/owner src/components/Registration/registrationMachine.ts: RegistrationServices, RegistrationAction
368
+ @org/owner src/components/Registration.tsx: ComponentProps
369
+ @org/owner src/types/Product.ts: ProductDetail
370
+ --- DUPLICATE EXPORTS (2)
371
+ @org/owner src/components/Registration.tsx: Registration, default
372
+ @org/owner src/components/Products.tsx: ProductsList, default
383
373
 
384
374
  The owner of `package.json` is considered the owner of unused (dev) dependencies.
385
375
 
@@ -397,26 +387,26 @@ collect the various issues in one go?
397
387
 
398
388
  This table is a work in progress, but here's a first impression. Based on their docs (please report any mistakes):
399
389
 
400
- | Feature | **knip** | [depcheck][1] | [unimported][2] | [ts-unused-exports][3] | [ts-prune][4] | [find-unused-exports][5] |
401
- | -------------------------------- | :------: | :-----------: | :-------------: | :--------------------: | :-----------: | :----------------------: |
402
- | Unused files | ✅ | - | ✅ | - | - | - |
403
- | Unused dependencies | ✅ | ✅ | ✅ | - | - | - |
404
- | Unlisted dependencies | ✅ | ✅ | ✅ | - | - | - |
405
- | [Custom dependency resolvers][7] | ❌ | ✅ | ❌ | - | - | - |
406
- | Unused exports | ✅ | - | - | ✅ | ✅ | ✅ |
407
- | Duplicate exports | ✅ | - | - | ❌ | ❌ | ❌ |
408
- | Search namespaces | ✅ | - | - | ✅ | ❌ | ❌ |
409
- | Custom reporters | ✅ | - | - | - | - | - |
410
- | Pure JavaScript/ESM | ✅ | ✅ | ✅ | - | - | ✅ |
411
- | Configure entry files | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ |
412
- | [Support monorepos][8] | 🟠 | - | - | - | - | - |
413
- | ESLint plugin available | - | - | - | ✅ | - | - |
390
+ | Feature | **knip** | [depcheck][7] | [unimported][8] | [ts-unused-exports][9] | [ts-prune][10] | [find-unused-exports][11] |
391
+ | --------------------------------- | :------: | :-----------: | :-------------: | :--------------------: | :------------: | :-----------------------: |
392
+ | Unused files | ✅ | - | ✅ | - | - | - |
393
+ | Unused dependencies | ✅ | ✅ | ✅ | - | - | - |
394
+ | Unlisted dependencies | ✅ | ✅ | ✅ | - | - | - |
395
+ | [Custom dependency resolvers][12] | ❌ | ✅ | ❌ | - | - | - |
396
+ | Unused exports | ✅ | - | - | ✅ | ✅ | ✅ |
397
+ | Duplicate exports | ✅ | - | - | ❌ | ❌ | ❌ |
398
+ | Search namespaces | ✅ | - | - | ✅ | ❌ | ❌ |
399
+ | Custom reporters | ✅ | - | - | - | - | - |
400
+ | Pure JavaScript/ESM | ✅ | ✅ | ✅ | - | - | ✅ |
401
+ | Configure entry files | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ |
402
+ | [Support monorepos][13] | 🟠 | - | - | - | - | - |
403
+ | ESLint plugin available | - | - | - | ✅ | - | - |
414
404
 
415
405
  ✅ = Supported, ❌ = Not supported, - = Out of scope
416
406
 
417
407
  ## Monorepos
418
408
 
419
- Knip wants to [support monorepos](#monorepos) properly, the first steps in this direction are implemented.
409
+ Knip wants to [support monorepos][14] properly, the first steps in this direction are implemented.
420
410
 
421
411
  ## Custom dependency resolvers
422
412
 
@@ -425,8 +415,7 @@ directory of a monorepo is nice for DX. But Knip will need some help to find it
425
415
  `eslint-plugin-cypress` _dependency_. Or see it is not listed in `package.json`. Or that the dependency is still listed,
426
416
  but no longer in use. Many popular projects reference plugins in similar ways, such as Babel, Webpack and Storybook.
427
417
 
428
- Big compliments to [depcheck](https://github.com/depcheck/depcheck#special) which already does this! They call this
429
- "specials". [Knip has this ambition][6], too.
418
+ Big compliments to [depcheck][15] which already does this! They call this "specials". [Knip has this ambition][16], too.
430
419
 
431
420
  unimported is strict in this regard and works based on production files and `dependencies`, so does not have custom
432
421
  dependency resolvers which are usually only needed for `devDependencies`.
@@ -434,19 +423,28 @@ dependency resolvers which are usually only needed for `devDependencies`.
434
423
  ## TypeScript language services
435
424
 
436
425
  TypeScript language services could play a major role in most of the "unused" areas, as they have an overview of the
437
- project as a whole. For instance, this powers the "Find references" feature in VS Code. I think features like "duplicate
438
- exports" or "custom dependency resolvers" are userland territory, much like code linters.
426
+ project as a whole. This powers things in VS Code like "Find references" or the "Module "./some" declares 'Thing'
427
+ locally, but it is not exported" message. I think features like "duplicate exports" or "custom dependency resolvers" are
428
+ userland territory, much like code linters.
439
429
 
440
430
  ## Knip?!
441
431
 
442
432
  Knip is Dutch for a "cut". A Dutch expression is "to be ge**knip**t for something", which means to be perfectly suited
443
433
  for the job. I'm motivated to make knip perfectly suited for the job of cutting projects to perfection! ✂️
444
434
 
445
- [1]: https://github.com/depcheck/depcheck
446
- [2]: https://github.com/smeijer/unimported
447
- [3]: https://github.com/pzavolinsky/ts-unused-exports
448
- [4]: https://github.com/nadeesha/ts-prune
449
- [5]: https://github.com/jaydenseric/find-unused-exports
450
- [6]: https://github.com/webpro/knip/issues/7
451
- [7]: #custom-dependency-resolvers
452
- [8]: #monorepos-1
435
+ [1]: #reporters
436
+ [2]: #custom-reporters
437
+ [3]: #why-yet-another-unused-filedependencyexport-finder
438
+ [4]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
439
+ [5]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
440
+ [6]: ./assets/how-it-works.drawio.svg
441
+ [7]: https://github.com/depcheck/depcheck
442
+ [8]: https://github.com/smeijer/unimported
443
+ [9]: https://github.com/pzavolinsky/ts-unused-exports
444
+ [10]: https://github.com/nadeesha/ts-prune
445
+ [11]: https://github.com/jaydenseric/find-unused-exports
446
+ [12]: #custom-dependency-resolvers
447
+ [13]: #monorepos-1
448
+ [14]: #monorepos
449
+ [15]: https://github.com/depcheck/depcheck#special
450
+ [16]: https://github.com/webpro/knip/issues/7
package/dist/help.js CHANGED
@@ -8,8 +8,8 @@ Options:
8
8
  -c/--config [file] Configuration file path (default: ./knip.json or package.json#knip)
9
9
  -t/--tsConfig [file] TypeScript configuration path (default: ./tsconfig.json)
10
10
  --dir Working directory (default: current working directory)
11
- --include Report only listed issue group(s) (see below)
12
- --exclude Exclude issue group(s) from report (see below)
11
+ --include Report only listed issue type(s) (see below)
12
+ --exclude Exclude issue type(s) from report (see below)
13
13
  --ignore Ignore files matching this glob pattern (can be set multiple times)
14
14
  --no-gitignore Don't use .gitignore
15
15
  --dev Include \`devDependencies\` in report(s)
@@ -21,7 +21,7 @@ Options:
21
21
  --debug Show debug output
22
22
  --debug-level Set verbosity of debug output (default: 1, max: 2)
23
23
 
24
- Issue groups: files, dependencies, unlisted, exports, nsExports, types, nsTypes, duplicates
24
+ Issue types: files, dependencies, unlisted, exports, nsExports, types, nsTypes, duplicates
25
25
 
26
26
  Examples:
27
27
 
@@ -9,7 +9,7 @@ const logArray = (collection) => console.log(node_util_1.default.inspect(collect
9
9
  const debugLogObject = (config, minimumLevel, name, obj) => {
10
10
  if (minimumLevel > config.debug.level)
11
11
  return;
12
- console.log(`[exportman] ${name}:`);
12
+ console.log(`[knip] ${name}:`);
13
13
  console.log(node_util_1.default.inspect(obj, { depth: null, colors: true }));
14
14
  };
15
15
  exports.debugLogObject = debugLogObject;
@@ -18,11 +18,11 @@ const debugLogFiles = (config, minimumLevel, name, filePaths) => {
18
18
  return;
19
19
  const { debug } = config;
20
20
  if (debug.level > 1) {
21
- console.debug(`[exportman] ${name} (${filePaths.length}):`);
21
+ console.debug(`[knip] ${name} (${filePaths.length}):`);
22
22
  logArray(filePaths);
23
23
  }
24
24
  else {
25
- console.debug(`[exportman] ${name} (${filePaths.length})`);
25
+ console.debug(`[knip] ${name} (${filePaths.length})`);
26
26
  }
27
27
  };
28
28
  exports.debugLogFiles = debugLogFiles;
@@ -31,11 +31,11 @@ const debugLogSourceFiles = (config, minimumLevel, name, sourceFiles) => {
31
31
  return;
32
32
  const { debug } = config;
33
33
  if (debug.level > 1) {
34
- console.debug(`[exportman] ${name} (${sourceFiles.length}):`);
34
+ console.debug(`[knip] ${name} (${sourceFiles.length}):`);
35
35
  logArray(sourceFiles.map(sourceFile => sourceFile.getFilePath()));
36
36
  }
37
37
  else {
38
- console.debug(`[exportman] ${name} (${sourceFiles.length})`);
38
+ console.debug(`[knip] ${name} (${sourceFiles.length})`);
39
39
  }
40
40
  };
41
41
  exports.debugLogSourceFiles = debugLogSourceFiles;
@@ -44,11 +44,11 @@ const debugLogDiff = (config, minimumLevel, name, arrA, arrB) => {
44
44
  return;
45
45
  const onlyInA = arrA.filter(itemA => !arrB.includes(itemA)).sort();
46
46
  const onlyInB = arrB.filter(itemB => !arrA.includes(itemB)).sort();
47
- console.log(`[exportman] ${name}`);
48
- console.log(`[exportman] Only in left:`);
47
+ console.log(`[knip] ${name}`);
48
+ console.log(`[knip] Only in left:`);
49
49
  logArray(onlyInA);
50
50
  console.log();
51
- console.log(`[exportman] Only in right:`);
51
+ console.log(`[knip] Only in right:`);
52
52
  logArray(onlyInB);
53
53
  };
54
54
  exports.debugLogDiff = debugLogDiff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript project",
5
5
  "keywords": [
6
6
  "find",