@knip/mcp 0.0.20 → 0.0.21

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.
Files changed (57) hide show
  1. package/package.json +2 -2
  2. package/src/docs/docs/blog/brief-history.md +30 -0
  3. package/src/docs/docs/blog/for-editors-and-agents.md +131 -0
  4. package/src/docs/docs/blog/knip-v3.mdx +88 -0
  5. package/src/docs/docs/blog/knip-v4.mdx +149 -0
  6. package/src/docs/docs/blog/knip-v5.mdx +190 -0
  7. package/src/docs/docs/blog/migration-to-v1.md +65 -0
  8. package/src/docs/docs/blog/release-notes-v2.md +46 -0
  9. package/src/docs/docs/blog/slim-down-to-speed-up.md +269 -0
  10. package/src/docs/docs/blog/state-of-knip.md +191 -0
  11. package/src/docs/docs/blog/two-years.mdx +107 -0
  12. package/src/docs/docs/explanations/comparison-and-migration.md +133 -0
  13. package/src/docs/docs/explanations/entry-files.md +70 -0
  14. package/src/docs/docs/explanations/plugins.md +347 -0
  15. package/src/docs/docs/explanations/why-use-knip.md +128 -0
  16. package/src/docs/docs/features/auto-fix.mdx +348 -0
  17. package/src/docs/docs/features/compilers.md +172 -0
  18. package/src/docs/docs/features/integrated-monorepos.md +61 -0
  19. package/src/docs/docs/features/monorepos-and-workspaces.md +149 -0
  20. package/src/docs/docs/features/production-mode.md +95 -0
  21. package/src/docs/docs/features/reporters.md +304 -0
  22. package/src/docs/docs/features/rules-and-filters.md +102 -0
  23. package/src/docs/docs/features/script-parser.md +156 -0
  24. package/src/docs/docs/features/source-mapping.md +100 -0
  25. package/src/docs/docs/guides/configuring-project-files.md +205 -0
  26. package/src/docs/docs/guides/contributing.md +24 -0
  27. package/src/docs/docs/guides/handling-issues.mdx +708 -0
  28. package/src/docs/docs/guides/issue-reproduction.md +103 -0
  29. package/src/docs/docs/guides/namespace-imports.md +125 -0
  30. package/src/docs/docs/guides/performance.md +108 -0
  31. package/src/docs/docs/guides/troubleshooting.md +133 -0
  32. package/src/docs/docs/guides/using-knip-in-ci.md +50 -0
  33. package/src/docs/docs/guides/working-with-commonjs.md +72 -0
  34. package/src/docs/docs/index.mdx +160 -0
  35. package/src/docs/docs/overview/configuration.md +104 -0
  36. package/src/docs/docs/overview/features.md +66 -0
  37. package/src/docs/docs/overview/getting-started.mdx +205 -0
  38. package/src/docs/docs/overview/screenshots-videos.md +42 -0
  39. package/src/docs/docs/playground.mdx +38 -0
  40. package/src/docs/docs/reference/cli.md +511 -0
  41. package/src/docs/docs/reference/configuration-hints.md +146 -0
  42. package/src/docs/docs/reference/configuration.md +430 -0
  43. package/src/docs/docs/reference/dynamic-configuration.mdx +72 -0
  44. package/src/docs/docs/reference/faq.md +493 -0
  45. package/src/docs/docs/reference/integrations.md +105 -0
  46. package/src/docs/docs/reference/issue-types.md +45 -0
  47. package/src/docs/docs/reference/jsdoc-tsdoc-tags.md +133 -0
  48. package/src/docs/docs/reference/known-issues.md +86 -0
  49. package/src/docs/docs/reference/plugins/.gitkeep +0 -0
  50. package/src/docs/docs/reference/plugins.md +146 -0
  51. package/src/docs/docs/reference/related-tooling.md +46 -0
  52. package/src/docs/docs/sponsors.mdx +64 -0
  53. package/src/docs/docs/typescript/unused-dependencies.md +86 -0
  54. package/src/docs/docs/typescript/unused-exports.md +87 -0
  55. package/src/docs/docs/writing-a-plugin/argument-parsing.md +202 -0
  56. package/src/docs/docs/writing-a-plugin/index.md +392 -0
  57. package/src/docs/docs/writing-a-plugin/inputs.md +162 -0
