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 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
- - [Cypress][17]
279
- - [ESLint][18]
280
- - [Gatsby][19]
281
- - [GitHub Actions][20]
282
- - [husky][21]
283
- - [Jest][22]
284
- - [Lefthook][23]
285
- - [lint-staged][24]
286
- - [markdownlint][25]
287
- - [Mocha][26]
288
- - [Next.js][27]
289
- - [npm-package-json-lint][28]
290
- - [Nx][29]
291
- - [nyc][30]
292
- - [Playwright][31]
293
- - [PostCSS][32]
294
- - [Prettier][33]
295
- - [Release It][34]
296
- - [Remark][35]
297
- - [Remix][36]
298
- - [Rollup][37]
299
- - [Sentry][38]
300
- - [Storybook][39]
301
- - [Stryker][40]
302
- - [TypeDoc][41]
303
- - [TypeScript][42]
304
- - [Vitest][43]
305
- - [Webpack][44]
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][45]
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][46]):
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`][47]
422
- - [`compact`][48]
423
- - [`json`][49]
424
- - [`symbol`][50] (default)
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][51].
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][1], maybe the `config` and/or `entry` files
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][52].
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][53].
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 | **knip** | [depcheck][54] | [unimported][55] | [ts-unused-exports][56] | [ts-prune][57] |
538
- | :--------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
539
- | Unused files | ✅ | - | ✅ | - | - |
540
- | Unused dependencies | ✅ | ✅ | ✅ | - | - |
541
- | Unlisted dependencies | ✅ | ✅ | ✅ | - | - |
542
- | [Plugins][1] | ✅ | ✅ | ❌ | - | - |
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][52] | ✅ | ❌ | ❌ | - | - |
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][58].
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/cypress
619
- [18]: ./src/plugins/eslint
620
- [19]: ./src/plugins/gatsby
621
- [20]: ./src/plugins/github-actions
622
- [21]: ./src/plugins/husky
623
- [22]: ./src/plugins/jest
624
- [23]: ./src/plugins/lefthook
625
- [24]: ./src/plugins/lint-staged
626
- [25]: ./src/plugins/markdownlint
627
- [26]: ./src/plugins/mocha
628
- [27]: ./src/plugins/next
629
- [28]: ./src/plugins/npm-package-json-lint
630
- [29]: ./src/plugins/nx
631
- [30]: ./src/plugins/nyc
632
- [31]: ./src/plugins/playwright
633
- [32]: ./src/plugins/postcss
634
- [33]: ./src/plugins/prettier
635
- [34]: ./src/plugins/release-it
636
- [35]: ./src/plugins/remark
637
- [36]: ./src/plugins/remix
638
- [37]: ./src/plugins/rollup
639
- [38]: ./src/plugins/sentry
640
- [39]: ./src/plugins/storybook
641
- [40]: ./src/plugins/stryker
642
- [41]: ./src/plugins/typedoc
643
- [42]: ./src/plugins/typescript
644
- [43]: ./src/plugins/vitest
645
- [44]: ./src/plugins/webpack
646
- [45]: #config
647
- [46]: https://github.com/webpro/knip/blob/main/src/constants.ts
648
- [47]: #code-owners
649
- [48]: #compact
650
- [49]: #json
651
- [50]: #symbol-default
652
- [51]: ./docs/custom-reporters.md
653
- [52]: #create-a-new-plugin
654
- [53]: #libraries-and-unused-exports
655
- [54]: https://github.com/depcheck/depcheck
656
- [55]: https://github.com/smeijer/unimported
657
- [56]: https://github.com/pzavolinsky/ts-unused-exports
658
- [57]: https://github.com/nadeesha/ts-prune
659
- [58]: #production-mode
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 = ['commitlint.config.{js,ts}'];
8
- const findCommitLintDependencies = async (configFilePath) => {
9
- const config = await _load(configFilePath);
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,3 @@
1
+ export type PluginConfig = {
2
+ import?: string[];
3
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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';
@@ -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,3 @@
1
+ export type PluginConfig = {
2
+ plugins?: (string | [string, Record<string, unknown>])[];
3
+ };
@@ -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
- return config?.plugin ?? [];
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 loadJSON = async (filePath) => {
15
+ export const loadFile = async (filePath) => {
15
16
  try {
16
17
  const contents = await readFile(filePath);
17
- return JSON.parse(stripJsonComments(contents.toString()));
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
+ };
@@ -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 (ext === '.json' || ext === '.jsonc' || /rc$/.test(filePath)) {
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 yaml.load((await fs.readFile(filePath)).toString());
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.14.3";
1
+ export declare const version = "1.16.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.14.3';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "1.14.3",
3
+ "version": "1.16.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",
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"