knip 1.14.2 → 1.14.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
@@ -35,13 +35,19 @@ with OpenAI_</sup>
35
35
 
36
36
  When coming from version v0.13.3 or before, please see [migration to v1][7].
37
37
 
38
+ ## Announcement: Knip v2
39
+
40
+ The next major release is upcoming. Please see [https://github.com/webpro/knip/issues/73][8] for the full story. Use
41
+ `npm install knip@next` to try it out if you're curious! No changes in configuration necessary. Find the updated
42
+ documentation at [https://github.com/webpro/knip/blob/v2/README.md][9].
43
+
38
44
  ## Issues
39
45
 
40
- Are you seeing false positives? Please report them by [opening an issue in this repo][8]. Bonus points for linking to a
46
+ Are you seeing false positives? Please report them by [opening an issue in this repo][10]. Bonus points for linking to a
41
47
  public repository using Knip, or even opening a pull request with a directory and example files in `test/fixtures`.
42
48
  Correctness and bug fixes have priority over performance and new features.
43
49
 
44
- Also see the [FAQ][9].
50
+ Also see the [FAQ][11].
45
51
 
46
52
  ## Installation
47
53
 
@@ -190,7 +196,7 @@ Use `--exclude` to ignore reports you're not interested in:
190
196
  Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.
191
197
 
192
198
  Still not happy with the results? Getting too much output/false positives? The [FAQ][9] may be useful. Feel free to open
193
- an issue and I'm happy to look into it. Also see the next section on how to [ignore][10] certain false positives:
199
+ an issue and I'm happy to look into it. Also see the next section on how to [ignore][12] certain false positives:
194
200
 
195
201
  ## Ignore
196
202
 
@@ -265,38 +271,38 @@ Here's some example output when running Knip in a workspace:
265
271
 
266
272
  Knip contains a growing list of plugins:
267
273
 
268
- - [Babel][11]
269
- - [Capacitor][12]
270
- - [Changesets][13]
271
- - [commitlint][14]
272
- - [Cypress][15]
273
- - [ESLint][16]
274
- - [Gatsby][17]
275
- - [GitHub Actions][18]
276
- - [husky][19]
277
- - [Jest][20]
278
- - [Lefthook][21]
279
- - [lint-staged][22]
280
- - [markdownlint][23]
281
- - [Mocha][24]
282
- - [Next.js][25]
283
- - [npm-package-json-lint][26]
284
- - [Nx][27]
285
- - [nyc][28]
286
- - [Playwright][29]
287
- - [PostCSS][30]
288
- - [Prettier][31]
289
- - [Release It][32]
290
- - [Remark][33]
291
- - [Remix][34]
292
- - [Rollup][35]
293
- - [Sentry][36]
294
- - [Storybook][37]
295
- - [Stryker][38]
296
- - [TypeDoc][39]
297
- - [TypeScript][40]
298
- - [Vitest][41]
299
- - [Webpack][42]
274
+ - [Babel][13]
275
+ - [Capacitor][14]
276
+ - [Changesets][15]
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]
300
306
 
301
307
  Plugins are automatically activated. Each plugin is automatically enabled based on simple heuristics. Most of them check
302
308
  whether one or one of a few (dev) dependencies are listed in `package.json`. Once enabled, they add a set of
@@ -304,7 +310,7 @@ configuration and/or entry files for Knip to analyze. These defaults can be over
304
310
 
305
311
  Most plugins use one or both of the following file types:
306
312
 
307
- - `config` - custom dependency resolvers are applied to the [config files][43]
313
+ - `config` - custom dependency resolvers are applied to the [config files][45]
308
314
  - `entry` - files to include with the analysis of the rest of the source code
309
315
 
310
316
  See each plugin's documentation for its default values.
@@ -329,6 +335,13 @@ rest to find which of those dependencies are unused or missing.
329
335
  Other configuration files use `require` or `import` statements to use dependencies, so they can be analyzed like the
330
336
  rest of the source files. These configuration files are also considered `entry` files.
331
337
 
338
+ 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]):
340
+
341
+ - `**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs}`
342
+ - `**/__tests__/**/*.{js,jsx,ts,tsx,mjs,cjs}`
343
+ - `test/**/*.{js,jsx,ts,tsx,mjs,cjs}`
344
+
332
345
  ### Disable a plugin
333
346
 
334
347
  In case a plugin causes issues, it can be disabled by using `false` as its value (e.g. `"webpack": false`).
@@ -405,10 +418,10 @@ Each workspace can also have its own `paths` configured. Note that Knip `paths`
405
418
 
