knip 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (654) hide show
  1. package/README.md +134 -145
  2. package/dist/binaries/bash-parser.d.ts +6 -0
  3. package/dist/binaries/bash-parser.js +57 -0
  4. package/dist/binaries/index.d.ts +2 -0
  5. package/dist/binaries/index.js +22 -0
  6. package/dist/binaries/resolvers/fallback.d.ts +2 -0
  7. package/dist/binaries/resolvers/fallback.js +14 -0
  8. package/dist/binaries/resolvers/index.d.ts +4 -0
  9. package/dist/binaries/resolvers/index.js +4 -0
  10. package/dist/binaries/resolvers/node.d.ts +3 -0
  11. package/dist/binaries/resolvers/node.js +20 -0
  12. package/dist/binaries/resolvers/npx.d.ts +2 -0
  13. package/dist/binaries/resolvers/npx.js +5 -0
  14. package/dist/binaries/resolvers/pnpm.d.ts +2 -0
  15. package/dist/binaries/resolvers/pnpm.js +45 -0
  16. package/dist/binaries/resolvers/yarn.d.ts +2 -0
  17. package/dist/binaries/resolvers/yarn.js +46 -0
  18. package/dist/binaries/types.d.ts +18 -0
  19. package/dist/binaries/types.js +1 -0
  20. package/dist/cli.js +2 -3
  21. package/dist/commonjs.test.d.ts +1 -0
  22. package/dist/commonjs.test.js +29 -0
  23. package/dist/compilers.test.d.ts +1 -0
  24. package/dist/compilers.test.js +18 -0
  25. package/dist/configuration-chief.d.ts +7 -12
  26. package/dist/configuration-chief.js +25 -23
  27. package/dist/console-streamer.d.ts +12 -0
  28. package/dist/console-streamer.js +34 -0
  29. package/dist/constants.js +6 -2
  30. package/dist/definitely-typed.test.d.ts +1 -0
  31. package/dist/definitely-typed.test.js +35 -0
  32. package/dist/dependencies.test.d.ts +1 -0
  33. package/dist/dependencies.test.js +76 -0
  34. package/dist/dependency-deputy.d.ts +2 -8
  35. package/dist/dependency-deputy.js +21 -17
  36. package/dist/entry-js.test.d.ts +1 -0
  37. package/dist/entry-js.test.js +38 -0
  38. package/dist/exports.test.d.ts +1 -0
  39. package/dist/exports.test.js +48 -0
  40. package/dist/fixtures/binaries/dir/index.d.ts +1 -0
  41. package/dist/fixtures/binaries/dir/index.js +1 -0
  42. package/dist/fixtures/binaries/main.d.ts +1 -0
  43. package/dist/fixtures/binaries/main.js +1 -0
  44. package/dist/fixtures/binaries/require.d.ts +1 -0
  45. package/dist/fixtures/binaries/require.js +1 -0
  46. package/dist/fixtures/binaries/script.d.ts +1 -0
  47. package/dist/fixtures/binaries/script.js +1 -0
  48. package/dist/fixtures/commonjs/dir/mod.d.ts +1 -0
  49. package/dist/fixtures/commonjs/dir/mod.js +5 -0
  50. package/dist/fixtures/commonjs/dir/mod1.d.ts +7 -0
  51. package/dist/fixtures/commonjs/dir/mod1.js +5 -0
  52. package/dist/fixtures/commonjs/dir/mod2.d.ts +4 -0
  53. package/dist/fixtures/commonjs/dir/mod2.js +4 -0
  54. package/dist/fixtures/commonjs/dir/mod3.d.ts +2 -0
  55. package/dist/fixtures/commonjs/dir/mod3.js +4 -0
  56. package/dist/fixtures/commonjs/export-is.d.ts +2 -0
  57. package/dist/fixtures/commonjs/export-is.js +2 -0
  58. package/dist/fixtures/commonjs/index.d.ts +1 -0
  59. package/dist/fixtures/commonjs/index.js +31 -0
  60. package/dist/fixtures/commonjs/odd.d.ts +1 -0
  61. package/dist/fixtures/commonjs/odd.js +7 -0
  62. package/dist/fixtures/compilers/component.d.ts +2 -0
  63. package/dist/fixtures/compilers/component.jsx +1 -0
  64. package/dist/fixtures/compilers/index.d.ts +1 -0
  65. package/dist/fixtures/compilers/index.js +1 -0
  66. package/dist/fixtures/compilers/knip.d.ts +0 -0
  67. package/dist/fixtures/compilers/knip.js +7 -0
  68. package/dist/fixtures/definitely-typed/index.d.ts +1 -0
  69. package/dist/fixtures/definitely-typed/index.js +1 -0
  70. package/dist/fixtures/dependencies/entry.d.ts +1 -0
  71. package/dist/fixtures/dependencies/entry.js +6 -0
  72. package/dist/fixtures/dependencies/my-module.d.ts +3 -0
  73. package/dist/fixtures/dependencies/my-module.js +6 -0
  74. package/dist/fixtures/dependencies/unused-module.d.ts +1 -0
  75. package/dist/fixtures/dependencies/unused-module.js +6 -0
  76. package/dist/fixtures/entry-js/dangling.d.ts +1 -0
  77. package/dist/fixtures/entry-js/dangling.js +1 -0
  78. package/dist/fixtures/entry-js/index.d.ts +1 -0
  79. package/dist/fixtures/entry-js/index.js +2 -0
  80. package/dist/fixtures/entry-js/my-module.d.ts +4 -0
  81. package/dist/fixtures/entry-js/my-module.js +6 -0
  82. package/dist/fixtures/entry-js/my-namespace.d.ts +5 -0
  83. package/dist/fixtures/entry-js/my-namespace.js +3 -0
  84. package/dist/fixtures/exports/dangling.d.ts +1 -0
  85. package/dist/fixtures/exports/dangling.js +1 -0
  86. package/dist/fixtures/exports/default-arrow-function.d.ts +2 -0
  87. package/dist/fixtures/exports/default-arrow-function.js +1 -0
  88. package/dist/fixtures/exports/default-class.d.ts +2 -0
  89. package/dist/fixtures/exports/default-class.js +2 -0
  90. package/dist/fixtures/exports/default-function.d.ts +1 -0
  91. package/dist/fixtures/exports/default-function.js +1 -0
  92. package/dist/fixtures/exports/default-generator-function.d.ts +1 -0
  93. package/dist/fixtures/exports/default-generator-function.js +1 -0
  94. package/dist/fixtures/exports/default-named-class.d.ts +2 -0
  95. package/dist/fixtures/exports/default-named-class.js +2 -0
  96. package/dist/fixtures/exports/default-named-function.d.ts +1 -0
  97. package/dist/fixtures/exports/default-named-function.js +1 -0
  98. package/dist/fixtures/exports/default-named-generator-function.d.ts +1 -0
  99. package/dist/fixtures/exports/default-named-generator-function.js +1 -0
  100. package/dist/fixtures/exports/default.d.ts +3 -0
  101. package/dist/fixtures/exports/default.js +2 -0
  102. package/dist/fixtures/exports/dynamic-import.d.ts +4 -0
  103. package/dist/fixtures/exports/dynamic-import.js +3 -0
  104. package/dist/fixtures/exports/index.d.ts +2 -0
  105. package/dist/fixtures/exports/index.js +6 -0
  106. package/dist/fixtures/exports/my-module.d.ts +5 -0
  107. package/dist/fixtures/exports/my-module.js +7 -0
  108. package/dist/fixtures/exports/my-namespace.d.ts +5 -0
  109. package/dist/fixtures/exports/my-namespace.js +3 -0
  110. package/dist/fixtures/exports/named.d.ts +11 -0
  111. package/dist/fixtures/exports/named.js +11 -0
  112. package/dist/fixtures/exports/types.d.ts +9 -0
  113. package/dist/fixtures/exports/types.js +3 -0
  114. package/dist/fixtures/gitignore/packages/a/build/dist.d.ts +2 -0
  115. package/dist/fixtures/gitignore/packages/a/build/dist.js +1 -0
  116. package/dist/fixtures/gitignore/packages/a/dist.d.ts +1 -0
  117. package/dist/fixtures/gitignore/packages/a/dist.js +1 -0
  118. package/dist/fixtures/gitignore/packages/a/index.d.ts +1 -0
  119. package/dist/fixtures/gitignore/packages/a/index.js +1 -0
  120. package/dist/fixtures/imports/dir/import-b.d.ts +2 -0
  121. package/dist/fixtures/imports/dir/import-b.js +1 -0
  122. package/dist/fixtures/imports/dir/mod.d.ts +1 -0
  123. package/dist/fixtures/imports/dir/mod.js +1 -0
  124. package/dist/fixtures/imports/index.d.ts +1 -0
  125. package/dist/fixtures/imports/index.js +35 -0
  126. package/dist/fixtures/js-only/dangling.d.ts +1 -0
  127. package/dist/fixtures/js-only/dangling.js +1 -0
  128. package/dist/fixtures/js-only/index.d.ts +1 -0
  129. package/dist/fixtures/js-only/index.js +2 -0
  130. package/dist/fixtures/js-only/my-namespace.d.ts +3 -0
  131. package/dist/fixtures/js-only/my-namespace.js +3 -0
  132. package/dist/fixtures/jsdoc/index.d.ts +4 -0
  133. package/dist/fixtures/jsdoc/index.js +8 -0
  134. package/dist/fixtures/members/index.d.ts +1 -0
  135. package/dist/fixtures/members/index.js +16 -0
  136. package/dist/fixtures/members/members.d.ts +23 -0
  137. package/dist/fixtures/members/members.js +38 -0
  138. package/dist/fixtures/namespace/index.d.ts +1 -0
  139. package/dist/fixtures/namespace/index.js +5 -0
  140. package/dist/fixtures/namespace/namespace.d.ts +3 -0
  141. package/dist/fixtures/namespace/namespace.js +3 -0
  142. package/dist/fixtures/namespace/re-exported-module.d.ts +2 -0
  143. package/dist/fixtures/namespace/re-exported-module.js +2 -0
  144. package/dist/fixtures/pathless/src/dir/module-a.d.ts +2 -0
  145. package/dist/fixtures/pathless/src/dir/module-a.js +1 -0
  146. package/dist/fixtures/pathless/src/index.d.ts +2 -0
  147. package/dist/fixtures/pathless/src/index.js +2 -0
  148. package/dist/fixtures/pathless/src/same.d.ts +2 -0
  149. package/dist/fixtures/pathless/src/same.js +1 -0
  150. package/dist/fixtures/paths-knip-config/abc/main.d.ts +0 -0
  151. package/dist/fixtures/paths-knip-config/abc/main.js +1 -0
  152. package/dist/fixtures/paths-knip-config/index.d.ts +1 -0
  153. package/dist/fixtures/paths-knip-config/index.js +1 -0
  154. package/dist/fixtures/paths-knip-config/knip.d.ts +3 -0
  155. package/dist/fixtures/paths-knip-config/knip.js +9 -0
  156. package/dist/fixtures/paths-knip-config/lib/fn.d.ts +2 -0
  157. package/dist/fixtures/paths-knip-config/lib/fn.js +1 -0
  158. package/dist/fixtures/paths-knip-config/lib/index.d.ts +2 -0
  159. package/dist/fixtures/paths-knip-config/lib/index.js +1 -0
  160. package/dist/fixtures/paths-knip-config/my-module.d.ts +2 -0
  161. package/dist/fixtures/paths-knip-config/my-module.js +1 -0
  162. package/dist/fixtures/paths-knip-config-workspaces/index.d.ts +1 -0
  163. package/dist/fixtures/paths-knip-config-workspaces/index.js +1 -0
  164. package/dist/fixtures/paths-knip-config-workspaces/lib/fn.d.ts +2 -0
  165. package/dist/fixtures/paths-knip-config-workspaces/lib/fn.js +1 -0
  166. package/dist/fixtures/paths-knip-config-workspaces/lib/index.d.ts +2 -0
  167. package/dist/fixtures/paths-knip-config-workspaces/lib/index.js +1 -0
  168. package/dist/fixtures/paths-knip-config-workspaces/my-module.d.ts +1 -0
  169. package/dist/fixtures/paths-knip-config-workspaces/my-module.js +1 -0
  170. package/dist/fixtures/paths-knip-config-workspaces/ws/index.d.ts +1 -0
  171. package/dist/fixtures/paths-knip-config-workspaces/ws/index.js +1 -0
  172. package/dist/fixtures/paths-knip-config-workspaces/ws/lib/main.d.ts +0 -0
  173. package/dist/fixtures/paths-knip-config-workspaces/ws/lib/main.js +1 -0
  174. package/dist/fixtures/paths-knip-config-workspaces/ws/util/lang.d.ts +2 -0
  175. package/dist/fixtures/paths-knip-config-workspaces/ws/util/lang.js +1 -0
  176. package/dist/fixtures/peer-dependencies/index.d.ts +1 -0
  177. package/dist/fixtures/peer-dependencies/index.js +1 -0
  178. package/dist/fixtures/plugins/ava/ava.config.d.mts +13 -0
  179. package/dist/fixtures/plugins/ava/ava.config.mjs +13 -0
  180. package/dist/fixtures/plugins/babel/babel.config.d.ts +14 -0
  181. package/dist/fixtures/plugins/babel/babel.config.js +47 -0
  182. package/dist/fixtures/plugins/capacitor/capacitor.config.d.ts +3 -0
  183. package/dist/fixtures/plugins/capacitor/capacitor.config.js +15 -0
  184. package/dist/fixtures/plugins/commitlint/commitlint.config.d.ts +2 -0
  185. package/dist/fixtures/plugins/commitlint/commitlint.config.js +2 -0
  186. package/dist/fixtures/plugins/cypress/cypress/support/commands.d.ts +1 -0
  187. package/dist/fixtures/plugins/cypress/cypress/support/commands.js +5 -0
  188. package/dist/fixtures/plugins/cypress/cypress/support/e2e.d.ts +2 -0
  189. package/dist/fixtures/plugins/cypress/cypress/support/e2e.js +2 -0
  190. package/dist/fixtures/plugins/cypress/cypress.config.d.ts +2 -0
  191. package/dist/fixtures/plugins/cypress/cypress.config.js +9 -0
  192. package/dist/fixtures/plugins/eslint/eslint.config.d.ts +7 -0
  193. package/dist/fixtures/plugins/eslint/eslint.config.js +11 -0
  194. package/dist/fixtures/plugins/eslint/index.d.ts +1 -0
  195. package/dist/fixtures/plugins/eslint/index.js +1 -0
  196. package/dist/fixtures/plugins/gatsby/gatsby-config.d.ts +17 -0
  197. package/dist/fixtures/plugins/gatsby/gatsby-config.js +40 -0
  198. package/dist/fixtures/plugins/gatsby/gatsby-node.d.ts +3 -0
  199. package/dist/fixtures/plugins/gatsby/gatsby-node.js +15 -0
  200. package/dist/fixtures/plugins/github-actions/comment.d.ts +0 -0
  201. package/dist/fixtures/plugins/github-actions/comment.js +1 -0
  202. package/dist/fixtures/plugins/github-actions/scripts/check-dependencies.d.ts +0 -0
  203. package/dist/fixtures/plugins/github-actions/scripts/check-dependencies.js +1 -0
  204. package/dist/fixtures/plugins/jest/jest.config.d.ts +2 -0
  205. package/dist/fixtures/plugins/jest/jest.config.js +7 -0
  206. package/dist/fixtures/plugins/jest/jest.config.shared.d.ts +2 -0
  207. package/dist/fixtures/plugins/jest/jest.config.shared.js +15 -0
  208. package/dist/fixtures/plugins/jest/jest.setup.d.ts +1 -0
  209. package/dist/fixtures/plugins/jest/jest.setup.js +1 -0
  210. package/dist/fixtures/plugins/jest/jest.transform.d.ts +1 -0
  211. package/dist/fixtures/plugins/jest/jest.transform.js +2 -0
  212. package/dist/fixtures/plugins/lefthook/example.d.mts +2 -0
  213. package/dist/fixtures/plugins/lefthook/example.mjs +1 -0
  214. package/dist/fixtures/plugins/next/next.config.d.ts +2 -0
  215. package/dist/fixtures/plugins/next/next.config.js +9 -0
  216. package/dist/fixtures/plugins/next/pages/[[...route]].d.ts +3 -0
  217. package/dist/fixtures/plugins/next/pages/[[...route]].jsx +3 -0
  218. package/dist/fixtures/plugins/next/pages/page.d.ts +3 -0
  219. package/dist/fixtures/plugins/next/pages/page.jsx +3 -0
  220. package/dist/fixtures/plugins/playwright/playwright.config.d.ts +3 -0
  221. package/dist/fixtures/plugins/playwright/playwright.config.js +10 -0
  222. package/dist/fixtures/plugins/playwright/test/some.spec.d.ts +1 -0
  223. package/dist/fixtures/plugins/playwright/test/some.spec.js +6 -0
  224. package/dist/fixtures/plugins/postcss/postcss.config.d.ts +1 -0
  225. package/dist/fixtures/plugins/postcss/postcss.config.js +4 -0
  226. package/dist/fixtures/plugins/remix/app/entry.client.d.ts +1 -0
  227. package/dist/fixtures/plugins/remix/app/entry.client.jsx +11 -0
  228. package/dist/fixtures/plugins/remix/app/entry.server.jsx +3 -0
  229. package/dist/fixtures/plugins/remix/app/root.d.ts +5 -0
  230. package/dist/fixtures/plugins/remix/app/root.jsx +31 -0
  231. package/dist/fixtures/plugins/remix/app/routes/index.d.ts +1 -0
  232. package/dist/fixtures/plugins/remix/app/routes/index.jsx +8 -0
  233. package/dist/fixtures/plugins/remix/app/utils.d.ts +1 -0
  234. package/dist/fixtures/plugins/remix/app/utils.js +1 -0
  235. package/dist/fixtures/plugins/remix/remix.config.d.ts +2 -0
  236. package/dist/fixtures/plugins/remix/remix.config.js +5 -0
  237. package/dist/fixtures/plugins/remix/remix.init/index.d.ts +4 -0
  238. package/dist/fixtures/plugins/remix/remix.init/index.js +4 -0
  239. package/dist/fixtures/plugins/remix/server.d.ts +0 -0
  240. package/dist/fixtures/plugins/remix/server.js +1 -0
  241. package/dist/fixtures/plugins/rollup/rollup.config.d.ts +16 -0
  242. package/dist/fixtures/plugins/rollup/rollup.config.js +26 -0
  243. package/dist/fixtures/plugins/sentry/sentry.client.config.d.ts +1 -0
  244. package/dist/fixtures/plugins/sentry/sentry.client.config.js +6 -0
  245. package/dist/fixtures/plugins/sentry/sentry.server.config.d.ts +1 -0
  246. package/dist/fixtures/plugins/sentry/sentry.server.config.js +1 -0
  247. package/dist/fixtures/plugins/storybook/addon/register.d.ts +0 -0
  248. package/dist/fixtures/plugins/storybook/addon/register.js +1 -0
  249. package/dist/fixtures/plugins/storybook/main.d.ts +10 -0
  250. package/dist/fixtures/plugins/storybook/main.js +38 -0
  251. package/dist/fixtures/plugins/storybook/preview.d.ts +13 -0
  252. package/dist/fixtures/plugins/storybook/preview.js +14 -0
  253. package/dist/fixtures/plugins/stryker/stryker.conf.cjs +6 -0
  254. package/dist/fixtures/plugins/stryker/stryker.conf.d.cts +3 -0
  255. package/dist/fixtures/plugins/stryker/stryker.conf.d.mts +6 -0
  256. package/dist/fixtures/plugins/stryker/stryker.conf.mjs +6 -0
  257. package/dist/fixtures/plugins/svelte/knip.d.ts +11 -0
  258. package/dist/fixtures/plugins/svelte/knip.js +10 -0
  259. package/dist/fixtures/plugins/svelte/src/routes/+page.d.ts +1 -0
  260. package/dist/fixtures/plugins/svelte/src/routes/+page.js +1 -0
  261. package/dist/fixtures/plugins/svelte/svelte.config.d.ts +2 -0
  262. package/dist/fixtures/plugins/svelte/svelte.config.js +9 -0
  263. package/dist/fixtures/plugins/svelte/vite.config.d.ts +2 -0
  264. package/dist/fixtures/plugins/svelte/vite.config.js +5 -0
  265. package/dist/fixtures/plugins/vitest/test/basic.spec.d.ts +1 -0
  266. package/dist/fixtures/plugins/vitest/test/basic.spec.js +8 -0
  267. package/dist/fixtures/plugins/vitest/vite.config.d.ts +2 -0
  268. package/dist/fixtures/plugins/vitest/vite.config.js +10 -0
  269. package/dist/fixtures/plugins/vitest/vitest.config.d.ts +2 -0
  270. package/dist/fixtures/plugins/vitest/vitest.config.js +10 -0
  271. package/dist/fixtures/plugins/webpack/merge.d.ts +2 -0
  272. package/dist/fixtures/plugins/webpack/merge.js +9 -0
  273. package/dist/fixtures/plugins/webpack/src/app-dep.d.ts +2 -0
  274. package/dist/fixtures/plugins/webpack/src/app-dep.js +1 -0
  275. package/dist/fixtures/plugins/webpack/src/app.d.ts +1 -0
  276. package/dist/fixtures/plugins/webpack/src/app.js +1 -0
  277. package/dist/fixtures/plugins/webpack/src/entry.d.ts +0 -0
  278. package/dist/fixtures/plugins/webpack/src/entry.js +1 -0
  279. package/dist/fixtures/plugins/webpack/src/unused.d.ts +0 -0
  280. package/dist/fixtures/plugins/webpack/src/unused.js +1 -0
  281. package/dist/fixtures/plugins/webpack/src/vendor.d.ts +0 -0
  282. package/dist/fixtures/plugins/webpack/src/vendor.js +1 -0
  283. package/dist/fixtures/plugins/webpack/webpack.common.d.ts +65 -0
  284. package/dist/fixtures/plugins/webpack/webpack.common.js +81 -0
  285. package/dist/fixtures/plugins/webpack/webpack.config.d.ts +2 -0
  286. package/dist/fixtures/plugins/webpack/webpack.config.js +4 -0
  287. package/dist/fixtures/plugins/webpack/webpack.dev.d.ts +2 -0
  288. package/dist/fixtures/plugins/webpack/webpack.dev.js +19 -0
  289. package/dist/fixtures/plugins/webpack/webpack.prod.d.ts +2 -0
  290. package/dist/fixtures/plugins/webpack/webpack.prod.js +16 -0
  291. package/dist/fixtures/re-exports/barrel.d.ts +1 -0
  292. package/dist/fixtures/re-exports/barrel.js +1 -0
  293. package/dist/fixtures/re-exports/entry.d.ts +1 -0
  294. package/dist/fixtures/re-exports/entry.js +2 -0
  295. package/dist/fixtures/re-exports/my-module.d.ts +4 -0
  296. package/dist/fixtures/re-exports/my-module.js +6 -0
  297. package/dist/fixtures/react/App.d.ts +1 -0
  298. package/dist/fixtures/react/App.jsx +7 -0
  299. package/dist/fixtures/react/Component.d.ts +1 -0
  300. package/dist/fixtures/react/Component.jsx +4 -0
  301. package/dist/fixtures/self-reference/entry.d.ts +1 -0
  302. package/dist/fixtures/self-reference/entry.js +8 -0
  303. package/dist/fixtures/self-reference/lib/module.d.ts +2 -0
  304. package/dist/fixtures/self-reference/lib/module.js +1 -0
  305. package/dist/fixtures/self-reference/out/entry.d.ts +1 -0
  306. package/dist/fixtures/self-reference/out/entry.js +11 -0
  307. package/dist/fixtures/self-reference/out/lib/module.d.mts +3 -0
  308. package/dist/fixtures/self-reference/out/lib/module.mjs +4 -0
  309. package/dist/fixtures/self-reference-from-plugin/entry.d.ts +0 -0
  310. package/dist/fixtures/self-reference-from-plugin/entry.js +2 -0
  311. package/dist/fixtures/self-reference-from-plugin/file.d.ts +2 -0
  312. package/dist/fixtures/self-reference-from-plugin/file.js +1 -0
  313. package/dist/fixtures/tsconfig-paths/aliased-dir/a.d.ts +1 -0
  314. package/dist/fixtures/tsconfig-paths/aliased-dir/a.js +1 -0
  315. package/dist/fixtures/tsconfig-paths/index.d.ts +1 -0
  316. package/dist/fixtures/tsconfig-paths/index.js +6 -0
  317. package/dist/fixtures/tsconfig-paths/internal-package/index.d.ts +2 -0
  318. package/dist/fixtures/tsconfig-paths/internal-package/index.js +2 -0
  319. package/dist/fixtures/tsconfig-paths/unprefixed/module.d.ts +2 -0
  320. package/dist/fixtures/tsconfig-paths/unprefixed/module.js +2 -0
  321. package/dist/fixtures/tsconfig-paths-extends/src/cli.d.ts +1 -0
  322. package/dist/fixtures/tsconfig-paths-extends/src/cli.js +3 -0
  323. package/dist/fixtures/tsconfig-paths-extends/src/index.d.ts +3 -0
  324. package/dist/fixtures/tsconfig-paths-extends/src/index.js +3 -0
  325. package/dist/fixtures/tsconfig-paths-extends/src/lib/main.d.ts +2 -0
  326. package/dist/fixtures/tsconfig-paths-extends/src/lib/main.js +1 -0
  327. package/dist/fixtures/tsconfig-paths-extends/src/util/index.d.ts +2 -0
  328. package/dist/fixtures/tsconfig-paths-extends/src/util/index.js +1 -0
  329. package/dist/fixtures/tsconfig-paths-implicit/src/hello/world.d.ts +1 -0
  330. package/dist/fixtures/tsconfig-paths-implicit/src/hello/world.js +1 -0
  331. package/dist/fixtures/tsconfig-paths-implicit/src/index.d.ts +1 -0
  332. package/dist/fixtures/tsconfig-paths-implicit/src/index.js +2 -0
  333. package/dist/fixtures/workspaces/apps/a/index.d.ts +1 -0
  334. package/dist/fixtures/workspaces/apps/a/index.js +6 -0
  335. package/dist/fixtures/workspaces/apps/b/index.d.ts +1 -0
  336. package/dist/fixtures/workspaces/apps/b/index.js +4 -0
  337. package/dist/fixtures/workspaces/docs/dangling.d.ts +1 -0
  338. package/dist/fixtures/workspaces/docs/dangling.js +1 -0
  339. package/dist/fixtures/workspaces/packages/lib-a/index.d.ts +4 -0
  340. package/dist/fixtures/workspaces/packages/lib-a/index.js +3 -0
  341. package/dist/fixtures/workspaces/packages/lib-b/ignored/index.d.ts +0 -0
  342. package/dist/fixtures/workspaces/packages/lib-b/ignored/index.js +1 -0
  343. package/dist/fixtures/workspaces/packages/lib-b/index.d.ts +3 -0
  344. package/dist/fixtures/workspaces/packages/lib-b/index.js +2 -0
  345. package/dist/fixtures/workspaces-nested/level-1-1/index.d.ts +1 -0
  346. package/dist/fixtures/workspaces-nested/level-1-1/index.js +1 -0
  347. package/dist/fixtures/workspaces-nested/level-1-1/index.spec.d.ts +1 -0
  348. package/dist/fixtures/workspaces-nested/level-1-1/index.spec.js +1 -0
  349. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.d.ts +1 -0
  350. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.js +1 -0
  351. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.spec.d.ts +1 -0
  352. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.spec.js +1 -0
  353. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.d.ts +1 -0
  354. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.js +1 -0
  355. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.spec.d.ts +1 -0
  356. package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.spec.js +1 -0
  357. package/dist/fixtures/workspaces-paths/packages/lib-a/src/dir/module-a.d.ts +2 -0
  358. package/dist/fixtures/workspaces-paths/packages/lib-a/src/dir/module-a.js +1 -0
  359. package/dist/fixtures/workspaces-paths/packages/lib-a/src/index.d.ts +2 -0
  360. package/dist/fixtures/workspaces-paths/packages/lib-a/src/index.js +2 -0
  361. package/dist/fixtures/workspaces-paths/packages/lib-a/src/same.d.ts +2 -0
  362. package/dist/fixtures/workspaces-paths/packages/lib-a/src/same.js +1 -0
  363. package/dist/fixtures/workspaces-paths/packages/lib-b/src/dir/module-b.d.ts +2 -0
  364. package/dist/fixtures/workspaces-paths/packages/lib-b/src/dir/module-b.js +1 -0
  365. package/dist/fixtures/workspaces-paths/packages/lib-b/src/index.d.ts +2 -0
  366. package/dist/fixtures/workspaces-paths/packages/lib-b/src/index.js +2 -0
  367. package/dist/fixtures/workspaces-paths/packages/lib-c/src/dir/module.d.ts +2 -0
  368. package/dist/fixtures/workspaces-paths/packages/lib-c/src/dir/module.js +1 -0
  369. package/dist/fixtures/workspaces-paths/packages/lib-c/src/index.d.ts +2 -0
  370. package/dist/fixtures/workspaces-paths/packages/lib-c/src/index.js +2 -0
  371. package/dist/fixtures/workspaces-paths/packages/lib-d/src/dir/module.d.ts +2 -0
  372. package/dist/fixtures/workspaces-paths/packages/lib-d/src/dir/module.js +1 -0
  373. package/dist/fixtures/workspaces-paths/packages/lib-d/src/index.d.ts +2 -0
  374. package/dist/fixtures/workspaces-paths/packages/lib-d/src/index.js +2 -0
  375. package/dist/fixtures/workspaces-paths/packages/lib-e/src/dir/module-e.d.ts +2 -0
  376. package/dist/fixtures/workspaces-paths/packages/lib-e/src/dir/module-e.js +1 -0
  377. package/dist/fixtures/workspaces-paths/packages/lib-e/src/index.d.ts +2 -0
  378. package/dist/fixtures/workspaces-paths/packages/lib-e/src/index.js +2 -0
  379. package/dist/fixtures/workspaces-pnpm/apps/a/index.d.ts +1 -0
  380. package/dist/fixtures/workspaces-pnpm/apps/a/index.js +6 -0
  381. package/dist/fixtures/workspaces-pnpm/apps/b/index.d.ts +1 -0
  382. package/dist/fixtures/workspaces-pnpm/apps/b/index.js +4 -0
  383. package/dist/fixtures/workspaces-pnpm/docs/dangling.d.ts +1 -0
  384. package/dist/fixtures/workspaces-pnpm/docs/dangling.js +1 -0
  385. package/dist/fixtures/workspaces-pnpm/packages/lib-a/index.d.ts +4 -0
  386. package/dist/fixtures/workspaces-pnpm/packages/lib-a/index.js +3 -0
  387. package/dist/fixtures/workspaces-pnpm/packages/lib-b/index.d.ts +3 -0
  388. package/dist/fixtures/workspaces-pnpm/packages/lib-b/index.js +2 -0
  389. package/dist/fixtures/workspaces-self-reference/packages/self-reference/entry.d.ts +1 -0
  390. package/dist/fixtures/workspaces-self-reference/packages/self-reference/entry.js +4 -0
  391. package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/entry.d.ts +0 -0
  392. package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/entry.js +2 -0
  393. package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/file.d.ts +2 -0
  394. package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/file.js +1 -0
  395. package/dist/fixtures/zero-config/exclude.d.ts +1 -0
  396. package/dist/fixtures/zero-config/exclude.js +1 -0
  397. package/dist/fixtures/zero-config/index.d.ts +1 -0
  398. package/dist/fixtures/zero-config/index.js +2 -0
  399. package/dist/fixtures/zero-config/my-module.d.ts +4 -0
  400. package/dist/fixtures/zero-config/my-module.js +6 -0
  401. package/dist/fixtures/zero-config/my-namespace.d.ts +5 -0
  402. package/dist/fixtures/zero-config/my-namespace.js +3 -0
  403. package/dist/gitignore.test.d.ts +1 -0
  404. package/dist/gitignore.test.js +22 -0
  405. package/dist/helpers/baseArguments.d.ts +8 -0
  406. package/dist/helpers/baseArguments.js +8 -0
  407. package/dist/helpers/baseCounters.d.ts +17 -0
  408. package/dist/helpers/baseCounters.js +7 -0
  409. package/dist/helpers/index.d.ts +2 -0
  410. package/dist/helpers/index.js +4 -0
  411. package/dist/imports.test.d.ts +1 -0
  412. package/dist/imports.test.js +39 -0
  413. package/dist/index.js +130 -169
  414. package/dist/issue-collector.d.ts +4 -11
  415. package/dist/issue-collector.js +9 -23
  416. package/dist/issues/initializers.d.ts +1 -2
  417. package/dist/issues/initializers.js +0 -1
  418. package/dist/js-only.test.d.ts +1 -0
  419. package/dist/js-only.test.js +26 -0
  420. package/dist/jsdoc.test.d.ts +1 -0
  421. package/dist/jsdoc.test.js +21 -0
  422. package/dist/manifest/helpers.d.ts +7 -1
  423. package/dist/manifest/helpers.js +5 -5
  424. package/dist/manifest/index.d.ts +2 -3
  425. package/dist/manifest/index.js +12 -9
  426. package/dist/members.test.d.ts +1 -0
  427. package/dist/members.test.js +28 -0
  428. package/dist/namespace.test.d.ts +1 -0
  429. package/dist/namespace.test.js +18 -0
  430. package/dist/npm-scripts.test.d.ts +1 -0
  431. package/dist/npm-scripts.test.js +78 -0
  432. package/dist/pathless.test.d.ts +1 -0
  433. package/dist/pathless.test.js +14 -0
  434. package/dist/paths-knip-config-workspaces.test.d.ts +1 -0
  435. package/dist/paths-knip-config-workspaces.test.js +18 -0
  436. package/dist/paths-knip-config.test.d.ts +1 -0
  437. package/dist/paths-knip-config.test.js +18 -0
  438. package/dist/peer-dependencies.test.d.ts +1 -0
  439. package/dist/peer-dependencies.test.js +20 -0
  440. package/dist/plugins/_template/index.js +2 -3
  441. package/dist/plugins/_template.test.d.ts +1 -0
  442. package/dist/plugins/_template.test.js +12 -0
  443. package/dist/plugins/ava/index.d.ts +6 -0
  444. package/dist/plugins/ava/index.js +21 -0
  445. package/dist/plugins/ava/types.d.ts +4 -0
  446. package/dist/plugins/ava/types.js +1 -0
  447. package/dist/plugins/ava.test.d.ts +1 -0
  448. package/dist/plugins/ava.test.js +18 -0
  449. package/dist/plugins/babel/index.d.ts +2 -2
  450. package/dist/plugins/babel/index.js +3 -7
  451. package/dist/plugins/babel/types.d.ts +5 -3
  452. package/dist/plugins/babel.test.d.ts +1 -0
  453. package/dist/plugins/babel.test.js +62 -0
  454. package/dist/plugins/capacitor/index.js +2 -3
  455. package/dist/plugins/capacitor.test.d.ts +1 -0
  456. package/dist/plugins/capacitor.test.js +31 -0
  457. package/dist/plugins/changesets/index.js +2 -3
  458. package/dist/plugins/changesets.test.d.ts +1 -0
  459. package/dist/plugins/changesets.test.js +12 -0
  460. package/dist/plugins/commitlint/index.js +11 -5
  461. package/dist/plugins/commitlint.test.d.ts +1 -0
  462. package/dist/plugins/commitlint.test.js +22 -0
  463. package/dist/plugins/cspell/index.d.ts +6 -0
  464. package/dist/plugins/cspell/index.js +17 -0
  465. package/dist/plugins/cspell/types.d.ts +3 -0
  466. package/dist/plugins/cspell/types.js +1 -0
  467. package/dist/plugins/cspell.test.d.ts +1 -0
  468. package/dist/plugins/cspell.test.js +10 -0
  469. package/dist/plugins/cypress.test.d.ts +1 -0
  470. package/dist/plugins/cypress.test.js +23 -0
  471. package/dist/plugins/eslint/fallback.js +1 -2
  472. package/dist/plugins/eslint/helpers.js +9 -12
  473. package/dist/plugins/eslint.test.d.ts +1 -0
  474. package/dist/plugins/eslint.test.js +43 -0
  475. package/dist/plugins/gatsby/index.js +2 -3
  476. package/dist/plugins/gatsby.test.d.ts +1 -0
  477. package/dist/plugins/gatsby.test.js +31 -0
  478. package/dist/plugins/github-actions/index.js +4 -4
  479. package/dist/plugins/github-actions.test.d.ts +1 -0
  480. package/dist/plugins/github-actions.test.js +25 -0
  481. package/dist/plugins/husky/index.js +2 -2
  482. package/dist/plugins/husky.test.d.ts +1 -0
  483. package/dist/plugins/husky.test.js +32 -0
  484. package/dist/plugins/index.d.ts +4 -0
  485. package/dist/plugins/index.js +4 -0
  486. package/dist/plugins/jest/index.d.ts +0 -1
  487. package/dist/plugins/jest/index.js +21 -36
  488. package/dist/plugins/jest.test.d.ts +1 -0
  489. package/dist/plugins/jest.test.js +18 -0
  490. package/dist/plugins/lefthook/index.js +6 -7
  491. package/dist/plugins/lefthook.test.d.ts +1 -0
  492. package/dist/plugins/lefthook.test.js +16 -0
  493. package/dist/plugins/lint-staged/index.js +3 -4
  494. package/dist/plugins/lint-staged.test.d.ts +1 -0
  495. package/dist/plugins/lint-staged.test.js +18 -0
  496. package/dist/plugins/markdownlint/helpers.d.ts +1 -0
  497. package/dist/plugins/markdownlint/helpers.js +6 -0
  498. package/dist/plugins/markdownlint/index.js +4 -5
  499. package/dist/plugins/markdownlint.test.d.ts +1 -0
  500. package/dist/plugins/markdownlint.test.js +12 -0
  501. package/dist/plugins/mocha/index.d.ts +0 -1
  502. package/dist/plugins/mocha/index.js +3 -6
  503. package/dist/plugins/mocha.test.d.ts +1 -0
  504. package/dist/plugins/mocha.test.js +22 -0
  505. package/dist/plugins/next.test.d.ts +1 -0
  506. package/dist/plugins/next.test.js +24 -0
  507. package/dist/plugins/npm-package-json-lint/index.js +2 -3
  508. package/dist/plugins/npm-package-json-lint.test.d.ts +1 -0
  509. package/dist/plugins/npm-package-json-lint.test.js +12 -0
  510. package/dist/plugins/nx/index.js +4 -5
  511. package/dist/plugins/nx.test.d.ts +1 -0
  512. package/dist/plugins/nx.test.js +15 -0
  513. package/dist/plugins/nyc/index.js +2 -3
  514. package/dist/plugins/nyc.test.d.ts +1 -0
  515. package/dist/plugins/nyc.test.js +10 -0
  516. package/dist/plugins/playwright/index.js +1 -1
  517. package/dist/plugins/playwright.test.d.ts +1 -0
  518. package/dist/plugins/playwright.test.js +20 -0
  519. package/dist/plugins/postcss/index.js +3 -7
  520. package/dist/plugins/postcss.test.d.ts +1 -0
  521. package/dist/plugins/postcss.test.js +33 -0
  522. package/dist/plugins/prettier/index.js +3 -5
  523. package/dist/plugins/prettier.test.d.ts +1 -0
  524. package/dist/plugins/prettier.test.js +10 -0
  525. package/dist/plugins/release-it/index.js +3 -4
  526. package/dist/plugins/release-it.test.d.ts +1 -0
  527. package/dist/plugins/release-it.test.js +10 -0
  528. package/dist/plugins/remark/index.js +1 -2
  529. package/dist/plugins/remark.test.d.ts +1 -0
  530. package/dist/plugins/remark.test.js +12 -0
  531. package/dist/plugins/remix.test.d.ts +1 -0
  532. package/dist/plugins/remix.test.js +39 -0
  533. package/dist/plugins/rollup.test.d.ts +1 -0
  534. package/dist/plugins/rollup.test.js +24 -0
  535. package/dist/plugins/semantic-release/index.d.ts +6 -0
  536. package/dist/plugins/semantic-release/index.js +17 -0
  537. package/dist/plugins/semantic-release/types.d.ts +3 -0
  538. package/dist/plugins/semantic-release/types.js +1 -0
  539. package/dist/plugins/semantic-release.test.d.ts +1 -0
  540. package/dist/plugins/semantic-release.test.js +31 -0
  541. package/dist/plugins/sentry.test.d.ts +1 -0
  542. package/dist/plugins/sentry.test.js +14 -0
  543. package/dist/plugins/storybook/index.js +5 -26
  544. package/dist/plugins/storybook.test.d.ts +1 -0
  545. package/dist/plugins/storybook.test.js +18 -0
  546. package/dist/plugins/stryker/index.js +2 -3
  547. package/dist/plugins/stryker.test.d.ts +1 -0
  548. package/dist/plugins/stryker.test.js +44 -0
  549. package/dist/plugins/svelte/index.d.ts +7 -0
  550. package/dist/plugins/svelte/index.js +9 -0
  551. package/dist/plugins/svelte.test.d.ts +1 -0
  552. package/dist/plugins/svelte.test.js +21 -0
  553. package/dist/plugins/typedoc/index.js +5 -6
  554. package/dist/plugins/typedoc/types.d.ts +1 -1
  555. package/dist/plugins/typedoc.test.d.ts +1 -0
  556. package/dist/plugins/typedoc.test.js +14 -0
  557. package/dist/plugins/typescript/index.js +3 -5
  558. package/dist/plugins/vitest/index.d.ts +0 -1
  559. package/dist/plugins/vitest/index.js +2 -4
  560. package/dist/plugins/vitest.test.d.ts +1 -0
  561. package/dist/plugins/vitest.test.js +17 -0
  562. package/dist/plugins/webpack/index.js +14 -24
  563. package/dist/plugins/webpack.test.d.ts +1 -0
  564. package/dist/plugins/webpack.test.js +56 -0
  565. package/dist/principal-factory.d.ts +0 -1
  566. package/dist/principal-factory.js +10 -10
  567. package/dist/project-principal.d.ts +5 -3
  568. package/dist/project-principal.js +22 -13
  569. package/dist/re-exports.test.d.ts +1 -0
  570. package/dist/re-exports.test.js +18 -0
  571. package/dist/react.test.d.ts +1 -0
  572. package/dist/react.test.js +19 -0
  573. package/dist/reporters/codeowners.js +4 -5
  574. package/dist/reporters/json.js +3 -4
  575. package/dist/reporters/symbols.js +2 -2
  576. package/dist/reporters/util.js +3 -3
  577. package/dist/self-reference-from-plugin.test.d.ts +1 -0
  578. package/dist/self-reference-from-plugin.test.js +47 -0
  579. package/dist/self-reference.test.d.ts +1 -0
  580. package/dist/self-reference.test.js +46 -0
  581. package/dist/source-lab.d.ts +21 -0
  582. package/dist/source-lab.js +135 -0
  583. package/dist/tsconfig-paths-extends.test.d.ts +1 -0
  584. package/dist/tsconfig-paths-extends.test.js +18 -0
  585. package/dist/tsconfig-paths-implicit.test.d.ts +1 -0
  586. package/dist/tsconfig-paths-implicit.test.js +18 -0
  587. package/dist/tsconfig-paths.test.d.ts +1 -0
  588. package/dist/tsconfig-paths.test.js +26 -0
  589. package/dist/types/plugins.d.ts +1 -4
  590. package/dist/typescript/SourceFileManager.js +3 -3
  591. package/dist/typescript/ast-helpers.d.ts +1 -0
  592. package/dist/typescript/ast-helpers.js +1 -0
  593. package/dist/typescript/ast-walker.d.ts +5 -3
  594. package/dist/typescript/ast-walker.js +42 -27
  595. package/dist/typescript/createHosts.js +4 -2
  596. package/dist/typescript/resolveModuleNames.js +2 -3
  597. package/dist/util/array.d.ts +1 -0
  598. package/dist/util/array.js +7 -0
  599. package/dist/util/binaries/resolvers/node.js +2 -3
  600. package/dist/util/find-import-specifiers.d.ts +5 -0
  601. package/dist/util/find-import-specifiers.js +48 -0
  602. package/dist/util/fs.d.ts +4 -1
  603. package/dist/util/fs.js +18 -13
  604. package/dist/util/get-included-issue-types.d.ts +16 -0
  605. package/dist/util/get-included-issue-types.js +30 -0
  606. package/dist/util/get-included-issue-types.test.d.ts +1 -0
  607. package/dist/util/get-included-issue-types.test.js +70 -0
  608. package/dist/util/getReferencesFromScripts.test.d.ts +1 -0
  609. package/dist/util/getReferencesFromScripts.test.js +126 -0
  610. package/dist/util/glob.js +4 -5
  611. package/dist/util/loader.js +9 -7
  612. package/dist/util/log.d.ts +1 -0
  613. package/dist/util/log.js +1 -0
  614. package/dist/util/members.d.ts +3 -0
  615. package/dist/util/members.js +25 -0
  616. package/dist/util/module.test.d.ts +1 -0
  617. package/dist/util/module.test.js +12 -0
  618. package/dist/util/modules.d.ts +1 -1
  619. package/dist/util/modules.js +4 -8
  620. package/dist/util/os.d.ts +1 -0
  621. package/dist/util/os.js +1 -0
  622. package/dist/util/path.d.ts +8 -2
  623. package/dist/util/path.js +9 -4
  624. package/dist/util/plugin.d.ts +1 -1
  625. package/dist/util/plugin.js +3 -6
  626. package/dist/util/project.d.ts +13 -0
  627. package/dist/util/project.js +48 -0
  628. package/dist/util/require.d.ts +3 -2
  629. package/dist/util/require.js +23 -6
  630. package/dist/util/resolve-included-issue-types.js +1 -1
  631. package/dist/util/tsconfig-loader.d.ts +2 -1
  632. package/dist/util/tsconfig-loader.js +4 -1
  633. package/dist/util/type.d.ts +2 -0
  634. package/dist/util/type.js +9 -0
  635. package/dist/util/workspace.test.d.ts +1 -0
  636. package/dist/util/workspace.test.js +13 -0
  637. package/dist/version.d.ts +1 -1
  638. package/dist/version.js +1 -1
  639. package/dist/workspace-worker.d.ts +22 -22
  640. package/dist/workspace-worker.js +50 -48
  641. package/dist/workspaces-nested.test.d.ts +1 -0
  642. package/dist/workspaces-nested.test.js +44 -0
  643. package/dist/workspaces-paths.test.d.ts +1 -0
  644. package/dist/workspaces-paths.test.js +21 -0
  645. package/dist/workspaces-pnpm.test.d.ts +1 -0
  646. package/dist/workspaces-pnpm.test.js +21 -0
  647. package/dist/workspaces.test.d.ts +1 -0
  648. package/dist/workspaces.test.js +56 -0
  649. package/dist/zero-config.test.d.ts +1 -0
  650. package/dist/zero-config.test.js +37 -0
  651. package/package.json +20 -18
  652. package/schema.json +19 -1
  653. package/dist/progress-updater.d.ts +0 -13
  654. package/dist/progress-updater.js +0 -22
