knip 5.68.0 → 5.69.1

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 (310) hide show
  1. package/dist/CatalogCounselor.d.ts +18 -0
  2. package/dist/CatalogCounselor.js +50 -0
  3. package/dist/ConfigurationChief.d.ts +6 -0
  4. package/dist/ConfigurationChief.js +3 -1
  5. package/dist/DependencyDeputy.js +10 -3
  6. package/dist/IssueFixer.d.ts +1 -6
  7. package/dist/IssueFixer.js +75 -46
  8. package/dist/JsonCatalogPeeker.d.ts +12 -0
  9. package/dist/JsonCatalogPeeker.js +68 -0
  10. package/dist/PackagePeeker.js +1 -0
  11. package/dist/YamlCatalogPeeker.d.ts +12 -0
  12. package/dist/YamlCatalogPeeker.js +66 -0
  13. package/dist/binaries/bash-parser.js +1 -1
  14. package/dist/compilers/index.d.ts +14 -4
  15. package/dist/constants.d.ts +9 -1
  16. package/dist/constants.js +9 -0
  17. package/dist/graph/analyze.d.ts +3 -1
  18. package/dist/graph/analyze.js +22 -16
  19. package/dist/graph/build.d.ts +3 -1
  20. package/dist/graph/build.js +2 -1
  21. package/dist/index.js +5 -2
  22. package/dist/plugins/_template/index.d.ts +3 -12
  23. package/dist/plugins/_template/index.js +2 -1
  24. package/dist/plugins/angular/index.d.ts +3 -10
  25. package/dist/plugins/angular/index.js +2 -1
  26. package/dist/plugins/astro/index.d.ts +3 -13
  27. package/dist/plugins/astro/index.js +2 -1
  28. package/dist/plugins/astro-db/index.d.ts +3 -8
  29. package/dist/plugins/astro-db/index.js +2 -1
  30. package/dist/plugins/ava/index.d.ts +3 -11
  31. package/dist/plugins/ava/index.js +2 -1
  32. package/dist/plugins/babel/index.d.ts +4 -10
  33. package/dist/plugins/babel/index.js +2 -1
  34. package/dist/plugins/biome/index.d.ts +3 -10
  35. package/dist/plugins/biome/index.js +2 -1
  36. package/dist/plugins/bumpp/index.d.ts +3 -8
  37. package/dist/plugins/bumpp/index.js +2 -1
  38. package/dist/plugins/bun/index.d.ts +3 -11
  39. package/dist/plugins/bun/index.js +2 -1
  40. package/dist/plugins/c8/index.d.ts +3 -10
  41. package/dist/plugins/c8/index.js +2 -1
  42. package/dist/plugins/capacitor/index.d.ts +3 -10
  43. package/dist/plugins/capacitor/index.js +2 -1
  44. package/dist/plugins/changelogen/index.d.ts +3 -9
  45. package/dist/plugins/changelogen/index.js +2 -1
  46. package/dist/plugins/changelogithub/index.d.ts +3 -9
  47. package/dist/plugins/changelogithub/index.js +2 -1
  48. package/dist/plugins/changesets/index.d.ts +3 -11
  49. package/dist/plugins/changesets/index.js +2 -1
  50. package/dist/plugins/commitizen/index.d.ts +3 -12
  51. package/dist/plugins/commitizen/index.js +2 -1
  52. package/dist/plugins/commitlint/index.d.ts +3 -10
  53. package/dist/plugins/commitlint/index.js +2 -1
  54. package/dist/plugins/convex/index.d.ts +3 -8
  55. package/dist/plugins/convex/index.js +2 -1
  56. package/dist/plugins/create-typescript-app/index.d.ts +3 -8
  57. package/dist/plugins/create-typescript-app/index.js +2 -1
  58. package/dist/plugins/cspell/index.d.ts +3 -10
  59. package/dist/plugins/cspell/index.js +2 -1
  60. package/dist/plugins/cucumber/index.d.ts +3 -11
  61. package/dist/plugins/cucumber/index.js +2 -1
  62. package/dist/plugins/cypress/index.d.ts +3 -11
  63. package/dist/plugins/cypress/index.js +2 -1
  64. package/dist/plugins/danger/index.d.ts +3 -8
  65. package/dist/plugins/danger/index.js +2 -1
  66. package/dist/plugins/dependency-cruiser/index.d.ts +3 -12
  67. package/dist/plugins/dependency-cruiser/index.js +2 -1
  68. package/dist/plugins/docusaurus/index.d.ts +3 -12
  69. package/dist/plugins/docusaurus/index.js +2 -1
  70. package/dist/plugins/dotenv/index.d.ts +3 -8
  71. package/dist/plugins/dotenv/index.js +2 -1
  72. package/dist/plugins/drizzle/index.d.ts +3 -10
  73. package/dist/plugins/drizzle/index.js +2 -1
  74. package/dist/plugins/eleventy/index.d.ts +3 -11
  75. package/dist/plugins/eleventy/index.js +2 -1
  76. package/dist/plugins/eslint/helpers.d.ts +1 -0
  77. package/dist/plugins/eslint/helpers.js +14 -1
  78. package/dist/plugins/eslint/index.d.ts +3 -19
  79. package/dist/plugins/eslint/index.js +7 -2
  80. package/dist/plugins/expo/index.d.ts +3 -11
  81. package/dist/plugins/expo/index.js +2 -1
  82. package/dist/plugins/gatsby/index.d.ts +3 -11
  83. package/dist/plugins/gatsby/index.js +2 -1
  84. package/dist/plugins/github-action/index.d.ts +3 -9
  85. package/dist/plugins/github-action/index.js +2 -1
  86. package/dist/plugins/github-actions/index.d.ts +3 -10
  87. package/dist/plugins/github-actions/index.js +2 -1
  88. package/dist/plugins/glob/index.d.ts +3 -11
  89. package/dist/plugins/glob/index.js +2 -1
  90. package/dist/plugins/graphql-codegen/index.d.ts +3 -11
  91. package/dist/plugins/graphql-codegen/index.js +2 -1
  92. package/dist/plugins/hardhat/index.d.ts +3 -9
  93. package/dist/plugins/hardhat/index.js +2 -1
  94. package/dist/plugins/husky/index.d.ts +3 -10
  95. package/dist/plugins/husky/index.js +2 -1
  96. package/dist/plugins/i18next-parser/index.d.ts +3 -12
  97. package/dist/plugins/i18next-parser/index.js +2 -1
  98. package/dist/plugins/index.d.ts +118 -942
  99. package/dist/plugins/index.js +2 -0
  100. package/dist/plugins/jest/index.d.ts +3 -14
  101. package/dist/plugins/jest/index.js +2 -1
  102. package/dist/plugins/karma/index.d.ts +3 -10
  103. package/dist/plugins/karma/index.js +2 -1
  104. package/dist/plugins/ladle/index.d.ts +3 -12
  105. package/dist/plugins/ladle/index.js +2 -1
  106. package/dist/plugins/lefthook/index.d.ts +3 -9
  107. package/dist/plugins/lefthook/index.js +2 -1
  108. package/dist/plugins/lint-staged/index.d.ts +3 -10
  109. package/dist/plugins/lint-staged/index.js +2 -1
  110. package/dist/plugins/linthtml/index.d.ts +3 -11
  111. package/dist/plugins/linthtml/index.js +2 -1
  112. package/dist/plugins/lockfile-lint/index.d.ts +3 -8
  113. package/dist/plugins/lockfile-lint/index.js +2 -1
  114. package/dist/plugins/lost-pixel/index.d.ts +3 -8
  115. package/dist/plugins/lost-pixel/index.js +2 -1
  116. package/dist/plugins/markdownlint/index.d.ts +3 -10
  117. package/dist/plugins/markdownlint/index.js +2 -1
  118. package/dist/plugins/mdx/index.d.ts +3 -0
  119. package/dist/plugins/mdx/index.js +32 -0
  120. package/dist/plugins/mdx/types.d.ts +3 -0
  121. package/dist/plugins/mdx/types.js +1 -0
  122. package/dist/plugins/mdxlint/index.d.ts +3 -10
  123. package/dist/plugins/mdxlint/index.js +7 -2
  124. package/dist/plugins/metro/index.d.ts +3 -11
  125. package/dist/plugins/metro/index.js +2 -1
  126. package/dist/plugins/mocha/index.d.ts +3 -14
  127. package/dist/plugins/mocha/index.js +2 -1
  128. package/dist/plugins/moonrepo/index.d.ts +3 -11
  129. package/dist/plugins/moonrepo/index.js +2 -1
  130. package/dist/plugins/msw/index.d.ts +3 -11
  131. package/dist/plugins/msw/index.js +2 -1
  132. package/dist/plugins/nano-staged/index.d.ts +3 -10
  133. package/dist/plugins/nano-staged/index.js +2 -1
  134. package/dist/plugins/nest/index.d.ts +3 -10
  135. package/dist/plugins/nest/index.js +2 -1
  136. package/dist/plugins/netlify/index.d.ts +3 -11
  137. package/dist/plugins/netlify/index.js +2 -1
  138. package/dist/plugins/next/index.d.ts +3 -10
  139. package/dist/plugins/next/index.js +6 -6
  140. package/dist/plugins/node/index.d.ts +3 -17
  141. package/dist/plugins/node/index.js +2 -1
  142. package/dist/plugins/node-modules-inspector/index.d.ts +3 -11
  143. package/dist/plugins/node-modules-inspector/index.js +2 -1
  144. package/dist/plugins/nodemon/index.d.ts +3 -10
  145. package/dist/plugins/nodemon/index.js +2 -1
  146. package/dist/plugins/npm-package-json-lint/index.d.ts +3 -11
  147. package/dist/plugins/npm-package-json-lint/index.js +2 -1
  148. package/dist/plugins/nuxt/index.d.ts +3 -12
  149. package/dist/plugins/nuxt/index.js +2 -1
  150. package/dist/plugins/nx/index.d.ts +3 -14
  151. package/dist/plugins/nx/index.js +2 -1
  152. package/dist/plugins/nyc/index.d.ts +3 -10
  153. package/dist/plugins/nyc/index.js +2 -1
  154. package/dist/plugins/oclif/index.d.ts +3 -10
  155. package/dist/plugins/oclif/index.js +2 -1
  156. package/dist/plugins/oxlint/index.d.ts +3 -11
  157. package/dist/plugins/oxlint/index.js +2 -1
  158. package/dist/plugins/playwright/index.d.ts +3 -15
  159. package/dist/plugins/playwright/index.js +2 -1
  160. package/dist/plugins/playwright-ct/index.d.ts +3 -10
  161. package/dist/plugins/playwright-ct/index.js +2 -1
  162. package/dist/plugins/playwright-test/index.d.ts +3 -12
  163. package/dist/plugins/playwright-test/index.js +2 -1
  164. package/dist/plugins/plop/index.d.ts +3 -8
  165. package/dist/plugins/plop/index.js +2 -1
  166. package/dist/plugins/pnpm/index.d.ts +3 -8
  167. package/dist/plugins/pnpm/index.js +2 -1
  168. package/dist/plugins/postcss/index.d.ts +3 -10
  169. package/dist/plugins/postcss/index.js +2 -1
  170. package/dist/plugins/preconstruct/index.d.ts +3 -10
  171. package/dist/plugins/preconstruct/index.js +2 -1
  172. package/dist/plugins/prettier/index.d.ts +3 -10
  173. package/dist/plugins/prettier/index.js +2 -1
  174. package/dist/plugins/prisma/index.d.ts +3 -13
  175. package/dist/plugins/prisma/index.js +10 -2
  176. package/dist/plugins/prisma/types.d.ts +3 -0
  177. package/dist/plugins/react-cosmos/index.d.ts +3 -11
  178. package/dist/plugins/react-cosmos/index.js +2 -1
  179. package/dist/plugins/react-router/index.d.ts +3 -10
  180. package/dist/plugins/react-router/index.js +3 -2
  181. package/dist/plugins/relay/index.d.ts +3 -15
  182. package/dist/plugins/relay/index.js +2 -1
  183. package/dist/plugins/release-it/index.d.ts +3 -10
  184. package/dist/plugins/release-it/index.js +2 -1
  185. package/dist/plugins/remark/index.d.ts +3 -11
  186. package/dist/plugins/remark/index.js +2 -1
  187. package/dist/plugins/remix/index.d.ts +3 -9
  188. package/dist/plugins/remix/index.js +2 -1
  189. package/dist/plugins/rollup/index.d.ts +3 -10
  190. package/dist/plugins/rollup/index.js +2 -1
  191. package/dist/plugins/rsbuild/index.d.ts +3 -10
  192. package/dist/plugins/rsbuild/index.js +2 -1
  193. package/dist/plugins/rslib/index.d.ts +3 -10
  194. package/dist/plugins/rslib/index.js +2 -1
  195. package/dist/plugins/rspack/index.d.ts +3 -10
  196. package/dist/plugins/rspack/index.js +2 -1
  197. package/dist/plugins/rstest/index.d.ts +3 -10
  198. package/dist/plugins/rstest/index.js +2 -1
  199. package/dist/plugins/semantic-release/index.d.ts +3 -12
  200. package/dist/plugins/semantic-release/index.js +2 -1
  201. package/dist/plugins/sentry/index.d.ts +3 -8
  202. package/dist/plugins/sentry/index.js +2 -1
  203. package/dist/plugins/simple-git-hooks/index.d.ts +3 -10
  204. package/dist/plugins/simple-git-hooks/index.js +2 -1
  205. package/dist/plugins/size-limit/index.d.ts +3 -9
  206. package/dist/plugins/size-limit/index.js +2 -1
  207. package/dist/plugins/sst/index.d.ts +3 -9
  208. package/dist/plugins/sst/index.js +2 -1
  209. package/dist/plugins/starlight/index.d.ts +3 -9
  210. package/dist/plugins/starlight/index.js +2 -1
  211. package/dist/plugins/storybook/index.d.ts +3 -12
  212. package/dist/plugins/storybook/index.js +2 -1
  213. package/dist/plugins/stryker/index.d.ts +3 -10
  214. package/dist/plugins/stryker/index.js +2 -1
  215. package/dist/plugins/stylelint/index.d.ts +3 -10
  216. package/dist/plugins/stylelint/index.js +2 -1
  217. package/dist/plugins/svelte/index.d.ts +3 -10
  218. package/dist/plugins/svelte/index.js +2 -1
  219. package/dist/plugins/svgo/index.d.ts +3 -8
  220. package/dist/plugins/svgo/index.js +2 -1
  221. package/dist/plugins/syncpack/index.d.ts +3 -8
  222. package/dist/plugins/syncpack/index.js +2 -1
  223. package/dist/plugins/tailwind/index.d.ts +3 -8
  224. package/dist/plugins/tailwind/index.js +2 -1
  225. package/dist/plugins/travis/index.d.ts +3 -10
  226. package/dist/plugins/travis/index.js +2 -1
  227. package/dist/plugins/ts-node/index.d.ts +3 -14
  228. package/dist/plugins/ts-node/index.js +2 -1
  229. package/dist/plugins/tsdown/index.d.ts +3 -13
  230. package/dist/plugins/tsdown/index.js +2 -1
  231. package/dist/plugins/tsup/index.d.ts +3 -13
  232. package/dist/plugins/tsup/index.js +2 -1
  233. package/dist/plugins/tsx/index.d.ts +3 -15
  234. package/dist/plugins/tsx/index.js +2 -1
  235. package/dist/plugins/typedoc/index.d.ts +3 -16
  236. package/dist/plugins/typedoc/index.js +2 -1
  237. package/dist/plugins/typescript/index.d.ts +3 -18
  238. package/dist/plugins/typescript/index.js +2 -1
  239. package/dist/plugins/unbuild/index.d.ts +3 -10
  240. package/dist/plugins/unbuild/index.js +2 -1
  241. package/dist/plugins/unocss/index.d.ts +3 -8
  242. package/dist/plugins/unocss/index.js +2 -1
  243. package/dist/plugins/vercel-og/index.d.ts +3 -8
  244. package/dist/plugins/vercel-og/index.js +2 -1
  245. package/dist/plugins/vike/index.d.ts +3 -8
  246. package/dist/plugins/vike/index.js +2 -1
  247. package/dist/plugins/vite/index.d.ts +3 -10
  248. package/dist/plugins/vite/index.js +2 -1
  249. package/dist/plugins/vitest/index.d.ts +3 -16
  250. package/dist/plugins/vitest/index.js +2 -1
  251. package/dist/plugins/vue/index.d.ts +3 -10
  252. package/dist/plugins/vue/index.js +2 -1
  253. package/dist/plugins/webdriver-io/index.d.ts +3 -10
  254. package/dist/plugins/webdriver-io/index.js +2 -1
  255. package/dist/plugins/webpack/index.d.ts +3 -13
  256. package/dist/plugins/webpack/index.js +2 -1
  257. package/dist/plugins/wireit/index.d.ts +3 -10
  258. package/dist/plugins/wireit/index.js +2 -1
  259. package/dist/plugins/wrangler/index.d.ts +3 -10
  260. package/dist/plugins/wrangler/index.js +2 -1
  261. package/dist/plugins/xo/index.d.ts +3 -11
  262. package/dist/plugins/xo/index.js +2 -1
  263. package/dist/plugins/yarn/index.d.ts +3 -9
  264. package/dist/plugins/yarn/index.js +2 -1
  265. package/dist/plugins/yorkie/index.d.ts +3 -11
  266. package/dist/plugins/yorkie/index.js +2 -1
  267. package/dist/reporters/json.js +1 -0
  268. package/dist/reporters/util/util.d.ts +1 -1
  269. package/dist/schema/configuration.d.ts +14 -4
  270. package/dist/schema/configuration.js +1 -0
  271. package/dist/schema/plugins.d.ts +5 -0
  272. package/dist/schema/plugins.js +1 -0
  273. package/dist/types/PluginNames.d.ts +2 -2
  274. package/dist/types/PluginNames.js +1 -0
  275. package/dist/types/config.d.ts +2 -0
  276. package/dist/types/exports.d.ts +1 -1
  277. package/dist/types/imports.d.ts +1 -3
  278. package/dist/types/issues.d.ts +3 -0
  279. package/dist/types/package-json.d.ts +12 -1
  280. package/dist/types.d.ts +1 -1
  281. package/dist/typescript/ast-helpers.d.ts +1 -1
  282. package/dist/typescript/get-imports-and-exports.js +18 -17
  283. package/dist/typescript/visitors/dynamic-imports/importCall.js +23 -15
  284. package/dist/typescript/visitors/dynamic-imports/importType.js +7 -1
  285. package/dist/typescript/visitors/dynamic-imports/index.js +2 -1
  286. package/dist/typescript/visitors/dynamic-imports/jsDocType.js +13 -2
  287. package/dist/typescript/visitors/dynamic-imports/requireCall.js +13 -9
  288. package/dist/typescript/visitors/dynamic-imports/resolveCall.js +7 -1
  289. package/dist/typescript/visitors/dynamic-imports/urlConstructor.d.ts +3 -0
  290. package/dist/typescript/visitors/dynamic-imports/urlConstructor.js +24 -0
  291. package/dist/typescript/visitors/exports/exportDeclaration.js +1 -1
  292. package/dist/typescript/visitors/helpers.js +13 -2
  293. package/dist/typescript/visitors/imports/importDeclaration.js +9 -8
  294. package/dist/typescript/visitors/imports/importEqualsDeclaration.js +9 -1
  295. package/dist/typescript/visitors/imports/reExportDeclaration.js +10 -5
  296. package/dist/util/catalog.d.ts +6 -0
  297. package/dist/util/catalog.js +62 -0
  298. package/dist/util/cli-arguments.d.ts +1 -1
  299. package/dist/util/cli-arguments.js +3 -3
  300. package/dist/util/create-options.d.ts +17 -4
  301. package/dist/util/create-options.js +8 -5
  302. package/dist/util/errors.js +11 -1
  303. package/dist/util/get-included-issue-types.d.ts +1 -1
  304. package/dist/util/get-included-issue-types.js +3 -2
  305. package/dist/util/get-referenced-inputs.js +4 -0
  306. package/dist/util/trace.js +4 -4
  307. package/dist/version.d.ts +1 -1
  308. package/dist/version.js +1 -1
  309. package/package.json +1 -1
  310. package/schema.json +4 -0
