@knip/mcp 0.0.19 → 0.0.20

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 (70) hide show
  1. package/package.json +16 -16
  2. package/src/docs/blog/knip-v3.mdx +1 -1
  3. package/src/docs/blog/knip-v4.mdx +1 -1
  4. package/src/docs/explanations/comparison-and-migration.md +2 -0
  5. package/src/docs/explanations/plugins.md +22 -4
  6. package/src/docs/features/auto-fix.mdx +2 -2
  7. package/src/docs/guides/handling-issues.mdx +1 -1
  8. package/src/docs/guides/issue-reproduction.md +7 -6
  9. package/src/docs/guides/performance.md +1 -1
  10. package/src/docs/overview/features.md +1 -1
  11. package/src/docs/reference/faq.md +101 -38
  12. package/src/docs/reference/jsdoc-tsdoc-tags.md +12 -1
  13. package/src/docs/reference/plugins.md +7 -1
  14. package/src/docs/writing-a-plugin/index.md +1 -1
  15. package/src/docs/docs/blog/brief-history.md +0 -30
  16. package/src/docs/docs/blog/for-editors-and-agents.md +0 -131
  17. package/src/docs/docs/blog/knip-v3.mdx +0 -88
  18. package/src/docs/docs/blog/knip-v4.mdx +0 -149
  19. package/src/docs/docs/blog/knip-v5.mdx +0 -190
  20. package/src/docs/docs/blog/migration-to-v1.md +0 -65
  21. package/src/docs/docs/blog/release-notes-v2.md +0 -46
  22. package/src/docs/docs/blog/slim-down-to-speed-up.md +0 -269
  23. package/src/docs/docs/blog/state-of-knip.md +0 -191
  24. package/src/docs/docs/blog/two-years.mdx +0 -107
  25. package/src/docs/docs/explanations/comparison-and-migration.md +0 -133
  26. package/src/docs/docs/explanations/entry-files.md +0 -70
  27. package/src/docs/docs/explanations/plugins.md +0 -347
  28. package/src/docs/docs/explanations/why-use-knip.md +0 -128
  29. package/src/docs/docs/features/auto-fix.mdx +0 -348
  30. package/src/docs/docs/features/compilers.md +0 -172
  31. package/src/docs/docs/features/integrated-monorepos.md +0 -61
  32. package/src/docs/docs/features/monorepos-and-workspaces.md +0 -149
  33. package/src/docs/docs/features/production-mode.md +0 -95
  34. package/src/docs/docs/features/reporters.md +0 -304
  35. package/src/docs/docs/features/rules-and-filters.md +0 -102
  36. package/src/docs/docs/features/script-parser.md +0 -156
  37. package/src/docs/docs/features/source-mapping.md +0 -100
  38. package/src/docs/docs/guides/configuring-project-files.md +0 -205
  39. package/src/docs/docs/guides/contributing.md +0 -24
  40. package/src/docs/docs/guides/handling-issues.mdx +0 -708
  41. package/src/docs/docs/guides/issue-reproduction.md +0 -103
  42. package/src/docs/docs/guides/namespace-imports.md +0 -125
  43. package/src/docs/docs/guides/performance.md +0 -108
  44. package/src/docs/docs/guides/troubleshooting.md +0 -133
  45. package/src/docs/docs/guides/using-knip-in-ci.md +0 -50
  46. package/src/docs/docs/guides/working-with-commonjs.md +0 -72
  47. package/src/docs/docs/index.mdx +0 -160
  48. package/src/docs/docs/overview/configuration.md +0 -104
  49. package/src/docs/docs/overview/features.md +0 -66
  50. package/src/docs/docs/overview/getting-started.mdx +0 -205
  51. package/src/docs/docs/overview/screenshots-videos.md +0 -42
  52. package/src/docs/docs/playground.mdx +0 -38
  53. package/src/docs/docs/reference/cli.md +0 -511
  54. package/src/docs/docs/reference/configuration-hints.md +0 -146
  55. package/src/docs/docs/reference/configuration.md +0 -430
  56. package/src/docs/docs/reference/dynamic-configuration.mdx +0 -72
  57. package/src/docs/docs/reference/faq.md +0 -430
  58. package/src/docs/docs/reference/integrations.md +0 -105
  59. package/src/docs/docs/reference/issue-types.md +0 -43
  60. package/src/docs/docs/reference/jsdoc-tsdoc-tags.md +0 -122
  61. package/src/docs/docs/reference/known-issues.md +0 -86
  62. package/src/docs/docs/reference/plugins/.gitkeep +0 -0
  63. package/src/docs/docs/reference/plugins.md +0 -140
  64. package/src/docs/docs/reference/related-tooling.md +0 -46
  65. package/src/docs/docs/sponsors.mdx +0 -64
  66. package/src/docs/docs/typescript/unused-dependencies.md +0 -86
  67. package/src/docs/docs/typescript/unused-exports.md +0 -87
  68. package/src/docs/docs/writing-a-plugin/argument-parsing.md +0 -202
  69. package/src/docs/docs/writing-a-plugin/index.md +0 -392
  70. package/src/docs/docs/writing-a-plugin/inputs.md +0 -162