package/README.md CHANGED
@@ -40,7 +40,7 @@ for the full story.
40
40
  ## Issues
41
41
 
42
42
  Are you seeing false positives? Please report them by [opening an issue in this repo][9]. Bonus points for linking to a
43
- public repository using Knip, or even opening a pull request with a directory and example files in `test/fixtures`.
43
+ public repository using Knip, or even opening a pull request with a directory and example files in `tests/fixtures`.
44
44
  Correctness and bug fixes have priority over performance and new features.
45
45
 
46
46
  Also see the [FAQ][10].
@@ -59,19 +59,19 @@ with a configuration file (or a `knip` property in `package.json`). Here's a `kn
59
59
  ```json
60
60
  {
61
61
  "$schema": "https://unpkg.com/knip@next/schema.json",
62
- "entry": ["index.{js,mjs,cjs,jsx,ts,tsx}", "src/index.{js,mjs,cjs,jsx,ts,tsx}"],
63
- "project": ["**/*.{js,mjs,cjs,jsx,ts,tsx}"]
62
+ "entry": ["index.{js,mjs,cjs,jsx,ts,tsx,mts,cts}", "src/index.{js,mjs,cjs,jsx,ts,tsx,mts,cts}"],
63
+ "project": ["**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}"]
64
64
  }
65
65
  ```