406
419
  Knip provides the following built-in reporters:
407
420
 
408
- - [`codeowners`][44]
409
- - [`compact`][45]
410
- - [`json`][46]
411
- - [`symbol`][47] (default)
421
+ - [`codeowners`][47]
422
+ - [`compact`][48]
423
+ - [`json`][49]
424
+ - [`symbol`][50] (default)
412
425
 
413
426
  The `compact` reporter shows the sorted files first, and then a list of symbols:
414
427
 
@@ -435,7 +448,7 @@ type ReporterOptions = {
435
448
 
436
449
  The data can then be used to write issues to `stdout`, a JSON or CSV file, or sent to a service.
437
450
 
438
- Find more details and ideas in [custom reporters][48].
451
+ Find more details and ideas in [custom reporters][51].
439
452
 
440
453
  ## Libraries and "unused" exports
441
454
 
@@ -493,7 +506,7 @@ When unused dependencies are related to dependencies having a Knip [plugin][1],
493
506
  for that dependency are at custom locations. The default values are at the plugin's documentation, and can be overridden
494
507
  to match the custom location(s).
495
508
 
496
- When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][49].
509
+ When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][52].
497
510
 
498
511
  #### Too many unused exports
499
512
 
@@ -501,7 +514,7 @@ When the project is a library and the exports are meant to be used by consumers
501
514
 
502
515
  1. By default, unused exports of `entry` files are not reported. You could re-export from an existing entry file, or
503
516
  add the containing file to the `entry` array in the configuration.
504
- 2. The exported values or types can be marked [using the JSDoc `@public` tag][50].
517
+ 2. The exported values or types can be marked [using the JSDoc `@public` tag][53].
505
518
 
506
519
  ### How to start using Knip in CI while having too many issues to sort out?
507
520
 
@@ -521,7 +534,7 @@ All of this is hiding problems, so please make sure to plan for fixing them and/
521
534
 
522
535
  This table is an ongoing comparison. Based on their docs (please report any mistakes):
523
536
 
524
- | Feature | **knip** | [depcheck][51] | [unimported][52] | [ts-unused-exports][53] | [ts-prune][54] |
537
+ | Feature | **knip** | [depcheck][54] | [unimported][55] | [ts-unused-exports][56] | [ts-prune][57] |
525
538
  | :--------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
526
539
  | Unused files | ✅ | - | ✅ | - | - |
527
540
  | Unused dependencies | ✅ | ✅ | ✅ | - | - |
@@ -556,7 +569,7 @@ The following commands are similar:
556
569
  unimported
557
570
  knip --production --dependencies --include files
558
571
 
559
- Also see [production mode][55].
572
+ Also see [production mode][58].
560
573
 
561
574
  ### ts-unused-exports
562
575
 
@@ -593,51 +606,54 @@ for the job. I'm motivated to make knip perfectly suited for the job of cutting
593
606
  [5]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
594
607
  [6]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
595
608
  [7]: ./docs/migration-to-v1.md