@@ -32,6 +32,7 @@ export default async ({ report, issues, options, cwd }) => {
32
32
  ...(report.enumMembers && { enumMembers: {} }),
33
33
  ...(report.classMembers && { classMembers: {} }),
34
34
  ...(report.duplicates && { duplicates: [] }),
35
+ ...(report.catalog && { catalog: [] }),
35
36
  };
36
37
  return row;
37
38
  };
@@ -3,7 +3,7 @@ import type { Issue, IssueSeverity, IssueSymbol } from '../../types/issues.js';
3
3
  import { Table } from '../../util/table.js';
4
4
  export declare const dim: import("picocolors/types.js").Formatter;
5
5
  export declare const bright: import("picocolors/types.js").Formatter;
6
- export declare const getIssueTypeTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) => "Unused files" | "Unused dependencies" | "Unused devDependencies" | "Referenced optional peerDependencies" | "Unlisted dependencies" | "Unlisted binaries" | "Unresolved imports" | "Unused exports" | "Exports in used namespace" | "Unused exported types" | "Exported types in used namespace" | "Unused exported enum members" | "Unused exported class members" | "Duplicate exports";
6
+ export declare const getIssueTypeTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) => "Unused files" | "Unused dependencies" | "Unused devDependencies" | "Referenced optional peerDependencies" | "Unlisted dependencies" | "Unlisted binaries" | "Unresolved imports" | "Unused exports" | "Exports in used namespace" | "Unused exported types" | "Exported types in used namespace" | "Unused exported enum members" | "Unused exported class members" | "Duplicate exports" | "Unused catalog entries";
7
7
  export declare const getColoredTitle: (title: string, count: number) => string;
