knip 1.14.3 → 1.16.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 +109 -97
- package/dist/cli.js +0 -0
- package/dist/plugins/commitlint/index.js +10 -3
- package/dist/plugins/cspell/index.d.ts +6 -0
- package/dist/plugins/cspell/index.js +19 -0
- package/dist/plugins/cspell/types.d.ts +3 -0
- package/dist/plugins/cspell/types.js +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/semantic-release/index.d.ts +6 -0
- package/dist/plugins/semantic-release/index.js +18 -0
- package/dist/plugins/semantic-release/types.d.ts +3 -0
- package/dist/plugins/semantic-release/types.js +1 -0
- package/dist/plugins/typedoc/index.js +17 -2
- package/dist/util/fs.d.ts +4 -0
- package/dist/util/fs.js +17 -2
- package/dist/util/loader.js +7 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspace-worker.d.ts +1 -1
- package/package.json +1 -1
- package/schema.json +8 -0
package/README.md
CHANGED
|
@@ -275,34 +275,36 @@ Knip contains a growing list of plugins:
|
|
|
275
275
|
- [Capacitor][14]
|
|
276
276
|
- [Changesets][15]
|
|
277
277
|
- [commitlint][16]
|
|
278
|
-
- [
|
|
279
|
-
- [
|
|
280
|
-
- [
|
|
281
|
-
- [
|
|
282
|
-
- [
|
|
283
|
-
- [
|
|
284
|
-
- [
|
|
285
|
-
- [
|
|
286
|
-
- [
|
|
287
|
-
- [
|
|
288
|
-
- [
|
|
289
|
-
- [
|
|
290
|
-
- [
|
|
291
|
-
- [
|
|
292
|
-
- [
|
|
293
|
-
- [
|
|
294
|
-
- [
|
|
295
|
-
- [
|
|
296
|
-
- [
|
|
297
|
-
- [
|
|
298
|
-
- [
|
|
299
|
-
- [
|
|
300
|
-
- [
|
|
301
|
-
- [
|
|
302
|
-
- [
|
|
303
|
-
- [
|
|
304
|
-
- [
|
|
305
|
-
- [
|
|
278
|
+
- [cspell][17]
|
|
279
|
+
- [Cypress][18]
|
|
280
|
+
- [ESLint][19]
|
|
281
|
+
- [Gatsby][20]
|
|
282
|
+
- [GitHub Actions][21]
|
|
283
|
+
- [husky][22]
|
|
284
|
+
- [Jest][23]
|
|
285
|
+
- [Lefthook][24]
|
|
286
|
+
- [lint-staged][25]
|
|
287
|
+
- [markdownlint][26]
|
|
288
|
+
- [Mocha][27]
|
|
289
|
+
- [Next.js][28]
|
|
290
|
+
- [npm-package-json-lint][29]
|
|
291
|
+
- [Nx][30]
|
|
292
|
+
- [nyc][31]
|
|
293
|
+
- [Playwright][32]
|
|
294
|
+
- [PostCSS][33]
|
|
295
|
+
- [Prettier][34]
|
|
296
|
+
- [Release It][35]
|
|
297
|
+
- [Remark][36]
|
|
298
|
+
- [Remix][37]
|
|
299
|
+
- [Rollup][38]
|
|
300
|
+
- [Semantic Release][39]
|
|
301
|
+
- [Sentry][40]
|
|
302
|
+
- [Storybook][41]
|
|
303
|
+
- [Stryker][42]
|
|
304
|
+
- [TypeDoc][43]
|
|
305
|
+
- [TypeScript][44]
|
|
306
|
+
- [Vitest][45]
|
|
307
|
+
- [Webpack][46]
|
|
306
308
|
|
|
307
309
|
Plugins are automatically activated. Each plugin is automatically enabled based on simple heuristics. Most of them check
|
|
308
310
|
whether one or one of a few (dev) dependencies are listed in `package.json`. Once enabled, they add a set of
|
|
@@ -310,7 +312,7 @@ configuration and/or entry files for Knip to analyze. These defaults can be over
|
|
|
310
312
|
|
|
311
313
|
Most plugins use one or both of the following file types:
|
|
312
314
|
|
|
313
|
-
- `config` - custom dependency resolvers are applied to the [config files][
|
|
315
|
+
- `config` - custom dependency resolvers are applied to the [config files][47]
|
|
314
316
|
- `entry` - files to include with the analysis of the rest of the source code
|
|
315
317
|
|
|
316
318
|
See each plugin's documentation for its default values.
|
|
@@ -336,7 +338,7 @@ Other configuration files use `require` or `import` statements to use dependenci
|
|
|
336
338
|
rest of the source files. These configuration files are also considered `entry` files.
|
|
337
339
|
|
|
338
340
|
For plugins related to test files, it's good to know that the following glob patterns are always included by default
|
|
339
|
-
(see [TEST_FILE_PATTERNS in constants.ts][
|
|
341
|
+
(see [TEST_FILE_PATTERNS in constants.ts][48]):
|
|
340
342
|
|
|
341
343
|
- `**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs}`
|
|
342
344
|
- `**/__tests__/**/*.{js,jsx,ts,tsx,mjs,cjs}`
|
|
@@ -418,10 +420,10 @@ Each workspace can also have its own `paths` configured. Note that Knip `paths`
|
|
|
418
420
|
|
|
419
421
|
Knip provides the following built-in reporters:
|
|
420
422
|
|
|
421
|
-
- [`codeowners`][
|
|
422
|
-
- [`compact`][
|
|
423
|
-
- [`json`][
|
|
424
|
-
- [`symbol`][
|
|
423
|
+
- [`codeowners`][49]
|
|
424
|
+
- [`compact`][50]
|
|
425
|
+
- [`json`][51]
|
|
426
|
+
- [`symbol`][52] (default)
|
|
425
427
|
|
|
426
428
|
The `compact` reporter shows the sorted files first, and then a list of symbols:
|
|
427
429
|
|
|
@@ -448,7 +450,7 @@ type ReporterOptions = {
|
|
|
448
450
|
|
|
449
451
|
The data can then be used to write issues to `stdout`, a JSON or CSV file, or sent to a service.
|
|
450
452
|
|
|
451
|
-
Find more details and ideas in [custom reporters][
|
|
453
|
+
Find more details and ideas in [custom reporters][53].
|
|
452
454
|
|
|
453
455
|
## Libraries and "unused" exports
|
|
454
456
|
|
|
@@ -502,11 +504,11 @@ instance by ignoring specific folders that are not related to the source code im
|
|
|
502
504
|
Dependencies that are only imported in unused files are also marked as unused. So a long list of unused files would be
|
|
503
505
|
good to remedy first.
|
|
504
506
|
|
|
505
|
-
When unused dependencies are related to dependencies having a Knip [plugin][
|
|
507
|
+
When unused dependencies are related to dependencies having a Knip [plugin][2], maybe the `config` and/or `entry` files
|
|
506
508
|
for that dependency are at custom locations. The default values are at the plugin's documentation, and can be overridden
|
|
507
509
|
to match the custom location(s).
|
|
508
510
|
|
|
509
|
-
When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][
|
|
511
|
+
When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][54].
|
|
510
512
|
|
|
511
513
|
#### Too many unused exports
|
|
512
514
|
|
|
@@ -514,7 +516,7 @@ When the project is a library and the exports are meant to be used by consumers
|
|
|
514
516
|
|
|
515
517
|
1. By default, unused exports of `entry` files are not reported. You could re-export from an existing entry file, or
|
|
516
518
|
add the containing file to the `entry` array in the configuration.
|
|
517
|
-
2. The exported values or types can be marked [using the JSDoc `@public` tag][
|
|
519
|
+
2. The exported values or types can be marked [using the JSDoc `@public` tag][55].
|
|
518
520
|
|
|
519
521
|
### How to start using Knip in CI while having too many issues to sort out?
|
|
520
522
|
|
|
@@ -534,22 +536,22 @@ All of this is hiding problems, so please make sure to plan for fixing them and/
|
|
|
534
536
|
|
|
535
537
|
This table is an ongoing comparison. Based on their docs (please report any mistakes):
|
|
536
538
|
|
|
537
|
-
| Feature
|
|
538
|
-
|
|
|
539
|
-
| Unused files
|
|
540
|
-
| Unused dependencies
|
|
541
|
-
| Unlisted dependencies
|
|
542
|
-
| [Plugins][
|
|
543
|
-
| Unused exports
|
|
544
|
-
| Unused class members
|
|
545
|
-
| Unused enum members
|
|
546
|
-
| Duplicate exports
|
|
547
|
-
| Search namespaces
|
|
548
|
-
| Custom reporters
|
|
549
|
-
| JavaScript support
|
|
550
|
-
| Configure entry files
|
|
551
|
-
| [Support workspaces/monorepos][
|
|
552
|
-
| ESLint plugin available
|
|
539
|
+
| Feature | **knip** | [depcheck][56] | [unimported][57] | [ts-unused-exports][58] | [ts-prune][59] |
|
|
540
|
+
| :-------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
|
|
541
|
+
| Unused files | ✅ | - | ✅ | - | - |
|
|
542
|
+
| Unused dependencies | ✅ | ✅ | ✅ | - | - |
|
|
543
|
+
| Unlisted dependencies | ✅ | ✅ | ✅ | - | - |
|
|
544
|
+
| [Plugins][2] | ✅ | ✅ | ❌ | - | - |
|
|
545
|
+
| Unused exports | ✅ | - | - | ✅ | ✅ |
|
|
546
|
+
| Unused class members | ✅ | - | - | - | - |
|
|
547
|
+
| Unused enum members | ✅ | - | - | - | - |
|
|
548
|
+
| Duplicate exports | ✅ | - | - | ❌ | ❌ |
|
|
549
|
+
| Search namespaces | ✅ | - | - | ✅ | ❌ |
|
|
550
|
+
| Custom reporters | ✅ | - | - | - | - |
|
|
551
|
+
| JavaScript support | ✅ | ✅ | ✅ | - | - |
|
|
552
|
+
| Configure entry files | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
553
|
+
| [Support workspaces/monorepos][1] | ✅ | ❌ | ❌ | - | - |
|
|
554
|
+
| ESLint plugin available | - | - | - | ✅ | - |
|
|
553
555
|
|
|
554
556
|
✅ = Supported, ❌ = Not supported, - = Out of scope
|
|
555
557
|
|
|
@@ -569,7 +571,7 @@ The following commands are similar:
|
|
|
569
571
|
unimported
|
|
570
572
|
knip --production --dependencies --include files
|
|
571
573
|
|
|
572
|
-
Also see [production mode][
|
|
574
|
+
Also see [production mode][60].
|
|
573
575
|
|
|
574
576
|
### ts-unused-exports
|
|
575
577
|
|
|
@@ -599,6 +601,12 @@ userland territory, much like code linters.
|
|
|
599
601
|
Knip is Dutch for a "cut". A Dutch expression is "to be ge**knip**t for something", which means to be perfectly suited
|
|
600
602
|
for the job. I'm motivated to make knip perfectly suited for the job of cutting projects to perfection! ✂️
|
|
601
603
|
|
|
604
|
+
## Contributors
|
|
605
|
+
|
|
606
|
+
Special thanks to the wonderful people who have contributed to this project:
|
|
607
|
+
|
|
608
|
+
[![Contributors][62]][61]
|
|
609
|
+
|
|
602
610
|
[1]: #workspaces--monorepos
|
|
603
611
|
[2]: #plugins
|
|
604
612
|
[3]: #reporters
|
|
@@ -615,45 +623,49 @@ for the job. I'm motivated to make knip perfectly suited for the job of cutting
|
|
|
615
623
|
[14]: ./src/plugins/capacitor
|
|
616
624
|
[15]: ./src/plugins/changesets
|
|
617
625
|
[16]: ./src/plugins/commitlint
|
|
618
|
-
[17]: ./src/plugins/
|
|
619
|
-
[18]: ./src/plugins/
|
|
620
|
-
[19]: ./src/plugins/
|
|
621
|
-
[20]: ./src/plugins/
|
|
622
|
-
[21]: ./src/plugins/
|
|
623
|
-
[22]: ./src/plugins/
|
|
624
|
-
[23]: ./src/plugins/
|
|
625
|
-
[24]: ./src/plugins/
|
|
626
|
-
[25]: ./src/plugins/
|
|
627
|
-
[26]: ./src/plugins/
|
|
628
|
-
[27]: ./src/plugins/
|
|
629
|
-
[28]: ./src/plugins/
|
|
630
|
-
[29]: ./src/plugins/
|
|
631
|
-
[30]: ./src/plugins/
|
|
632
|
-
[31]: ./src/plugins/
|
|
633
|
-
[32]: ./src/plugins/
|
|
634
|
-
[33]: ./src/plugins/
|
|
635
|
-
[34]: ./src/plugins/
|
|
636
|
-
[35]: ./src/plugins/
|
|
637
|
-
[36]: ./src/plugins/
|
|
638
|
-
[37]: ./src/plugins/
|
|
639
|
-
[38]: ./src/plugins/
|
|
640
|
-
[39]: ./src/plugins/
|
|
641
|
-
[40]: ./src/plugins/
|
|
642
|
-
[41]: ./src/plugins/
|
|
643
|
-
[42]: ./src/plugins/
|
|
644
|
-
[43]: ./src/plugins/
|
|
645
|
-
[44]: ./src/plugins/
|
|
646
|
-
[45]:
|
|
647
|
-
[46]:
|
|
648
|
-
[47]: #
|
|
649
|
-
[48]:
|
|
650
|
-
[49]: #
|
|
651
|
-
[50]: #
|
|
652
|
-
[51]:
|
|
653
|
-
[52]: #
|
|
654
|
-
[53]:
|
|
655
|
-
[54]:
|
|
656
|
-
[55]:
|
|
657
|
-
[56]: https://github.com/
|
|
658
|
-
[57]: https://github.com/
|
|
659
|
-
[58]:
|
|
626
|
+
[17]: ./src/plugins/cspell
|
|
627
|
+
[18]: ./src/plugins/cypress
|
|
628
|
+
[19]: ./src/plugins/eslint
|
|
629
|
+
[20]: ./src/plugins/gatsby
|
|
630
|
+
[21]: ./src/plugins/github-actions
|
|
631
|
+
[22]: ./src/plugins/husky
|
|
632
|
+
[23]: ./src/plugins/jest
|
|
633
|
+
[24]: ./src/plugins/lefthook
|
|
634
|
+
[25]: ./src/plugins/lint-staged
|
|
635
|
+
[26]: ./src/plugins/markdownlint
|
|
636
|
+
[27]: ./src/plugins/mocha
|
|
637
|
+
[28]: ./src/plugins/next
|
|
638
|
+
[29]: ./src/plugins/npm-package-json-lint
|
|
639
|
+
[30]: ./src/plugins/nx
|
|
640
|
+
[31]: ./src/plugins/nyc
|
|
641
|
+
[32]: ./src/plugins/playwright
|
|
642
|
+
[33]: ./src/plugins/postcss
|
|
643
|
+
[34]: ./src/plugins/prettier
|
|
644
|
+
[35]: ./src/plugins/release-it
|
|
645
|
+
[36]: ./src/plugins/remark
|
|
646
|
+
[37]: ./src/plugins/remix
|
|
647
|
+
[38]: ./src/plugins/rollup
|
|
648
|
+
[39]: ./src/plugins/semantic-release
|
|
649
|
+
[40]: ./src/plugins/sentry
|
|
650
|
+
[41]: ./src/plugins/storybook
|
|
651
|
+
[42]: ./src/plugins/stryker
|
|
652
|
+
[43]: ./src/plugins/typedoc
|
|
653
|
+
[44]: ./src/plugins/typescript
|
|
654
|
+
[45]: ./src/plugins/vitest
|
|
655
|
+
[46]: ./src/plugins/webpack
|
|
656
|
+
[47]: #config
|
|
657
|
+
[48]: https://github.com/webpro/knip/blob/main/src/constants.ts
|
|
658
|
+
[49]: #code-owners
|
|
659
|
+
[50]: #compact
|
|
660
|
+
[51]: #json
|
|
661
|
+
[52]: #symbol-default
|
|
662
|
+
[53]: ./docs/custom-reporters.md
|
|
663
|
+
[54]: #create-a-new-plugin
|
|
664
|
+
[55]: #libraries-and-unused-exports
|
|
665
|
+
[56]: https://github.com/depcheck/depcheck
|
|
666
|
+
[57]: https://github.com/smeijer/unimported
|
|
667
|
+
[58]: https://github.com/pzavolinsky/ts-unused-exports
|
|
668
|
+
[59]: https://github.com/nadeesha/ts-prune
|
|
669
|
+
[60]: #production-mode
|
|
670
|
+
[61]: https://github.com/webpro/knip/graphs/contributors
|
|
671
|
+
[62]: https://contrib.rocks/image?repo=webpro/knip
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -4,9 +4,16 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
4
4
|
export const NAME = 'commitlint';
|
|
5
5
|
export const ENABLERS = ['@commitlint/cli'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
export const CONFIG_FILE_PATTERNS = [
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = [
|
|
8
|
+
'.commitlintrc',
|
|
9
|
+
'.commitlintrc.{json,yaml,yml,js,cjs,ts,cts}',
|
|
10
|
+
'commitlint.config.{js,cjs,ts,cts}',
|
|
11
|
+
'package.json',
|
|
12
|
+
];
|
|
13
|
+
const findCommitLintDependencies = async (configFilePath, { manifest }) => {
|
|
14
|
+
const config = configFilePath.endsWith('package.json')
|
|
15
|
+
? manifest.commitlint
|
|
16
|
+
: await _load(configFilePath);
|
|
10
17
|
return config?.extends ? [config.extends].flat() : [];
|
|
11
18
|
};
|
|
12
19
|
export const findDependencies = timerify(findCommitLintDependencies);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
|
+
export declare const NAME = "cspell";
|
|
3
|
+
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { _load } from '../../util/loader.js';
|
|
2
|
+
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
3
|
+
import { timerify } from '../../util/performance.js';
|
|
4
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
5
|
+
export const NAME = 'cspell';
|
|
6
|
+
export const ENABLERS = ['cspell'];
|
|
7
|
+
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
|
+
export const CONFIG_FILE_PATTERNS = [
|
|
9
|
+
'cspell.config.{js,cjs,json,yaml,yml}',
|
|
10
|
+
'cspell.{json,yaml,yml}',
|
|
11
|
+
'.c{s,S}pell.json',
|
|
12
|
+
'cSpell.json',
|
|
13
|
+
];
|
|
14
|
+
const findPluginDependencies = async (configFilePath) => {
|
|
15
|
+
const config = await _load(configFilePath);
|
|
16
|
+
const imports = config?.import ?? [];
|
|
17
|
+
return imports.map(getPackageNameFromModuleSpecifier);
|
|
18
|
+
};
|
|
19
|
+
export const findDependencies = timerify(findPluginDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * as babel from './babel/index.js';
|
|
|
2
2
|
export * as capacitor from './capacitor/index.js';
|
|
3
3
|
export * as changesets from './changesets/index.js';
|
|
4
4
|
export * as commitlint from './commitlint/index.js';
|
|
5
|
+
export * as cspell from './cspell/index.js';
|
|
5
6
|
export * as cypress from './cypress/index.js';
|
|
6
7
|
export * as eslint from './eslint/index.js';
|
|
7
8
|
export * as gatsby from './gatsby/index.js';
|
|
@@ -23,6 +24,7 @@ export * as releaseIt from './release-it/index.js';
|
|
|
23
24
|
export * as remark from './remark/index.js';
|
|
24
25
|
export * as remix from './remix/index.js';
|
|
25
26
|
export * as rollup from './rollup/index.js';
|
|
27
|
+
export * as semanticRelease from './semantic-release/index.js';
|
|
26
28
|
export * as sentry from './sentry/index.js';
|
|
27
29
|
export * as storybook from './storybook/index.js';
|
|
28
30
|
export * as stryker from './stryker/index.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * as babel from './babel/index.js';
|
|
|
2
2
|
export * as capacitor from './capacitor/index.js';
|
|
3
3
|
export * as changesets from './changesets/index.js';
|
|
4
4
|
export * as commitlint from './commitlint/index.js';
|
|
5
|
+
export * as cspell from './cspell/index.js';
|
|
5
6
|
export * as cypress from './cypress/index.js';
|
|
6
7
|
export * as eslint from './eslint/index.js';
|
|
7
8
|
export * as gatsby from './gatsby/index.js';
|
|
@@ -23,6 +24,7 @@ export * as releaseIt from './release-it/index.js';
|
|
|
23
24
|
export * as remark from './remark/index.js';
|
|
24
25
|
export * as remix from './remix/index.js';
|
|
25
26
|
export * as rollup from './rollup/index.js';
|
|
27
|
+
export * as semanticRelease from './semantic-release/index.js';
|
|
26
28
|
export * as sentry from './sentry/index.js';
|
|
27
29
|
export * as storybook from './storybook/index.js';
|
|
28
30
|
export * as stryker from './stryker/index.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
|
+
export declare const NAME = "Semantic Release";
|
|
3
|
+
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _load } from '../../util/loader.js';
|
|
2
|
+
import { timerify } from '../../util/performance.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
export const NAME = 'Semantic Release';
|
|
5
|
+
export const ENABLERS = ['semantic-release'];
|
|
6
|
+
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = [
|
|
8
|
+
'.releaserc',
|
|
9
|
+
'.releaserc.{yaml,yml,json,js,cjs}',
|
|
10
|
+
'release.config.{js,cjs}',
|
|
11
|
+
'package.json',
|
|
12
|
+
];
|
|
13
|
+
const findPluginDependencies = async (configFilePath, { manifest }) => {
|
|
14
|
+
const config = configFilePath.endsWith('package.json') ? manifest.release : await _load(configFilePath);
|
|
15
|
+
const plugins = config?.plugins ?? [];
|
|
16
|
+
return plugins.map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
|
|
17
|
+
};
|
|
18
|
+
export const findDependencies = timerify(findPluginDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { _load } from '../../util/loader.js';
|
|
3
|
+
import { isAbsolute } from '../../util/path.js';
|
|
2
4
|
import { timerify } from '../../util/performance.js';
|
|
3
5
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
6
|
export const NAME = 'TypeDoc';
|
|
@@ -10,8 +12,21 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
10
12
|
'.config/typedoc.{js,cjs,json,jsonc}',
|
|
11
13
|
'.config/typedoc.config.{js,cjs}',
|
|
12
14
|
];
|
|
13
|
-
const findPluginDependencies = async (configFilePath) => {
|
|
15
|
+
const findPluginDependencies = async (configFilePath, { cwd }) => {
|
|
14
16
|
const config = await _load(configFilePath);
|
|
15
|
-
|
|
17
|
+
const entryFiles = [];
|
|
18
|
+
const dependencies = [];
|
|
19
|
+
(config?.plugin ?? []).forEach(plugin => {
|
|
20
|
+
if (isAbsolute(plugin)) {
|
|
21
|
+
entryFiles.push(plugin);
|
|
22
|
+
}
|
|
23
|
+
else if (plugin.startsWith('.')) {
|
|
24
|
+
entryFiles.push(path.join(cwd, plugin));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
dependencies.push(plugin);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return { dependencies, entryFiles };
|
|
16
31
|
};
|
|
17
32
|
export const findDependencies = timerify(findPluginDependencies);
|
package/dist/util/fs.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const isFile: (filePath: string) => boolean;
|
|
2
2
|
export declare const findFile: (workingDir: string, fileName: string) => string | undefined;
|
|
3
|
+
export declare const loadFile: (filePath: string) => Promise<string>;
|
|
3
4
|
export declare const loadJSON: (filePath: string) => Promise<any>;
|
|
5
|
+
export declare const loadYAML: (filePath: string) => Promise<unknown>;
|
|
6
|
+
export declare const parseJSON: (contents: string) => Promise<any>;
|
|
7
|
+
export declare const parseYAML: (contents: string) => Promise<unknown>;
|
package/dist/util/fs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { statSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import yaml from 'js-yaml';
|
|
4
5
|
import stripJsonComments from 'strip-json-comments';
|
|
5
6
|
import { LoaderError } from './errors.js';
|
|
6
7
|
export const isFile = (filePath) => {
|
|
@@ -11,12 +12,26 @@ export const findFile = (workingDir, fileName) => {
|
|
|
11
12
|
const filePath = path.join(workingDir, fileName);
|
|
12
13
|
return isFile(filePath) ? filePath : undefined;
|
|
13
14
|
};
|
|
14
|
-
export const
|
|
15
|
+
export const loadFile = async (filePath) => {
|
|
15
16
|
try {
|
|
16
17
|
const contents = await readFile(filePath);
|
|
17
|
-
return
|
|
18
|
+
return contents.toString();
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
20
21
|
throw new LoaderError(`Error loading ${filePath}`, { cause: error });
|
|
21
22
|
}
|
|
22
23
|
};
|
|
24
|
+
export const loadJSON = async (filePath) => {
|
|
25
|
+
const contents = await loadFile(filePath);
|
|
26
|
+
return parseJSON(contents);
|
|
27
|
+
};
|
|
28
|
+
export const loadYAML = async (filePath) => {
|
|
29
|
+
const contents = await loadFile(filePath);
|
|
30
|
+
return parseYAML(contents);
|
|
31
|
+
};
|
|
32
|
+
export const parseJSON = async (contents) => {
|
|
33
|
+
return JSON.parse(stripJsonComments(contents));
|
|
34
|
+
};
|
|
35
|
+
export const parseYAML = async (contents) => {
|
|
36
|
+
return yaml.load(contents);
|
|
37
|
+
};
|
package/dist/util/loader.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { pathToFileURL } from 'node:url';
|
|
4
3
|
import { load as esmLoad } from '@esbuild-kit/esm-loader';
|
|
5
|
-
import yaml from 'js-yaml';
|
|
6
4
|
import { require } from '../util/require.js';
|
|
7
5
|
import { LoaderError } from './errors.js';
|
|
8
|
-
import { loadJSON } from './fs.js';
|
|
6
|
+
import { loadJSON, loadYAML, loadFile, parseJSON, parseYAML } from './fs.js';
|
|
9
7
|
import { timerify } from './performance.js';
|
|
10
8
|
const load = async (filePath) => {
|
|
11
9
|
try {
|
|
12
10
|
const ext = path.extname(filePath);
|
|
13
|
-
if (
|
|
11
|
+
if (/rc$/.test(filePath)) {
|
|
12
|
+
const contents = await loadFile(filePath);
|
|
13
|
+
return parseYAML(contents).catch(() => parseJSON(contents));
|
|
14
|
+
}
|
|
15
|
+
if (ext === '.json' || ext === '.jsonc') {
|
|
14
16
|
return loadJSON(filePath);
|
|
15
17
|
}
|
|
16
18
|
if (ext === '.yaml' || ext === '.yml') {
|
|
17
|
-
return
|
|
19
|
+
return loadYAML(filePath);
|
|
18
20
|
}
|
|
19
21
|
if (ext === '.mjs') {
|
|
20
22
|
const fileUrl = pathToFileURL(filePath);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.16.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.16.0';
|
|
@@ -51,7 +51,7 @@ export default class WorkspaceWorker {
|
|
|
51
51
|
installedBinaries: InstalledBinaries;
|
|
52
52
|
referencedDependencyIssues: ReferencedDependencyIssues;
|
|
53
53
|
entryFiles: Set<string>;
|
|
54
|
-
enabledPlugins: ("babel" | "capacitor" | "changesets" | "commitlint" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "typescript" | "vitest" | "webpack" | "githubActions" | "lefthook" | "lintStaged" | "npmPackageJsonLint" | "releaseIt" | "typedoc")[];
|
|
54
|
+
enabledPlugins: ("babel" | "capacitor" | "changesets" | "commitlint" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "typescript" | "vitest" | "webpack" | "cspell" | "githubActions" | "lefthook" | "lintStaged" | "npmPackageJsonLint" | "releaseIt" | "semanticRelease" | "typedoc")[];
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
export {};
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -180,6 +180,10 @@
|
|
|
180
180
|
"title": "commitlint plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/commitlint/README.md)",
|
|
181
181
|
"$ref": "#/definitions/plugin"
|
|
182
182
|
},
|
|
183
|
+
"cspell": {
|
|
184
|
+
"title": "cspell plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/cspell/README.md)",
|
|
185
|
+
"$ref": "#/definitions/plugin"
|
|
186
|
+
},
|
|
183
187
|
"cypress": {
|
|
184
188
|
"title": "Cypress plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/cypress/README.md)",
|
|
185
189
|
"$ref": "#/definitions/plugin"
|
|
@@ -264,6 +268,10 @@
|
|
|
264
268
|
"title": "Rollup plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/rollup/README.md)",
|
|
265
269
|
"$ref": "#/definitions/plugin"
|
|
266
270
|
},
|
|
271
|
+
"semantic-release": {
|
|
272
|
+
"title": "semantic-release plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/semantic-release/README.md)",
|
|
273
|
+
"$ref": "#/definitions/plugin"
|
|
274
|
+
},
|
|
267
275
|
"sentry": {
|
|
268
276
|
"title": "Sentry plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/sentry/README.md)",
|
|
269
277
|
"$ref": "#/definitions/plugin"
|