knip 6.42.1 → 6.44.0

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 (187) hide show
  1. package/dist/CacheConsultant.d.ts +1 -0
  2. package/dist/CacheConsultant.js +2 -0
  3. package/dist/CatalogCounselor.d.ts +1 -3
  4. package/dist/CatalogCounselor.js +18 -15
  5. package/dist/ConfigurationChief.d.ts +42 -0
  6. package/dist/DependencyDeputy.d.ts +2 -1
  7. package/dist/DependencyDeputy.js +9 -4
  8. package/dist/IssueCollector.js +1 -0
  9. package/dist/IssueFixer.js +10 -5
  10. package/dist/ProjectPrincipal.d.ts +3 -2
  11. package/dist/ProjectPrincipal.js +32 -10
  12. package/dist/WorkspaceWorker.d.ts +5 -2
  13. package/dist/WorkspaceWorker.js +35 -17
  14. package/dist/binaries/resolvers/bun.js +1 -0
  15. package/dist/binaries/resolvers/npm.js +12 -2
  16. package/dist/binaries/resolvers/pnpm.js +5 -3
  17. package/dist/binaries/util.js +2 -1
  18. package/dist/cli.js +6 -1
  19. package/dist/compilers/compilers.js +2 -2
  20. package/dist/compilers/index.d.ts +5 -0
  21. package/dist/compilers/index.js +1 -1
  22. package/dist/constants.d.ts +1 -0
  23. package/dist/constants.js +2 -0
  24. package/dist/graph/analyze.js +3 -2
  25. package/dist/graph/build.d.ts +2 -0
  26. package/dist/graph/build.js +37 -22
  27. package/dist/graph-explorer/cache.d.ts +2 -1
  28. package/dist/graph-explorer/cache.js +5 -1
  29. package/dist/graph-explorer/explorer.d.ts +3 -5
  30. package/dist/graph-explorer/explorer.js +24 -3
  31. package/dist/plugins/_vue/auto-import.js +31 -1
  32. package/dist/plugins/biome/index.js +1 -1
  33. package/dist/plugins/buf/index.d.ts +3 -0
  34. package/dist/plugins/buf/index.js +33 -0
  35. package/dist/plugins/buf/types.d.ts +8 -0
  36. package/dist/plugins/buf/types.js +1 -0
  37. package/dist/plugins/cspell/index.js +1 -0
  38. package/dist/plugins/dependency-cruiser/index.js +2 -2
  39. package/dist/plugins/docusaurus/helpers.js +4 -4
  40. package/dist/plugins/electron-forge/index.d.ts +3 -0
  41. package/dist/plugins/electron-forge/index.js +94 -0
  42. package/dist/plugins/electron-vite/index.js +2 -2
  43. package/dist/plugins/eslint/helpers.d.ts +1 -0
  44. package/dist/plugins/eslint/helpers.js +1 -1
  45. package/dist/plugins/eslint/resolveFromAST.js +35 -10
  46. package/dist/plugins/expo/helpers.d.ts +1 -1
  47. package/dist/plugins/expo/helpers.js +15 -8
  48. package/dist/plugins/expo/types.d.ts +2 -1
  49. package/dist/plugins/expressive-code/index.d.ts +1 -1
  50. package/dist/plugins/expressive-code/index.js +2 -2
  51. package/dist/plugins/gatsby/index.js +6 -6
  52. package/dist/plugins/gatsby/types.d.ts +1 -1
  53. package/dist/plugins/github-actions/index.js +1 -1
  54. package/dist/plugins/i18next-parser/index.js +2 -2
  55. package/dist/plugins/index.d.ts +8 -1
  56. package/dist/plugins/index.js +14 -0
  57. package/dist/plugins/jasmine/index.js +2 -2
  58. package/dist/plugins/karma/index.js +4 -4
  59. package/dist/plugins/kysely-codegen/index.d.ts +3 -0
  60. package/dist/plugins/kysely-codegen/index.js +20 -0
  61. package/dist/plugins/lefthook/index.js +2 -2
  62. package/dist/plugins/lingui/index.d.ts +3 -0
  63. package/dist/plugins/lingui/index.js +16 -0
  64. package/dist/plugins/lockfile-lint/index.js +2 -2
  65. package/dist/plugins/lost-pixel/index.js +2 -2
  66. package/dist/plugins/lunaria/index.js +2 -2
  67. package/dist/plugins/marko/index.js +5 -6
  68. package/dist/plugins/mastra/index.d.ts +3 -0
  69. package/dist/plugins/mastra/index.js +57 -0
  70. package/dist/plugins/mcp/index.d.ts +3 -0
  71. package/dist/plugins/mcp/index.js +33 -0
  72. package/dist/plugins/mcp/types.d.ts +11 -0
  73. package/dist/plugins/mcp/types.js +1 -0
  74. package/dist/plugins/mise/index.js +0 -3
  75. package/dist/plugins/mocha/index.js +42 -3
  76. package/dist/plugins/mocha/types.d.ts +1 -0
  77. package/dist/plugins/next/index.d.ts +3 -0
  78. package/dist/plugins/next/index.js +57 -9
  79. package/dist/plugins/next/types.d.ts +11 -0
  80. package/dist/plugins/next/types.js +1 -0
  81. package/dist/plugins/nx/index.js +3 -8
  82. package/dist/plugins/nyc/index.js +1 -1
  83. package/dist/plugins/openapi-ts/index.js +2 -2
  84. package/dist/plugins/oxfmt/index.js +2 -2
  85. package/dist/plugins/playwright/index.js +6 -11
  86. package/dist/plugins/pnpm/index.js +2 -4
  87. package/dist/plugins/purgecss/index.d.ts +3 -0
  88. package/dist/plugins/purgecss/index.js +16 -0
  89. package/dist/plugins/railway/index.js +1 -4
  90. package/dist/plugins/remix/index.js +1 -1
  91. package/dist/plugins/rstest/index.js +2 -2
  92. package/dist/plugins/serverless-framework/index.js +1 -1
  93. package/dist/plugins/storybook/index.js +5 -5
  94. package/dist/plugins/sveltekit/resolveFromAST.js +1 -1
  95. package/dist/plugins/syncpack/index.js +2 -2
  96. package/dist/plugins/tailwind/compiler.js +6 -2
  97. package/dist/plugins/tanstack-router/index.js +3 -2
  98. package/dist/plugins/taskfile/index.js +4 -7
  99. package/dist/plugins/textlint/helpers.js +2 -2
  100. package/dist/plugins/travis/index.js +2 -2
  101. package/dist/plugins/typescript/index.js +9 -7
  102. package/dist/plugins/unocss/index.js +2 -2
  103. package/dist/plugins/vite-plugin-pwa/index.js +1 -4
  104. package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +0 -2
  105. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
  106. package/dist/plugins/vite-pwa-assets-generator/index.js +2 -2
  107. package/dist/plugins/vitest/helpers.d.ts +1 -1
  108. package/dist/plugins/vitest/helpers.js +17 -10
  109. package/dist/plugins/vitest/index.js +53 -45
  110. package/dist/plugins/vitest/types.d.ts +11 -7
  111. package/dist/plugins/webpack/index.js +4 -2
  112. package/dist/plugins/yarn/index.js +2 -4
  113. package/dist/reporters/codeclimate.d.ts +2 -2
  114. package/dist/reporters/codeclimate.js +2 -4
  115. package/dist/reporters/codeowners.d.ts +2 -2
  116. package/dist/reporters/codeowners.js +9 -9
  117. package/dist/reporters/compact.d.ts +2 -2
  118. package/dist/reporters/compact.js +8 -7
  119. package/dist/reporters/cycles.d.ts +2 -2
  120. package/dist/reporters/cycles.js +7 -6
  121. package/dist/reporters/disclosure.d.ts +2 -2
  122. package/dist/reporters/disclosure.js +6 -4
  123. package/dist/reporters/github-actions.d.ts +2 -2
  124. package/dist/reporters/github-actions.js +7 -5
  125. package/dist/reporters/index.d.ts +10 -10
  126. package/dist/reporters/json.d.ts +2 -2
  127. package/dist/reporters/json.js +2 -4
  128. package/dist/reporters/markdown.d.ts +2 -2
  129. package/dist/reporters/markdown.js +11 -9
  130. package/dist/reporters/sarif.d.ts +2 -2
  131. package/dist/reporters/sarif.js +2 -3
  132. package/dist/reporters/symbols.d.ts +2 -2
  133. package/dist/reporters/symbols.js +6 -4
  134. package/dist/run.d.ts +1 -1
  135. package/dist/run.js +3 -10
  136. package/dist/schema/configuration.d.ts +105 -0
  137. package/dist/schema/plugins.d.ts +35 -0
  138. package/dist/schema/plugins.js +7 -0
  139. package/dist/session/configuration.d.ts +12 -0
  140. package/dist/session/configuration.js +43 -0
  141. package/dist/session/incremental.d.ts +54 -0
  142. package/dist/session/incremental.js +49 -0
  143. package/dist/session/session.d.ts +1 -1
  144. package/dist/session/session.js +62 -27
  145. package/dist/session/watch.d.ts +2 -0
  146. package/dist/session/watch.js +41 -0
  147. package/dist/types/PluginNames.d.ts +2 -2
  148. package/dist/types/PluginNames.js +7 -0
  149. package/dist/types/config.d.ts +2 -0
  150. package/dist/types/issues.d.ts +4 -0
  151. package/dist/types/package-json.d.ts +0 -3
  152. package/dist/typescript/ast-nodes.js +3 -3
  153. package/dist/typescript/get-imports-and-exports.js +2 -0
  154. package/dist/typescript/visitors/calls.js +15 -11
  155. package/dist/typescript/visitors/exports.js +5 -4
  156. package/dist/typescript/visitors/imports.d.ts +2 -1
  157. package/dist/typescript/visitors/imports.js +25 -19
  158. package/dist/typescript/visitors/members.js +23 -26
  159. package/dist/typescript/visitors/walk.d.ts +3 -0
  160. package/dist/typescript/visitors/walk.js +55 -3
  161. package/dist/util/cli-arguments.d.ts +2 -1
  162. package/dist/util/cli-arguments.js +3 -0
  163. package/dist/util/create-input-handler.js +1 -1
  164. package/dist/util/create-options.d.ts +72 -1
  165. package/dist/util/create-options.js +13 -2
  166. package/dist/util/file-entry-cache.d.ts +2 -0
  167. package/dist/util/file-entry-cache.js +19 -1
  168. package/dist/util/gitignore-cache.d.ts +1 -0
  169. package/dist/util/gitignore-cache.js +1 -0
  170. package/dist/util/glob-core.js +4 -2
  171. package/dist/util/glob.d.ts +1 -0
  172. package/dist/util/glob.js +6 -0
  173. package/dist/util/input.d.ts +2 -0
  174. package/dist/util/loader.d.ts +1 -0
  175. package/dist/util/loader.js +38 -2
  176. package/dist/util/modules.js +5 -2
  177. package/dist/util/path.d.ts +1 -0
  178. package/dist/util/path.js +1 -0
  179. package/dist/util/remove-export.js +3 -1
  180. package/dist/util/reporter.d.ts +1 -1
  181. package/dist/util/reporter.js +53 -9
  182. package/dist/util/watch.d.ts +5 -11
  183. package/dist/util/watch.js +84 -68
  184. package/dist/version.d.ts +1 -1
  185. package/dist/version.js +1 -1
  186. package/package.json +4 -4
  187. package/schema.json +28 -0