8
8
  export declare const getDimmedTitle: (title: string, count: number) => string;
9
9
  type LogIssueLine = {
@@ -227,6 +227,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
227
227
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
228
228
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
229
229
  }, z.core.$strip>]>>;
230
+ mdx: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
231
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
232
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
233
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
234
+ }, z.core.$strip>]>>;
230
235
  mdxlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
231
236
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
232
237
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -813,6 +818,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
813
818
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
814
819
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
815
820
  }, z.core.$strip>]>>;
821
+ mdx: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
822
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
823
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
824
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
825
+ }, z.core.$strip>]>>;
816
826
  mdxlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
817
827
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
818
828
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1184,10 +1194,10 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1184
1194
  ignoreUnresolved: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
1185
1195
  includeEntryExports: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
1186
1196
  }, z.core.$strict>>>;
1187
- include: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">]>>>;
1188
- exclude: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">]>>>;
1197
+ include: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">, z.ZodMiniLiteral<"catalog">]>>>;
1198
+ exclude: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">, z.ZodMiniLiteral<"catalog">]>>>;
1189
1199
  $schema: z.ZodMiniOptional<z.ZodMiniString<string>>;
1190
- rules: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">]> & z.core.$partial, z.ZodMiniEnum<{
1200
+ rules: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">, z.ZodMiniLiteral<"catalog">]> & z.core.$partial, z.ZodMiniEnum<{
1191
1201
  error: "error";