596
- [8]: https://github.com/webpro/knip/issues
597
- [9]: #faq
598
- [10]: #ignore
599
- [11]: ./src/plugins/babel
600
- [12]: ./src/plugins/capacitor
601
- [13]: ./src/plugins/changesets
602
- [14]: ./src/plugins/commitlint
603
- [15]: ./src/plugins/cypress
604
- [16]: ./src/plugins/eslint
605
- [17]: ./src/plugins/gatsby
606
- [18]: ./src/plugins/github-actions
607
- [19]: ./src/plugins/husky
608
- [20]: ./src/plugins/jest
609
- [21]: ./src/plugins/lefthook
610
- [22]: ./src/plugins/lint-staged
611
- [23]: ./src/plugins/markdownlint
612
- [24]: ./src/plugins/mocha
613
- [25]: ./src/plugins/next
614
- [26]: ./src/plugins/npm-package-json-lint
615
- [27]: ./src/plugins/nx
616
- [28]: ./src/plugins/nyc
617
- [29]: ./src/plugins/playwright
618
- [30]: ./src/plugins/postcss
619
- [31]: ./src/plugins/prettier
620
- [32]: ./src/plugins/release-it
621
- [33]: ./src/plugins/remark
622
- [34]: ./src/plugins/remix
623
- [35]: ./src/plugins/rollup
624
- [36]: ./src/plugins/sentry
625
- [37]: ./src/plugins/storybook
626
- [38]: ./src/plugins/stryker
627
- [39]: ./src/plugins/typedoc
628
- [40]: ./src/plugins/typescript
629
- [41]: ./src/plugins/vitest
630
- [42]: ./src/plugins/webpack
631
- [43]: #config
632
- [44]: #code-owners
633
- [45]: #compact
634
- [46]: #json
635
- [47]: #symbol-default
636
- [48]: ./docs/custom-reporters.md
637
- [49]: #create-a-new-plugin
638
- [50]: #libraries-and-unused-exports
639
- [51]: https://github.com/depcheck/depcheck
640
- [52]: https://github.com/smeijer/unimported
641
- [53]: https://github.com/pzavolinsky/ts-unused-exports
642
- [54]: https://github.com/nadeesha/ts-prune
643
- [55]: #production-mode
609
+ [8]: https://github.com/webpro/knip/issues/73
610
+ [9]: https://github.com/webpro/knip/blob/v2/README.md
611
+ [10]: https://github.com/webpro/knip/issues
612
+ [11]: #faq
613
+ [12]: #ignore
614
+ [13]: ./src/plugins/babel
615
+ [14]: ./src/plugins/capacitor
616
+ [15]: ./src/plugins/changesets
617
+ [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
package/dist/constants.js CHANGED
@@ -8,7 +8,11 @@ export const DEFAULT_WORKSPACE_CONFIG = {
8
8
  paths: {},
9
9
  ignore: [],
10
10
  };
11
- export const TEST_FILE_PATTERNS = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/__tests__/**/*.{js,jsx,ts,tsx}'];
11
+ export const TEST_FILE_PATTERNS = [
12
+ '**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs}',
13
+ '**/__tests__/**/*.{js,jsx,ts,tsx,mjs,cjs}',
14
+ 'test/**/*.{js,jsx,ts,tsx,mjs,cjs}',
15
+ ];
12
16
  export const IGNORED_GLOBAL_BINARIES = [
13
17
  'bun',
14
18
  'deno',
@@ -3,5 +3,5 @@ export declare const NAME = "Jest";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const ENTRY_FILE_PATTERNS: never[];
7
7
  export declare const findDependencies: GenericPluginCallback;
@@ -9,7 +9,7 @@ export const NAME = 'Jest';
9
9
  export const ENABLERS = ['jest'];
10
10
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
11
11
  export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}'];
12
- export const ENTRY_FILE_PATTERNS = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
12
+ export const ENTRY_FILE_PATTERNS = [];
13
13
  const join = (base, id) => (isAbsolute(id) ? id : path.join(path.dirname(base), id));
14
14
  const resolveExtensibleConfig = async (configFilePath) => {
15
15
  const config = await _load(configFilePath);
@@ -3,5 +3,5 @@ export declare const NAME = "Mocha";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const ENTRY_FILE_PATTERNS: never[];
7
7
  export declare const findDependencies: GenericPluginCallback;
@@ -6,7 +6,7 @@ export const NAME = 'Mocha';
6
6
  export const ENABLERS = ['mocha'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
9
- export const ENTRY_FILE_PATTERNS = ['test/**/*.{js,cjs,mjs}'];
9
+ export const ENTRY_FILE_PATTERNS = [];
10
10
  const findMochaDependencies = async (configFilePath, { manifest }) => {
11
11
  const config = configFilePath.endsWith('package.json') ? manifest.mocha : await _load(configFilePath);
12
12
  if (config) {
@@ -2,4 +2,4 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  export const NAME = 'Playwright';
3
3
  export const ENABLERS = ['@playwright/test'];
4
4
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- export const ENTRY_FILE_PATTERNS = ['playwright.config.{js,ts}', '.*{test,spec}.{js,ts,mjs}'];
5
+ export const ENTRY_FILE_PATTERNS = ['playwright.config.{js,ts}'];
@@ -3,5 +3,5 @@ export declare const NAME = "Vitest";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const ENTRY_FILE_PATTERNS: never[];
7
7
  export declare const findDependencies: GenericPluginCallback;
@@ -7,7 +7,7 @@ export const NAME = 'Vitest';
7
7
  export const ENABLERS = ['vitest'];
8
8
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
9
9
  export const CONFIG_FILE_PATTERNS = ['vitest.config.ts', 'vite.config.ts'];
10
- export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'];
10
+ export const ENTRY_FILE_PATTERNS = [];
11
11
  const findVitestDependencies = async (configFilePath) => {
12
12
  const config = await _load(configFilePath);
13
13
  if (!config || !config.test)
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.14.2";
1
+ export declare const version = "1.14.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.14.2';
1
+ export const version = '1.14.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "1.14.2",
3
+ "version": "1.14.3",
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",