@@ -1,86 +0,0 @@
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
@@ -1,140 +0,0 @@
1
- ---
2
- title: Plugins (131)
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
- - [Expo](/reference/plugins/expo "Expo")
36
- - [Expressive Code](/reference/plugins/expressive-code "Expressive Code")
37
- - [Gatsby](/reference/plugins/gatsby "Gatsby")
38
- - [GitHub Action](/reference/plugins/github-action "GitHub Action")
39
- - [GitHub Actions](/reference/plugins/github-actions "GitHub Actions")
40
- - [glob](/reference/plugins/glob "glob")
41
- - [GraphQL Codegen](/reference/plugins/graphql-codegen "GraphQL Codegen")
42
- - [Hardhat](/reference/plugins/hardhat "Hardhat")
43
- - [husky](/reference/plugins/husky "husky")
44
- - [i18next Parser](/reference/plugins/i18next-parser "i18next Parser")
45
- - [Jest](/reference/plugins/jest "Jest")
46
- - [Karma](/reference/plugins/karma "Karma")
47
- - [Knex](/reference/plugins/knex "Knex")
48
- - [Ladle](/reference/plugins/ladle "Ladle")
49
- - [Lefthook](/reference/plugins/lefthook "Lefthook")
50
- - [lint-staged](/reference/plugins/lint-staged "lint-staged")
51
- - [LintHTML](/reference/plugins/linthtml "LintHTML")
52
- - [lockfile-lint](/reference/plugins/lockfile-lint "lockfile-lint")
53
- - [Lost Pixel](/reference/plugins/lost-pixel "Lost Pixel")
54
- - [markdownlint](/reference/plugins/markdownlint "markdownlint")
55
- - [MDX](/reference/plugins/mdx "MDX")
56
- - [mdxlint](/reference/plugins/mdxlint "mdxlint")
57
- - [Metro](/reference/plugins/metro "Metro")
58
- - [Mocha](/reference/plugins/mocha "Mocha")
59
- - [moonrepo](/reference/plugins/moonrepo "moonrepo")
60
- - [Mock Service Worker](/reference/plugins/msw "Mock Service Worker")
61
- - [Nano Staged](/reference/plugins/nano-staged "Nano Staged")
62
- - [Nest](/reference/plugins/nest "Nest")
63
- - [Netlify](/reference/plugins/netlify "Netlify")
64
- - [Next.js](/reference/plugins/next "Next.js")
65
- - [next-intl](/reference/plugins/next-intl "next-intl")
66
- - [Next.js MDX](/reference/plugins/next-mdx "Next.js MDX")
67
- - [Nitro](/reference/plugins/nitro "Nitro")
68
- - [Node.js](/reference/plugins/node "Node.js")
69
- - [node-modules-inspector](/reference/plugins/node-modules-inspector "node-modules-inspector")
70
- - [nodemon](/reference/plugins/nodemon "nodemon")
71
- - [npm-package-json-lint](/reference/plugins/npm-package-json-lint "npm-package-json-lint")
72
- - [Nuxt](/reference/plugins/nuxt "Nuxt")
73
- - [Nx](/reference/plugins/nx "Nx")
74
- - [nyc](/reference/plugins/nyc "nyc")
75
- - [oclif](/reference/plugins/oclif "oclif")
76
- - [Oxlint](/reference/plugins/oxlint "Oxlint")
77
- - [Parcel](/reference/plugins/parcel "Parcel")
78
- - [Playwright](/reference/plugins/playwright "Playwright")
79
- - [Playwright for components](/reference/plugins/playwright-ct "Playwright for components")
80
- - [playwright-test](/reference/plugins/playwright-test "playwright-test")
81
- - [Plop](/reference/plugins/plop "Plop")
82
- - [pnpm](/reference/plugins/pnpm "pnpm")
83
- - [PostCSS](/reference/plugins/postcss "PostCSS")
84
- - [Preconstruct](/reference/plugins/preconstruct "Preconstruct")
85
- - [Prettier](/reference/plugins/prettier "Prettier")
86
- - [Prisma](/reference/plugins/prisma "Prisma")
87
- - [React Cosmos](/reference/plugins/react-cosmos "React Cosmos")
88
- - [React Router](/reference/plugins/react-router "React Router")
89
- - [Relay](/reference/plugins/relay "Relay")
90
- - [Release It!](/reference/plugins/release-it "Release It!")
91
- - [Remark](/reference/plugins/remark "Remark")
92
- - [Remix](/reference/plugins/remix "Remix")
93
- - [Rollup](/reference/plugins/rollup "Rollup")
94
- - [Rsbuild](/reference/plugins/rsbuild "Rsbuild")
95
- - [Rslib](/reference/plugins/rslib "Rslib")
96
- - [Rspack](/reference/plugins/rspack "Rspack")
97
- - [Rstest](/reference/plugins/rstest "Rstest")
98
- - [Semantic Release](/reference/plugins/semantic-release "Semantic Release")
99
- - [Sentry](/reference/plugins/sentry "Sentry")
100
- - [simple-git-hooks](/reference/plugins/simple-git-hooks "simple-git-hooks")
101
- - [size-limit](/reference/plugins/size-limit "size-limit")
102
- - [SST](/reference/plugins/sst "SST")
103
- - [Starlight](/reference/plugins/starlight "Starlight")
104
- - [Storybook](/reference/plugins/storybook "Storybook")
105
- - [Stryker](/reference/plugins/stryker "Stryker")
106
- - [Stylelint](/reference/plugins/stylelint "Stylelint")
107
- - [Svelte](/reference/plugins/svelte "Svelte")
108
- - [SvelteKit](/reference/plugins/sveltekit "SvelteKit")
109
- - [SVGO](/reference/plugins/svgo "SVGO")
110
- - [SVGR](/reference/plugins/svgr "SVGR")
111
- - [SWC](/reference/plugins/swc "SWC")
112
- - [Syncpack](/reference/plugins/syncpack "Syncpack")
113
- - [Tailwind](/reference/plugins/tailwind "Tailwind")
114
- - [TanStack Router](/reference/plugins/tanstack-router "TanStack Router")
115
- - [Taskfile](/reference/plugins/taskfile "Taskfile")
116
- - [Travis CI](/reference/plugins/travis "Travis CI")
117
- - [ts-node](/reference/plugins/ts-node "ts-node")
118
- - [tsdown](/reference/plugins/tsdown "tsdown")
119
- - [tsup](/reference/plugins/tsup "tsup")
120
- - [tsx](/reference/plugins/tsx "tsx")
121
- - [TypeDoc](/reference/plugins/typedoc "TypeDoc")
122
- - [TypeScript](/reference/plugins/typescript "TypeScript")
123
- - [unbuild](/reference/plugins/unbuild "unbuild")
124
- - [UnoCSS](/reference/plugins/unocss "UnoCSS")
125
- - [Vercel OG](/reference/plugins/vercel-og "Vercel OG")
126
- - [Vike](/reference/plugins/vike "Vike")
127
- - [Vite](/reference/plugins/vite "Vite")
128
- - [VitePress](/reference/plugins/vitepress "VitePress")
129
- - [Vitest](/reference/plugins/vitest "Vitest")
130
- - [Vue](/reference/plugins/vue "Vue")
131
- - [WebdriverIO](/reference/plugins/webdriver-io "WebdriverIO")
132
- - [webpack](/reference/plugins/webpack "webpack")
133
- - [Wireit](/reference/plugins/wireit "Wireit")
134
- - [Wrangler](/reference/plugins/wrangler "Wrangler")
135
- - [xo](/reference/plugins/xo "xo")
136
- - [Yarn](/reference/plugins/yarn "Yarn")
137
- - [yorkie](/reference/plugins/yorkie "yorkie")
138
-
139
-
140
- :::
@@ -1,46 +0,0 @@
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
@@ -1,64 +0,0 @@
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
@@ -1,86 +0,0 @@
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
@@ -1,87 +0,0 @@
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