66
66
 
67
67
  If this matches your project, you don't need any configuration. But let's say you are using `.ts` files excusively and
68
- have all source files in the `lib` directory:
68
+ have all source files only in the `src` directory:
69
69
 
70
70
  ```json
71
71
  {
72
72
  "$schema": "https://unpkg.com/knip@next/schema.json",
73
- "entry": ["lib/index.ts"],
74
- "project": ["lib/**/*.ts"]
73
+ "entry": ["src/index.ts"],
74
+ "project": ["src/**/*.ts"]
75
75
  }
76
76
  ```
77
77
 
@@ -196,8 +196,8 @@ Use `--exclude` to ignore reports you're not interested in:
196
196
 
197
197
  Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.
198
198
 
199
- Still not happy with the results? Getting too much output/false positives? The [FAQ][9] may be useful. Feel free to open
200
- an issue and I'm happy to look into it. Also see the next section on how to [ignore][11] certain false positives:
199
+ Still not happy with the results? Getting too much output/false positives? The [FAQ][10] may be useful. Feel free to
200
+ open an issue and I'm happy to look into it. Also see the next section on how to [ignore][11] certain false positives:
201
201
 
202
202
  ## Ignore
203
203
 
@@ -281,38 +281,42 @@ Use `--debug` to get more verbose output.
281
281
 
