knip 2.22.0 → 2.24.0
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 +147 -133
- package/dist/plugins/lefthook/index.js +4 -3
- package/dist/plugins/release-it/index.js +6 -0
- package/dist/plugins/release-it/types.d.ts +6 -0
- package/dist/plugins/vite/index.d.ts +3 -2
- package/dist/plugins/vite/index.js +9 -2
- package/dist/plugins/vite/types.d.ts +4 -0
- package/dist/plugins/vite/types.js +1 -0
- package/dist/plugins/vitest/index.d.ts +3 -1
- package/dist/plugins/vitest/index.js +6 -3
- package/dist/plugins/vitest/types.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -25,54 +25,56 @@ The dots don't connect themselves. This is where Knip comes in:
|
|
|
25
25
|
- [x] Finds duplicate exports
|
|
26
26
|
- [x] Supports any combination of JavaScript and TypeScript
|
|
27
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
29
|
- [x] Run Knip as part of your CI environment to detect issues and prevent regressions
|
|
29
30
|
|
|
30
31
|
Knip shines in both small and large projects. It's a fresh take on keeping your projects clean & tidy!
|
|
31
32
|
|
|
32
|
-
[![An orange cow with scissors, Van Gogh style][
|
|
33
|
+
[![An orange cow with scissors, Van Gogh style][9]][8] <sup>_“An orange cow with scissors, Van Gogh style” - generated
|
|
33
34
|
with OpenAI_</sup>
|
|
34
35
|
|
|
35
|
-
For updates or questions, come hang out in [The Knip Barn (Discord)][
|
|
36
|
-
[@webpro (fosstodon.org)][
|
|
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
38
|
|
|
38
39
|
## Contents
|
|
39
40
|
|
|
40
|
-
- [Getting Started][
|
|
41
|
-
- [Installation][
|
|
42
|
-
- [Default Configuration][
|
|
43
|
-
- [Let's Go!][
|
|
44
|
-
- [Configuration][
|
|
45
|
-
- [Entry Files][
|
|
41
|
+
- [Getting Started][14]
|
|
42
|
+
- [Installation][15]
|
|
43
|
+
- [Default Configuration][16]
|
|
44
|
+
- [Let's Go!][17]
|
|
45
|
+
- [Configuration][18]
|
|
46
|
+
- [Entry Files][19]
|
|
46
47
|
- [Workspaces][1]
|
|
47
48
|
- [Plugins][2]
|
|
48
49
|
- [Compilers][3]
|
|
49
|
-
- [Ignore files, binaries, dependencies and workspaces][
|
|
50
|
-
- [Public exports][
|
|
51
|
-
- [Ignore exports used in file][
|
|
52
|
-
- [Include exports in entry files][
|
|
53
|
-
- [Paths][
|
|
54
|
-
- [Production Mode][
|
|
55
|
-
- [Strict][
|
|
56
|
-
- [Ignore `@internal` exports][
|
|
57
|
-
- [Plugins][
|
|
58
|
-
- [Output][
|
|
59
|
-
- [Screenshots][
|
|
60
|
-
- [Reading the report][
|
|
61
|
-
- [Rules & Filters][
|
|
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]
|
|
56
|
+
- [Strict][26]
|
|
57
|
+
- [Ignore `@internal` exports][27]
|
|
58
|
+
- [Plugins][28]
|
|
59
|
+
- [Output][29]
|
|
60
|
+
- [Screenshots][30]
|
|
61
|
+
- [Reading the report][31]
|
|
62
|
+
- [Rules & Filters][32]
|
|
62
63
|
- [Reporters][4]
|
|
63
|
-
- [Fixing Issues][
|
|
64
|
-
- [
|
|
65
|
-
- [
|
|
66
|
-
- [
|
|
67
|
-
|
|
68
|
-
- [
|
|
69
|
-
- [
|
|
70
|
-
- [ts-
|
|
71
|
-
- [
|
|
72
|
-
- [
|
|
73
|
-
- [
|
|
74
|
-
- [
|
|
75
|
-
- [
|
|
64
|
+
- [Fixing Issues][33]
|
|
65
|
+
- [JSDoc tags][7]
|
|
66
|
+
- [Command Line Options][34]
|
|
67
|
+
- [Potential boost with `--no-gitignore`][35]
|
|
68
|
+
- [Comparison & Migration][36]
|
|
69
|
+
- [depcheck][37]
|
|
70
|
+
- [unimported][38]
|
|
71
|
+
- [ts-unused-exports][39]
|
|
72
|
+
- [ts-prune][40]
|
|
73
|
+
- [Projects using Knip][41]
|
|
74
|
+
- [Articles, etc.][42]
|
|
75
|
+
- [Why "Knip"?][43]
|
|
76
|
+
- [Really, another unused file/dependency/export finder?][44]
|
|
77
|
+
- [Contributors][45]
|
|
76
78
|
|
|
77
79
|
## Getting Started
|
|
78
80
|
|
|
@@ -93,7 +95,7 @@ Knip has good defaults and you can run it without any configuration. The (simpli
|
|
|
93
95
|
}
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
There's more, jump to [Entry Files][
|
|
98
|
+
There's more, jump to [Entry Files][19] for details.
|
|
97
99
|
|
|
98
100
|
Places where Knip looks for configuration (ordered by priority):
|
|
99
101
|
|
|
@@ -135,7 +137,7 @@ Run the checks with `npx knip`. Or first add this script to `package.json`:
|
|
|
135
137
|
Then use `npm run knip` to analyze the project and output unused files, dependencies and exports. Knip works just fine
|
|
136
138
|
with `yarn` or `pnpm` as well.
|
|
137
139
|
|
|
138
|
-
See [Command Line Options][
|
|
140
|
+
See [Command Line Options][34] for an overview of available CLI options.
|
|
139
141
|
|
|
140
142
|
## Configuration
|
|
141
143
|
|
|
@@ -198,7 +200,7 @@ Here's an example `knip.json` configuration with some custom `entry` and `projec
|
|
|
198
200
|
```
|
|
199
201
|
|
|
200
202
|
It might be useful to run Knip first with no or little configuration to see where it needs custom `entry` and/or
|
|
201
|
-
`project` files. Each workspace has the same [default configuration][
|
|
203
|
+
`project` files. Each workspace has the same [default configuration][18].
|
|
202
204
|
|
|
203
205
|
The root workspace is named `"."` under `workspaces` (like in the example).
|
|
204
206
|
|
|
@@ -321,7 +323,7 @@ has them at `e2e-tests/*.spec.ts`. Here's how to configure this:
|
|
|
321
323
|
#### Multi-project repositories
|
|
322
324
|
|
|
323
325
|
Some repositories have a single `package.json`, but consist of multiple projects with configuration files across the
|
|
324
|
-
repository (such as the [Nx "intregrated repo" style][
|
|
326
|
+
repository (such as the [Nx "intregrated repo" style][46]). Let's assume some of these projects are apps and have their
|
|
325
327
|
own Cypress configuration and test files. In that case, we could configure the Cypress plugin like this:
|
|
326
328
|
|
|
327
329
|
```json
|
|
@@ -338,7 +340,7 @@ In case a plugin causes issues, it can be disabled by using `false` as its value
|
|
|
338
340
|
|
|
339
341
|
#### Create a new plugin
|
|
340
342
|
|
|
341
|
-
Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][
|
|
343
|
+
Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][47]. This
|
|
342
344
|
guide also contains more details if you want to learn more about plugins and why they are useful.
|
|
343
345
|
|
|
344
346
|
### Compilers
|
|
@@ -361,7 +363,7 @@ export default {
|
|
|
361
363
|
};
|
|
362
364
|
```
|
|
363
365
|
|
|
364
|
-
Read [Compilers][
|
|
366
|
+
Read [Compilers][48] for more details and examples.
|
|
365
367
|
|
|
366
368
|
### Ignore files, binaries, dependencies and workspaces
|
|
367
369
|
|
|
@@ -528,7 +530,7 @@ The report contains the following types of issues:
|
|
|
528
530
|
|
|
529
531
|
When an issue type has zero issues, it is not shown.
|
|
530
532
|
|
|
531
|
-
Getting too many reported issues and false positives? Read more about [handling issues][
|
|
533
|
+
Getting too many reported issues and false positives? Read more about [handling issues][49].
|
|
532
534
|
|
|
533
535
|
### Rules & Filters
|
|
534
536
|
|
|
@@ -555,7 +557,7 @@ Example:
|
|
|
555
557
|
}
|
|
556
558
|
```
|
|
557
559
|
|
|
558
|
-
See [reading the report][
|
|
560
|
+
See [reading the report][31] for the list of issue types.
|
|
559
561
|
|
|
560
562
|
The rules are modeled after the ESLint `rules` configuration, and could be extended in the future. For instance, to
|
|
561
563
|
apply filters or configurations only to a specific issue type.
|
|
@@ -576,7 +578,7 @@ Use `--exclude` to ignore reports you're not interested in:
|
|
|
576
578
|
|
|
577
579
|
Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.
|
|
578
580
|
|
|
579
|
-
See [reading the report][
|
|
581
|
+
See [reading the report][31] for the list of issue types.
|
|
580
582
|
|
|
581
583
|
#### When to use rules or filters
|
|
582
584
|
|
|
@@ -600,13 +602,13 @@ Knip provides the following built-in reporters:
|
|
|
600
602
|
|
|
601
603
|
When the provided built-in reporters are not sufficient, a custom reporter can be implemented.
|
|
602
604
|
|
|
603
|
-
Find more details in [reporters and preprocessors][
|
|
605
|
+
Find more details in [reporters and preprocessors][50].
|
|
604
606
|
|
|
605
607
|
#### Preprocessers
|
|
606
608
|
|
|
607
609
|
Use preprocessers to modify the results before they're passed to the reporter(s).
|
|
608
610
|
|
|
609
|
-
Find more details in [reporters and preprocessors][
|
|
611
|
+
Find more details in [reporters and preprocessors][50].
|
|
610
612
|
|
|
611
613
|
## Fixing Issues
|
|
612
614
|
|
|
@@ -624,9 +626,20 @@ Tip: back up files or use an VCS like Git before deleting files or making change
|
|
|
624
626
|
|
|
625
627
|
Repeat the process to reveal new unused files and exports. It's so liberating to remove unused things!
|
|
626
628
|
|
|
627
|
-
Getting too many reported issues and false positives? Read more about [handling issues][
|
|
629
|
+
Getting too many reported issues and false positives? Read more about [handling issues][49] describing potential causes
|
|
628
630
|
for false positives, and how to handle them.
|
|
629
631
|
|
|
632
|
+
## JSDoc tags
|
|
633
|
+
|
|
634
|
+
Knip takes the following JSDoc/TSDoc tags into account:
|
|
635
|
+
|
|
636
|
+
| Tag | Description |
|
|
637
|
+
| :---------- | :------------------------------------------------------ |
|
|
638
|
+
| `@public` | Do not report this unused export, type or member |
|
|
639
|
+
| `@beta` | ^^ Idem |
|
|
640
|
+
| `@internal` | Do not report this unused export in `--production` mode |
|
|
641
|
+
| `@alias` | Do not report this duplicate export |
|
|
642
|
+
|
|
630
643
|
## Command Line Options
|
|
631
644
|
|
|
632
645
|
$ npx knip --help
|
|
@@ -675,13 +688,13 @@ for false positives, and how to handle them.
|
|
|
675
688
|
|
|
676
689
|
## Potential boost with `--no-gitignore`
|
|
677
690
|
|
|
678
|
-
To increase performance in a large monorepo, check out [Potential boost with `--no-gitignore`][
|
|
691
|
+
To increase performance in a large monorepo, check out [Potential boost with `--no-gitignore`][51].
|
|
679
692
|
|
|
680
693
|
## Comparison & Migration
|
|
681
694
|
|
|
682
695
|
This table is an ongoing comparison. Based on their docs (please report any mistakes):
|
|
683
696
|
|
|
684
|
-
| Feature | **knip** | [depcheck][
|
|
697
|
+
| Feature | **knip** | [depcheck][52] | [unimported][53] | [ts-unused-exports][54] | [ts-prune][55] |
|
|
685
698
|
| :---------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
|
|
686
699
|
| Unused files | ✅ | - | ✅ | - | - |
|
|
687
700
|
| Unused dependencies | ✅ | ✅ | ✅ | - | - |
|
|
@@ -717,7 +730,7 @@ The following commands are similar:
|
|
|
717
730
|
unimported
|
|
718
731
|
knip --production --dependencies --include files
|
|
719
732
|
|
|
720
|
-
Also see [production mode][
|
|
733
|
+
Also see [production mode][25].
|
|
721
734
|
|
|
722
735
|
### ts-unused-exports
|
|
723
736
|
|
|
@@ -739,25 +752,25 @@ The following commands are similar:
|
|
|
739
752
|
|
|
740
753
|
Many thanks to some of the early adopters of Knip:
|
|
741
754
|
|
|
742
|
-
- [Block Protocol][
|
|
743
|
-
- [DeepmergeTS][
|
|
744
|
-
- [eslint-plugin-functional][
|
|
745
|
-
- [freeCodeCamp.org][
|
|
746
|
-
- [is-immutable-type][
|
|
747
|
-
- [IsaacScript][
|
|
748
|
-
- [Nuxt][
|
|
749
|
-
- [Owncast][
|
|
750
|
-
- [release-it][
|
|
751
|
-
- [Template TypeScript Node Package][
|
|
752
|
-
- [Tipi][
|
|
755
|
+
- [Block Protocol][56]
|
|
756
|
+
- [DeepmergeTS][57]
|
|
757
|
+
- [eslint-plugin-functional][58]
|
|
758
|
+
- [freeCodeCamp.org][59]
|
|
759
|
+
- [is-immutable-type][60]
|
|
760
|
+
- [IsaacScript][61]
|
|
761
|
+
- [Nuxt][62]
|
|
762
|
+
- [Owncast][63]
|
|
763
|
+
- [release-it][64]
|
|
764
|
+
- [Template TypeScript Node Package][65]
|
|
765
|
+
- [Tipi][66]
|
|
753
766
|
|
|
754
767
|
## Articles, etc.
|
|
755
768
|
|
|
756
|
-
- Discord: hang out in [The Knip Barn][
|
|
757
|
-
- Ask your questions in the [Knip knowledge base][
|
|
758
|
-
- Smashing Magazine: [Knip: An Automated Tool For Finding Unused Files, Exports, And Dependencies][
|
|
759
|
-
- Effective TypeScript: [Recommendation Update: ✂️ Use knip to detect dead code and types][
|
|
760
|
-
- Josh Goldberg: [Speeding Up Centered Part 4: Unused Code Bloat][
|
|
769
|
+
- Discord: hang out in [The Knip Barn][10]
|
|
770
|
+
- Ask your questions in the [Knip knowledge base][67] (powered by OpenAI and [7-docs][68], experimental!)
|
|
771
|
+
- Smashing Magazine: [Knip: An Automated Tool For Finding Unused Files, Exports, And Dependencies][69]
|
|
772
|
+
- Effective TypeScript: [Recommendation Update: ✂️ Use knip to detect dead code and types][70]
|
|
773
|
+
- Josh Goldberg: [Speeding Up Centered Part 4: Unused Code Bloat][71]
|
|
761
774
|
|
|
762
775
|
## Why "Knip"?
|
|
763
776
|
|
|
@@ -775,7 +788,7 @@ each file, and traversing all of this, why not collect the various issues in one
|
|
|
775
788
|
|
|
776
789
|
Special thanks to the wonderful people who have contributed to this project:
|
|
777
790
|
|
|
778
|
-
[![Contributors][
|
|
791
|
+
[![Contributors][73]][72]
|
|
779
792
|
|
|
780
793
|
[1]: #workspaces
|
|
781
794
|
[2]: #plugins
|
|
@@ -783,72 +796,73 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
783
796
|
[4]: #reporters
|
|
784
797
|
[5]: #custom-reporters
|
|
785
798
|
[6]: #preprocessers
|
|
786
|
-
[7]:
|
|
787
|
-
[8]:
|
|
788
|
-
[9]:
|
|
789
|
-
[10]: https://
|
|
790
|
-
[11]: https://
|
|
791
|
-
[12]: https://
|
|
792
|
-
[13]:
|
|
793
|
-
[14]: #
|
|
794
|
-
[15]: #
|
|
795
|
-
[16]: #
|
|
796
|
-
[17]: #
|
|
797
|
-
[18]: #
|
|
798
|
-
[19]: #
|
|
799
|
-
[20]: #
|
|
800
|
-
[21]: #
|
|
801
|
-
[22]: #
|
|
802
|
-
[23]: #
|
|
803
|
-
[24]: #
|
|
804
|
-
[25]: #
|
|
805
|
-
[26]: #
|
|
806
|
-
[27]: #
|
|
807
|
-
[28]: #
|
|
808
|
-
[29]: #
|
|
809
|
-
[30]: #
|
|
810
|
-
[31]: #
|
|
811
|
-
[32]: #
|
|
812
|
-
[33]: #
|
|
813
|
-
[34]: #
|
|
814
|
-
[35]: #
|
|
815
|
-
[36]: #
|
|
816
|
-
[37]: #
|
|
817
|
-
[38]: #
|
|
818
|
-
[39]: #ts-
|
|
819
|
-
[40]: #
|
|
820
|
-
[41]: #
|
|
821
|
-
[42]: #
|
|
822
|
-
[43]: #
|
|
823
|
-
[44]: #
|
|
824
|
-
[45]:
|
|
825
|
-
[46]:
|
|
826
|
-
[47]: ./docs/
|
|
827
|
-
[48]: ./docs/
|
|
828
|
-
[49]: ./docs/
|
|
829
|
-
[50]: ./docs/
|
|
830
|
-
[51]:
|
|
831
|
-
[52]: https://github.com/
|
|
832
|
-
[53]: https://github.com/
|
|
833
|
-
[54]: https://github.com/
|
|
834
|
-
[55]: https://github.com/
|
|
835
|
-
[56]: https://github.com/
|
|
836
|
-
[57]: https://github.com/
|
|
837
|
-
[58]: https://github.com/
|
|
838
|
-
[59]: https://github.com/
|
|
839
|
-
[60]: https://github.com/
|
|
840
|
-
[61]: https://github.com/
|
|
841
|
-
[62]: https://github.com/
|
|
842
|
-
[63]: https://github.com/
|
|
843
|
-
[64]: https://github.com/
|
|
844
|
-
[65]: https://github.com/
|
|
845
|
-
[66]: https://
|
|
846
|
-
[67]: https://
|
|
847
|
-
[68]: https://
|
|
848
|
-
[69]: https://
|
|
849
|
-
[70]: https://
|
|
850
|
-
[71]: https://
|
|
851
|
-
[72]: https://
|
|
799
|
+
[7]: #jsdoc-tags
|
|
800
|
+
[8]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
|
|
801
|
+
[9]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
|
|
802
|
+
[10]: https://discord.gg/ya5yktTq
|
|
803
|
+
[11]: https://twitter.com/webprolific
|
|
804
|
+
[12]: https://fosstodon.org/@webpro
|
|
805
|
+
[13]: https://github.com/webpro/knip/issues
|
|
806
|
+
[14]: #getting-started
|
|
807
|
+
[15]: #installation
|
|
808
|
+
[16]: #default-configuration
|
|
809
|
+
[17]: #lets-go
|
|
810
|
+
[18]: #configuration
|
|
811
|
+
[19]: #entry-files
|
|
812
|
+
[20]: #ignore-files-binaries-dependencies-and-workspaces
|
|
813
|
+
[21]: #public-exports
|
|
814
|
+
[22]: #ignore-exports-used-in-file
|
|
815
|
+
[23]: #include-exports-in-entry-files
|
|
816
|
+
[24]: #paths
|
|
817
|
+
[25]: #production-mode
|
|
818
|
+
[26]: #strict
|
|
819
|
+
[27]: #ignore-internal-exports
|
|
820
|
+
[28]: #plugins-1
|
|
821
|
+
[29]: #output
|
|
822
|
+
[30]: #screenshots
|
|
823
|
+
[31]: #reading-the-report
|
|
824
|
+
[32]: #rules--filters
|
|
825
|
+
[33]: #fixing-issues
|
|
826
|
+
[34]: #command-line-options
|
|
827
|
+
[35]: #potential-boost-with---no-gitignore
|
|
828
|
+
[36]: #comparison--migration
|
|
829
|
+
[37]: #depcheck
|
|
830
|
+
[38]: #unimported
|
|
831
|
+
[39]: #ts-unused-exports
|
|
832
|
+
[40]: #ts-prune
|
|
833
|
+
[41]: #projects-using-knip
|
|
834
|
+
[42]: #articles-etc
|
|
835
|
+
[43]: #why-knip
|
|
836
|
+
[44]: #really-another-unused-filedependencyexport-finder
|
|
837
|
+
[45]: #contributors
|
|
838
|
+
[46]: https://nx.dev/concepts/integrated-vs-package-based
|
|
839
|
+
[47]: ./docs/writing-a-plugin.md
|
|
840
|
+
[48]: ./docs/compilers.md
|
|
841
|
+
[49]: ./docs/handling-issues.md
|
|
842
|
+
[50]: ./docs/reporters-and-preprocessors.md
|
|
843
|
+
[51]: ./docs/perf-boost-with-no-gitignore.md
|
|
844
|
+
[52]: https://github.com/depcheck/depcheck
|
|
845
|
+
[53]: https://github.com/smeijer/unimported
|
|
846
|
+
[54]: https://github.com/pzavolinsky/ts-unused-exports
|
|
847
|
+
[55]: https://github.com/nadeesha/ts-prune
|
|
848
|
+
[56]: https://github.com/blockprotocol/blockprotocol
|
|
849
|
+
[57]: https://github.com/RebeccaStevens/deepmerge-ts
|
|
850
|
+
[58]: https://github.com/eslint-functional/eslint-plugin-functional
|
|
851
|
+
[59]: https://github.com/freeCodeCamp/freeCodeCamp
|
|
852
|
+
[60]: https://github.com/RebeccaStevens/is-immutable-type
|
|
853
|
+
[61]: https://github.com/IsaacScript/isaacscript
|
|
854
|
+
[62]: https://github.com/nuxt/nuxt
|
|
855
|
+
[63]: https://github.com/owncast/owncast
|
|
856
|
+
[64]: https://github.com/release-it/release-it
|
|
857
|
+
[65]: https://github.com/JoshuaKGoldberg/template-typescript-node-package
|
|
858
|
+
[66]: https://github.com/meienberger/runtipi
|
|
859
|
+
[67]: https://knip.deno.dev
|
|
860
|
+
[68]: https://github.com/7-docs/7-docs
|
|
861
|
+
[69]: https://www.smashingmagazine.com/2023/08/knip-automated-tool-find-unused-files-exports-dependencies/
|
|
862
|
+
[70]: https://effectivetypescript.com/2023/07/29/knip/
|
|
863
|
+
[71]: https://www.joshuakgoldberg.com/blog/speeding-up-centered-part-4-unused-code-bloat/
|
|
864
|
+
[72]: https://github.com/webpro/knip/graphs/contributors
|
|
865
|
+
[73]: https://contrib.rocks/image?repo=webpro/knip
|
|
852
866
|
[plugin-ava]: ./src/plugins/ava
|
|
853
867
|
[plugin-babel]: ./src/plugins/babel
|
|
854
868
|
[plugin-capacitor]: ./src/plugins/capacitor
|
|
@@ -6,21 +6,22 @@ import { getValuesByKeyDeep } from '../../util/object.js';
|
|
|
6
6
|
import { timerify } from '../../util/Performance.js';
|
|
7
7
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
8
8
|
export const NAME = 'Lefthook';
|
|
9
|
-
export const ENABLERS = ['lefthook', '@arkweid/lefthook'];
|
|
9
|
+
export const ENABLERS = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthook'];
|
|
10
10
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
11
11
|
const gitHookPaths = getGitHookPaths();
|
|
12
12
|
export const CONFIG_FILE_PATTERNS = ['lefthook.yml', ...gitHookPaths];
|
|
13
13
|
const findLefthookDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
14
|
+
const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
|
|
14
15
|
if (configFilePath.endsWith('.yml')) {
|
|
15
16
|
const config = await load(configFilePath);
|
|
16
17
|
if (!config)
|
|
17
18
|
return [];
|
|
18
19
|
const scripts = getValuesByKeyDeep(config, 'run').filter((value) => typeof value === 'string');
|
|
19
|
-
|
|
20
|
+
const lefthook = process.env.CI ? ENABLERS.filter(dependency => dependencies.includes(dependency)) : [];
|
|
21
|
+
return [...lefthook, ..._getDependenciesFromScripts(scripts, { cwd, manifest, knownGlobalsOnly: true })];
|
|
20
22
|
}
|
|
21
23
|
const script = readFileSync(configFilePath, 'utf8');
|
|
22
24
|
const scriptDependencies = _getDependenciesFromScripts([script], { cwd, manifest, knownGlobalsOnly: false });
|
|
23
|
-
const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
|
|
24
25
|
const matches = scriptDependencies.find(dep => dependencies.includes(fromBinary(dep)));
|
|
25
26
|
return matches ? [matches] : [];
|
|
26
27
|
};
|
|
@@ -18,6 +18,12 @@ const findReleaseItDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
|
18
18
|
return [];
|
|
19
19
|
const plugins = config.plugins ? Object.keys(config.plugins) : [];
|
|
20
20
|
const scripts = config.hooks ? Object.values(config.hooks).flat() : [];
|
|
21
|
+
if (typeof config.github?.releaseNotes === 'string') {
|
|
22
|
+
scripts.push(config.github.releaseNotes);
|
|
23
|
+
}
|
|
24
|
+
if (typeof config.gitlab?.releaseNotes === 'string') {
|
|
25
|
+
scripts.push(config.gitlab.releaseNotes);
|
|
26
|
+
}
|
|
21
27
|
const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
|
|
22
28
|
return [...plugins, ...dependencies];
|
|
23
29
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Vite";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { timerify } from '../../util/Performance.js';
|
|
2
|
+
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { findVitestDeps } from '../vitest/index.js';
|
|
2
4
|
export const NAME = 'Vite';
|
|
3
5
|
export const ENABLERS = ['vite'];
|
|
4
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
5
|
-
export const
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = ['vite.config.{js,ts}'];
|
|
8
|
+
const findViteDependencies = async (configFilePath) => {
|
|
9
|
+
const config = await load(configFilePath);
|
|
10
|
+
return findVitestDeps(config);
|
|
11
|
+
};
|
|
12
|
+
export const findDependencies = timerify(findViteDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { VitestConfig } from './types.js';
|
|
1
2
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
3
|
export declare const NAME = "Vitest";
|
|
3
4
|
export declare const ENABLERS: string[];
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
-
export declare const ENTRY_FILE_PATTERNS:
|
|
7
|
+
export declare const ENTRY_FILE_PATTERNS: never[];
|
|
8
|
+
export declare const findVitestDeps: (config: VitestConfig) => any[];
|
|
7
9
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -6,9 +6,8 @@ export const NAME = 'Vitest';
|
|
|
6
6
|
export const ENABLERS = ['vitest'];
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
8
|
export const CONFIG_FILE_PATTERNS = ['vitest.config.ts'];
|
|
9
|
-
export const ENTRY_FILE_PATTERNS = [
|
|
10
|
-
const
|
|
11
|
-
const config = await load(configFilePath);
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = [];
|
|
10
|
+
export const findVitestDeps = (config) => {
|
|
12
11
|
if (!config || !config.test)
|
|
13
12
|
return [];
|
|
14
13
|
const cfg = config.test;
|
|
@@ -19,4 +18,8 @@ const findVitestDependencies = async (configFilePath) => {
|
|
|
19
18
|
const globalSetup = cfg.globalSetup ? [cfg.globalSetup].flat() : [];
|
|
20
19
|
return compact([...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup]);
|
|
21
20
|
};
|
|
21
|
+
const findVitestDependencies = async (configFilePath) => {
|
|
22
|
+
const config = await load(configFilePath);
|
|
23
|
+
return findVitestDeps(config);
|
|
24
|
+
};
|
|
22
25
|
export const findDependencies = timerify(findVitestDependencies);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.24.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.24.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"@npmcli/package-json": "5.0.0",
|
|
66
66
|
"@release-it/bumper": "5.1.0",
|
|
67
67
|
"@swc/cli": "0.1.62",
|
|
68
|
-
"@swc/core": "1.3.
|
|
68
|
+
"@swc/core": "1.3.84",
|
|
69
69
|
"@types/eslint": "8.44.2",
|
|
70
70
|
"@types/js-yaml": "4.0.5",
|
|
71
71
|
"@types/micromatch": "4.0.2",
|
|
72
72
|
"@types/minimist": "1.2.2",
|
|
73
|
-
"@types/node": "20.
|
|
73
|
+
"@types/node": "20.6.0",
|
|
74
74
|
"@types/npmcli__map-workspaces": "3.0.1",
|
|
75
75
|
"@types/webpack": "5.28.2",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
77
|
-
"@typescript-eslint/parser": "6.
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "6.7.0",
|
|
77
|
+
"@typescript-eslint/parser": "6.7.0",
|
|
78
78
|
"c8": "8.0.1",
|
|
79
|
-
"eslint": "8.
|
|
79
|
+
"eslint": "8.49.0",
|
|
80
80
|
"eslint-import-resolver-typescript": "3.6.0",
|
|
81
81
|
"eslint-plugin-import": "2.28.1",
|
|
82
|
-
"eslint-plugin-n": "16.0
|
|
82
|
+
"eslint-plugin-n": "16.1.0",
|
|
83
83
|
"prettier": "3.0.3",
|
|
84
84
|
"release-it": "16.1.5",
|
|
85
85
|
"remark-cli": "11.0.0",
|