knip 0.13.2 → 0.13.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 +40 -35
- package/dist/types.d.ts +16 -16
- package/dist/util/debug.d.ts +1 -1
- package/dist/util/performance.d.ts +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -29,12 +29,14 @@ tools answers the question [why another unused file/dependency/export finder?][3
|
|
|
29
29
|
|
|
30
30
|
Knip is a fresh take on keeping your projects clean & tidy!
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
**NOTE:** See the [v1.0.0-alpha.0 "Atlantic" release][4] for a big milestone in the development of Knip.
|
|
33
|
+
|
|
34
|
+
[![An orange cow with scissors, Van Gogh style][6]][5] <sup>_“An orange cow with scissors, Van Gogh style” - generated
|
|
33
35
|
with OpenAI_</sup>
|
|
34
36
|
|
|
35
37
|
## Roadmap
|
|
36
38
|
|
|
37
|
-
Please report any false positives by [opening an issue in this repo][
|
|
39
|
+
Please report any false positives by [opening an issue in this repo][7]. Bonus points for adding a public repository or
|
|
38
40
|
opening a pull request with a directory and example files in `test/fixtures`. Correctness and bug fixes have priority
|
|
39
41
|
over new features:
|
|
40
42
|
|
|
@@ -43,7 +45,7 @@ over new features:
|
|
|
43
45
|
- [ ] Custom dependency resolvers: find dependencies used in npm scripts.
|
|
44
46
|
- [ ] Custom dependency resolvers: find unused and unlisted plugins for Webpack, ESLint & Babel, etc. (#7)
|
|
45
47
|
- [ ] Smart default configurations and more fine-grained configuration options.
|
|
46
|
-
- [ ] Full support for monorepos (partial [monorepos support][
|
|
48
|
+
- [ ] Full support for monorepos (partial [monorepos support][8] with `--dir` exists).
|
|
47
49
|
- [ ] Fix issues: remove `export` keyword, uninstall unused dependencies, delete files (like `--fix` of ESLint).
|
|
48
50
|
- [ ] Add more reporters and report customization options (#3).
|
|
49
51
|
|
|
@@ -82,7 +84,7 @@ Knip works by creating two sets of files:
|
|
|
82
84
|
3. The subset of project files that is not production code will be reported as unused files (in red).
|
|
83
85
|
4. Then the production code (in blue) will be analyzed for unused exports.
|
|
84
86
|
|
|
85
|
-
![How it works][
|
|
87
|
+
![How it works][9]
|
|
86
88
|
|
|
87
89
|
## Options
|
|
88
90
|
|
|
@@ -327,10 +329,10 @@ configuration can be tweaked further to the project structure.
|
|
|
327
329
|
|
|
328
330
|
Knip provides the following built-in reporters:
|
|
329
331
|
|
|
330
|
-
- [`json`][
|
|
331
|
-
- [`symbol`][
|
|
332
|
-
- [`compact`][
|
|
333
|
-
- [`codeowners`][
|
|
332
|
+
- [`json`][10]
|
|
333
|
+
- [`symbol`][11] (default)
|
|
334
|
+
- [`compact`][12]
|
|
335
|
+
- [`codeowners`][13]
|
|
334
336
|
|
|
335
337
|
### Custom Reporters
|
|
336
338
|
|
|
@@ -385,11 +387,11 @@ per file like this:
|
|
|
385
387
|
]
|
|
386
388
|
```
|
|
387
389
|
|
|
388
|
-
The keys match the [known issue types][
|
|
390
|
+
The keys match the [known issue types][14].
|
|
389
391
|
|
|
390
392
|
#### Usage Ideas
|
|
391
393
|
|
|
392
|
-
Use tools like [miller][
|
|
394
|
+
Use tools like [miller][15] or [jtbl][16] to consume the JSON and render a table in the terminal.
|
|
393
395
|
|
|
394
396
|
##### Table
|
|
395
397
|
|
|
@@ -506,12 +508,12 @@ collect the various issues in one go?
|
|
|
506
508
|
|
|
507
509
|
This table is a work in progress, but here's a first impression. Based on their docs (please report any mistakes):
|
|
508
510
|
|
|
509
|
-
| Feature | **knip** | [depcheck][
|
|
511
|
+
| Feature | **knip** | [depcheck][17] | [unimported][18] | [ts-unused-exports][19] | [ts-prune][20] | [find-unused-exports][21] |
|
|
510
512
|
| :-------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: | :-----------------------: |
|
|
511
513
|
| Unused files | ✅ | - | ✅ | - | - | - |
|
|
512
514
|
| Unused dependencies | ✅ | ✅ | ✅ | - | - | - |
|
|
513
515
|
| Unlisted dependencies | ✅ | ✅ | ✅ | - | - | - |
|
|
514
|
-
| [Custom dependency resolvers][
|
|
516
|
+
| [Custom dependency resolvers][22] | ❌ | ✅ | ❌ | - | - | - |
|
|
515
517
|
| Unused exports | ✅ | - | - | ✅ | ✅ | ✅ |
|
|
516
518
|
| Unused class members | ✅ | - | - | - | - | - |
|
|
517
519
|
| Unused enum members | ✅ | - | - | - | - | - |
|
|
@@ -520,11 +522,13 @@ This table is a work in progress, but here's a first impression. Based on their
|
|
|
520
522
|
| Custom reporters | ✅ | - | - | - | - | - |
|
|
521
523
|
| JavaScript support | ✅ | ✅ | ✅ | - | - | ✅ |
|
|
522
524
|
| Configure entry files | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
523
|
-
| [Support monorepos][
|
|
525
|
+
| [Support monorepos][23] | 🟠 | - | - | - | - | - |
|
|
524
526
|
| ESLint plugin available | - | - | - | ✅ | - | - |
|
|
525
527
|
|
|
526
528
|
✅ = Supported, ❌ = Not supported, - = Out of scope
|
|
527
529
|
|
|
530
|
+
**NOTE:** See the [v1.0.0-alpha.0 "Atlantic" release][6] for a big milestone in the development of Knip.
|
|
531
|
+
|
|
528
532
|
## Monorepos
|
|
529
533
|
|
|
530
534
|
Knip wants to [support monorepos][14] properly, the first steps in this direction are implemented.
|
|
@@ -536,7 +540,7 @@ directory of a monorepo is nice for DX. But Knip will need some help to find it
|
|
|
536
540
|
`eslint-plugin-cypress` dependency. Or see it is not listed in `package.json`. Or that the dependency is still listed,
|
|
537
541
|
but no longer in use. Many popular projects reference plugins in similar ways, such as Babel, Webpack and Storybook.
|
|
538
542
|
|
|
539
|
-
Big compliments to [depcheck][
|
|
543
|
+
Big compliments to [depcheck][24] which already does this! They call this "specials". This is on [Knip's roadmap][25],
|
|
540
544
|
as well, with the additional ambition to also find used dependencies that are not listed in `package.json`.
|
|
541
545
|
|
|
542
546
|
unimported is strict in this regard and works based on production files and `dependencies`, so does not have custom
|
|
@@ -557,24 +561,25 @@ for the job. I'm motivated to make knip perfectly suited for the job of cutting
|
|
|
557
561
|
[1]: #reporters
|
|
558
562
|
[2]: #custom-reporters
|
|
559
563
|
[3]: #really-another-unused-filedependencyexport-finder
|
|
560
|
-
[4]: https://
|
|
561
|
-
[5]:
|
|
562
|
-
[6]:
|
|
563
|
-
[7]:
|
|
564
|
-
[8]:
|
|
565
|
-
[9]:
|
|
566
|
-
[10]: #
|
|
567
|
-
[11]: #
|
|
568
|
-
[12]: #
|
|
569
|
-
[13]: #
|
|
570
|
-
[14]:
|
|
571
|
-
[15]: https://github.com/
|
|
572
|
-
[16]: https://github.com/
|
|
573
|
-
[17]: https://github.com/
|
|
574
|
-
[18]: https://github.com/
|
|
575
|
-
[19]: https://github.com/
|
|
576
|
-
[20]: https://github.com/
|
|
577
|
-
[21]:
|
|
578
|
-
[22]: #
|
|
579
|
-
[23]:
|
|
580
|
-
[24]: #
|
|
564
|
+
[4]: https://github.com/webpro/knip/releases
|
|
565
|
+
[5]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
|
|
566
|
+
[6]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
|
|
567
|
+
[7]: https://github.com/webpro/knip/issues
|
|
568
|
+
[8]: #monorepos
|
|
569
|
+
[9]: ./assets/how-it-works.drawio.svg
|
|
570
|
+
[10]: #json
|
|
571
|
+
[11]: #symbol-default
|
|
572
|
+
[12]: #compact
|
|
573
|
+
[13]: #code-owners
|
|
574
|
+
[14]: #reading-the-report
|
|
575
|
+
[15]: https://github.com/johnkerl/miller
|
|
576
|
+
[16]: https://github.com/kellyjonbrazil/jtbl
|
|
577
|
+
[17]: https://github.com/depcheck/depcheck
|
|
578
|
+
[18]: https://github.com/smeijer/unimported
|
|
579
|
+
[19]: https://github.com/pzavolinsky/ts-unused-exports
|
|
580
|
+
[20]: https://github.com/nadeesha/ts-prune
|
|
581
|
+
[21]: https://github.com/jaydenseric/find-unused-exports
|
|
582
|
+
[22]: #custom-dependency-resolvers
|
|
583
|
+
[23]: #monorepos-1
|
|
584
|
+
[24]: https://github.com/depcheck/depcheck#special
|
|
585
|
+
[25]: #roadmap
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { SourceFile } from 'ts-morph';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type SymbolType = 'type' | 'interface' | 'enum';
|
|
3
|
+
export type Issue = {
|
|
4
4
|
filePath: string;
|
|
5
5
|
symbol: string;
|
|
6
6
|
symbols?: string[];
|
|
7
7
|
symbolType?: SymbolType;
|
|
8
8
|
parentSymbol?: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
10
|
+
export type IssueSet = Set<string>;
|
|
11
|
+
export type IssueRecords = Record<string, Record<string, Issue>>;
|
|
12
|
+
export type Issues = {
|
|
13
13
|
files: IssueSet;
|
|
14
14
|
dependencies: IssueRecords;
|
|
15
15
|
devDependencies: IssueRecords;
|
|
@@ -22,22 +22,22 @@ export declare type Issues = {
|
|
|
22
22
|
enumMembers: IssueRecords;
|
|
23
23
|
classMembers: IssueRecords;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
25
|
+
export type IssueType = keyof Issues;
|
|
26
|
+
export type SymbolIssueType = Exclude<IssueType, 'files'>;
|
|
27
|
+
export type Report = {
|
|
28
28
|
[key in keyof Issues]: boolean;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
type BaseLocalConfiguration = {
|
|
31
31
|
entryFiles: string[];
|
|
32
32
|
projectFiles: string[];
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type LocalConfiguration = BaseLocalConfiguration & {
|
|
35
35
|
dev?: boolean | BaseLocalConfiguration;
|
|
36
36
|
include?: string[];
|
|
37
37
|
exclude?: string[];
|
|
38
38
|
};
|
|
39
|
-
export
|
|
40
|
-
export
|
|
39
|
+
export type ImportedConfiguration = LocalConfiguration | Record<string, LocalConfiguration>;
|
|
40
|
+
export type UnresolvedConfiguration = {
|
|
41
41
|
cwd: string;
|
|
42
42
|
workingDir: string;
|
|
43
43
|
configFilePath?: string;
|
|
@@ -54,7 +54,7 @@ export declare type UnresolvedConfiguration = {
|
|
|
54
54
|
level: number;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type Configuration = {
|
|
58
58
|
workingDir: string;
|
|
59
59
|
report: Report;
|
|
60
60
|
projectFiles: SourceFile[];
|
|
@@ -74,8 +74,8 @@ export declare type Configuration = {
|
|
|
74
74
|
level: number;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
export
|
|
78
|
-
export
|
|
77
|
+
export type Counters = Record<IssueType | 'processed' | 'total', number>;
|
|
78
|
+
export type ReporterOptions = {
|
|
79
79
|
report: Report;
|
|
80
80
|
issues: Issues;
|
|
81
81
|
cwd: string;
|
|
@@ -83,5 +83,5 @@ export declare type ReporterOptions = {
|
|
|
83
83
|
isDev: boolean;
|
|
84
84
|
options: string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
86
|
+
export type Reporter = (options: ReporterOptions) => void;
|
|
87
87
|
export {};
|
package/dist/util/debug.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { PerformanceObserver, PerformanceEntry } from 'node:perf_hooks';
|
|
3
3
|
import EasyTable from 'easy-table';
|
|
4
4
|
import type { TimerifyOptions } from 'node:perf_hooks';
|
|
5
|
-
|
|
5
|
+
type Timerify = <T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions) => T;
|
|
6
6
|
export declare const timerify: Timerify;
|
|
7
7
|
declare class Performance {
|
|
8
8
|
enabled: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"find",
|
|
@@ -42,27 +42,27 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "ISC",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@snyk/github-codeowners": "1.
|
|
45
|
+
"@snyk/github-codeowners": "1.1.0",
|
|
46
46
|
"easy-table": "1.2.0",
|
|
47
|
-
"esbuild": "0.15.
|
|
48
|
-
"esbuild-register": "3.
|
|
47
|
+
"esbuild": "0.15.18",
|
|
48
|
+
"esbuild-register": "3.4.1",
|
|
49
49
|
"globby": "13.1.2",
|
|
50
50
|
"micromatch": "4.0.5",
|
|
51
51
|
"summary": "2.1.0",
|
|
52
|
-
"ts-morph": "
|
|
53
|
-
"ts-morph-helpers": "0.6.
|
|
52
|
+
"ts-morph": "17.0.1",
|
|
53
|
+
"ts-morph-helpers": "0.6.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/micromatch": "4.0.2",
|
|
57
|
-
"@types/node": "18.11.
|
|
57
|
+
"@types/node": "18.11.11",
|
|
58
58
|
"globstar": "1.0.0",
|
|
59
|
-
"prettier": "2.
|
|
60
|
-
"release-it": "15.5.
|
|
59
|
+
"prettier": "2.8.0",
|
|
60
|
+
"release-it": "15.5.1",
|
|
61
61
|
"remark-cli": "11.0.0",
|
|
62
62
|
"remark-preset-webpro": "0.0.1",
|
|
63
|
-
"tsx": "3.
|
|
64
|
-
"type-fest": "3.
|
|
65
|
-
"typescript": "4.
|
|
63
|
+
"tsx": "3.12.1",
|
|
64
|
+
"type-fest": "3.3.0",
|
|
65
|
+
"typescript": "4.9.3"
|
|
66
66
|
},
|
|
67
67
|
"release-it": {
|
|
68
68
|
"github": {
|