282
282
  Knip contains a growing list of plugins:
283
283
 
284
- - [Babel][12]
285
- - [Capacitor][13]
286
- - [Changesets][14]
287
- - [commitlint][15]
288
- - [Cypress][16]
289
- - [ESLint][17]
290
- - [Gatsby][18]
291
- - [GitHub Actions][19]
292
- - [husky][20]
293
- - [Jest][21]
294
- - [Lefthook][22]
295
- - [lint-staged][23]
296
- - [markdownlint][24]
297
- - [Mocha][25]
298
- - [Next.js][26]
299
- - [npm-package-json-lint][27]
300
- - [Nx][28]
301
- - [nyc][29]
302
- - [Playwright][30]
303
- - [PostCSS][31]
304
- - [Prettier][32]
305
- - [Release It][33]
306
- - [Remark][34]
307
- - [Remix][35]
308
- - [Rollup][36]
309
- - [Sentry][37]
310
- - [Storybook][38]
311
- - [Stryker][39]
312
- - [TypeDoc][40]
313
- - [TypeScript][41]
314
- - [Vitest][42]
315
- - [Webpack][43]
284
+ - [Ava][plugin-ava]
285
+ - [Babel][plugin-babel]
286
+ - [Capacitor][plugin-capacitor]
287
+ - [Changesets][plugin-changesets]
288
+ - [commitlint][plugin-commitlint]
289
+ - [cspell][plugin-cspell]
290
+ - [Cypress][plugin-cypress]
291
+ - [ESLint][plugin-eslint]
292
+ - [Gatsby][plugin-gatsby]
293
+ - [GitHub Actions][plugin-github-actions]
294
+ - [husky][plugin-husky]
295
+ - [Jest][plugin-jest]
296
+ - [Lefthook][plugin-lefthook]
297
+ - [lint-staged][plugin-lint-staged]
298
+ - [markdownlint][plugin-markdownlint]
299
+ - [Mocha][plugin-mocha]
300
+ - [Next.js][plugin-next]
301
+ - [npm-package-json-lint][plugin-npm-package-json-lint]
302
+ - [Nx][plugin-nx]
303
+ - [nyc][plugin-nyc]
304
+ - [Playwright][plugin-playwright]
305
+ - [PostCSS][plugin-postcss]
306
+ - [Prettier][plugin-prettier]
307
+ - [Release It][plugin-release-it]
308
+ - [Remark][plugin-remark]
309
+ - [Remix][plugin-remix]
310
+ - [Rollup][plugin-rollup]
311
+ - [Semantic Release][plugin-semantic-release]
312
+ - [Sentry][plugin-sentry]
313
+ - [Storybook][plugin-storybook]
314
+ - [Stryker][plugin-stryker]
315
+ - [Svelte][plugin-svelte]
316
+ - [TypeDoc][plugin-typedoc]
317
+ - [TypeScript][plugin-typescript]
318
+ - [Vitest][plugin-vitest]
319
+ - [Webpack][plugin-webpack]
316
320
 