@@ -0,0 +1,133 @@
1
+ ---
2
+ title: JSDoc & TSDoc Tags
3
+ ---
4
+
5
+ JSDoc or TSDoc tags can be used to make exceptions for unused or duplicate
6
+ exports.
7
+
8
+ Knip tries to minimize configuration and introduces no new syntax. That's why it
9
+ hooks into JSDoc and TSDoc tags.
10
+
11
+ :::caution
12
+
13
+ Adding tags or excluding a certain type of issues from the report is usually not
14
+ recommended. It hides issues, which is often a sign of code smell or ambiguity
15
+ and ends up harder to maintain. It's usually better to refactor the code (or
16
+ report an issue with Knip for false positives).
17
+
18
+ :::
19
+
20
+ JSDoc comments always start with `/**` (not `//`) and can be single or
21
+ multi-line.
22
+
23
+ ## Tags
24
+
25
+ Use arbitrary [tags][1] to exclude or include tagged exports from the report.
26
+ Example:
27
+
28
+ ```ts
29
+ /** @lintignore */
30
+ export const myUnusedExport = 1;
31
+
32
+ /** @lintignore */
33
+ import Unresolved from "./generated/lib.js";
34
+ ```
35
+
36
+ And then include (`+`) or exclude (`-`) these tagged exports from the report
37
+ like so:
38
+
39
+ ```shell
40
+ knip --tags=-lintignore,-internal
41
+ ```
42
+
43
+ Tags can also be [configured in `knip.json`][2].
44
+
45
+ When an excluded tag is no longer necessary because the export is actually used,
46
+ Knip reports a **tag hint**:
47
+
48
+ ```sh
49
+ Tag hints (1)
50
+ ignored unimported.ts Unused tag in unimported.ts: ignored → @custom
51
+ ```
52
+
53
+ This helps you clean up tags that were added to suppress issues that have since
54
+ been resolved.
55
+
56
+ ## `@public`
57
+
58
+ By default, Knip reports unused exports in non-entry files.
59
+
60
+ Tag the export as `@public` and Knip will not report it.
61
+
62
+ Example:
63
+
64
+ ```ts
65
+ /**
66
+ * @public
67
+ */
68
+ export const unusedFunction = () => {};
69
+ ```
70
+
71
+ This tag can also be used to make exceptions in entry files when using
72
+ [--include-entry-exports][3].
73
+
74
+ [JSDoc: @public][4] and [TSDoc: @public][5]
75
+
76
+ ## `@internal`
77
+
78
+ Internal exports are not meant for public consumption, but only for internal
79
+ usage such as tests. This means they would be reported in [production mode][6].
80
+
81
+ Mark the export with `@internal` and Knip will not report the export in
82
+ production mode.
83
+
84
+ Example:
85
+
86
+ ```ts
87
+ /** @internal */
88
+ export const internalTestedFunction = () => {};
89
+ ```
90
+
91
+ In general it's not recommended to expose and test implementation details, but
92
+ exceptions are possible. Those should not be reported as false positives, so
93
+ when using production mode you'll need to help Knip out by tagging them as
94
+ `@internal`.
95
+
96
+ [TSDoc: @internal][7]
97
+
98
+ ## `@alias`
99
+
100
+ Knip reports duplicate exports. To prevent this, tag one of the exports as
101
+ `@alias`.
102
+
103
+ Example:
104
+
105
+ ```ts
106
+ export const Component = () => {};
107
+
108
+ /** @alias */
109
+ export default Component;
110
+ ```
111
+
112
+ An alternative solution is to use `--exclude duplicates` and exclude all
113
+ duplicates from being reported.
114
+
115
+ [JSDoc: @alias][8]
116
+
117
+ ## `@beta`
118
+
119
+ Works identical to [`@public`][9]. Knip ignores other tags like `@alpha` and
120
+ `@experimental`.
121
+
122
+ [TSDoc: @beta][10]
123
+
124
+ [1]: ../reference/cli.md#--tags
125
+ [2]: ./configuration.md#tags
126
+ [3]: ./cli.md#--include-entry-exports
127
+ [4]: https://jsdoc.app/tags-public.html
128
+ [5]: https://tsdoc.org/pages/tags/public/
129
+ [6]: ../features/production-mode.md
130
+ [7]: https://tsdoc.org/pages/tags/internal/
131
+ [8]: https://jsdoc.app/tags-alias.html
132
+ [9]: #public
133
+ [10]: https://tsdoc.org/pages/tags/beta/
@@ -0,0 +1,86 @@
1
+ ---
2
+ title: Known Issues
3
+ ---
4
+
5
+ List of known issues and workarounds for exceptions thrown during a Knip run.
6
+
7
+ See [handling issues][1] to learn more about dealing with lint issues.
8
+
9
+ ## Exceptions from config files
10
+
11
+ An exception may be thrown when a Knip plugin loads a JavaScript or TypeScript
12
+ configuration file such as `webpack.config.js` or `vite.config.ts`:
13
+
14
+ ```sh
15
+ $ knip
16
+ Error loading .../vite.config.ts
17
+ ```
18
+
19
+ Knip may load such files differently, in a different environment, with missing
20
+ environment variables, missing path aliases, etcetera. Use `--debug` to locate
21
+ the cause of the issue with more details.
22
+
23
+ Potential workarounds:
24
+
25
+ - [Set path aliases][2] for "Cannot find module" errors
26
+ - Set missing environment variable(s), potential solutions:
27
+ - Use a helper package like [dotenvx][3]
28
+ - `KEY=VAL knip`
29
+ - `node --env-file .env $(which knip)`
30
+ - Disable loading the file by overriding the default `config` for that plugin.
31
+ - Example: `vite: { config: [] }`
32
+ - In a monorepo, be more specific like so:
33
+ `workspaces: { "packages/lib": { vite: { config: [] } } }`
34
+ - If this helps, add the file as an `entry` file for static analysis.
35
+ - Disable the related plugin.
36
+ - Example: `eslint: false`
37
+ - In a monorepo, be more specific like so:
38
+ `workspaces: { "packages/lib": { eslint: false } }`
39
+ - If this helps, add the file as an `entry` file for static analysis.
40
+ - As a last resort, ignore the workspace: `ignoreWorkspaces: ["packages/lib"]`.
41
+
42
+ ## Path aliases in config files
43
+
44
+ Loading the configuration file (e.g. `cypress.config.ts`) for one of Knip's
45
+ plugins may give an error:
46
+
47
+ ```sh
48
+ $ knip
49
+ Analyzing workspace ....
50
+ Error loading .../cypress.config.ts
51
+ Reason: Cannot find module '@alias/name'
52
+ Require stack:
53
+ - .../cypress.config.ts
54
+ ```
55
+
56
+ Some tools (such as Cypress and Jest) support using TypeScript path aliases in
57
+ the configuration file.
58
+
59
+ Potential workarounds:
60
+
61
+ - Rewrite the import in the configuration file to a relative import.
62
+ - Inject support with a module like `tsx`: `NODE_OPTIONS="--import tsx" knip`
63
+ - Or `tsconfig-paths`: `NODE_OPTIONS="--import tsconfig-paths/register.js" knip`
64
+ - Use Bun with [knip-bun][4].
65
+ - See [exceptions from config files][5] for more potential workarounds.
66
+
67
+ ## Nx Daemon
68
+
69
+ In Nx projects you might encounter this error:
70
+
71
+ ```sh
72
+ NX Daemon process terminated and closed the connection
73
+ ```
74
+
75
+ The solution is to [disable the Nx Daemon][6]:
76
+
77
+ ```sh
78
+ NX_DAEMON=false knip
79
+ ```
80
+
81
+ [1]: ../guides/handling-issues.mdx
82
+ [2]: #path-aliases-in-config-files
83
+ [3]: https://dotenvx.com/
84
+ [4]: ./cli.md#knip-bun
85
+ [5]: #exceptions-from-config-files
86
+ [6]: https://nx.dev/concepts/nx-daemon#turning-it-off
File without changes
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: Plugins (137)
3
+ tableOfContents: false
4
+ ---
5
+
6
+ :::section{.columns.min200}
7
+ - [Angular](/reference/plugins/angular "Angular")
8
+ - [Astro](/reference/plugins/astro "Astro")
9
+ - [Astro DB](/reference/plugins/astro-db "Astro DB")
10
+ - [astro-og-canvas](/reference/plugins/astro-og-canvas "astro-og-canvas")
11
+ - [Ava](/reference/plugins/ava "Ava")
12
+ - [Babel](/reference/plugins/babel "Babel")
13
+ - [Biome](/reference/plugins/biome "Biome")
14
+ - [bumpp](/reference/plugins/bumpp "bumpp")
15
+ - [Bun](/reference/plugins/bun "Bun")
16
+ - [c8](/reference/plugins/c8 "c8")
17
+ - [Capacitor](/reference/plugins/capacitor "Capacitor")
18
+ - [Changelogen](/reference/plugins/changelogen "Changelogen")
19
+ - [Changelogithub](/reference/plugins/changelogithub "Changelogithub")
20
+ - [Changesets](/reference/plugins/changesets "Changesets")
21
+ - [Commitizen](/reference/plugins/commitizen "Commitizen")
22
+ - [commitlint](/reference/plugins/commitlint "commitlint")
23
+ - [Convex](/reference/plugins/convex "Convex")
24
+ - [create-typescript-app](/reference/plugins/create-typescript-app "create-typescript-app")
25
+ - [CSpell](/reference/plugins/cspell "CSpell")
26
+ - [Cucumber](/reference/plugins/cucumber "Cucumber")
27
+ - [Cypress](/reference/plugins/cypress "Cypress")
28
+ - [Danger](/reference/plugins/danger "Danger")
29
+ - [dependency-cruiser](/reference/plugins/dependency-cruiser "dependency-cruiser")
30
+ - [Docusaurus](/reference/plugins/docusaurus "Docusaurus")
31
+ - [dotenv](/reference/plugins/dotenv "dotenv")
32
+ - [Drizzle](/reference/plugins/drizzle "Drizzle")
33
+ - [Eleventy](/reference/plugins/eleventy "Eleventy")
34
+ - [ESLint](/reference/plugins/eslint "ESLint")
35
+ - [execa](/reference/plugins/execa "execa")
36
+ - [Expo](/reference/plugins/expo "Expo")
37
+ - [Expressive Code](/reference/plugins/expressive-code "Expressive Code")
38
+ - [Gatsby](/reference/plugins/gatsby "Gatsby")
39
+ - [GitHub Action](/reference/plugins/github-action "GitHub Action")
40
+ - [GitHub Actions](/reference/plugins/github-actions "GitHub Actions")
41
+ - [glob](/reference/plugins/glob "glob")
42
+ - [GraphQL Codegen](/reference/plugins/graphql-codegen "GraphQL Codegen")
43
+ - [Hardhat](/reference/plugins/hardhat "Hardhat")
44
+ - [husky](/reference/plugins/husky "husky")
45
+ - [i18next Parser](/reference/plugins/i18next-parser "i18next Parser")
46
+ - [Jest](/reference/plugins/jest "Jest")
47
+ - [Karma](/reference/plugins/karma "Karma")
48
+ - [Knex](/reference/plugins/knex "Knex")
49
+ - [Ladle](/reference/plugins/ladle "Ladle")
50
+ - [Lefthook](/reference/plugins/lefthook "Lefthook")
51
+ - [lint-staged](/reference/plugins/lint-staged "lint-staged")
52
+ - [LintHTML](/reference/plugins/linthtml "LintHTML")
53
+ - [lockfile-lint](/reference/plugins/lockfile-lint "lockfile-lint")
54
+ - [Lost Pixel](/reference/plugins/lost-pixel "Lost Pixel")
55
+ - [markdownlint](/reference/plugins/markdownlint "markdownlint")
56
+ - [MDX](/reference/plugins/mdx "MDX")
57
+ - [mdxlint](/reference/plugins/mdxlint "mdxlint")
58
+ - [Metro](/reference/plugins/metro "Metro")
59
+ - [Mocha](/reference/plugins/mocha "Mocha")
60
+ - [moonrepo](/reference/plugins/moonrepo "moonrepo")
61
+ - [Mock Service Worker](/reference/plugins/msw "Mock Service Worker")
62
+ - [Nano Staged](/reference/plugins/nano-staged "Nano Staged")
63
+ - [Nest](/reference/plugins/nest "Nest")
64
+ - [Netlify](/reference/plugins/netlify "Netlify")
65
+ - [Next.js](/reference/plugins/next "Next.js")
66
+ - [next-intl](/reference/plugins/next-intl "next-intl")
67
+ - [Next.js MDX](/reference/plugins/next-mdx "Next.js MDX")
68
+ - [Nitro](/reference/plugins/nitro "Nitro")
69
+ - [Node.js](/reference/plugins/node "Node.js")
70
+ - [node-modules-inspector](/reference/plugins/node-modules-inspector "node-modules-inspector")
71
+ - [nodemon](/reference/plugins/nodemon "nodemon")
72
+ - [npm-package-json-lint](/reference/plugins/npm-package-json-lint "npm-package-json-lint")
73
+ - [Nuxt](/reference/plugins/nuxt "Nuxt")
74
+ - [Nx](/reference/plugins/nx "Nx")
75
+ - [nyc](/reference/plugins/nyc "nyc")
76
+ - [oclif](/reference/plugins/oclif "oclif")
77
+ - [Oxlint](/reference/plugins/oxlint "Oxlint")
78
+ - [Parcel](/reference/plugins/parcel "Parcel")
79
+ - [Payload CMS](/reference/plugins/payload "Payload CMS")
80
+ - [Playwright](/reference/plugins/playwright "Playwright")
81
+ - [Playwright for components](/reference/plugins/playwright-ct "Playwright for components")
82
+ - [playwright-test](/reference/plugins/playwright-test "playwright-test")
83
+ - [Plop](/reference/plugins/plop "Plop")
84
+ - [pm2](/reference/plugins/pm2 "pm2")
85
+ - [pnpm](/reference/plugins/pnpm "pnpm")
86
+ - [PostCSS](/reference/plugins/postcss "PostCSS")
87
+ - [Preconstruct](/reference/plugins/preconstruct "Preconstruct")
88
+ - [Prettier](/reference/plugins/prettier "Prettier")
89
+ - [Prisma](/reference/plugins/prisma "Prisma")
90
+ - [Qwik](/reference/plugins/qwik "Qwik")
91
+ - [React Cosmos](/reference/plugins/react-cosmos "React Cosmos")
92
+ - [React Native](/reference/plugins/react-native "React Native")
93
+ - [React Router](/reference/plugins/react-router "React Router")
94
+ - [Relay](/reference/plugins/relay "Relay")
95
+ - [Release It!](/reference/plugins/release-it "Release It!")
96
+ - [Remark](/reference/plugins/remark "Remark")
97
+ - [Remix](/reference/plugins/remix "Remix")
98
+ - [Rollup](/reference/plugins/rollup "Rollup")
99
+ - [Rsbuild](/reference/plugins/rsbuild "Rsbuild")
100
+ - [Rslib](/reference/plugins/rslib "Rslib")
101
+ - [Rspack](/reference/plugins/rspack "Rspack")
102
+ - [Rstest](/reference/plugins/rstest "Rstest")
103
+ - [Semantic Release](/reference/plugins/semantic-release "Semantic Release")
104
+ - [Sentry](/reference/plugins/sentry "Sentry")
105
+ - [simple-git-hooks](/reference/plugins/simple-git-hooks "simple-git-hooks")
106
+ - [size-limit](/reference/plugins/size-limit "size-limit")
107
+ - [SST](/reference/plugins/sst "SST")
108
+ - [Starlight](/reference/plugins/starlight "Starlight")
109
+ - [Storybook](/reference/plugins/storybook "Storybook")
110
+ - [Stryker](/reference/plugins/stryker "Stryker")
111
+ - [Stylelint](/reference/plugins/stylelint "Stylelint")
112
+ - [Svelte](/reference/plugins/svelte "Svelte")
113
+ - [SvelteKit](/reference/plugins/sveltekit "SvelteKit")
114
+ - [SVGO](/reference/plugins/svgo "SVGO")
115
+ - [SVGR](/reference/plugins/svgr "SVGR")
116
+ - [SWC](/reference/plugins/swc "SWC")
117
+ - [Syncpack](/reference/plugins/syncpack "Syncpack")
118
+ - [Tailwind](/reference/plugins/tailwind "Tailwind")
119
+ - [TanStack Router](/reference/plugins/tanstack-router "TanStack Router")
120
+ - [Taskfile](/reference/plugins/taskfile "Taskfile")
121
+ - [Travis CI](/reference/plugins/travis "Travis CI")
122
+ - [ts-node](/reference/plugins/ts-node "ts-node")
123
+ - [tsdown](/reference/plugins/tsdown "tsdown")
124
+ - [tsup](/reference/plugins/tsup "tsup")
125
+ - [tsx](/reference/plugins/tsx "tsx")
126
+ - [TypeDoc](/reference/plugins/typedoc "TypeDoc")
127
+ - [TypeScript](/reference/plugins/typescript "TypeScript")
128
+ - [unbuild](/reference/plugins/unbuild "unbuild")
129
+ - [UnoCSS](/reference/plugins/unocss "UnoCSS")
130
+ - [Vercel OG](/reference/plugins/vercel-og "Vercel OG")
131
+ - [Vike](/reference/plugins/vike "Vike")
132
+ - [Vite](/reference/plugins/vite "Vite")
133
+ - [VitePress](/reference/plugins/vitepress "VitePress")
134
+ - [Vitest](/reference/plugins/vitest "Vitest")
135
+ - [Vue](/reference/plugins/vue "Vue")
136
+ - [WebdriverIO](/reference/plugins/webdriver-io "WebdriverIO")
137
+ - [webpack](/reference/plugins/webpack "webpack")
138
+ - [Wireit](/reference/plugins/wireit "Wireit")
139
+ - [Wrangler](/reference/plugins/wrangler "Wrangler")
140
+ - [xo](/reference/plugins/xo "xo")
141
+ - [Yarn](/reference/plugins/yarn "Yarn")
142
+ - [yorkie](/reference/plugins/yorkie "yorkie")
143
+ - [zx](/reference/plugins/zx "zx")
144
+
145
+
146
+ :::
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Related Tooling
3
+ ---
4
+
5
+ This is an overview of related tooling for features Knip does not support.
6
+
7
+ ## Unused imports & variables
8
+
9
+ Knip doesn't look for unused imports and variables within a file. The focus is
10
+ on exported values and types across files.
11
+
12
+ Use [ESLint][1], [Biome][2] or [oxlint][3] to find unused variables within
13
+ files.
14
+
15
+ Use [remove-unused-vars][4] to remove unused code within files, but in a more
16
+ valiant way. Using input from any of the above linters, it actually removes a
17
+ lot more unused code. This pairs great with Knip.
18
+
19
+ ## Unused properties
20
+
21
+ Knip does not yet support finding unused members of types, interfaces and
22
+ objects. This includes returned objects from exported functions and objects
23
+ passed as React component props.
24
+
25
+ Knip does support finding unused members of enums and classes, and exported
26
+ values and types on imported namespaces.
27
+
28
+ ## Circular dependencies
29
+
30
+ Knip has no issues with circular dependencies, and does not report them. Tools
31
+ that do support this include [DPDM][5], [Madge][6] and [skott][7].
32
+
33
+ ## Cleanup
34
+
35
+ The [e18e.dev][8] website and in particular the [Cleanup][9] section is a great
36
+ resource when dealing with technical debt.
37
+
38
+ [1]: https://eslint.org
39
+ [2]: https://biomejs.dev/linter/
40
+ [3]: https://oxc.rs/docs/guide/usage/linter.html
41
+ [4]: https://github.com/webpro-nl/remove-unused-vars
42
+ [5]: https://github.com/acrazing/dpdm
43
+ [6]: https://github.com/pahen/madge
44
+ [7]: https://github.com/antoine-coulon/skott
45
+ [8]: https://e18e.dev
46
+ [9]: https://e18e.dev/guide/cleanup.html
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: 'Become a sponsor!'
3
+ template: splash
4
+ ---
5
+
6
+ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
7
+ import Posts from '../../components/Posts.astro';
8
+ import Projects from '../../components/Projects.astro';
9
+ import SponsorsComponent from '../../components/Sponsors.astro';
10
+ import SponsorsChart from '../../components/SponsorsChart.astro';
11
+
12
+ :::article{.prose}
13
+
14
+ Knip is a powerful tool that helps thousands of developers keep their JavaScript
15
+ and TypeScript projects lean and maintainable. Knip saves teams valuable time
16
+ and resources.
17
+
18
+ Building and maintaining Knip has been, and remains, a lot of work. Supportive
19
+ resources allow me to focus on maintenance and development of Knip, which is
20
+ [relied upon][1] [by many][2] in the JavaScript community. Please consider
21
+ supporting the project! The following platforms are available to support Knip:
22
+
23
+ - [GitHub Sponsors][3]
24
+ - [OpenCollective][4]
25
+
26
+ You or your company logo with a backlink to your website will be added to this
27
+ page if you decide to support the project on an ongoing basis. Eternal gratitude
28
+ to the companies and people supporting the project!
29
+
30
+ :::
31
+
32
+ <SponsorsComponent showAll={true} />
33
+
34
+ ## Monthly Overview
35
+
36
+ Overview of gross GitHub and OpenCollective sponsorships and invoices, starting
37
+ from the moment the project openly asked for support. Actual development started
38
+ one year before that.
39
+
40
+ <SponsorsChart />
41
+
42
+ - The monthly aggregated average over the charted period is $513.
43
+ - The monthly recurring average without one-time payments is $350.
44
+ - GitHub Sponsors is for my GitHub account. This has more repositories, but in
45
+ practice targets mostly Knip (and perhaps some [release-it][5]).
46
+ - [Chart generated][6] using [Venz][7].
47
+
48
+ ## Trusted by the world's best software teams
49
+
50
+ <section class="columns min300">
51
+ <Projects />
52
+ </section>
53
+
54
+ ## Don't just take our word for it
55
+
56
+ <Posts />
57
+
58
+ [1]: #trusted-by-the-worlds-best-software-teams
59
+ [2]: https://github.com/webpro-nl/knip/network/dependents
60
+ [3]: https://github.com/sponsors/webpro
61
+ [4]: https://opencollective.com/knip
62
+ [5]: https://github.com/release-it/release-it
63
+ [6]: https://try.venz.dev?type=pivot&lp=tr&br=0&labelX=month&labelY=amount+\($\)&l=GitHub+Sponsors&color=%23fbfbfb&l=Open+Collective&color=%232487ff&label=2023-11&data=9,0&label=2023-12&data=74,0&label=2024-01&data=239,0&label=2024-02&data=489,0&label=2024-03&data=189,0&label=2024-04&data=204,750&label=2024-05&data=304,101&label=2024-06&data=1204,0&label=2024-07&data=204,35&label=2024-08&data=229,25&label=2024-09&data=2729,25&label=2024-10&data=410,45&label=2024-11&data=222,45&label=2024-12&data=222,145&label=2025-01&data=342,145&label=2025-02&data=244,145&label=2025-03&data=222,145&label=2025-04&data=222,145&label=2025-05&data=242,145&label=2025-06&data=247,145&label=2025-07&data=297,145&label=2025-08&data=268,145&label=2025-09&data=350,145&label=2025-10&data=375,145&label=2025-11&data=549,145&label=2025-12&data=355,145
64
+ [7]: https://try.venz.dev
@@ -0,0 +1,86 @@
1
+ ---
2
+ title: Unused dependencies
3
+ description: Find and remove unused dependencies with Knip
4
+ prev: false
5
+ next: false
6
+ ---
7
+
8
+ One of Knip's core features is finding unused dependencies in your JavaScript
9
+ and TypeScript projects. And it comes with many more features to remove clutter
10
+ and keep your projects in great shape.
11
+
12
+ ## Why are unused dependencies a problem?
13
+
14
+ Having unused dependencies in your `package.json` is an issue for various
15
+ reasons:
16
+
17
+ - They might end up in the final production bundle, increasing size and load
18
+ times for end users.
19
+ - They waste space in `node_modules` and add to the installation time of the
20
+ project.
21
+ - They slow down tooling such as linters and bundlers that analyze dependencies.
22
+ - They are confusing and noisy in `package.json`.
23
+ - They cause unnecessary extra work when managing and upgrading dependencies.
24
+ - They can cause version conflicts with other dependencies in use.
25
+ - They can cause false security alerts.
26
+ - They might have restrictive licenses and make your project subject to theirs.
27
+ - They usually come with transitive dependencies that have the same issues.
28
+
29
+ ## How do I find unused dependencies?
30
+
31
+ Use Knip to find and remove unused dependencies. It also finds dependencies that
32
+ are missing in `package.json` and has a lot more features to keep your
33
+ JavaScript and TypeScript projects tidy.
34
+
35
+ It's easy to [get started][1] and make package management easier and more fun!
36
+
37
+ <div style="display: flex; justify-content: center; margin: 4rem auto;">
38
+ <img src="/logo.svg" alt="Logo of Knip, to find unused dependencies, exports and files" class="logo-border" />
39
+ </div>
40
+
41
+ ## How does Knip identify unused dependencies?
42
+
43
+ Knip works by analyzing `package.json` files, source code and configuration
44
+ files for other tooling in the project to find unused and missing dependencies.
45
+ Knip has many heuristics, [plugins][2] and [compilers][3] to fully automate the
46
+ process.
47
+
48
+ ## Can Knip remove unused dependencies?
49
+
50
+ Yes, Knip can automatically remove unused dependencies installed by a package
51
+ manager like npm or pnpm for you. Add the `--fix` argument to [auto-fix][4] and
52
+ remove unused dependencies from `package.json`.
53
+
54
+ ## Can Knip detect missing dependencies?
55
+
56
+ Yes, Knip detects missing dependencies. It analyzes `package.json` files, and
57
+ reports packages that are missing. They should be added to `package.json` to
58
+ avoid relying on transitive dependencies that can cause version mismatches and
59
+ breakage.
60
+
61
+ ## Does Knip work with monorepos?
62
+
63
+ Yes, Knip has first-class support for [monorepos and workspaces][5]. It analyzes
64
+ all workspaces in the project and understands their relationship.
65
+
66
+ For instance, if a dependency is listed in the root `package.json` it does not
67
+ need to be listed in other workspaces. Except if you enable `--strict` checking.
68
+
69
+ ## Does Knip separate dependencies and devDependencies?
70
+
71
+ Yes, Knip understands the difference between dependencies and devDependencies.
72
+ It has a [production mode][6] to focus on production code only and find dead
73
+ code and dependencies that would otherwise only be referenced by tests and other
74
+ tooling. This allows you to remove both unused exported code and their tests.
75
+
76
+ ## Does Knip work with my package manager?
77
+
78
+ Yes, Knip works with any package manager: npm, pnpm, Bun and Yarn are all
79
+ supported. It's easy to [get started][1] with any package manager.
80
+
81
+ [1]: ../overview/getting-started.mdx
82
+ [2]: ../reference/plugins.md
83
+ [3]: ../features/compilers.md
84
+ [4]: ../features/auto-fix.mdx
85
+ [5]: ../features/monorepos-and-workspaces.md
86
+ [6]: ../features/production-mode.md
@@ -0,0 +1,87 @@
1
+ ---
2
+ title: Unused exports
3
+ description: Find and remove unused exports with Knip
4
+ prev: false
5
+ next: false
6
+ ---
7
+
8
+ Finding unused exports in your JavaScript and TypeScript projects is one of
9
+ Knip's core features. And it comes with even more features to identify and
10
+ remove clutter to keep your projects in great shape.
11
+
12
+ ## Why are unused exports a problem?
13
+
14
+ Having unused exports in your codebase is problematic for several reasons:
15
+
16
+ - They increase bundle sizes if not properly eliminated by tree-shaking.
17
+ - They clutter the codebase and make it harder to navigate and understand.
18
+ - They mislead developers into thinking certain code is used when it's not.
19
+ - They make refactoring and maintaining the codebase more difficult.
20
+ - They slow down tooling that analyze the codebase, such as bundlers, linters
21
+ and type checkers.
22
+ - They may represent dead code that is no longer needed but hasn't been cleaned
23
+ up.
24
+
25
+ ## How do I find unused exports?
26
+
27
+ Knip is a powerful tool that can help you find and remove unused exports in your
28
+ JavaScript and TypeScript projects. It analyzes the codebase, identifies exports
29
+ that are not imported anywhere, and reports them.
30
+
31
+ [Get started and install Knip][1] to run it on your project. Knip will scan your
32
+ files and provide a detailed report of unused exports, and much more.
33
+
34
+ <div style="display: flex; justify-content: center; margin: 4rem auto;">
35
+ <img src="/logo.svg" alt="Logo of Knip, to find unused dependencies, exports and files" class="logo-border" />
36
+ </div>
37
+
38
+ ## How does Knip identify unused exports?
39
+
40
+ Knip performs both static and dynamic analysis to determine which exports are
41
+ actually being used in your codebase. It looks at import statements, export
42
+ usage, and [a lot more code patterns][2] to identify unused exports.
43
+
44
+ Knip supports JavaScript and TypeScript projects, and handles both [CommonJS][3]
45
+ and ES Modules syntax.
46
+
47
+ ## Can Knip remove unused exports?
48
+
49
+ Yes, Knip not only finds unused exports but can also remove them for you. Run
50
+ Knip with the `--fix` flag to enable [the auto-fix feature][4], and it will
51
+ modify your source code and remove the unused exports.
52
+
53
+ It's always recommended to review the changes made by Knip before committing
54
+ them to ensure no unintended modifications were made.
55
+
56
+ ## Can Knip handle large codebases?
57
+
58
+ Absolutely. Knip supports [monorepos with workspaces][5] and utilizes [workspace
59
+ sharing][6] to efficiently analyze large monorepos. This makes it easier and
60
+ more fun to manage and optimize large multi-package projects.
61
+
62
+ ## Does Knip work with my favorite editor or IDE?
63
+
64
+ Knip is a command-line tool that runs independently of your editor or IDE.
65
+ However, if you run Knip inside an integrated IDE terminal, the report contains
66
+ file names and positions in a format IDEs like VS Code and WebStorm understand
67
+ to easily navigate around.
68
+
69
+ ## How is Knip different from ESLint for finding unused exports?
70
+
71
+ While linters like ESLint can find unused imports and variables within
72
+ individual files, Knip analyzes the entire project to determine which exports
73
+ are actually unused. By building [a comprehensive module graph][7], Knip
74
+ identifies exports that are not imported or used anywhere in the codebase. This
75
+ allows Knip to catch unused exports and dead code that ESLint and other linters
76
+ would miss.
77
+
78
+ Also see [Why isn't Knip an ESLint plugin?][8]
79
+
80
+ [1]: ../overview/getting-started.mdx
81
+ [2]: ../reference/faq.md#what-does-knip-look-for-in-source-files
82
+ [3]: ../guides/working-with-commonjs.md
83
+ [4]: ../features/auto-fix.mdx
84
+ [5]: ../features/monorepos-and-workspaces.md
85
+ [6]: ../guides/performance.md#workspace-sharing
86
+ [7]: ../reference/faq.md#whats-in-the-graphs
87
+ [8]: ../reference/faq.md#why-isnt-knip-an-eslint-plugin