1192
1202
  warn: "warn";
1193
1203
  off: "off";
@@ -1204,7 +1214,7 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1204
1214
  ignoreExportsUsedInFile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniObject<{
1205
1215
  [k: string]: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
1206
1216
  }, z.core.$strict>]>>;
1207
- ignoreIssues: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">]>>>>;
1217
+ ignoreIssues: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"classMembers">, z.ZodMiniLiteral<"catalog">]>>>>;
1208
1218
  ignoreWorkspaces: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
1209
1219
  includeEntryExports: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
1210
1220
  compilers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniUnion<readonly [z.ZodMiniLiteral<true>, z.ZodMiniCustom<SyncCompiler, SyncCompiler>]>, z.ZodMiniCustom<AsyncCompiler, AsyncCompiler>]>>>;
@@ -22,6 +22,7 @@ const issueTypeSchema = z.union([
22
22
  z.literal('duplicates'),
23
23
  z.literal('enumMembers'),
24
24
  z.literal('classMembers'),
25
+ z.literal('catalog'),
25
26
  ]);
26
27
  const rulesSchema = z.partialRecord(issueTypeSchema, z.enum(['error', 'warn', 'off']));
27
28
  const ignorableSymbolTypes = Object.values(SYMBOL_TYPE).filter(type => type !== 'unknown');