317
321
  Plugins are automatically activated. Each plugin is automatically enabled based on simple heuristics. Most of them check
318
322
  whether one or one of a few (dev) dependencies are listed in `package.json`. Once enabled, they add a set of
@@ -320,25 +324,16 @@ configuration and/or entry files for Knip to analyze. These defaults can be over
320
324
 
321
325
  Most plugins use one or both of the following file types:
322
326
 
323
- - `config` - custom dependency resolvers are applied to the [config files][44]
327
+ - `config` - custom dependency resolvers are applied to the [config files][12]
324
328
  - `entry` - files to include with the analysis of the rest of the source code
325
329
 
326
330
  See each plugin's documentation for its default values.
327
331
 
328
332
  ### `config`
329
333
 
330
- Plugins may include `config` files. They are parsed by the plugin's custom dependency resolver. Here are some examples
331
- to get an idea of how they work and why they are needed:
332
-
333
- - The `eslint` plugin tells Knip that the `"prettier"` entry in the array of `plugins` means that the
334
- `eslint-plugin-prettier` dependency should be installed. Or that the `"airbnb"` entry in `extends` requires the
335
- `eslint-config-airbnb` dependency.
336
- - The `storybook` plugin understands that `core.builder: 'webpack5'` in `main.js` means that the
337
- `@storybook/builder-webpack5` and `@storybook/manager-webpack5` dependencies are required.
338
- - Static configuration files such as JSON and YAML always require a custom dependency resolver.
339
-
340
- Custom dependency resolvers return all referenced dependencies for the configuration files it is given. Knip handles the
341
- rest to find which of those dependencies are unused or missing.
334
+ Plugins may include `config` files. They are parsed by the plugin's custom dependency finder. Custom dependency finders
335
+ return all dependencies referenced in the configuration files it is given. Knip handles the rest to determine which of
336
+ those dependencies are unused or missing.
342
337
 