@@ -5,6 +5,7 @@ export declare class CacheConsultant<T> {
5
5
  getFileDescriptor: (filePath: string) => FileDescriptor<T>;
6
6
  reconcile: () => void;
7
7
  removeEntry: (filePath: string) => void;
8
+ setFileData: (filePath: string, data: T) => void;
8
9
  constructor(name: string, options: MainOptions);
9
10
  getCachedFile(filePath: string): T | undefined;
10
11
  }
@@ -7,6 +7,7 @@ export class CacheConsultant {
7
7
  getFileDescriptor = () => dummyFileDescriptor;
8
8
  reconcile = () => { };
9
9
  removeEntry = () => { };
10
+ setFileData = () => { };
10
11
  constructor(name, options) {
11
12
  if (!options.isCache)
12
13
  return;
@@ -15,6 +16,7 @@ export class CacheConsultant {
15
16
  this.getFileDescriptor = timerify(this.cache.getFileDescriptor.bind(this.cache));
16
17
  this.reconcile = timerify(this.cache.reconcile.bind(this.cache));
17
18
  this.removeEntry = timerify(this.cache.removeEntry.bind(this.cache));
19
+ this.setFileData = this.cache.setFileData.bind(this.cache);
18
20
  }
19
21
  getCachedFile(filePath) {
20
22
  if (!this.cache)
@@ -9,12 +9,10 @@ export type CatalogContainer = {
9
9
  overrides?: Catalog;
10
10
  };
11
11
  export declare class CatalogCounselor {
12
- private filePath;
12
+ private sources;
13
13
  private entries;
14
14
  private referencedEntries;
15
15
  private referenceIssues;
16
- private overrideReferences;
17
- private fileContent?;
18
16
  constructor(options: MainOptions);
19
17
  private addReferencedCatalogEntry;
20
18
  addReference({ catalogName, packageName }: CatalogReference): void;
@@ -6,18 +6,20 @@ import { extractCatalogReferences, getOverrideCatalogReferences, parseCatalog, }
6
6
  import { extname } from './util/path.js';
7
7
  import { YamlCatalogPeeker } from './YamlCatalogPeeker.js';
8
8
  export class CatalogCounselor {
9
- filePath;
9
+ sources = [];
10
10
  entries = new Set();
11
11
  referencedEntries = new Set();
12
12
  referenceIssues = [];
13
- overrideReferences = [];
14
- fileContent;
15
13
  constructor(options) {
16
- this.filePath = options.catalog.filePath;
17
- this.entries = parseCatalog(options.catalog);
18
- this.overrideReferences = getOverrideCatalogReferences(options.catalog.overrides);
19
- for (const reference of this.overrideReferences)
20
- this.addReference(reference);
14
+ for (const container of options.catalog) {
15
+ const entries = parseCatalog(container);
16
+ const overrideReferences = getOverrideCatalogReferences(container.overrides);
17
+ for (const entry of entries)
18
+ this.entries.add(entry);
19
+ for (const reference of overrideReferences)
20
+ this.addReference(reference);
21
+ this.sources.push({ filePath: container.filePath, entries, overrideReferences });
22
+ }
21
23
  }
22
24
  addReferencedCatalogEntry(entryName) {
23
25
  this.referencedEntries.add(entryName);
@@ -52,16 +54,17 @@ export class CatalogCounselor {
52
54
  }
53
55
  }
54
56
  async settleCatalogIssues(options) {
55
- const filePath = this.filePath;
56
57
  const workspace = ROOT_WORKSPACE_NAME;
57
58
  const catalogIssues = [];
58
59
  const overrideReferenceIssues = [];
59
- if (this.entries.size > 0 || this.overrideReferences.length > 0) {
60
- this.fileContent = await readFile(filePath, 'utf-8');
60
+ for (const { filePath, entries, overrideReferences } of this.sources) {
61
+ if (entries.size === 0 && overrideReferences.length === 0)
62
+ continue;
63
+ const fileContent = await readFile(filePath, 'utf-8');
61
64
  const isYaml = ['.yml', '.yaml'].includes(extname(filePath));
62
- const yamlPeeker = isYaml ? new YamlCatalogPeeker(this.fileContent) : undefined;
63
- const peeker = yamlPeeker ?? new JsonCatalogPeeker(this.fileContent);
64
- for (const entry of this.entries.keys()) {
65
+ const yamlPeeker = isYaml ? new YamlCatalogPeeker(fileContent) : undefined;
66
+ const peeker = yamlPeeker ?? new JsonCatalogPeeker(fileContent);
67
+ for (const entry of entries) {
65
68
  if (!this.referencedEntries.has(entry)) {
66
69
  const [parentSymbol, symbol] = entry.split(':');
67
70
  const pos = peeker.getLocation(parentSymbol, symbol);
@@ -71,7 +74,7 @@ export class CatalogCounselor {
71
74
  catalogIssues.push({ type: 'catalog', filePath, workspace, symbol, parentSymbol, fixes, ...pos });
72
75
  }
73
76
  }
74
- for (const { catalogName, packageName, selector } of this.overrideReferences) {
77
+ for (const { catalogName, packageName, selector } of overrideReferences) {
75
78
  if (this.entries.has(`${catalogName}:${packageName}`))
76
79
  continue;
77
80
  const pos = yamlPeeker?.getOverrideCatalogReferenceLocation(selector);
@@ -102,6 +102,11 @@ export declare class ConfigurationChief {
102
102
  entry?: string | string[] | undefined;
103
103
  project?: string | string[] | undefined;
104
104
  } | undefined;
105
+ buf?: string | boolean | string[] | {
106
+ config?: string | string[] | undefined;
107
+ entry?: string | string[] | undefined;
108
+ project?: string | string[] | undefined;
109
+ } | undefined;
105
110
  bumpp?: string | boolean | string[] | {
106
111
  config?: string | string[] | undefined;
107
112
  entry?: string | string[] | undefined;
@@ -202,6 +207,11 @@ export declare class ConfigurationChief {
202
207
  entry?: string | string[] | undefined;
203
208
  project?: string | string[] | undefined;
204
209
  } | undefined;
210
+ 'electron-forge'?: string | boolean | string[] | {
211
+ config?: string | string[] | undefined;
212
+ entry?: string | string[] | undefined;
213
+ project?: string | string[] | undefined;
214
+ } | undefined;
205
215
  'electron-vite'?: string | boolean | string[] | {
206
216
  config?: string | string[] | undefined;
207
217
  entry?: string | string[] | undefined;
@@ -327,6 +337,11 @@ export declare class ConfigurationChief {
327
337
  entry?: string | string[] | undefined;
328
338
  project?: string | string[] | undefined;
329
339
  } | undefined;
340
+ 'kysely-codegen'?: string | boolean | string[] | {
341
+ config?: string | string[] | undefined;
342
+ entry?: string | string[] | undefined;
343
+ project?: string | string[] | undefined;
344
+ } | undefined;
330
345
  ladle?: string | boolean | string[] | {
331
346
  config?: string | string[] | undefined;
332
347
  entry?: string | string[] | undefined;
@@ -342,6 +357,11 @@ export declare class ConfigurationChief {
342
357
  entry?: string | string[] | undefined;
343
358
  project?: string | string[] | undefined;
344
359
  } | undefined;
360
+ lingui?: string | boolean | string[] | {
361
+ config?: string | string[] | undefined;
362
+ entry?: string | string[] | undefined;
363
+ project?: string | string[] | undefined;
364
+ } | undefined;
345
365
  'lint-staged'?: string | boolean | string[] | {
346
366
  config?: string | string[] | undefined;
347
367
  entry?: string | string[] | undefined;
@@ -382,6 +402,16 @@ export declare class ConfigurationChief {
382
402
  entry?: string | string[] | undefined;
383
403
  project?: string | string[] | undefined;
384
404
  } | undefined;
405
+ mastra?: string | boolean | string[] | {
406
+ config?: string | string[] | undefined;
407
+ entry?: string | string[] | undefined;
408
+ project?: string | string[] | undefined;
409
+ } | undefined;
410
+ mcp?: string | boolean | string[] | {
411
+ config?: string | string[] | undefined;
412
+ entry?: string | string[] | undefined;
413
+ project?: string | string[] | undefined;
414
+ } | undefined;
385
415
  mdx?: string | boolean | string[] | {
386
416
  config?: string | string[] | undefined;
387
417
  entry?: string | string[] | undefined;
@@ -607,6 +637,11 @@ export declare class ConfigurationChief {
607
637
  entry?: string | string[] | undefined;
608
638
  project?: string | string[] | undefined;
609
639
  } | undefined;
640
+ purgecss?: string | boolean | string[] | {
641
+ config?: string | string[] | undefined;
642
+ entry?: string | string[] | undefined;
643
+ project?: string | string[] | undefined;
644
+ } | undefined;
610
645
  quasar?: string | boolean | string[] | {
611
646
  config?: string | string[] | undefined;
612
647
  entry?: string | string[] | undefined;
@@ -1074,6 +1109,7 @@ export declare class ConfigurationChief {
1074
1109
  babel?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1075
1110
  biome?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1076
1111
  borp?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1112
+ buf?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1077
1113
  bumpp?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1078
1114
  bun?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1079
1115
  c8?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -1094,6 +1130,7 @@ export declare class ConfigurationChief {
1094
1130
  docusaurus?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1095
1131
  dotenv?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1096
1132
  drizzle?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1133
+ "electron-forge"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1097
1134
  "electron-vite"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1098
1135
  eleventy?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1099
1136
  esbuild?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -1119,9 +1156,11 @@ export declare class ConfigurationChief {
1119
1156
  jest?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1120
1157
  karma?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1121
1158
  knex?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1159
+ "kysely-codegen"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1122
1160
  ladle?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1123
1161
  "laravel-vite-plugin"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1124
1162
  lefthook?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1163
+ lingui?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1125
1164
  "lint-staged"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1126
1165
  linthtml?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1127
1166
  lit?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -1130,6 +1169,8 @@ export declare class ConfigurationChief {
1130
1169
  lunaria?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1131
1170
  markdownlint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1132
1171
  marko?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1172
+ mastra?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1173
+ mcp?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1133
1174
  mdx?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1134
1175
  mdxlint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1135
1176
  metro?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -1175,6 +1216,7 @@ export declare class ConfigurationChief {
1175
1216
  preconstruct?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1176
1217
  prettier?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1177
1218
  prisma?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1219
+ purgecss?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1178
1220
  quasar?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1179
1221
  qwik?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
1180
1222
  railway?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -9,6 +9,7 @@ interface DependencyReferenceOptions {
9
9
  isTypeOnly?: boolean;
10
10
  isResolved?: boolean;
11
11
  isPublishedType?: boolean;
12
+ isCaught?: boolean;
12
13
  }
13
14
  export declare class DependencyDeputy {
14
15
  isProduction: boolean;
@@ -63,7 +64,7 @@ export declare class DependencyDeputy {
63
64
  isPeerOptional: boolean;
64
65
  }[];
65
66
  getOptionalPeerDependencies(workspaceName: string): DependencySet;
66
- maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string, { specifier, isDevOnly, isTypeOnly, isResolved, isPublishedType }: DependencyReferenceOptions): boolean;
67
+ maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string, { specifier, isDevOnly, isTypeOnly, isResolved, isPublishedType, isCaught }: DependencyReferenceOptions): boolean;
67
68
  maybeAddReferencedBinary(workspace: Workspace, binaryName: string): Set<string> | undefined;
68
69
  private isInDependencies;
69
70
  settleDependencyIssues(): {
@@ -124,7 +124,7 @@ export class DependencyDeputy {
124
124
  getOptionalPeerDependencies(workspaceName) {
125
125
  return this._manifests.get(workspaceName)?.optionalPeerDependencies ?? new Set();
126
126
  }
127
- maybeAddReferencedExternalDependency(workspace, packageName, { specifier, isDevOnly, isTypeOnly, isResolved, isPublishedType }) {
127
+ maybeAddReferencedExternalDependency(workspace, packageName, { specifier, isDevOnly, isTypeOnly, isResolved, isPublishedType, isCaught }) {
128
128
  if (!this.isReportDependencies)
129
129
  return true;
130
130
  if (specifier.startsWith('node:') || isBuiltin(specifier))
@@ -133,9 +133,11 @@ export class DependencyDeputy {
133
133
  return true;
134
134
  if (packageName === workspace.pkgName)
135
135
  return true;
136
+ const optionalPeerDependencies = this.getOptionalPeerDependencies(workspace.name);
136
137
  const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...workspace.ancestors.toReversed()];
137
138
  const isDevOrTypeOnly = isDevOnly || (isTypeOnly && !isPublishedType);
138
- const closestWorkspaceName = workspaceNames.find(name => this.isInDependencies(name, packageName, isDevOrTypeOnly));
139
+ const isCaughtOptionalPeer = isCaught && optionalPeerDependencies.has(packageName);
140
+ const closestWorkspaceName = workspaceNames.find(name => this.isInDependencies(name, packageName, isDevOrTypeOnly, isCaughtOptionalPeer));
139
141
  const typesPackageName = !isDefinitelyTyped(packageName) && getDefinitelyTypedFor(packageName);
140
142
  const closestWorkspaceNameForTypes = typesPackageName && workspaceNames.find(name => this.isInDependencies(name, typesPackageName, isDevOrTypeOnly));
141
143
  if (closestWorkspaceNameForTypes && !this.hasTypesIncluded.get(closestWorkspaceNameForTypes)?.has(packageName))
@@ -199,12 +201,15 @@ export class DependencyDeputy {
199
201
  return optionalDependencies;
200
202
  return;
201
203
  }
202
- isInDependencies(workspaceName, packageName, isDevOnly) {
204
+ isInDependencies(workspaceName, packageName, isDevOnly, isCaughtOptionalPeer) {
203
205
  const manifest = this._manifests.get(workspaceName);
204
206
  if (!manifest)
205
207
  return false;
206
- if (this.isStrict && !isDevOnly)
208
+ if (this.isStrict && !isDevOnly) {
209
+ if (isCaughtOptionalPeer && manifest.optionalPeerDependencies.has(packageName))
210
+ return true;
207
211
  return this.getProductionDependencies(workspaceName).includes(packageName);
212
+ }
208
213
  return manifest.allDependencies.has(packageName);
209
214
  }
210
215
  settleDependencyIssues() {
@@ -172,6 +172,7 @@ export class IssueCollector {
172
172
  }
173
173
  this.issues = initIssues();
174
174
  this.counters = initCounters();
175
+ this.tagHints.clear();
175
176
  return unusedFiles;
176
177
  }
177
178
  getIssues() {
@@ -75,9 +75,12 @@ class IssueFixer {
75
75
  continue;
76
76
  const absFilePath = join(this.options.cwd, filePath);
77
77
  const originalSource = await readFile(absFilePath, 'utf-8');
78
- let sourceFileText = fixes
79
- .sort((a, b) => b[0] - a[0])
80
- .reduce((text, [start, end, flags]) => removeExport({ text, start, end, flags }), originalSource);
78
+ const disjointFixes = [];
79
+ for (const fix of fixes.sort((a, b) => a[0] - b[0] || b[1] - a[1])) {
80
+ if (fix[0] >= (disjointFixes.at(-1)?.[1] ?? 0))
81
+ disjointFixes.push(fix);
82
+ }
83
+ let sourceFileText = disjointFixes.reduceRight((text, [start, end, flags]) => removeExport({ text, start, end, flags }), originalSource);
81
84
  if (MODULE_MARKER.test(originalSource) && !MODULE_MARKER.test(sourceFileText)) {
82
85
  sourceFileText = `${sourceFileText.trimEnd()}\n\nexport {};\n`;
83
86
  }
@@ -87,7 +90,8 @@ class IssueFixer {
87
90
  const issueMap = issues[type]?.[filePath];
88
91
  if (issueMap)
89
92
  for (const issue of Object.values(issueMap))
90
- issue.isFixed = true;
93
+ if (issue.fixes.length > 0)
94
+ issue.isFixed = true;
91
95
  }
92
96
  }
93
97
  return touchedFiles;
@@ -131,7 +135,8 @@ class IssueFixer {
131
135
  const keep = (_, i) => !remove.has(i + 1);
132
136
  await writeFile(absFilePath, fileContent.split('\n').filter(keep).join('\n'));
133
137
  for (const issue of issuesForFile)
134
- issue.isFixed = true;
138
+ if (issue.fixes.length > 0)
139
+ issue.isFixed = true;
135
140
  touchedFiles.add(filePath);
136
141
  }
137
142
  else {
@@ -2,7 +2,7 @@ import type { ParseResult } from 'oxc-parser';
2
2
  import { CacheConsultant } from './CacheConsultant.ts';
3
3
  import type { Compilers } from './compilers/types.ts';
4
4
  import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile, PluginVisitorContext, PluginVisitorObject } from './types/config.ts';
5
- import type { FileNode, ModuleGraph } from './types/module-graph.ts';
5
+ import type { FileNode } from './types/module-graph.ts';
6
6
  import type { Paths } from './types/project.ts';
7
7
  import type { ResolveGlobPattern } from './typescript/resolve-module-names.ts';
8
8
  import { SourceFileManager } from './typescript/SourceFileManager.ts';
@@ -39,6 +39,7 @@ export declare class ProjectPrincipal {
39
39
  addCompilers(workspaceName: string, compilers: Compilers): void;
40
40
  addPaths(paths: Paths, basePath: string, scope: string): void;
41
41
  addRootDirs(rootDirs: string[] | undefined, scope: string): void;
42
+ collectConfigurationImports(paths: Set<string>): void;
42
43
  init(): void;
43
44
  private hasAcceptedExtension;
44
45
  addEntryPath(filePath: string, options?: {
@@ -57,5 +58,5 @@ export declare class ProjectPrincipal {
57
58
  private getCachedFile;
58
59
  analyzeSourceFile(filePath: string, sourceText: string, options: GetImportsAndExportsOptions, ignoreExportsUsedInFile: IgnoreExportsUsedInFile, parseResult?: ParseResult, cachedFile?: FileNode): FileNode;
59
60
  invalidateFile(filePath: string): void;
60
- reconcileCache(graph: ModuleGraph): void;
61
+ reconcileCache(): void;
61
62
  }
@@ -10,6 +10,14 @@ import { SourceFileManager } from './typescript/SourceFileManager.js';
10
10
  import { compact } from './util/array.js';
11
11
  import { timerify } from './util/Performance.js';
12
12
  import { extname, isInNodeModules, toAbsolute } from './util/path.js';
13
+ const copyFileNode = (file) => ({
14
+ ...file,
15
+ imports: {
16
+ ...file.imports,
17
+ external: new Set(file.imports.external),
18
+ externalRefs: new Set(file.imports.externalRefs),
19
+ },
20
+ });
13
21
  export class ProjectPrincipal {
14
22
  entryPaths = new Set();
15
23
  projectPaths = new Set();
@@ -55,7 +63,7 @@ export class ProjectPrincipal {
55
63
  this.pluginVisitorObjects.push(createBunShellVisitor(this.pluginCtx));
56
64
  this.fileManager = new SourceFileManager({
57
65
  compilers: this.compilers,
58
- isSession: options.isSession || options.isWatch,
66
+ isSession: options.isSession,
59
67
  });
60
68
  this.walkAndAnalyze = timerify(this.walkAndAnalyze.bind(this), 'walkAndAnalyze');
61
69
  }
@@ -92,6 +100,23 @@ export class ProjectPrincipal {
92
100
  const scoped = this.rootDirs.get(scope) ?? [];
93
101
  this.rootDirs.set(scope, compact([...scoped, ...rootDirs]));
94
102
  }
103
+ collectConfigurationImports(paths) {
104
+ for (const filePath of paths) {
105
+ if (!DEFAULT_EXTENSIONS.has(extname(filePath)))
106
+ continue;
107
+ const source = this.fileManager.readRawFile(filePath);
108
+ if (source === undefined)
109
+ continue;
110
+ try {
111
+ for (const specifier of extractSpecifiers(_parseFile(filePath, source), source, filePath)) {
112
+ const resolved = this.resolveSpecifier(specifier, filePath);
113
+ if (resolved && !isInNodeModules(resolved))
114
+ paths.add(resolved);
115
+ }
116
+ }
117
+ catch { }
118
+ }
119
+ }
95
120
  init() {
96
121
  const scopedPaths = this.paths.size > 0 ? Array.from(this.paths, ([scope, paths]) => ({ scope, paths })) : undefined;
97
122
  const scopedRootDirs = this.rootDirs.size > 0 ? Array.from(this.rootDirs, ([scope, rootDirs]) => ({ scope, rootDirs })) : undefined;
@@ -225,7 +250,7 @@ export class ProjectPrincipal {
225
250
  getCachedFile(filePath) {
226
251
  const cachedFile = this.cache.getCachedFile(filePath);
227
252
  const skipExports = this.skipExportsAnalysis.has(filePath) || !this.isReportExports;
228
- return cachedFile?.skipExports === skipExports ? cachedFile : undefined;
253
+ return cachedFile?.skipExports === skipExports ? copyFileNode(cachedFile) : undefined;
229
254
  }
230
255
  analyzeSourceFile(filePath, sourceText, options, ignoreExportsUsedInFile, parseResult, cachedFile) {
231
256
  if (cachedFile)
@@ -243,19 +268,16 @@ export class ProjectPrincipal {
243
268
  const visitor = ignoreExportsUsedInFile
244
269
  ? (this._localRefsVisitor ??= buildVisitor(this.pluginVisitorObjects, true))
245
270
  : (this._visitor ??= buildVisitor(this.pluginVisitorObjects, false));
246
- return _getImportsAndExports(filePath, sourceText, this.resolveModule, options, ignoreExportsUsedInFile, skipExports, visitor, this.pluginVisitorObjects.length > 0 ? this.pluginCtx : undefined, parseResult);
271
+ const file = _getImportsAndExports(filePath, sourceText, this.resolveModule, options, ignoreExportsUsedInFile, skipExports, visitor, this.pluginVisitorObjects.length > 0 ? this.pluginCtx : undefined, parseResult);
272
+ if (this.projectPaths.has(filePath))
273
+ this.cache.setFileData(filePath, copyFileNode(file));
274
+ return file;
247
275
  }
248
276
  invalidateFile(filePath) {
249
277
  this.fileManager.invalidate(filePath);
250
278
  this.cache.removeEntry(filePath);
251
279
  }
252
- reconcileCache(graph) {
253
- for (const [filePath, file] of graph) {
254
- const fd = this.cache.getFileDescriptor(filePath);
255
- if (!fd?.meta)
256
- continue;
257
- fd.meta.data = { ...file, internalImportCache: undefined, importedBy: undefined };
258
- }
280
+ reconcileCache() {
259
281
  this.cache.reconcile();
260
282
  }
261
283
  }
@@ -8,6 +8,7 @@ import type { DependencySet } from './types/workspace.ts';
8
8
  import { type Manifest } from './util/package-json.ts';
9
9
  import type { MainOptions } from './util/create-options.ts';
10
10
  import { type Input } from './util/input.ts';
11
+ import type { ConfigurationFiles } from './session/configuration.ts';
11
12
  type WorkspaceManagerOptions = {
12
13
  name: string;
13
14
  dir: string;
@@ -24,6 +25,7 @@ type WorkspaceManagerOptions = {
24
25
  ignoredWorkspacePatterns: string[];
25
26
  enabledPluginsInAncestors: string[];
26
27
  configFilesMap: Map<string, Map<PluginName, Set<string>>>;
28
+ configurationFiles?: ConfigurationFiles;
27
29
  options: MainOptions;
28
30
  };
29
31
  type CacheItem = {
@@ -51,7 +53,8 @@ export declare class WorkspaceWorker {
51
53
  enabledPluginsInAncestors: string[];
52
54
  cache: CacheConsultant<Partial<Record<PluginName, CacheItem>>>;
53
55
  configFilesMap: Map<string, Map<PluginName, Set<string>>>;
54
- constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }: WorkspaceManagerOptions);
56
+ configurationFiles: ConfigurationFiles | undefined;
57
+ constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, configurationFiles, options, }: WorkspaceManagerOptions);
55
58
  init(): Promise<void>;
56
59
  private determineEnabledPlugins;
57
60
  private getConfigForPlugin;
@@ -60,7 +63,7 @@ export declare class WorkspaceWorker {
60
63
  getPluginProjectFilePatterns(patterns?: string[]): string[];
61
64
  private getPluginConfig;
62
65
  getPluginConfigPatterns(): string[];
63
- getPluginEntryFilePatterns(patterns: string[]): string[];
66
+ getPluginEntryFilePatterns(patterns: string[], base?: string): string[];
64
67
  getProductionEntryFilePatterns(): string[];
65
68
  getProductionProjectFilePatterns(): string[];
66
69
  private getConfigurationFilePatterns;
@@ -9,12 +9,13 @@ import { createManifest } from './util/package-json.js';
9
9
  import { isExternalReExportsOnly } from './typescript/ast-helpers.js';
10
10
  import { _parseFile } from './typescript/ast-nodes.js';
11
11
  import { compact } from './util/array.js';
12
- import { debugLogArray, debugLogObject } from './util/debug.js';
12
+ import { debugLog, debugLogArray, debugLogObject } from './util/debug.js';
13
13
  import { _glob, hasNoProductionSuffix, hasProductionSuffix, negate } from './util/glob.js';
14
+ import { expandIgnorePatterns } from './util/parse-and-convert-gitignores.js';
14
15
  import { isCatalog, isConfig, toConfig, toDebugString, toEntry, toProductionEntry, } from './util/input.js';
15
16
  import { filterTransitiveDependencies } from './util/filter-transitive-dependencies.js';
16
17
  import { timerify } from './util/Performance.js';
17
- import { basename, dirname, join, relative, toRelative } from './util/path.js';
18
+ import { basename, dirname, extname, join, relative, toRelative } from './util/path.js';
18
19
  import { extractPatternExtensions } from './util/pattern-extensions.js';
19
20
  import { formatCauseMessage } from './util/errors.js';
20
21
  import { logError } from './util/log.js';
@@ -41,7 +42,8 @@ export class WorkspaceWorker {
41
42
  enabledPluginsInAncestors;
42
43
  cache;
43
44
  configFilesMap;
44
- constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, options, }) {
45
+ configurationFiles;
46
+ constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, handleConfigLoadError, findWorkspaceByFilePath, getManifest, readRawFile, configFilesMap, configurationFiles, options, }) {
45
47
  this.name = name;
46
48
  this.dir = dir;
47
49
  this.config = config;
@@ -52,6 +54,7 @@ export class WorkspaceWorker {
52
54
  this.ignoredWorkspacePatterns = ignoredWorkspacePatterns;
53
55
  this.enabledPluginsInAncestors = enabledPluginsInAncestors;
54
56
  this.configFilesMap = configFilesMap;
57
+ this.configurationFiles = configurationFiles;
55
58
  this.handleInput = handleInput;
56
59
  this.handleConfigLoadError = handleConfigLoadError;
57
60
  this.findWorkspaceByFilePath = findWorkspaceByFilePath;
@@ -128,9 +131,14 @@ export class WorkspaceWorker {
128
131
  }
129
132
  return patterns;
130
133
  }
131
- getPluginEntryFilePatterns(patterns) {
134
+ getPluginEntryFilePatterns(patterns, base) {
132
135
  const negateWorkspaces = patterns.some(pattern => pattern.startsWith('**/')) ? this.negatedWorkspacePatterns : [];
133
- return [patterns, negateWorkspaces, this.ignoredWorkspacePatterns.map(negate)].flat();
136
+ const prefix = `${this.name}/`;
137
+ const toWorkspaceRelative = (name) => (name.startsWith(prefix) ? name.slice(prefix.length) : name);
138
+ const ignoredWorkspaces = base
139
+ ? expandIgnorePatterns(this.ignoredWorkspacePatterns.map(toWorkspaceRelative))
140
+ : this.ignoredWorkspacePatterns;
141
+ return [patterns, negateWorkspaces, ignoredWorkspaces.map(negate)].flat();
134
142
  }
135
143
  getProductionEntryFilePatterns() {
136
144
  const entry = this.config.entry.filter(hasProductionSuffix);
@@ -220,7 +228,8 @@ export class WorkspaceWorker {
220
228
  const [productionScripts, developmentScripts] = getFilteredScripts(manifest.scripts ?? {});
221
229
  const inputsFromManifest = _getInputsFromScripts(Object.values(developmentScripts), baseOptions);
222
230
  const productionInputsFromManifest = _getInputsFromScripts(Object.values(productionScripts), baseOptions);
223
- const hasProductionInput = (input) => productionInputsFromManifest.find(d => d.specifier === input.specifier && d.type === input.type);
231
+ for (const input of productionInputsFromManifest)
232
+ input.production = true;
224
233
  const createGetInputsFromScripts = (containingFilePath) => (scripts, options) => _getInputsFromScripts(scripts, { ...baseOptions, ...options, containingFilePath });
225
234
  const inputs = [];
226
235
  const configFilesMap = this.configFilesMap;
@@ -264,7 +273,7 @@ export class WorkspaceWorker {
264
273
  else if (isConfig(input)) {
265
274
  storeConfigFilePath(input.pluginName, { ...input, containingFilePath: inputContainingFilePath });
266
275
  }
267
- else if (!isProduction || (isProduction && (input.production || hasProductionInput(input)))) {
276
+ else if (!isProduction || input.production) {
268
277
  inputs.push({ ...input, containingFilePath: inputContainingFilePath });
269
278
  }
270
279
  }
@@ -324,6 +333,7 @@ export class WorkspaceWorker {
324
333
  if (seenConfigFiles.has(configFilePath))
325
334
  continue;
326
335
  seenConfigFiles.add(configFilePath);
336
+ this.configurationFiles?.paths.add(configFilePath);
327
337
  const isManifest = basename(configFilePath) === 'package.json';
328
338
  const fd = isManifest ? undefined : this.cache.getFileDescriptor(configFilePath);
329
339
  const data = fd?.changed ? undefined : fd?.meta?.data?.[pluginName];
@@ -378,14 +388,17 @@ export class WorkspaceWorker {
378
388
  }
379
389
  }
380
390
  catch (error) {
381
- if (!(error instanceof Error))
382
- throw error;
383
391
  hasLoadConfigError = true;
384
- this.handleConfigLoadError();
385
392
  const relPath = toRelative(configFilePath, this.options.cwd);
386
- const cause = formatCauseMessage(error, this.options.cwd);
387
- logError(`Error loading ${relPath} (${cause})`);
388
- logError('Please fix or visit https://knip.dev/reference/known-issues');
393
+ const cause = formatCauseMessage(error instanceof Error ? error : new Error(String(error)), this.options.cwd);
394
+ if (plugin.isLoadConfigOptional) {
395
+ debugLog(wsName, `Error loading ${relPath} (${cause})`);
396
+ }
397
+ else {
398
+ this.handleConfigLoadError();
399
+ logError(`Error loading ${relPath} (${cause})`);
400
+ logError('Please fix or visit https://knip.dev/reference/known-issues');
401
+ }
389
402
  }
390
403
  }
391
404
  }
@@ -398,9 +411,11 @@ export class WorkspaceWorker {
398
411
  cache.resolveFromAST = inputs;
399
412
  }
400
413
  if (!isManifest) {
401
- inputs.push(toEntry(configFilePath));
414
+ if (extname(configFilePath)) {
415
+ inputs.push(toEntry(configFilePath));
416
+ cache.configFile = toEntry(configFilePath);
417
+ }
402
418
  storeConfigFilePath(pluginName, toConfig(pluginName, configFilePath));
403
- cache.configFile = toEntry(configFilePath);
404
419
  if (hasLoadConfigError) {
405
420
  this.cache.removeEntry(configFilePath);
406
421
  }
@@ -414,9 +429,11 @@ export class WorkspaceWorker {
414
429
  for (const id of dependencies)
415
430
  addInput(id, id.containingFilePath ?? containingFilePath);
416
431
  }
417
- if (inputs.some(input => input.specifier.startsWith('!')))
432
+ if (inputs.some(input => input.specifier.startsWith('!'))) {
418
433
  for (const input of inputs)
419
- input.group = pluginName;
434
+ if (!seenConfigFiles.has(input.specifier))
435
+ input.group = pluginName;
436
+ }
420
437
  return inputs;
421
438
  };
422
439
  const enabledPluginTitles = this.enabledPlugins.map(name => Plugins[name].title);
@@ -424,6 +441,7 @@ export class WorkspaceWorker {
424
441
  for (const pluginName of this.enabledPlugins) {
425
442
  const configFiles = this.configFilesMap.get(wsName);
426
443
  const patterns = [...this.getConfigurationFilePatterns(pluginName), ...(configFiles?.get(pluginName) ?? [])];
444
+ this.configurationFiles?.addPatterns(this.dir, compact(patterns));
427
445
  configFiles?.delete(pluginName);
428
446
  for (const input of await runPlugin(pluginName, compact(patterns)))
429
447
  inputs.push(input);
@@ -21,6 +21,7 @@ const commands = new Set([
21
21
  'discord',
22
22
  'exec',
23
23
  'feedback',
24
+ 'fmt',
24
25
  'fuzzilli',
25
26
  'getcompletes',
26
27
  'help',
@@ -3,6 +3,15 @@ import { isBinary, toBinary, toDependency } from '../../util/input.js';
3
3
  import { extractBinary, isValidBinary, stripVersionFromSpecifier } from '../../util/modules.js';
4
4
  import { isInternal } from '../../util/path.js';
5
5
  import { argsAfter, expandScript } from '../util.js';
6
+ const runCommands = new Set(['run', 'run-script', 'rum', 'urn']);
7
+ const lifecycleScripts = new Map([
8
+ ['start', 'start'],
9
+ ['stop', 'stop'],
10
+ ['restart', 'restart'],
11
+ ['test', 'test'],
12
+ ['t', 'test'],
13
+ ['tst', 'test'],
14
+ ]);
6
15
  export const resolve = (_binary, words, options) => {
7
16
  const { fromArgs, manifest } = options;
8
17
  const parsed = parseArgs(words, {
@@ -49,8 +58,9 @@ export const resolve = (_binary, words, options) => {
49
58
  return [...packageInputs, ...inputs];
50
59
  }
51
60
  const _childArgs = parsed['--'] && parsed['--'].length > 0 ? fromArgs(argsAfter(words, '--'), { isForwardedArgs: true }) : [];
52
- if (command === 'run' && manifest.scriptNames.has(script)) {
53
- return expandScript(script, argsAfter(words, '--'), manifest.scripts, options) ?? _childArgs;
61
+ const name = runCommands.has(command) ? script : lifecycleScripts.get(command);
62
+ if (name && manifest.scriptNames.has(name)) {
63
+ return expandScript(name, argsAfter(words, '--'), manifest.scripts, options) ?? _childArgs;
54
64
  }
55
65
  return [];
56
66
  };