@@ -231,6 +231,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
231
231
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
232
232
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
233
233
  }, z.core.$strip>]>;
234
+ mdx: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
235
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
236
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
237
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
238
+ }, z.core.$strip>]>;
234
239
  mdxlint: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
235
240
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
236
241
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -55,6 +55,7 @@ export const pluginsSchema = z.object({
55
55
  'lockfile-lint': pluginSchema,
56
56
  'lost-pixel': pluginSchema,
57
57
  markdownlint: pluginSchema,
58
+ mdx: pluginSchema,
58
59
  mdxlint: pluginSchema,
59
60
  metro: pluginSchema,
60
61
  mocha: pluginSchema,
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'syncpack' | 'tailwind' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "syncpack", "tailwind", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'syncpack' | 'tailwind' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "syncpack", "tailwind", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
@@ -44,6 +44,7 @@ export const pluginNames = [
44
44
  'lockfile-lint',
45
45
  'lost-pixel',
46
46
  'markdownlint',
47
+ 'mdx',
47
48
  'mdxlint',
48
49
  'metro',
49
50
  'mocha',
@@ -3,6 +3,7 @@ import type { z } from 'zod/mini';
3
3
  import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
4
4
  import type { knipConfigurationSchema } from '../schema/configuration.js';
5
5
  import type { pluginSchema } from '../schema/plugins.js';
6
+ import type { ParsedCLIArgs } from '../util/cli-arguments.js';
6
7
  import type { Input } from '../util/input.js';
7
8
  import type { Args } from './args.js';
8
9
  import type { IssueType, SymbolType } from './issues.js';
@@ -21,6 +22,7 @@ export interface BinaryResolverOptions extends GetInputsFromScriptsOptions {
21
22
  }
22
23
  export type BinaryResolver = (binary: string, args: string[], options: BinaryResolverOptions) => Input[];
23
24
  export type RawConfiguration = z.infer<typeof knipConfigurationSchema>;
25
+ export type RawConfigurationOrFn = RawConfiguration | ((options: ParsedCLIArgs) => RawConfiguration | Promise<RawConfiguration>);
24
26
  export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
25
27
  export type IgnorePatterns = (string | RegExp)[];
26
28
  type IgnorableExport = Exclude<SymbolType, 'unknown'>;
@@ -1,7 +1,7 @@
1
1
  import type ts from 'typescript';
2
2
  import type { SymbolType } from './issues.js';
3
3
  type Identifier = string;
4
- export type ExportPosTuple = [number, number, number];
4
+ type ExportPosTuple = [number, number, number];
5
5
  export type Fix = ExportPosTuple | undefined;
6
6
  export type Fixes = Array<ExportPosTuple>;
7
7
  export type ExportNode = {
@@ -6,7 +6,5 @@ export interface ImportNode {
6
6
  namespace?: string | undefined;
7
7
  pos: number;
8
8
  symbol?: ts.Symbol;
9
- isTypeOnly?: boolean;
10
- isReExport?: boolean;
11
- resolve?: boolean;
9
+ modifiers: number;
12
10
  }
@@ -1,4 +1,5 @@
1
1
  import type { SYMBOL_TYPE } from '../constants.js';
2
+ import type { Fixes } from './exports.js';
2
3
  export type SymbolType = (typeof SYMBOL_TYPE)[keyof typeof SYMBOL_TYPE];
3
4
  export type IssueSymbol = {
4
5
  symbol: string;
@@ -19,6 +20,7 @@ export type Issue = {
19
20
  pos?: number;
20
21
  line?: number;
21
22
  col?: number;
23
+ fixes: Fixes;
22
24
  isFixed?: boolean;
23
25
  };
24
26
  export type IssueSet = Set<string>;
@@ -39,6 +41,7 @@ export type Issues = {
39
41
  duplicates: IssueRecords;
40
42
  enumMembers: IssueRecords;
41
43
  classMembers: IssueRecords;
44
+ catalog: IssueRecords;
42
45
  };
43
46
  export type IssueType = keyof Issues;
44
47
  export type SymbolIssueType = Exclude<IssueType, 'files'>;
@@ -1,4 +1,4 @@
1
- import type { PluginMap } from './config.js';
1
+ import type { PluginMap, WorkspaceConfiguration } from './config.js';
2
2
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
3
3
  type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
4
4
  type Dependencies = Record<string, string>;
@@ -23,6 +23,8 @@ type PluginConfig<P> = {
23
23
  };
24
24
  type Plugins = PluginConfig<PluginMap>;
25
25
  export type Scripts = Record<string, string>;
26
+ export type Catalog = Record<string, string>;
27
+ export type Catalogs = Record<string, Catalog>;
26
28
  export type PackageJson = {
27
29
  name?: string;
28
30
  main?: string;
@@ -30,6 +32,8 @@ export type PackageJson = {
30
32
  version?: string;
31
33
  workspaces?: string[] | {
32
34
  packages?: string[];
35
+ catalog?: Catalog;
36
+ catalogs?: Catalogs;
33
37
  };
34
38
  exports?: Exports;
35
39
  imports?: Imports;
@@ -41,11 +45,18 @@ export type PackageJson = {
41
45
  peerDependenciesMeta?: Record<string, {
42
46
  optional: true;
43
47
  }>;
48
+ resolutions?: Dependencies;
44
49
  module?: string;
45
50
  browser?: string;
46
51
  types?: string;
47
52
  typings?: string;
53
+ catalog?: Catalog;
54
+ catalogs?: Catalogs;
48
55
  packageManager?: string;
56
+ pnpm?: {
57
+ overrides?: Dependencies;
58
+ };
59
+ knip?: WorkspaceConfiguration;
49
60
  } & Plugins;
50
61
  export type WorkspacePackage = {
51
62
  dir: string;
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { RawConfiguration as KnipConfig } from './types/config.js';
1
+ export type { RawConfigurationOrFn as KnipConfig } from './types/config.js';
2
2
  export type { Preprocessor, Reporter, ReporterOptions } from './types/issues.js';
@@ -1,7 +1,7 @@
1
1
  import ts from 'typescript';
2
2
  import type { Fix } from '../types/exports.js';
3
3
  import type { SymbolType } from '../types/issues.js';
4
- export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): boolean;
4
+ export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): node is ts.ImportDeclaration;
5
5
  export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpression;
6
6
  export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
7
7
  export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
@@ -1,10 +1,10 @@
1
1
  import { isBuiltin } from 'node:module';
2
2
  import ts from 'typescript';
3
- import { ALIAS_TAG, ANONYMOUS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
3
+ import { ALIAS_TAG, ANONYMOUS, IMPORT_MODIFIERS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
4
4
  import { addNsValue, addValue, createImports } from '../util/module-graph.js';
5
5
  import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
6
6
  import { timerify } from '../util/Performance.js';
7
- import { isInNodeModules } from '../util/path.js';
7
+ import { dirname, isInNodeModules, resolve } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
9
9
  import { getAccessMembers, getDestructuredNames, getJSDocTags, getLineAndCharacterOfPosition, getTypeRef, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isInForIteration, isObjectEnumerationCallExpressionArgument, isReferencedInExport, } from './ast-helpers.js';
10
10
  import { findInternalReferences, isType } from './find-internal-references.js';
@@ -76,7 +76,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
76
76
  }
77
77
  };
78
78
  const addInternalImport = (options) => {
79
- const { identifier, symbol, filePath, namespace, alias, specifier, isReExport } = options;
79
+ const { identifier, symbol, filePath, namespace, alias, specifier } = options;
80
80
  const isStar = identifier === IMPORT_STAR;
81
81
  specifiers.add([{ specifier, pos: options.pos, line: options.line, col: options.col }, filePath]);
82
82
  const file = internal.get(filePath);
@@ -84,7 +84,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
84
84
  if (!file)
85
85
  internal.set(filePath, imports);
86
86
  const nsOrAlias = symbol ? String(symbol.escapedName) : alias;
87
- if (isReExport) {
87
+ if (options.modifiers & IMPORT_MODIFIERS.RE_EXPORT) {
88
88
  if (isStar && namespace) {
89
89
  addValue(imports.reExportedNs, namespace, sourceFile.fileName);
90
90
  }
@@ -118,7 +118,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
118
118
  if (module) {
119
119
  const filePath = module.resolvedFileName;
120
120
  if (filePath) {
121
- if (opts.resolve && !isInNodeModules(filePath)) {
121
+ if (opts.modifiers && opts.modifiers & IMPORT_MODIFIERS.ENTRY && !isInNodeModules(filePath)) {
122
122
  resolved.add(filePath);
123
123
  return;
124
124
  }
@@ -128,36 +128,37 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
128
128
  ...opts,
129
129
  identifier: opts.identifier ?? ANONYMOUS,
130
130
  filePath,
131
- isReExport: opts.isReExport ?? false,
132
131
  line: line + 1,
133
132
  col: character + 1,
134
133
  });
135
134
  }
136
135
  if (module.isExternalLibraryImport) {
137
- if (options.skipTypeOnly && opts.isTypeOnly)
136
+ if (options.skipTypeOnly && opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY)
138
137
  return;
139
- const isInNM = isInNodeModules(opts.specifier);
140
- const sanitizedSpecifier = sanitizeSpecifier(isInNM || isInNodeModules(filePath) ? getPackageNameFromFilePath(opts.specifier) : opts.specifier);
138
+ const sanitizedSpecifier = sanitizeSpecifier(isInNodeModules(filePath) || isInNodeModules(opts.specifier)
139
+ ? getPackageNameFromFilePath(opts.specifier)
140
+ : opts.specifier);
141
141
  if (!isStartsLikePackageName(sanitizedSpecifier)) {
142
142
  return;
143
143
  }
144
- if (isInNM) {
145
- external.add({ specifier: sanitizedSpecifier });
146
- }
147
- else {
148
- const { line, character } = sourceFile.getLineAndCharacterOfPosition(opts.pos);
149
- external.add({ specifier: sanitizedSpecifier, pos: opts.pos, line: line + 1, col: character + 2 });
150
- }
144
+ const pos = node.moduleSpecifier?.getStart() ?? opts.pos;
145
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(pos);
146
+ external.add({ specifier: sanitizedSpecifier, pos: opts.pos, line: line + 1, col: character + 2 });
151
147
  }
152
148
  }
153
149
  }
154
150
  else {
155
- if (options.skipTypeOnly && opts.isTypeOnly)
151
+ if (options.skipTypeOnly && opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY)
156
152
  return;
157
153
  if (shouldIgnore(getJSDocTags(node), options.tags))
158
154
  return;
159
155
  if (opts.specifier.startsWith(PROTOCOL_VIRTUAL))
160
156
  return;
157
+ const r = resolve(dirname(sourceFile.fileName), opts.specifier);
158
+ if (opts.modifiers && opts.modifiers & IMPORT_MODIFIERS.OPTIONAL) {
159
+ resolved.add(r);
160
+ return;
161
+ }
161
162
  const pos = 'moduleSpecifier' in node ? node.moduleSpecifier.pos : node.pos;
162
163
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(pos);
163
164
  unresolved.add({ specifier: opts.specifier, pos, line: line + 1, col: character + 2 });
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { ANONYMOUS } from '../../../constants.js';
2
+ import { ANONYMOUS, IMPORT_MODIFIERS } from '../../../constants.js';
3
3
  import { findAncestor, findDescendants, getAccessedIdentifiers, isAccessExpression, isImportCall, isTopLevel, stripQuotes, } from '../../ast-helpers.js';
4
4
  import { importVisitor as visit } from '../index.js';
5
5
  const getSymbol = (node, isTopLevel) => (isTopLevel ? node.symbol : undefined);
@@ -7,6 +7,7 @@ export default visit(() => true, node => {
7
7
  if (isImportCall(node)) {
8
8
  if (node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])) {
9
9
  const specifier = node.arguments[0].text;
10
+ const modifiers = IMPORT_MODIFIERS.NONE;
10
11
  if (specifier) {
11
12
  const accessExpression = findAncestor(node, _node => {
12
13
  if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
@@ -27,7 +28,7 @@ export default visit(() => true, node => {
27
28
  if (accessExpressions.length > 0) {
28
29
  return accessExpressions.map(binding => {
29
30
  const identifier = String(binding.name.escapedText);
30
- return { identifier, specifier, pos };
31
+ return { identifier, specifier, pos, modifiers };
31
32
  });
32
33
  }
33
34
  }
@@ -35,21 +36,21 @@ export default visit(() => true, node => {
35
36
  return arg.name.elements.map(element => {
36
37
  const identifier = (element.propertyName ?? element.name).getText();
37
38
  const alias = element.propertyName ? element.name.getText() : undefined;
38
- return { identifier, alias, specifier, pos: element.pos };
39
+ return { identifier, alias, specifier, pos: element.pos, modifiers };
39
40
  });
40
41
  }
41
42
  }
42
- return { identifier: 'default', specifier, pos };
43
+ return { identifier: 'default', specifier, pos, modifiers };
43
44
  }
44
45
  if (identifier !== 'catch')
45
- return { identifier, specifier, pos };
46
+ return { identifier, specifier, pos, modifiers };
46
47
  }
47
48
  if (ts.isElementAccessExpression(accessExpression) &&
48
49
  ts.isStringLiteral(accessExpression.argumentExpression)) {
49
50
  const name = stripQuotes(accessExpression.argumentExpression.text);
50
51
  const pos = accessExpression.argumentExpression.pos;
51
52
  const identifier = name;
52
- return { identifier, specifier, pos };
53
+ return { identifier, specifier, pos, modifiers };
53
54
  }
54
55
  }
55
56
  const variableDeclaration = accessExpression &&
@@ -67,9 +68,16 @@ export default visit(() => true, node => {
67
68
  const scope = findAncestor(variableDeclaration, ts.isFunctionBody) || node.getSourceFile();
68
69
  const accessed = getAccessedIdentifiers(alias, scope);
69
70
  if (accessed.length > 0) {
70
- return accessed.map(acc => ({ identifier: acc.identifier, alias, symbol, specifier, pos: acc.pos }));
71
+ return accessed.map(acc => ({
72
+ identifier: acc.identifier,
73
+ alias,
74
+ symbol,
75
+ specifier,
76
+ pos: acc.pos,
77
+ modifiers,
78
+ }));
71
79
  }
72
- return { identifier: 'default', alias, symbol, specifier, pos: node.arguments[0].pos };
80
+ return { identifier: 'default', alias, symbol, specifier, pos: node.arguments[0].pos, modifiers };
73
81
  }
74
82
  const bindings = findDescendants(variableDeclaration, ts.isBindingElement);
75
83
  if (bindings.length > 0) {
@@ -77,10 +85,10 @@ export default visit(() => true, node => {
77
85
  const identifier = (element.propertyName ?? element.name).getText();
78
86
  const alias = element.propertyName ? element.name.getText() : undefined;
79
87
  const symbol = getSymbol(element, isTLA);
80
- return { identifier, alias, symbol, specifier, pos: element.pos };
88
+ return { identifier, alias, symbol, specifier, pos: element.pos, modifiers };
81
89
  });
82
90
  }
83
- return { identifier: ANONYMOUS, specifier, pos: node.arguments[0].pos };
91
+ return { identifier: ANONYMOUS, specifier, pos: node.arguments[0].pos, modifiers };
84
92
  }
85
93
  const arrayLiteralExpression = node.parent;
86
94
  const variableDeclarationParent = node.parent.parent?.parent?.parent;
@@ -98,20 +106,20 @@ export default visit(() => true, node => {
98
106
  const identifier = (element.propertyName ?? element.name).getText();
99
107
  const alias = element.propertyName ? element.name.getText() : undefined;
100
108
  const symbol = getSymbol(element, isTL);
101
- return { identifier, alias, symbol, specifier, pos: element.pos };
109
+ return { identifier, alias, symbol, specifier, pos: element.pos, modifiers };
102
110
  });
103
111
  }
104
112
  if (!ts.isOmittedExpression(element) && ts.isIdentifier(element.name)) {
105
113
  const alias = String(element.name.escapedText);
106
114
  const symbol = getSymbol(element, isTL);
107
- return { identifier: 'default', symbol, alias, specifier, pos: element.pos };
115
+ return { identifier: 'default', symbol, alias, specifier, pos: element.pos, modifiers };
108
116
  }
109
- return { identifier: 'default', specifier, pos: element.pos };
117
+ return { identifier: 'default', specifier, pos: element.pos, modifiers };
110
118
  }
111
119
  }
112
- return { identifier: 'default', specifier, pos: node.arguments[0].pos };
120
+ return { identifier: 'default', specifier, pos: node.arguments[0].pos, modifiers };
113
121
  }
114
- return { specifier, identifier: 'default', pos: node.arguments[0].pos };
122
+ return { specifier, identifier: 'default', pos: node.arguments[0].pos, modifiers };
115
123
  }
116
124
  }
117
125
  });
@@ -1,9 +1,15 @@
1
1
  import ts from 'typescript';
2
+ import { IMPORT_MODIFIERS } from '../../../constants.js';
2
3
  import { importVisitor as visit } from '../index.js';
3
4
  export default visit(() => true, node => {
4
5
  if (ts.isImportTypeNode(node)) {
5
6
  if (ts.isLiteralTypeNode(node.argument) && ts.isStringLiteral(node.argument.literal)) {
6
- return { specifier: node.argument.literal.text, identifier: undefined, pos: 0, isTypeOnly: true };
7
+ return {
8
+ specifier: node.argument.literal.text,
9
+ identifier: undefined,
10
+ pos: node.argument.literal.getStart(),
11
+ modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
12
+ };
7
13
  }
8
14
  }
9
15
  });
@@ -3,5 +3,6 @@ import importType from './importType.js';
3
3
  import jsDocType from './jsDocType.js';
4
4
  import requireCall from './requireCall.js';
5
5
  import resolveCall from './resolveCall.js';
6
- const visitors = [importCall, importType, jsDocType, resolveCall, requireCall];
6
+ import urlConstructor from './urlConstructor.js';
7
+ const visitors = [importCall, importType, jsDocType, resolveCall, requireCall, urlConstructor];
7
8
  export default (sourceFile) => visitors.map(v => v(sourceFile));
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
+ import { IMPORT_MODIFIERS } from '../../../constants.js';
2
3
  import { importVisitor as visit } from '../index.js';
3
4
  const supportsJSDocImportTag = 'isJSDocImportTag' in ts;
4
5
  const getImportSpecifiers = (node) => {
@@ -8,12 +9,22 @@ const getImportSpecifiers = (node) => {
8
9
  const importClause = node.argument;
9
10
  if (ts.isLiteralTypeNode(importClause) && ts.isStringLiteral(importClause.literal)) {
10
11
  const identifier = node.qualifier && ts.isIdentifier(node.qualifier) ? String(node.qualifier.escapedText) : 'default';
11
- imports.push({ specifier: importClause.literal.text, identifier, pos: importClause.literal.pos });
12
+ imports.push({
13
+ specifier: importClause.literal.text,
14
+ identifier,
15
+ pos: importClause.literal.pos,
16
+ modifiers: IMPORT_MODIFIERS.NONE,
17
+ });
12
18
  }
13
19
  }
14
20
  if (supportsJSDocImportTag && ts.isJSDocImportTag(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {
15
21
  const moduleSpecifier = node.moduleSpecifier;
16
- imports.push({ specifier: moduleSpecifier.text, identifier: undefined, pos: moduleSpecifier.pos });
22
+ imports.push({
23
+ specifier: moduleSpecifier.text,
24
+ identifier: undefined,
25
+ pos: moduleSpecifier.pos,
26
+ modifiers: IMPORT_MODIFIERS.NONE,
27
+ });
17
28
  }
18
29
  ts.forEachChild(node, visit);
19
30
  }
@@ -1,22 +1,21 @@
1
1
  import ts from 'typescript';
2
- import { IMPORT_STAR } from '../../../constants.js';
2
+ import { IMPORT_MODIFIERS, IMPORT_STAR } from '../../../constants.js';
3
3
  import { findAncestor, findDescendants, isModuleExportsAccess, isRequireCall, isTopLevel } from '../../ast-helpers.js';
4
- import { isNotJS } from '../helpers.js';
5
4
  import { importVisitor as visit } from '../index.js';
6
5
  export default visit(() => true, node => {
7
6
  if (isRequireCall(node)) {
8
7
  if (ts.isStringLiteralLike(node.arguments[0])) {
9
8
  const specifier = node.arguments[0].text;
9
+ const modifiers = IMPORT_MODIFIERS.NONE;
10
10
  if (specifier) {
11
11
  const propertyAccessExpression = findAncestor(node, _node => {
12
12
  if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
13
13
  return 'STOP';
14
14
  return ts.isPropertyAccessExpression(_node);
15
15
  });
16
- const resolve = isNotJS(node.getSourceFile());
17
16
  if (propertyAccessExpression) {
18
17
  const identifier = String(propertyAccessExpression.name.escapedText);
19
- return { identifier, specifier, pos: propertyAccessExpression.name.pos, resolve };
18
+ return { identifier, specifier, pos: propertyAccessExpression.name.pos, modifiers };
20
19
  }
21
20
  const variableDeclaration = node.parent;
22
21
  if (ts.isVariableDeclaration(variableDeclaration) &&
@@ -30,7 +29,7 @@ export default visit(() => true, node => {
30
29
  symbol: isTLA ? variableDeclaration.symbol : undefined,
31
30
  specifier,
32
31
  pos: node.arguments[0].pos,
33
- resolve,
32
+ modifiers,
34
33
  };
35
34
  }
36
35
  const bindings = findDescendants(variableDeclaration, ts.isBindingElement);
@@ -39,17 +38,22 @@ export default visit(() => true, node => {
39
38
  const identifier = (element.propertyName ?? element.name).getText();
40
39
  const alias = element.propertyName ? element.name.getText() : undefined;
41
40
  const symbol = isTLA ? element.symbol : undefined;
42
- return { identifier, specifier, alias, symbol, pos: element.pos, resolve };
41
+ return { identifier, specifier, alias, symbol, pos: element.pos, modifiers };
43
42
  });
44
43
  }
45
- return { identifier: 'default', specifier, pos: node.arguments[0].pos, resolve };
44
+ return { identifier: 'default', specifier, pos: node.arguments[0].pos, modifiers };
46
45
  }
47
46
  if (ts.isBinaryExpression(node.parent) &&
48
47
  ts.isPropertyAccessExpression(node.parent.left) &&
49
48
  isModuleExportsAccess(node.parent.left)) {
50
- return { identifier: IMPORT_STAR, specifier, isReExport: true, pos: node.arguments[0].pos };
49
+ return {
50
+ identifier: IMPORT_STAR,
51
+ specifier,
52
+ pos: node.arguments[0].pos,
53
+ modifiers: IMPORT_MODIFIERS.RE_EXPORT,
54
+ };
51
55
  }
52
- return { identifier: 'default', specifier, pos: node.arguments[0].pos, resolve };
56
+ return { identifier: 'default', specifier, pos: node.arguments[0].pos, modifiers };
53
57
  }
54
58
  }
55
59
  }
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
+ import { IMPORT_MODIFIERS } from '../../../constants.js';
2
3
  import { isPropertyAccessCall } from '../../ast-helpers.js';
3
4
  import { importVisitor as visit } from '../index.js';
4
5
  export default visit(() => true, node => {
@@ -6,7 +7,12 @@ export default visit(() => true, node => {
6
7
  if (node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])) {
7
8
  const specifier = node.arguments[0].text;
8
9
  if (specifier)
9
- return { specifier, identifier: undefined, pos: node.arguments[0].pos, resolve: true };
10
+ return {
11
+ specifier,
12
+ identifier: undefined,
13
+ pos: node.arguments[0].pos,
14
+ modifiers: IMPORT_MODIFIERS.ENTRY,
15
+ };
10
16
  }
11
17
  }
12
18
  });
@@ -0,0 +1,3 @@
1
+ import ts from 'typescript';
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../../types/config.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
3
+ export default _default;