343
338
  ### `entry`
344
339
 
@@ -351,15 +346,13 @@ In case a plugin causes issues, it can be disabled by using `false` as its value
351
346
 
352
347
  ### Create a new plugin
353
348
 
354
- Getting false positives because a plugin is missing? Want to help out? Feel free to add your own plugin! Here's how to
355
- get started:
356
-
357
- npm run create-plugin -- --name [myplugin]
349
+ Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][13]. This
350
+ guide also contains more details if you want to learn more about plugins and why they are useful.
358
351
 
359
352
  ## Compilers
360
353
 
361
354
  Knip v2 introduces compilers which allows to include files that are not JavaScript or TypeScript in the process of
362
- finding unused or missing dependencies.
355
+ finding unused or missing dependencies. For instance, `.mdx`, `.vue` and `.svelte` files come to mind.
363
356
 
364
357
  Currently this is only supported by using `knip.js` or `knip.ts`. Provide a `compilers` object in the configuration
365
358
  where each key represents the extension and the value is a function that takes the contents of these files as input and
@@ -375,6 +368,8 @@ export default {
375
368
  };
376
369
  ```
377
370
 
371
+ Read [Compilers][14] for more details and examples.
372
+
378
373
  ## Production Mode
379
374
 
380
375
  The default mode for Knip is holistic and targets all project code, including configuration files and tests. Test files
@@ -403,17 +398,16 @@ Here's what's included in production mode analysis:
403
398
 
404
399
  Additionally, the `--strict` flag can be used to:
405
400
 
406
- - Consider only `dependencies` (not `devDependencies`) when finding unused or unlisted dependencies.
407
- - Consider only non-type imports (i.e. ignore `import type {}`).
408
- - Assume each workspace is self-contained: they have their own `dependencies` (and not rely on packages of ancestor
409
- workspaces).
401
+ - Consider `dependencies` (not `devDependencies`) when finding unused or unlisted dependencies.
402
+ - Include `peerDependencies` when finding unused or unlisted dependencies.
403
+ - Ignore type-only imports (`import type {}`).
404
+ - Verify each workspace is self-contained: have their own `dependencies` (and not use packages of ancestor workspaces).
410
405
 
411
406
  ### Plugins
412
407
 
413
408
  Plugins also have this distinction. For instance, Next.js entry files for pages (`pages/**/*.tsx`) and Remix routes
414
- (`app/routes/**/*.tsx`) are production code, while Jest and Playwright entry files (e.g. `*.spec.ts`) are not. All of
415
- this is handled automatically by Knip and its plugins. You only need to point Knip to additional files or custom file
416
- locations. The more plugins Knip will have, the more projects can be analyzed out of the box!
409
+ (`app/routes/**/*.tsx`) are production code, while Jest and Storybook entry files (e.g. `*.spec.ts` or `*.stories.js`)
410
+ are not. All of this is handled automatically by Knip and its plugins.
417
411
 
418
412
  ## Paths
419
413
 
@@ -440,10 +434,10 @@ Each workspace can also have its own `paths` configured. Note that Knip `paths`
440
434
 
441
435
  Knip provides the following built-in reporters:
442
436
 
443
- - [`codeowners`][45]
444
- - [`compact`][46]
445
- - [`json`][47]
446
- - [`symbol`][48] (default)
437
+ - codeowners
438
+ - compact
439
+ - json
440
+ - symbol
447
441
 
448
442
  The `compact` reporter shows the sorted files first, and then a list of symbols:
449
443
 
@@ -470,13 +464,12 @@ type ReporterOptions = {
470
464
 
471
465
  The data can then be used to write issues to `stdout`, a JSON or CSV file, or sent to a service.
472
466
 
473
- Find more details and ideas in [custom reporters][49].
467
+ Find more details and ideas in [custom reporters][15].
474
468
 
475
- ## Libraries and "unused" exports
469
+ ## Public exports
476
470
 
477
- Libraries and applications are identical when it comes to files and dependencies: whatever is unused should be removed.
478
- Yet libraries usually have exports meant to be used by other libraries or applications. Such public variables and types
479
- in libraries can be marked with the JSDoc `@public` tag:
471
+ Sometimes a file that's not an entry file has one or more exports that are public, and should not be reported as unused.
472
+ Such variables and types can be marked with the JSDoc `@public` tag:
480
473
 
481
474
  ```js
482
475
  /**
@@ -528,7 +521,7 @@ When unused dependencies are related to dependencies having a Knip [plugin][1],
528
521
  for that dependency are at custom locations. The default values are at the plugin's documentation, and can be overridden
529
522
  to match the custom location(s).
530
523
 
531
- When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][50].
524
+ When the dependencies don't have a Knip plugin yet, please file an issue or [create a new plugin][16].
532
525
 
533
526
  #### Too many unused exports
534
527
 
@@ -536,7 +529,7 @@ When the project is a library and the exports are meant to be used by consumers
536
529
 
537
530
  1. By default, unused exports of `entry` files are not reported. You could re-export from an existing entry file, or
538
531
  add the containing file to the `entry` array in the configuration.
539
- 2. The exported values or types can be marked [using the JSDoc `@public` tag][51].
532
+ 2. The exported values or types can be marked [using the JSDoc `@public` tag][17]
540
533
 
541
534
  ### How to start using Knip in CI while having too many issues to sort out?
542
535
 
@@ -556,22 +549,23 @@ All of this is hiding problems, so please make sure to plan for fixing them and/
556
549
 
557
550
  This table is an ongoing comparison. Based on their docs (please report any mistakes):
558
551
 
559
- | Feature | **knip** | [depcheck][52] | [unimported][53] | [ts-unused-exports][54] | [ts-prune][55] |
560
- | :--------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
561
- | Unused files | ✅ | - | ✅ | - | - |
562
- | Unused dependencies | ✅ | ✅ | ✅ | - | - |
563
- | Unlisted dependencies | ✅ | ✅ | ✅ | - | - |
564
- | [Plugins][1] | ✅ | ✅ | ❌ | - | - |
565
- | Unused exports | ✅ | - | - | | |
566
- | Unused class members | ✅ | - | - | - | - |
567
- | Unused enum members | ✅ | - | - | - | - |
568
- | Duplicate exports | ✅ | - | - | | |
569
- | Search namespaces | ✅ | - | - | | ❌ |
570
- | Custom reporters | ✅ | - | - | - | - |
571
- | JavaScript support | ✅ | | | - | - |
572
- | Configure entry files | ✅ | | ✅ | | |
573
- | [Support workspaces/monorepos][52] | ✅ | ❌ | | - | - |
574
- | ESLint plugin available | - | - | - | | - |
552
+ | Feature | **knip** | [depcheck][18] | [unimported][19] | [ts-unused-exports][20] | [ts-prune][21] |
553
+ | :-------------------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
554
+ | Unused files | ✅ | - | ✅ | - | - |
555
+ | Unused dependencies | ✅ | ✅ | ✅ | - | - |
556
+ | Unlisted dependencies | ✅ | ✅ | ✅ | - | - |
557
+ | [Plugins][2] | ✅ | ✅ | ❌ | - | - |
558
+ | [Compilers][3] | ✅ | - | - | - | - |
559
+ | Unused exports | ✅ | - | - | | |
560
+ | Unused class members | ✅ | - | - | - | - |
561
+ | Unused enum members | ✅ | - | - | - | - |
562
+ | Duplicate exports | ✅ | - | - | | ❌ |
563
+ | Search namespaces | ✅ | - | - | | |
564
+ | Custom reporters | ✅ | - | - | - | - |
565
+ | JavaScript support | ✅ | | ✅ | - | - |
566
+ | Configure entry files | ✅ | ❌ | | | |
567
+ | [Support workspaces/monorepos][1] | | | | - | - |
568
+ | ESLint plugin available | - | - | - | ✅ | - |
575
569
 
576
570
  ✅ = Supported, ❌ = Not supported, - = Out of scope
577
571
 
@@ -591,7 +585,7 @@ The following commands are similar:
591
585
  unimported
592
586
  knip --production --dependencies --include files
593
587
 
594
- Also see [production mode][56].
588
+ Also see [production mode][22].
595
589
 
596
590
  ### ts-unused-exports
597
591
 
@@ -609,13 +603,6 @@ The following commands are similar:
609
603
  knip --include exports,types
610
604
  knip --exports # Adds unused exports/types in namespaces and unused enum/class members
611
605
 
612
- ## TypeScript language services
613
-
614
- TypeScript language services could play a major role in most of the "unused" areas, as they have an overview of the
615
- project as a whole. This powers things in VS Code like "Find references" or the "Module "./some" declares 'Thing'
616
- locally, but it is not exported" message. I think features like "duplicate exports" or "custom dependency resolvers" are
617
- userland territory, much like code linters.
618
-
619
606
  ## Knip?!
620
607
 
621
608
  Knip is Dutch for a "cut". A Dutch expression is "to be ge**knip**t for something", which means to be perfectly suited
@@ -632,48 +619,50 @@ for the job. I'm motivated to make knip perfectly suited for the job of cutting
632
619
  [9]: https://github.com/webpro/knip/issues
633
620
  [10]: #faq
634
621
  [11]: #ignore
635
- [12]: ./src/plugins/babel
636
- [13]: ./src/plugins/capacitor
637
- [14]: ./src/plugins/changesets
638
- [15]: ./src/plugins/commitlint
639
- [16]: ./src/plugins/cypress
640
- [17]: ./src/plugins/eslint
641
- [18]: ./src/plugins/gatsby
642
- [19]: ./src/plugins/github-actions
643
- [20]: ./src/plugins/husky
644
- [21]: ./src/plugins/jest
645
- [22]: ./src/plugins/lefthook
646
- [23]: ./src/plugins/lint-staged
647
- [24]: ./src/plugins/markdownlint
648
- [25]: ./src/plugins/mocha
649
- [26]: ./src/plugins/next
650
- [27]: ./src/plugins/npm-package-json-lint
651
- [28]: ./src/plugins/nx
652
- [29]: ./src/plugins/nyc
653
- [30]: ./src/plugins/playwright
654
- [31]: ./src/plugins/postcss
655
- [32]: ./src/plugins/prettier
656
- [33]: ./src/plugins/release-it
657
- [34]: ./src/plugins/remark
658
- [35]: ./src/plugins/remix
659
- [36]: ./src/plugins/rollup
660
- [37]: ./src/plugins/sentry
661
- [38]: ./src/plugins/storybook
662
- [39]: ./src/plugins/stryker
663
- [40]: ./src/plugins/typedoc
664
- [41]: ./src/plugins/typescript
665
- [42]: ./src/plugins/vitest
666
- [43]: ./src/plugins/webpack
667
- [44]: #config
668
- [45]: #code-owners
669
- [46]: #compact
670
- [47]: #json
671
- [48]: #symbol-default
672
- [49]: ./docs/custom-reporters.md
673
- [50]: #create-a-new-plugin
674
- [51]: #libraries-and-unused-exports
675
- [52]: https://github.com/depcheck/depcheck
676
- [53]: https://github.com/smeijer/unimported
677
- [54]: https://github.com/pzavolinsky/ts-unused-exports
678
- [55]: https://github.com/nadeesha/ts-prune
679
- [56]: #production-mode
622
+ [12]: #config
623
+ [13]: ./docs/writing-a-plugin.md
624
+ [14]: ./docs/compilers.md
625
+ [15]: ./docs/custom-reporters.md
626
+ [16]: #create-a-new-plugin
627
+ [17]: #public-exports
628
+ [18]: https://github.com/depcheck/depcheck
629
+ [19]: https://github.com/smeijer/unimported
630
+ [20]: https://github.com/pzavolinsky/ts-unused-exports
631
+ [21]: https://github.com/nadeesha/ts-prune
632
+ [22]: #production-mode
633
+ [plugin-ava]: ./src/plugins/ava
634
+ [plugin-babel]: ./src/plugins/babel
635
+ [plugin-capacitor]: ./src/plugins/capacitor
636
+ [plugin-changesets]: ./src/plugins/changesets
637
+ [plugin-commitlint]: ./src/plugins/commitlint
638
+ [plugin-cspell]: ./src/plugins/cspell
639
+ [plugin-cypress]: ./src/plugins/cypress
640
+ [plugin-eslint]: ./src/plugins/eslint
641
+ [plugin-gatsby]: ./src/plugins/gatsby
642
+ [plugin-github-actions]: ./src/plugins/github-actions
643
+ [plugin-husky]: ./src/plugins/husky
644
+ [plugin-jest]: ./src/plugins/jest
645
+ [plugin-lefthook]: ./src/plugins/lefthook
646
+ [plugin-lint-staged]: ./src/plugins/lint-staged
647
+ [plugin-markdownlint]: ./src/plugins/markdownlint
648
+ [plugin-mocha]: ./src/plugins/mocha
649
+ [plugin-next]: ./src/plugins/next
650
+ [plugin-npm-package-json-lint]: ./src/plugins/npm-package-json-lint
651
+ [plugin-nx]: ./src/plugins/nx
652
+ [plugin-nyc]: ./src/plugins/nyc
653
+ [plugin-playwright]: ./src/plugins/playwright
654
+ [plugin-postcss]: ./src/plugins/postcss
655
+ [plugin-prettier]: ./src/plugins/prettier
656
+ [plugin-release-it]: ./src/plugins/release-it
657
+ [plugin-remark]: ./src/plugins/remark
658
+ [plugin-remix]: ./src/plugins/remix
659
+ [plugin-rollup]: ./src/plugins/rollup
660
+ [plugin-semantic-release]: ./src/plugins/semantic-release
661
+ [plugin-sentry]: ./src/plugins/sentry
662
+ [plugin-storybook]: ./src/plugins/storybook
663
+ [plugin-stryker]: ./src/plugins/stryker
664
+ [plugin-svelte]: ./src/plugins/svelte
665
+ [plugin-typedoc]: ./src/plugins/typedoc
666
+ [plugin-typescript]: ./src/plugins/typescript
667
+ [plugin-vitest]: ./src/plugins/vitest
668
+ [plugin-webpack]: ./src/plugins/webpack
@@ -0,0 +1,6 @@
1
+ import type { PackageJson } from 'type-fest';
2
+ export declare const getBinariesFromScript: (script: string, { cwd, manifest, knownGlobalsOnly }: {
3
+ cwd: string;
4
+ manifest: PackageJson;
5
+ knownGlobalsOnly?: boolean | undefined;
6
+ }) => string[];
@@ -0,0 +1,57 @@
1
+ import parse from 'bash-parser';
2
+ import parseArgs from 'minimist';
3
+ import * as FallbackResolver from './resolvers/fallback.js';
4
+ import * as KnownResolvers from './resolvers/index.js';
5
+ const spawningBinaries = ['cross-env', 'dotenv'];
6
+ export const getBinariesFromScript = (script, { cwd, manifest, knownGlobalsOnly = false }) => {
7
+ if (!script)
8
+ return [];
9
+ const fromArgs = (args) => getBinariesFromScript(args.join(' '), { cwd, manifest });
10
+ const getBinariesFromNodes = (nodes) => nodes.flatMap(node => {
11
+ switch (node.type) {
12
+ case 'Command': {
13
+ const binary = node.name?.text;
14
+ const commandExpansions = node.prefix?.flatMap(prefix => prefix.expansion?.filter(expansion => expansion.type === 'CommandExpansion') ?? []) ?? [];
15
+ if (commandExpansions.length > 0) {
16
+ return commandExpansions.flatMap(expansion => getBinariesFromNodes(expansion.commandAST.commands)) ?? [];
17
+ }
18
+ if (!binary || binary === '.' || binary === 'source')
19
+ return [];
20
+ if (binary.startsWith('-') || binary.startsWith('"') || binary.startsWith('..'))
21
+ return [];
22
+ if (['bun', 'deno'].includes(binary))
23
+ return [];
24
+ const args = node.suffix?.map(arg => arg.text) ?? [];
25
+ if (['!', 'test'].includes(binary))
26
+ return fromArgs(args);
27
+ if (binary in KnownResolvers) {
28
+ return KnownResolvers[binary].resolve(binary, args, { cwd, manifest, fromArgs });
29
+ }
30
+ if (knownGlobalsOnly)
31
+ return [];
32
+ if (spawningBinaries.includes(binary)) {
33
+ const parsedArgs = parseArgs(args);
34
+ const [spawnedBinary] = parsedArgs._;
35
+ if (spawnedBinary) {
36
+ const restArgs = args.slice(args.indexOf(spawnedBinary));
37
+ return [binary, ...fromArgs(restArgs)];
38
+ }
39
+ else {
40
+ return [];
41
+ }
42
+ }
43
+ return FallbackResolver.resolve(binary, args, { cwd, manifest, fromArgs });
44
+ }
45
+ case 'LogicalExpression':
46
+ return getBinariesFromNodes([node.left, node.right]);
47
+ case 'If':
48
+ return getBinariesFromNodes([...node.clause.commands, ...node.then.commands]);
49
+ case 'For':
50
+ return getBinariesFromNodes(node.do.commands);
51
+ default:
52
+ return [];
53
+ }
54
+ });
55
+ const parsed = parse(script);
56
+ return parsed?.commands ? getBinariesFromNodes(parsed.commands) : [];
57
+ };
@@ -0,0 +1,2 @@
1
+ import type { GetReferencesFromScripts } from './types.js';
2
+ export declare const _getReferencesFromScripts: GetReferencesFromScripts;
@@ -0,0 +1,22 @@
1
+ import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
2
+ import { compact } from '../util/array.js';
3
+ import { partition } from '../util/array.js';
4
+ import { getPackageNameFromModuleSpecifier, stripBinary } from '../util/modules.js';
5
+ import { isInternal } from '../util/path.js';
6
+ import { timerify } from '../util/performance.js';
7
+ import { getBinariesFromScript } from './bash-parser.js';
8
+ const defaultCwd = process.cwd();
9
+ const getReferencesFromScripts = (npmScripts, options = {}) => {
10
+ const { cwd = defaultCwd, manifest = {}, ignore = [], knownGlobalsOnly = false } = options;
11
+ const scripts = [npmScripts].flat();
12
+ const results = scripts.flatMap(script => getBinariesFromScript(script, { cwd, manifest, knownGlobalsOnly }));
13
+ const [entryFiles, binaries] = partition(compact(results), isInternal);
14
+ return {
15
+ entryFiles,
16
+ binaries: binaries
17
+ .map(stripBinary)
18
+ .map(getPackageNameFromModuleSpecifier)
19
+ .filter(binaryName => !IGNORED_GLOBAL_BINARIES.includes(binaryName) && !ignore.includes(binaryName)),
20
+ };
21
+ };
22
+ export const _getReferencesFromScripts = timerify(getReferencesFromScripts);
@@ -0,0 +1,2 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const resolve: Resolver;
@@ -0,0 +1,14 @@
1
+ import parseArgs from 'minimist';
2
+ import { tryResolveFilePaths } from './node.js';
3
+ const argResolvers = {
4
+ 'babel-node': parsed => [parsed._[0], parsed.require].flat(),
5
+ 'ts-node': parsed => [parsed._[0], parsed.require].flat(),
6
+ tsx: parsed => parsed._.filter(p => p !== 'watch'),
7
+ default: parsed => [parsed.require].flat(),
8
+ };
9
+ export const resolve = (binary, args, { cwd }) => {
10
+ const parsed = parseArgs(args, { string: ['r'], alias: { require: ['r', 'loader'] } });
11
+ const resolver = argResolvers[binary] ?? argResolvers.default;
12
+ const resolve = resolver(parsed);
13
+ return [binary, ...tryResolveFilePaths(cwd, resolve)];
14
+ };
@@ -0,0 +1,4 @@
1
+ export * as node from './node.js';
2
+ export * as npx from './npx.js';
3
+ export * as pnpm from './pnpm.js';
4
+ export * as yarn from './yarn.js';
@@ -0,0 +1,4 @@
1
+ export * as node from './node.js';
2
+ export * as npx from './npx.js';
3
+ export * as pnpm from './pnpm.js';
4
+ export * as yarn from './yarn.js';
@@ -0,0 +1,3 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const tryResolveFilePaths: (cwd: string, specifiers: string[]) => string[];
3
+ export declare const resolve: Resolver;
@@ -0,0 +1,20 @@
1
+ import parseArgs from 'minimist';
2
+ import { isInNodeModules, join } from '../../util/path.js';
3
+ import { _tryResolve } from '../../util/require.js';
4
+ const tryResolveFilePath = (cwd, specifier, fallback) => {
5
+ if (specifier) {
6
+ const filePath = join(cwd, specifier);
7
+ if (!isInNodeModules(filePath)) {
8
+ const resolvedFilePath = _tryResolve(filePath, cwd);
9
+ if (resolvedFilePath)
10
+ return [resolvedFilePath];
11
+ }
12
+ return fallback ? [fallback] : [];
13
+ }
14
+ return [];
15
+ };
16
+ export const tryResolveFilePaths = (cwd, specifiers) => specifiers.flatMap(specifier => tryResolveFilePath(cwd, specifier, specifier));
17
+ export const resolve = (binary, args, { cwd }) => {
18
+ const parsed = parseArgs(args, { string: ['r'], alias: { require: ['r', 'loader', 'experimental-loader'] } });
19
+ return [...tryResolveFilePath(cwd, parsed._[0]), ...tryResolveFilePaths(cwd, [parsed.require].flat())];
20
+ };
@@ -0,0 +1,2 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const resolve: Resolver;
@@ -0,0 +1,5 @@
1
+ import parseArgs from 'minimist';
2
+ export const resolve = (binary, args, { fromArgs }) => {
3
+ const parsed = parseArgs(args, { '--': true, stopEarly: true, boolean: ['yes', 'no'], alias: { yes: 'y', no: 'n' } });
4
+ return [...(parsed.yes ? [] : fromArgs(parsed._)), ...(parsed['--'] ? fromArgs(parsed['--']) : [])];
5
+ };
@@ -0,0 +1,2 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const resolve: Resolver;
@@ -0,0 +1,45 @@
1
+ import parseArgs from 'minimist';
2
+ const commands = [
3
+ 'add',
4
+ 'dlx',
5
+ 'run',
6
+ 'i',
7
+ 'install',
8
+ 'up',
9
+ 'update',
10
+ 'upgrade',
11
+ 'remove',
12
+ 'rm',
13
+ 'uninstall',
14
+ 'un',
15
+ 'link',
16
+ 'ln',
17
+ 'unlink',
18
+ 'import',
19
+ 'rebuild',
20
+ 'rb',
21
+ 'prune',
22
+ 'fetch',
23
+ 'install-test',
24
+ 'it',
25
+ 'patch',
26
+ 'patch-commit',
27
+ 'audit',
28
+ 'list',
29
+ 'ls',
30
+ 'outdated',
31
+ 'why',
32
+ 'test',
33
+ 't',
34
+ 'tst',
35
+ ];
36
+ export const resolve = (binary, args, { manifest }) => {
37
+ const scripts = manifest.scripts ? Object.keys(manifest.scripts) : [];
38
+ const parsed = parseArgs(args, {});
39
+ const [command, result] = parsed._;
40
+ if (scripts.includes(command) || commands.includes(command))
41
+ return [];
42
+ if (command === 'exec')
43
+ return [result];
44
+ return command ? [command] : [];
45
+ };
@@ -0,0 +1,2 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const resolve: Resolver;