@shivaedev/quality 0.75.0 → 0.77.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 (674) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +66 -60
  3. package/dist/adapters/biome/pluginContract.d.ts +1 -1
  4. package/dist/adapters/biome/pluginContract.d.ts.map +1 -1
  5. package/dist/adapters/biome/pluginContract.js +2 -5
  6. package/dist/adapters/biome/pluginContract.js.map +1 -1
  7. package/dist/adapters/biome/run.d.ts.map +1 -1
  8. package/dist/adapters/biome/run.js +2 -0
  9. package/dist/adapters/biome/run.js.map +1 -1
  10. package/dist/adapters/biome/withExceptionConfig.d.ts.map +1 -1
  11. package/dist/adapters/biome/withExceptionConfig.js +21 -4
  12. package/dist/adapters/biome/withExceptionConfig.js.map +1 -1
  13. package/dist/adapters/changeKeyCheck.d.ts +10 -0
  14. package/dist/adapters/changeKeyCheck.d.ts.map +1 -0
  15. package/dist/adapters/{changeKeyFindings.js → changeKeyCheck.js} +8 -22
  16. package/dist/adapters/changeKeyCheck.js.map +1 -0
  17. package/dist/adapters/commandLine.d.ts +2 -0
  18. package/dist/adapters/commandLine.d.ts.map +1 -1
  19. package/dist/adapters/contextCaptureCheck.d.ts +9 -0
  20. package/dist/adapters/contextCaptureCheck.d.ts.map +1 -0
  21. package/dist/adapters/contextCaptureCheck.js +91 -0
  22. package/dist/adapters/contextCaptureCheck.js.map +1 -0
  23. package/dist/adapters/databaseUrlFindings.d.ts +1 -1
  24. package/dist/adapters/databaseUrlFindings.d.ts.map +1 -1
  25. package/dist/adapters/declaration-files/initialize.d.ts +6 -0
  26. package/dist/adapters/declaration-files/initialize.d.ts.map +1 -0
  27. package/dist/adapters/declaration-files/initialize.js +4 -0
  28. package/dist/adapters/declaration-files/initialize.js.map +1 -0
  29. package/dist/adapters/declaration-files/parse.d.ts +5 -0
  30. package/dist/adapters/declaration-files/parse.d.ts.map +1 -0
  31. package/dist/adapters/declaration-files/parse.js +6 -0
  32. package/dist/adapters/declaration-files/parse.js.map +1 -0
  33. package/dist/adapters/declaration-files/reader.d.ts +5 -0
  34. package/dist/adapters/declaration-files/reader.d.ts.map +1 -0
  35. package/dist/adapters/declaration-files/reader.js +23 -0
  36. package/dist/adapters/declaration-files/reader.js.map +1 -0
  37. package/dist/adapters/declaration-files/service.d.ts +9 -0
  38. package/dist/adapters/declaration-files/service.d.ts.map +1 -0
  39. package/dist/adapters/declaration-files/service.js +14 -0
  40. package/dist/adapters/declaration-files/service.js.map +1 -0
  41. package/dist/adapters/foreignResources.d.ts.map +1 -1
  42. package/dist/adapters/foreignResources.js +0 -4
  43. package/dist/adapters/foreignResources.js.map +1 -1
  44. package/dist/adapters/import-compiler/graph.d.ts +8 -2
  45. package/dist/adapters/import-compiler/graph.d.ts.map +1 -1
  46. package/dist/adapters/import-compiler/graph.js +4 -1
  47. package/dist/adapters/import-compiler/graph.js.map +1 -1
  48. package/dist/adapters/import-compiler/service.d.ts +7 -1
  49. package/dist/adapters/import-compiler/service.d.ts.map +1 -1
  50. package/dist/adapters/imports/graph.d.ts +6 -3
  51. package/dist/adapters/imports/graph.d.ts.map +1 -1
  52. package/dist/adapters/imports/graph.js +31 -18
  53. package/dist/adapters/imports/graph.js.map +1 -1
  54. package/dist/adapters/knip/configuration.d.ts +2 -2
  55. package/dist/adapters/knip/configuration.d.ts.map +1 -1
  56. package/dist/adapters/knip/configuration.js +11 -5
  57. package/dist/adapters/knip/configuration.js.map +1 -1
  58. package/dist/adapters/knip/entryPointFindings.d.ts +1 -1
  59. package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
  60. package/dist/adapters/knip/run.d.ts +1 -1
  61. package/dist/adapters/knip/run.d.ts.map +1 -1
  62. package/dist/adapters/knip/run.js +4 -1
  63. package/dist/adapters/knip/run.js.map +1 -1
  64. package/dist/adapters/outsideImportFindings.d.ts +5 -2
  65. package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
  66. package/dist/adapters/outsideImportFindings.js +12 -52
  67. package/dist/adapters/outsideImportFindings.js.map +1 -1
  68. package/dist/adapters/queueReadoutFindings.d.ts +1 -1
  69. package/dist/adapters/queueReadoutFindings.d.ts.map +1 -1
  70. package/dist/adapters/rule.d.ts +9 -1
  71. package/dist/adapters/rule.d.ts.map +1 -1
  72. package/dist/adapters/rule.js +21 -6
  73. package/dist/adapters/rule.js.map +1 -1
  74. package/dist/adapters/runMain.d.ts +3 -4
  75. package/dist/adapters/runMain.d.ts.map +1 -1
  76. package/dist/adapters/runMain.js +2 -1
  77. package/dist/adapters/runMain.js.map +1 -1
  78. package/dist/adapters/serviceIdFindings.d.ts +1 -1
  79. package/dist/adapters/serviceIdFindings.d.ts.map +1 -1
  80. package/dist/adapters/serviceModelCheck.d.ts +9 -0
  81. package/dist/adapters/serviceModelCheck.d.ts.map +1 -0
  82. package/dist/adapters/{serviceModelFindings.js → serviceModelCheck.js} +9 -23
  83. package/dist/adapters/serviceModelCheck.js.map +1 -0
  84. package/dist/adapters/sharedErrorCatalog.d.ts +13 -0
  85. package/dist/adapters/sharedErrorCatalog.d.ts.map +1 -0
  86. package/dist/adapters/sharedErrorCatalog.js +28 -0
  87. package/dist/adapters/sharedErrorCatalog.js.map +1 -0
  88. package/dist/adapters/sharedErrorModules.d.ts +1 -1
  89. package/dist/adapters/sharedErrorModules.d.ts.map +1 -1
  90. package/dist/adapters/sharedErrorModules.js.map +1 -1
  91. package/dist/adapters/specReaderSources.d.ts +3 -2
  92. package/dist/adapters/specReaderSources.d.ts.map +1 -1
  93. package/dist/adapters/specReaderSources.js +6 -3
  94. package/dist/adapters/specReaderSources.js.map +1 -1
  95. package/dist/adapters/storyProgram.d.ts +2 -0
  96. package/dist/adapters/storyProgram.d.ts.map +1 -1
  97. package/dist/adapters/storyProgram.js +13 -3
  98. package/dist/adapters/storyProgram.js.map +1 -1
  99. package/dist/adapters/typeScriptProgram.d.ts +5 -0
  100. package/dist/adapters/typeScriptProgram.d.ts.map +1 -0
  101. package/dist/adapters/typeScriptProgram.js +43 -0
  102. package/dist/adapters/typeScriptProgram.js.map +1 -0
  103. package/dist/baseline/compare.d.ts +2 -0
  104. package/dist/baseline/compare.d.ts.map +1 -1
  105. package/dist/baseline/compare.js +43 -17
  106. package/dist/baseline/compare.js.map +1 -1
  107. package/dist/baseline/format.d.ts +1 -0
  108. package/dist/baseline/format.d.ts.map +1 -1
  109. package/dist/baseline/format.js +6 -2
  110. package/dist/baseline/format.js.map +1 -1
  111. package/dist/baseline/merge.d.ts.map +1 -1
  112. package/dist/baseline/merge.js +14 -1
  113. package/dist/baseline/merge.js.map +1 -1
  114. package/dist/baseline/rewrite.d.ts.map +1 -1
  115. package/dist/baseline/rewrite.js +3 -1
  116. package/dist/baseline/rewrite.js.map +1 -1
  117. package/dist/baseline/update.d.ts +7 -0
  118. package/dist/baseline/update.d.ts.map +1 -1
  119. package/dist/baseline/update.js +29 -8
  120. package/dist/baseline/update.js.map +1 -1
  121. package/dist/biome/exceptionConfig.d.ts +3 -0
  122. package/dist/biome/exceptionConfig.d.ts.map +1 -1
  123. package/dist/biome/exceptionConfig.js +15 -1
  124. package/dist/biome/exceptionConfig.js.map +1 -1
  125. package/dist/biome/scannerRules.d.ts +3 -0
  126. package/dist/biome/scannerRules.d.ts.map +1 -0
  127. package/dist/biome/scannerRules.js +42 -0
  128. package/dist/biome/scannerRules.js.map +1 -0
  129. package/dist/cli/args.d.ts +2 -0
  130. package/dist/cli/args.d.ts.map +1 -1
  131. package/dist/cli/args.js +10 -1
  132. package/dist/cli/args.js.map +1 -1
  133. package/dist/cli/baseline.d.ts.map +1 -1
  134. package/dist/cli/baseline.js +5 -1
  135. package/dist/cli/baseline.js.map +1 -1
  136. package/dist/cli/lint.d.ts +9 -1
  137. package/dist/cli/lint.d.ts.map +1 -1
  138. package/dist/cli/lint.js +18 -5
  139. package/dist/cli/lint.js.map +1 -1
  140. package/dist/cli/migrateExceptions.d.ts.map +1 -1
  141. package/dist/cli/migrateExceptions.js +5 -8
  142. package/dist/cli/migrateExceptions.js.map +1 -1
  143. package/dist/cli/misplaced.d.ts +6 -0
  144. package/dist/cli/misplaced.d.ts.map +1 -1
  145. package/dist/cli/misplaced.js +4 -2
  146. package/dist/cli/misplaced.js.map +1 -1
  147. package/dist/cli/program.js +1 -1
  148. package/dist/cli/program.js.map +1 -1
  149. package/dist/cli/runSet.d.ts +5 -0
  150. package/dist/cli/runSet.d.ts.map +1 -0
  151. package/dist/cli/runSet.js +15 -0
  152. package/dist/cli/runSet.js.map +1 -0
  153. package/dist/cli/shrink.d.ts +4 -4
  154. package/dist/cli/shrink.d.ts.map +1 -1
  155. package/dist/cli/shrink.js.map +1 -1
  156. package/dist/cli/usage.d.ts +1 -1
  157. package/dist/cli/usage.d.ts.map +1 -1
  158. package/dist/cli/usage.js +7 -2
  159. package/dist/cli/usage.js.map +1 -1
  160. package/dist/config/decode.d.ts +1 -0
  161. package/dist/config/decode.d.ts.map +1 -1
  162. package/dist/config/decode.js +1 -0
  163. package/dist/config/decode.js.map +1 -1
  164. package/dist/config/load.d.ts +2 -0
  165. package/dist/config/load.d.ts.map +1 -1
  166. package/dist/config/load.js +1 -0
  167. package/dist/config/load.js.map +1 -1
  168. package/dist/config/resolve.d.ts +2 -1
  169. package/dist/config/resolve.d.ts.map +1 -1
  170. package/dist/config/resolve.js +9 -4
  171. package/dist/config/resolve.js.map +1 -1
  172. package/dist/config.d.ts +2 -0
  173. package/dist/config.d.ts.map +1 -1
  174. package/dist/config.js.map +1 -1
  175. package/dist/engine/childStarted.d.ts +4 -0
  176. package/dist/engine/childStarted.d.ts.map +1 -0
  177. package/dist/engine/childStarted.js +7 -0
  178. package/dist/engine/childStarted.js.map +1 -0
  179. package/dist/engine/evaluate.d.ts +1 -0
  180. package/dist/engine/evaluate.d.ts.map +1 -1
  181. package/dist/engine/evaluate.js +2 -1
  182. package/dist/engine/evaluate.js.map +1 -1
  183. package/dist/engine/runRule.d.ts +21 -0
  184. package/dist/engine/runRule.d.ts.map +1 -0
  185. package/dist/engine/runRule.js +70 -0
  186. package/dist/engine/runRule.js.map +1 -0
  187. package/dist/engine/runRules.d.ts +5 -12
  188. package/dist/engine/runRules.d.ts.map +1 -1
  189. package/dist/engine/runRules.js +49 -65
  190. package/dist/engine/runRules.js.map +1 -1
  191. package/dist/engine/session.d.ts +2 -1
  192. package/dist/engine/session.d.ts.map +1 -1
  193. package/dist/engine/session.js +20 -6
  194. package/dist/engine/session.js.map +1 -1
  195. package/dist/engine/violation.d.ts +7 -0
  196. package/dist/engine/violation.d.ts.map +1 -1
  197. package/dist/engine/violation.js +9 -0
  198. package/dist/engine/violation.js.map +1 -1
  199. package/dist/exceptions/MigrationFailure.d.ts +9 -0
  200. package/dist/exceptions/MigrationFailure.d.ts.map +1 -0
  201. package/dist/exceptions/MigrationFailure.js +4 -0
  202. package/dist/exceptions/MigrationFailure.js.map +1 -0
  203. package/dist/exceptions/biomeFindings.d.ts +5 -1
  204. package/dist/exceptions/biomeFindings.d.ts.map +1 -1
  205. package/dist/exceptions/biomeFindings.js +17 -18
  206. package/dist/exceptions/biomeFindings.js.map +1 -1
  207. package/dist/exceptions/migrateBiome.d.ts +3 -1
  208. package/dist/exceptions/migrateBiome.d.ts.map +1 -1
  209. package/dist/exceptions/migrateBiome.js +5 -3
  210. package/dist/exceptions/migrateBiome.js.map +1 -1
  211. package/dist/exceptions/migrateConfig.d.ts +3 -1
  212. package/dist/exceptions/migrateConfig.d.ts.map +1 -1
  213. package/dist/exceptions/migrateConfig.js +40 -25
  214. package/dist/exceptions/migrateConfig.js.map +1 -1
  215. package/dist/exceptions/registry.d.ts.map +1 -1
  216. package/dist/exceptions/registry.js +2 -2
  217. package/dist/exceptions/registry.js.map +1 -1
  218. package/dist/hooks/preCommit.d.ts +1 -2
  219. package/dist/hooks/preCommit.d.ts.map +1 -1
  220. package/dist/hooks/preCommit.js +18 -4
  221. package/dist/hooks/preCommit.js.map +1 -1
  222. package/dist/hooks/stagedCheck.d.ts +5 -0
  223. package/dist/hooks/stagedCheck.d.ts.map +1 -0
  224. package/dist/hooks/stagedCheck.js +43 -0
  225. package/dist/hooks/stagedCheck.js.map +1 -0
  226. package/dist/hooks/withStagedContent.d.ts +5 -0
  227. package/dist/hooks/withStagedContent.d.ts.map +1 -0
  228. package/dist/hooks/withStagedContent.js +84 -0
  229. package/dist/hooks/withStagedContent.js.map +1 -0
  230. package/dist/imports/browserGlobals.d.ts +1 -1
  231. package/dist/imports/browserGlobals.d.ts.map +1 -1
  232. package/dist/imports/browserNames.d.ts +1 -1
  233. package/dist/imports/browserNames.d.ts.map +1 -1
  234. package/dist/imports/browserNames.js +5 -3
  235. package/dist/imports/browserNames.js.map +1 -1
  236. package/dist/imports/departures.d.ts +1 -1
  237. package/dist/imports/departures.d.ts.map +1 -1
  238. package/dist/imports/fences/check.d.ts +1 -1
  239. package/dist/imports/fences/check.d.ts.map +1 -1
  240. package/dist/imports/fences/check.js +1 -1
  241. package/dist/imports/fences/check.js.map +1 -1
  242. package/dist/imports/fences/compilePolicy.d.ts +3 -1
  243. package/dist/imports/fences/compilePolicy.d.ts.map +1 -1
  244. package/dist/imports/fences/compilePolicy.js +5 -3
  245. package/dist/imports/fences/compilePolicy.js.map +1 -1
  246. package/dist/imports/fences/evaluate.d.ts +1 -1
  247. package/dist/imports/fences/evaluate.d.ts.map +1 -1
  248. package/dist/imports/fences/evaluate.js +1 -1
  249. package/dist/imports/fences/evaluate.js.map +1 -1
  250. package/dist/imports/globMatcher.d.ts.map +1 -1
  251. package/dist/imports/globMatcher.js +33 -31
  252. package/dist/imports/globMatcher.js.map +1 -1
  253. package/dist/imports/graph.d.ts +6 -1
  254. package/dist/imports/graph.d.ts.map +1 -1
  255. package/dist/imports/graph.js +30 -2
  256. package/dist/imports/graph.js.map +1 -1
  257. package/dist/imports/pnpmWorkspacePatterns.d.ts +12 -2
  258. package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
  259. package/dist/imports/pnpmWorkspacePatterns.js +31 -32
  260. package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
  261. package/dist/imports/withoutGenerated.js +1 -1
  262. package/dist/imports/withoutGenerated.js.map +1 -1
  263. package/dist/imports/workspace.d.ts +1 -1
  264. package/dist/imports/workspace.d.ts.map +1 -1
  265. package/dist/imports/workspace.js +1 -1
  266. package/dist/imports/workspace.js.map +1 -1
  267. package/dist/inventory/programmaticBuilds.d.ts +1 -1
  268. package/dist/inventory/programmaticBuilds.d.ts.map +1 -1
  269. package/dist/inventory/trackedPaths.d.ts +1 -0
  270. package/dist/inventory/trackedPaths.d.ts.map +1 -1
  271. package/dist/inventory/trackedPaths.js +9 -3
  272. package/dist/inventory/trackedPaths.js.map +1 -1
  273. package/dist/manifests/deliveredDependencies.d.ts +3 -0
  274. package/dist/manifests/deliveredDependencies.d.ts.map +1 -0
  275. package/dist/manifests/deliveredDependencies.js +8 -0
  276. package/dist/manifests/deliveredDependencies.js.map +1 -0
  277. package/dist/naming/developmentCode.d.ts +1 -1
  278. package/dist/naming/developmentCode.d.ts.map +1 -1
  279. package/dist/naming/packageTests.d.ts +1 -1
  280. package/dist/naming/packageTests.d.ts.map +1 -1
  281. package/dist/naming/testCode.d.ts +1 -1
  282. package/dist/naming/testCode.d.ts.map +1 -1
  283. package/dist/report/recap.d.ts +4 -0
  284. package/dist/report/recap.d.ts.map +1 -0
  285. package/dist/report/recap.js +23 -0
  286. package/dist/report/recap.js.map +1 -0
  287. package/dist/report/render.d.ts +2 -0
  288. package/dist/report/render.d.ts.map +1 -1
  289. package/dist/report/render.js +11 -4
  290. package/dist/report/render.js.map +1 -1
  291. package/dist/report/runSetLine.d.ts +3 -0
  292. package/dist/report/runSetLine.d.ts.map +1 -0
  293. package/dist/report/runSetLine.js +13 -0
  294. package/dist/report/runSetLine.js.map +1 -0
  295. package/dist/report/staleSections.d.ts.map +1 -1
  296. package/dist/report/staleSections.js +13 -0
  297. package/dist/report/staleSections.js.map +1 -1
  298. package/dist/rule.d.ts +30 -4
  299. package/dist/rule.d.ts.map +1 -1
  300. package/dist/rule.js +4 -2
  301. package/dist/rule.js.map +1 -1
  302. package/dist/rules/biome.d.ts +18 -1
  303. package/dist/rules/biome.d.ts.map +1 -1
  304. package/dist/rules/biome.js +32 -7
  305. package/dist/rules/biome.js.map +1 -1
  306. package/dist/rules/builtIn.d.ts +8 -8
  307. package/dist/rules/builtIn.d.ts.map +1 -1
  308. package/dist/rules/builtIn.js +0 -2
  309. package/dist/rules/builtIn.js.map +1 -1
  310. package/dist/rules/effect/adapterImports.d.ts +1 -1
  311. package/dist/rules/effect/adapterImports.d.ts.map +1 -1
  312. package/dist/rules/effect/adapterImports.js +1 -1
  313. package/dist/rules/effect/adapterImports.js.map +1 -1
  314. package/dist/rules/effect/boundary.d.ts +1 -1
  315. package/dist/rules/effect/boundary.d.ts.map +1 -1
  316. package/dist/rules/effect/boundary.js +60 -75
  317. package/dist/rules/effect/boundary.js.map +1 -1
  318. package/dist/rules/effect/boundaryFindings.d.ts +4 -0
  319. package/dist/rules/effect/boundaryFindings.d.ts.map +1 -0
  320. package/dist/rules/effect/boundaryFindings.js +63 -0
  321. package/dist/rules/effect/boundaryFindings.js.map +1 -0
  322. package/dist/rules/effect/boundaryReference.d.ts +4 -0
  323. package/dist/rules/effect/boundaryReference.d.ts.map +1 -1
  324. package/dist/rules/effect/boundaryReference.js +6 -3
  325. package/dist/rules/effect/boundaryReference.js.map +1 -1
  326. package/dist/rules/effect/contextCapture.d.ts.map +1 -1
  327. package/dist/rules/effect/contextCapture.js +3 -2
  328. package/dist/rules/effect/contextCapture.js.map +1 -1
  329. package/dist/rules/effect/errorTags.d.ts +10 -0
  330. package/dist/rules/effect/errorTags.d.ts.map +1 -0
  331. package/dist/rules/effect/errorTags.js +57 -0
  332. package/dist/rules/effect/errorTags.js.map +1 -0
  333. package/dist/rules/effect/failureHonesty.d.ts +1 -1
  334. package/dist/rules/effect/failureHonesty.d.ts.map +1 -1
  335. package/dist/rules/effect/failureHonesty.js +6 -5
  336. package/dist/rules/effect/failureHonesty.js.map +1 -1
  337. package/dist/rules/effect/policy.d.ts +1 -1
  338. package/dist/rules/effect/policy.d.ts.map +1 -1
  339. package/dist/rules/effect/policy.js +0 -2
  340. package/dist/rules/effect/policy.js.map +1 -1
  341. package/dist/rules/effect/promiseBridge.d.ts +3 -0
  342. package/dist/rules/effect/promiseBridge.d.ts.map +1 -0
  343. package/dist/rules/effect/promiseBridge.js +60 -0
  344. package/dist/rules/effect/promiseBridge.js.map +1 -0
  345. package/dist/rules/effect/rpcBoundary.d.ts.map +1 -1
  346. package/dist/rules/effect/rpcBoundary.js +92 -3
  347. package/dist/rules/effect/rpcBoundary.js.map +1 -1
  348. package/dist/rules/effect/serviceModel.d.ts.map +1 -1
  349. package/dist/rules/effect/serviceModel.js +3 -2
  350. package/dist/rules/effect/serviceModel.js.map +1 -1
  351. package/dist/rules/effect/serviceParameterCheck.d.ts +7 -0
  352. package/dist/rules/effect/serviceParameterCheck.d.ts.map +1 -0
  353. package/dist/rules/effect/serviceParameterCheck.js +15 -0
  354. package/dist/rules/effect/serviceParameterCheck.js.map +1 -0
  355. package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
  356. package/dist/rules/effect/serviceParameters.js +4 -36
  357. package/dist/rules/effect/serviceParameters.js.map +1 -1
  358. package/dist/rules/effect/sharedErrorClasses.d.ts.map +1 -1
  359. package/dist/rules/effect/sharedErrorClasses.js +31 -2
  360. package/dist/rules/effect/sharedErrorClasses.js.map +1 -1
  361. package/dist/rules/effect/workspaceProgram.d.ts +5 -0
  362. package/dist/rules/effect/workspaceProgram.d.ts.map +1 -0
  363. package/dist/rules/effect/workspaceProgram.js +32 -0
  364. package/dist/rules/effect/workspaceProgram.js.map +1 -0
  365. package/dist/rules/imports/adminPaths.d.ts +1 -1
  366. package/dist/rules/imports/adminPaths.d.ts.map +1 -1
  367. package/dist/rules/imports/cycles.d.ts +1 -1
  368. package/dist/rules/imports/cycles.d.ts.map +1 -1
  369. package/dist/rules/imports/fences.d.ts +1 -1
  370. package/dist/rules/imports/fences.d.ts.map +1 -1
  371. package/dist/rules/imports/manifest.d.ts +1 -1
  372. package/dist/rules/imports/manifest.d.ts.map +1 -1
  373. package/dist/rules/imports/noTestCode.d.ts +1 -1
  374. package/dist/rules/imports/noTestCode.d.ts.map +1 -1
  375. package/dist/rules/imports/runtime.d.ts +1 -1
  376. package/dist/rules/imports/runtime.d.ts.map +1 -1
  377. package/dist/rules/imports/runtime.js +32 -5
  378. package/dist/rules/imports/runtime.js.map +1 -1
  379. package/dist/rules/manifestsApplication.d.ts.map +1 -1
  380. package/dist/rules/manifestsApplication.js +4 -5
  381. package/dist/rules/manifestsApplication.js.map +1 -1
  382. package/dist/rules/manifestsNoTestKits.js +1 -1
  383. package/dist/rules/manifestsNoTestKits.js.map +1 -1
  384. package/dist/rules/maxLines.d.ts +1 -1
  385. package/dist/rules/maxLines.d.ts.map +1 -1
  386. package/dist/rules/packageFindings.d.ts +31 -0
  387. package/dist/rules/packageFindings.d.ts.map +1 -0
  388. package/dist/rules/packageFindings.js +65 -0
  389. package/dist/rules/packageFindings.js.map +1 -0
  390. package/dist/rules/parse.d.ts +4 -1
  391. package/dist/rules/parse.d.ts.map +1 -1
  392. package/dist/rules/parse.js +35 -2
  393. package/dist/rules/parse.js.map +1 -1
  394. package/dist/rules/rootedFindings.d.ts +5 -0
  395. package/dist/rules/rootedFindings.d.ts.map +1 -0
  396. package/dist/rules/rootedFindings.js +16 -0
  397. package/dist/rules/rootedFindings.js.map +1 -0
  398. package/dist/rules/stories/adapterOnlyFakes.d.ts +1 -1
  399. package/dist/rules/stories/adapterOnlyFakes.d.ts.map +1 -1
  400. package/dist/rules/stories/adapterOnlyFakes.js +1 -0
  401. package/dist/rules/stories/adapterOnlyFakes.js.map +1 -1
  402. package/dist/rules/stories/databaseUrl.d.ts +1 -1
  403. package/dist/rules/stories/databaseUrl.d.ts.map +1 -1
  404. package/dist/rules/stories/databaseUrl.js +1 -0
  405. package/dist/rules/stories/databaseUrl.js.map +1 -1
  406. package/dist/rules/stories/domainOutcomes.d.ts +1 -1
  407. package/dist/rules/stories/domainOutcomes.d.ts.map +1 -1
  408. package/dist/rules/stories/domainOutcomes.js +1 -0
  409. package/dist/rules/stories/domainOutcomes.js.map +1 -1
  410. package/dist/rules/stories/engine.d.ts +1 -1
  411. package/dist/rules/stories/engine.d.ts.map +1 -1
  412. package/dist/rules/stories/engine.js +1 -0
  413. package/dist/rules/stories/engine.js.map +1 -1
  414. package/dist/rules/stories/globalRetries.d.ts +1 -1
  415. package/dist/rules/stories/globalRetries.d.ts.map +1 -1
  416. package/dist/rules/stories/globalRetries.js +1 -0
  417. package/dist/rules/stories/globalRetries.js.map +1 -1
  418. package/dist/rules/stories/groupedOutcomes.d.ts +1 -1
  419. package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -1
  420. package/dist/rules/stories/groupedOutcomes.js +1 -0
  421. package/dist/rules/stories/groupedOutcomes.js.map +1 -1
  422. package/dist/rules/stories/importedChangeKeys.js +2 -2
  423. package/dist/rules/stories/importedChangeKeys.js.map +1 -1
  424. package/dist/rules/stories/namedValues.d.ts +1 -1
  425. package/dist/rules/stories/namedValues.d.ts.map +1 -1
  426. package/dist/rules/stories/namedValues.js +1 -0
  427. package/dist/rules/stories/namedValues.js.map +1 -1
  428. package/dist/rules/stories/noExpect.d.ts +1 -1
  429. package/dist/rules/stories/noExpect.d.ts.map +1 -1
  430. package/dist/rules/stories/noLimitImports.d.ts +1 -1
  431. package/dist/rules/stories/noLimitImports.d.ts.map +1 -1
  432. package/dist/rules/stories/noLimitImports.js +1 -0
  433. package/dist/rules/stories/noLimitImports.js.map +1 -1
  434. package/dist/rules/stories/positiveRefusals.d.ts +1 -1
  435. package/dist/rules/stories/positiveRefusals.d.ts.map +1 -1
  436. package/dist/rules/stories/positiveRefusals.js +1 -0
  437. package/dist/rules/stories/positiveRefusals.js.map +1 -1
  438. package/dist/rules/stories/queueReadouts.d.ts +1 -1
  439. package/dist/rules/stories/queueReadouts.d.ts.map +1 -1
  440. package/dist/rules/stories/queueReadouts.js +1 -0
  441. package/dist/rules/stories/queueReadouts.js.map +1 -1
  442. package/dist/rules/stories/sources.d.ts +2 -2
  443. package/dist/rules/stories/sources.d.ts.map +1 -1
  444. package/dist/rules/stories/specHelpers.d.ts +1 -1
  445. package/dist/rules/stories/specHelpers.d.ts.map +1 -1
  446. package/dist/rules/stories/specHelpers.js +3 -2
  447. package/dist/rules/stories/specHelpers.js.map +1 -1
  448. package/dist/rules/stories/specs.d.ts +1 -1
  449. package/dist/rules/stories/specs.d.ts.map +1 -1
  450. package/dist/rules/stories/specs.js +1 -0
  451. package/dist/rules/stories/specs.js.map +1 -1
  452. package/dist/rules/stories/waitOnEvents.d.ts +1 -1
  453. package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
  454. package/dist/rules/stories/waitOnEvents.js +3 -3
  455. package/dist/rules/stories/waitOnEvents.js.map +1 -1
  456. package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
  457. package/dist/rules/suppressions/noDoubleCast.js +4 -49
  458. package/dist/rules/suppressions/noDoubleCast.js.map +1 -1
  459. package/dist/rules/suppressions/typedCastCheck.d.ts +10 -0
  460. package/dist/rules/suppressions/typedCastCheck.d.ts.map +1 -0
  461. package/dist/rules/suppressions/typedCastCheck.js +48 -0
  462. package/dist/rules/suppressions/typedCastCheck.js.map +1 -0
  463. package/dist/rules/unusedCode.d.ts.map +1 -1
  464. package/dist/rules/unusedCode.js +1 -0
  465. package/dist/rules/unusedCode.js.map +1 -1
  466. package/dist/testing/adapters/cli.d.ts +1 -0
  467. package/dist/testing/adapters/cli.d.ts.map +1 -1
  468. package/dist/testing/adapters/cli.js +10 -8
  469. package/dist/testing/adapters/cli.js.map +1 -1
  470. package/dist/testing/adapters/git.d.ts +1 -16
  471. package/dist/testing/adapters/git.d.ts.map +1 -1
  472. package/dist/testing/adapters/git.js +5 -10
  473. package/dist/testing/adapters/git.js.map +1 -1
  474. package/dist/testing/adapters/hookRepository.d.ts +3 -2
  475. package/dist/testing/adapters/hookRepository.d.ts.map +1 -1
  476. package/dist/testing/adapters/hookRepository.js +11 -8
  477. package/dist/testing/adapters/hookRepository.js.map +1 -1
  478. package/dist/testing/adapters/imports.d.ts.map +1 -1
  479. package/dist/testing/adapters/imports.js +4 -1
  480. package/dist/testing/adapters/imports.js.map +1 -1
  481. package/dist/testing/ruleStory.d.ts +1 -1
  482. package/dist/testing/ruleStory.js +2 -2
  483. package/dist/testing/ruleStory.js.map +1 -1
  484. package/docs/debt-and-hooks.md +8 -4
  485. package/package.json +19 -19
  486. package/src/adapters/biome/pluginContract.ts +2 -5
  487. package/src/adapters/biome/run.ts +2 -0
  488. package/src/adapters/biome/withExceptionConfig.ts +26 -5
  489. package/src/adapters/{changeKeyFindings.ts → changeKeyCheck.ts} +8 -24
  490. package/src/adapters/contextCaptureCheck.ts +106 -0
  491. package/src/adapters/declaration-files/initialize.ts +4 -0
  492. package/src/adapters/declaration-files/parse.ts +9 -0
  493. package/src/adapters/declaration-files/reader.ts +28 -0
  494. package/src/adapters/declaration-files/service.ts +16 -0
  495. package/src/adapters/foreignResources.ts +0 -4
  496. package/src/adapters/import-compiler/graph.ts +7 -2
  497. package/src/adapters/imports/graph.ts +43 -18
  498. package/src/adapters/knip/configuration.ts +11 -5
  499. package/src/adapters/knip/run.ts +4 -1
  500. package/src/adapters/outsideImportFindings.ts +22 -65
  501. package/src/adapters/rule.ts +29 -6
  502. package/src/adapters/runMain.ts +7 -6
  503. package/src/adapters/{serviceModelFindings.ts → serviceModelCheck.ts} +10 -25
  504. package/src/adapters/sharedErrorCatalog.ts +43 -0
  505. package/src/adapters/sharedErrorModules.ts +1 -1
  506. package/src/adapters/specReaderSources.ts +6 -3
  507. package/src/adapters/storyProgram.ts +20 -3
  508. package/src/adapters/typeScriptProgram.ts +57 -0
  509. package/src/baseline/compare.ts +59 -19
  510. package/src/baseline/format.ts +7 -2
  511. package/src/baseline/merge.ts +15 -1
  512. package/src/baseline/rewrite.ts +3 -1
  513. package/src/baseline/update.ts +38 -8
  514. package/src/biome/exceptionConfig.ts +24 -3
  515. package/src/biome/scannerRules.ts +42 -0
  516. package/src/cli/args.ts +13 -2
  517. package/src/cli/baseline.ts +7 -1
  518. package/src/cli/lint.ts +34 -18
  519. package/src/cli/migrateExceptions.ts +8 -9
  520. package/src/cli/misplaced.ts +4 -2
  521. package/src/cli/program.ts +1 -1
  522. package/src/cli/runSet.ts +17 -0
  523. package/src/cli/shrink.ts +4 -11
  524. package/src/cli/usage.ts +7 -2
  525. package/src/config/decode.ts +1 -0
  526. package/src/config/load.ts +3 -0
  527. package/src/config/resolve.ts +11 -6
  528. package/src/config.ts +3 -0
  529. package/src/engine/childStarted.ts +8 -0
  530. package/src/engine/evaluate.ts +3 -1
  531. package/src/engine/runRule.ts +103 -0
  532. package/src/engine/runRules.ts +64 -86
  533. package/src/engine/session.ts +23 -5
  534. package/src/engine/violation.ts +16 -0
  535. package/src/exceptions/MigrationFailure.ts +5 -0
  536. package/src/exceptions/biomeFindings.ts +24 -21
  537. package/src/exceptions/migrateBiome.ts +10 -4
  538. package/src/exceptions/migrateConfig.ts +66 -29
  539. package/src/exceptions/registry.ts +2 -2
  540. package/src/hooks/preCommit.ts +22 -7
  541. package/src/hooks/stagedCheck.ts +54 -0
  542. package/src/hooks/withStagedContent.ts +111 -0
  543. package/src/imports/browserNames.ts +7 -5
  544. package/src/imports/fences/check.ts +1 -1
  545. package/src/imports/fences/compilePolicy.ts +6 -4
  546. package/src/imports/fences/evaluate.ts +2 -2
  547. package/src/imports/globMatcher.ts +42 -35
  548. package/src/imports/graph.ts +47 -3
  549. package/src/imports/pnpmWorkspacePatterns.ts +44 -39
  550. package/src/imports/withoutGenerated.ts +1 -1
  551. package/src/imports/workspace.ts +1 -1
  552. package/src/inventory/trackedPaths.ts +10 -3
  553. package/src/manifests/deliveredDependencies.ts +11 -0
  554. package/src/report/recap.ts +29 -0
  555. package/src/report/render.ts +13 -4
  556. package/src/report/runSetLine.ts +14 -0
  557. package/src/report/staleSections.ts +14 -0
  558. package/src/rule.ts +38 -7
  559. package/src/rules/biome.ts +53 -7
  560. package/src/rules/builtIn.ts +0 -2
  561. package/src/rules/effect/adapterImports.ts +1 -1
  562. package/src/rules/effect/boundary.ts +82 -83
  563. package/src/rules/effect/boundaryFindings.ts +71 -0
  564. package/src/rules/effect/boundaryReference.ts +7 -3
  565. package/src/rules/effect/contextCapture.ts +3 -2
  566. package/src/rules/effect/errorTags.ts +72 -0
  567. package/src/rules/effect/failureHonesty.ts +9 -5
  568. package/src/rules/effect/policy.ts +0 -2
  569. package/src/rules/effect/promiseBridge.ts +65 -0
  570. package/src/rules/effect/rpcBoundary.ts +111 -4
  571. package/src/rules/effect/serviceModel.ts +3 -2
  572. package/src/rules/effect/serviceParameterCheck.ts +22 -0
  573. package/src/rules/effect/serviceParameters.ts +5 -37
  574. package/src/rules/effect/sharedErrorClasses.ts +41 -3
  575. package/src/rules/effect/workspaceProgram.ts +34 -0
  576. package/src/rules/imports/runtime.ts +43 -6
  577. package/src/rules/manifestsApplication.ts +4 -5
  578. package/src/rules/manifestsNoTestKits.ts +1 -1
  579. package/src/rules/packageFindings.ts +103 -0
  580. package/src/rules/parse.ts +54 -3
  581. package/src/rules/rootedFindings.ts +19 -0
  582. package/src/rules/stories/adapterOnlyFakes.ts +1 -0
  583. package/src/rules/stories/databaseUrl.ts +1 -0
  584. package/src/rules/stories/domainOutcomes.ts +1 -0
  585. package/src/rules/stories/engine.ts +1 -0
  586. package/src/rules/stories/globalRetries.ts +1 -0
  587. package/src/rules/stories/groupedOutcomes.ts +1 -0
  588. package/src/rules/stories/importedChangeKeys.ts +2 -2
  589. package/src/rules/stories/namedValues.ts +1 -0
  590. package/src/rules/stories/noLimitImports.ts +1 -0
  591. package/src/rules/stories/positiveRefusals.ts +1 -0
  592. package/src/rules/stories/queueReadouts.ts +1 -0
  593. package/src/rules/stories/specHelpers.ts +8 -5
  594. package/src/rules/stories/specs.ts +1 -0
  595. package/src/rules/stories/waitOnEvents.ts +6 -3
  596. package/src/rules/suppressions/noDoubleCast.ts +5 -55
  597. package/src/rules/suppressions/typedCastCheck.ts +55 -0
  598. package/src/rules/unusedCode.ts +1 -0
  599. package/src/testing/adapters/cli.ts +13 -9
  600. package/src/testing/adapters/git.ts +6 -11
  601. package/src/testing/adapters/hookRepository.ts +12 -7
  602. package/src/testing/adapters/imports.ts +4 -1
  603. package/src/testing/ruleStory.ts +2 -2
  604. package/dist/adapters/biome/presetConfig.d.ts +0 -21
  605. package/dist/adapters/biome/presetConfig.d.ts.map +0 -1
  606. package/dist/adapters/biome/presetConfig.js +0 -32
  607. package/dist/adapters/biome/presetConfig.js.map +0 -1
  608. package/dist/adapters/changeKeyFindings.d.ts +0 -4
  609. package/dist/adapters/changeKeyFindings.d.ts.map +0 -1
  610. package/dist/adapters/changeKeyFindings.js.map +0 -1
  611. package/dist/adapters/contextCaptureFindings.d.ts +0 -4
  612. package/dist/adapters/contextCaptureFindings.d.ts.map +0 -1
  613. package/dist/adapters/contextCaptureFindings.js +0 -51
  614. package/dist/adapters/contextCaptureFindings.js.map +0 -1
  615. package/dist/adapters/nativeTransactionFindings.d.ts +0 -4
  616. package/dist/adapters/nativeTransactionFindings.d.ts.map +0 -1
  617. package/dist/adapters/nativeTransactionFindings.js +0 -98
  618. package/dist/adapters/nativeTransactionFindings.js.map +0 -1
  619. package/dist/adapters/rpcBoundaryFindings.d.ts +0 -4
  620. package/dist/adapters/rpcBoundaryFindings.d.ts.map +0 -1
  621. package/dist/adapters/rpcBoundaryFindings.js +0 -90
  622. package/dist/adapters/rpcBoundaryFindings.js.map +0 -1
  623. package/dist/adapters/serviceModelFindings.d.ts +0 -4
  624. package/dist/adapters/serviceModelFindings.d.ts.map +0 -1
  625. package/dist/adapters/serviceModelFindings.js.map +0 -1
  626. package/dist/adapters/sharedErrorFindings.d.ts +0 -4
  627. package/dist/adapters/sharedErrorFindings.d.ts.map +0 -1
  628. package/dist/adapters/sharedErrorFindings.js +0 -71
  629. package/dist/adapters/sharedErrorFindings.js.map +0 -1
  630. package/dist/adapters/transactionChanges.d.ts +0 -3
  631. package/dist/adapters/transactionChanges.d.ts.map +0 -1
  632. package/dist/adapters/transactionChanges.js +0 -81
  633. package/dist/adapters/transactionChanges.js.map +0 -1
  634. package/dist/adapters/vitePort.d.ts +0 -2
  635. package/dist/adapters/vitePort.d.ts.map +0 -1
  636. package/dist/adapters/vitePort.js +0 -5
  637. package/dist/adapters/vitePort.js.map +0 -1
  638. package/dist/appTestConfig.d.ts +0 -4
  639. package/dist/appTestConfig.d.ts.map +0 -1
  640. package/dist/appTestConfig.js +0 -9
  641. package/dist/appTestConfig.js.map +0 -1
  642. package/dist/appViteConfig.d.ts +0 -23
  643. package/dist/appViteConfig.d.ts.map +0 -1
  644. package/dist/appViteConfig.js +0 -17
  645. package/dist/appViteConfig.js.map +0 -1
  646. package/dist/biome/recommendedRules.d.ts +0 -3
  647. package/dist/biome/recommendedRules.d.ts.map +0 -1
  648. package/dist/biome/recommendedRules.js +0 -20
  649. package/dist/biome/recommendedRules.js.map +0 -1
  650. package/dist/rules/effect/program.d.ts +0 -8
  651. package/dist/rules/effect/program.d.ts.map +0 -1
  652. package/dist/rules/effect/program.js +0 -53
  653. package/dist/rules/effect/program.js.map +0 -1
  654. package/dist/rules/effect/sqlTransact.d.ts +0 -2
  655. package/dist/rules/effect/sqlTransact.d.ts.map +0 -1
  656. package/dist/rules/effect/sqlTransact.js +0 -9
  657. package/dist/rules/effect/sqlTransact.js.map +0 -1
  658. package/dist/rules/suppressions/biomeRecommended.d.ts +0 -7
  659. package/dist/rules/suppressions/biomeRecommended.d.ts.map +0 -1
  660. package/dist/rules/suppressions/biomeRecommended.js +0 -47
  661. package/dist/rules/suppressions/biomeRecommended.js.map +0 -1
  662. package/src/adapters/biome/presetConfig.ts +0 -34
  663. package/src/adapters/contextCaptureFindings.ts +0 -60
  664. package/src/adapters/nativeTransactionFindings.ts +0 -108
  665. package/src/adapters/rpcBoundaryFindings.ts +0 -98
  666. package/src/adapters/sharedErrorFindings.ts +0 -84
  667. package/src/adapters/transactionChanges.ts +0 -85
  668. package/src/adapters/vitePort.ts +0 -5
  669. package/src/appTestConfig.ts +0 -10
  670. package/src/appViteConfig.ts +0 -24
  671. package/src/biome/recommendedRules.ts +0 -27
  672. package/src/rules/effect/program.ts +0 -57
  673. package/src/rules/effect/sqlTransact.ts +0 -10
  674. package/src/rules/suppressions/biomeRecommended.ts +0 -60
@@ -0,0 +1,111 @@
1
+ import * as NodePath from "@effect/platform-node/NodePath";
2
+ import { Console, Effect, FileSystem, Path } from "effect";
3
+ import type { ChildProcessSpawner } from "effect/process";
4
+ import { SetupFailure } from "#failure.ts";
5
+ import { gitOrFail } from "#git/command.ts";
6
+ import { shellWords } from "#hooks/command.ts";
7
+ import { orWhenAbsent } from "#inventory/filesystem.ts";
8
+
9
+ type WorkingCopy =
10
+ | { readonly kind: "absent"; readonly path: string }
11
+ | { readonly blob: string; readonly bytes: Uint8Array; readonly kind: "file"; readonly mode: number; readonly path: string }
12
+ | { readonly kind: "link"; readonly path: string; readonly target: string };
13
+
14
+ function failed(error: { readonly message: string }): SetupFailure {
15
+ return new SetupFailure({ cause: error, message: error.message });
16
+ }
17
+
18
+ function recovery(copy: WorkingCopy): string {
19
+ const path = shellWords([copy.path]);
20
+ switch (copy.kind) {
21
+ case "absent":
22
+ return `rm -f ${path}`;
23
+ case "file":
24
+ return `git cat-file blob ${copy.blob} > ${path} && chmod ${copy.mode.toString(8)} ${path}`;
25
+ case "link":
26
+ return `ln -sfn ${shellWords([copy.target])} ${path}`;
27
+ }
28
+ }
29
+
30
+ function notice(root: string, copies: readonly WorkingCopy[]): string {
31
+ const [only] = copies;
32
+ const intro =
33
+ copies.length === 1 && only !== undefined
34
+ ? `${only.path} changed after staging; Biome checks its staged content in place, then the working copy is put back. If the hook stops first, run this in ${root}:`
35
+ : `${copies.length} files changed after staging; Biome checks their staged content in place, then the working copies are put back. If the hook stops first, run these in ${root}:`;
36
+ return [`quality: ${intro}`, ...copies.map((copy) => ` ${recovery(copy)}`)].join("\n");
37
+ }
38
+
39
+ // The blob outlives a killed hook, so the printed command still recovers the working copy.
40
+ const setAside = Effect.fn("Hooks.setAside")(function* (
41
+ root: string,
42
+ path: string,
43
+ ): Effect.fn.Return<WorkingCopy, SetupFailure, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner> {
44
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
45
+
46
+ const fs = yield* FileSystem.FileSystem;
47
+ const at = join(root, path);
48
+ const info = yield* orWhenAbsent(at, fs.lstat(at), undefined).pipe(Effect.mapError(failed));
49
+ if (info === undefined) {
50
+ return { kind: "absent", path };
51
+ }
52
+ if (info.type === "SymbolicLink") {
53
+ return { kind: "link", path, target: yield* fs.readLink(at).pipe(Effect.mapError(failed)) };
54
+ }
55
+ if (info.type !== "File") {
56
+ return yield* new SetupFailure({ message: `${path} changed after staging into a ${info.type}, so the staged check cannot set it aside.` });
57
+ }
58
+ const bytes = yield* fs.readFile(at).pipe(Effect.mapError(failed));
59
+ const blob = (yield* gitOrFail(root, ["hash-object", "-w", "--no-filters", "--", path])).trim();
60
+ return { blob, bytes, kind: "file", mode: info.mode & 0o7777, path };
61
+ });
62
+
63
+ const setAsideAll = Effect.fn("Hooks.setAsideAll")(function* (root: string, paths: readonly string[]) {
64
+ const copies = yield* Effect.forEach(paths, (path) => setAside(root, path));
65
+ yield* Console.log(notice(root, copies));
66
+ return copies;
67
+ });
68
+
69
+ const putBack = Effect.fn("Hooks.putBack")(function* (root: string, copy: WorkingCopy) {
70
+ const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
71
+
72
+ const fs = yield* FileSystem.FileSystem;
73
+ const at = join(root, copy.path);
74
+ yield* fs.remove(at, { force: true });
75
+ if (copy.kind === "file") {
76
+ yield* fs.writeFile(at, copy.bytes);
77
+ yield* fs.chmod(at, copy.mode);
78
+ }
79
+ if (copy.kind === "link") {
80
+ yield* fs.symlink(copy.target, at);
81
+ }
82
+ });
83
+
84
+ const restore = Effect.fn("Hooks.restore")(function* (root: string, copies: readonly WorkingCopy[]) {
85
+ const [, failures] = yield* Effect.partition(copies, (copy) => Effect.mapError(putBack(root, copy), (error) => ({ copy, error })));
86
+ if (failures.length === 0) {
87
+ return;
88
+ }
89
+ const lines = failures.map(({ copy, error }) => `quality: cannot put back the working copy of ${copy.path}: ${error.message}\n ${recovery(copy)}`);
90
+ yield* Console.error(lines.join("\n"));
91
+ return yield* new SetupFailure({
92
+ message: `${failures.length === 1 ? "a working copy was" : `${failures.length} working copies were`} not put back; run the commands above in ${root}.`,
93
+ });
94
+ });
95
+
96
+ // Biome reports no diagnostics for content piped to its stdin, so a file edited again after staging shows Biome its staged content
97
+ // on disk until the check ends.
98
+ export const withStagedContent = Effect.fn("Hooks.withStagedContent")(function* <TValue, TError, TRequirements>(
99
+ root: string,
100
+ edited: readonly string[],
101
+ check: Effect.Effect<TValue, TError, TRequirements>,
102
+ ) {
103
+ if (edited.length === 0) {
104
+ return yield* check;
105
+ }
106
+ return yield* Effect.acquireUseRelease(
107
+ setAsideAll(root, edited),
108
+ () => Effect.andThen(gitOrFail(root, ["--literal-pathspecs", "checkout-index", "--force", "--", ...edited]), check),
109
+ (copies) => restore(root, copies),
110
+ );
111
+ });
@@ -1,6 +1,7 @@
1
1
  import { dirname, join } from "node:path";
2
- import { Effect, type FileSystem } from "effect";
2
+ import { type Context, Effect, type FileSystem } from "effect";
3
3
  import ts from "typescript";
4
+ import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
4
5
  import { type FilesystemFailure, readRequiredText } from "#inventory/filesystem.ts";
5
6
 
6
7
  const portable = new Set([
@@ -67,8 +68,7 @@ const portable = new Set([
67
68
  "structuredClone",
68
69
  ]);
69
70
 
70
- function namesInDom(path: string, text: string): readonly string[] {
71
- const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
71
+ function namesInDom(source: ts.SourceFile): readonly string[] {
72
72
  return source.statements.flatMap((statement) => {
73
73
  if (ts.isVariableStatement(statement)) {
74
74
  return statement.declarationList.declarations.flatMap(({ name }) => (ts.isIdentifier(name) ? [name.text] : []));
@@ -80,9 +80,11 @@ function namesInDom(path: string, text: string): readonly string[] {
80
80
  export const browserNames = Effect.fn("Imports.browserNames")(function* (): Effect.fn.Return<
81
81
  ReadonlySet<string>,
82
82
  FilesystemFailure,
83
- FileSystem.FileSystem
83
+ Context.Service.Identifier<typeof DeclarationFiles> | FileSystem.FileSystem
84
84
  > {
85
85
  const path = join(dirname(ts.getDefaultLibFilePath({})), "lib.dom.d.ts");
86
86
  const text = yield* readRequiredText(path);
87
- return new Set(namesInDom(path, text).filter((name) => !portable.has(name)));
87
+ const declarations = yield* DeclarationFiles;
88
+ const source = yield* declarations.parse(path, text, { target: ts.ScriptTarget.Latest });
89
+ return new Set(namesInDom(source).filter((name) => !portable.has(name)));
88
90
  });
@@ -8,6 +8,6 @@ import type { RuleInputs } from "#rule.ts";
8
8
  export const checkFences = Effect.fn("Imports.checkFences")(function* (inputs: RuleInputs, configured: readonly Fence[]) {
9
9
  const graph = yield* importGraph(inputs);
10
10
  const fences = [...configured, ...(yield* discoverFences(inputs, graph.packages))];
11
- const policy = compilePolicy(fences, { files: inputs.files, packages: graph.packages });
11
+ const policy = yield* Effect.fromResult(compilePolicy(fences, { files: inputs.files, packages: graph.packages }));
12
12
  return policy.flatMap((compiled) => compiled.evaluate(graph));
13
13
  });
@@ -1,4 +1,6 @@
1
+ import { Result } from "effect";
1
2
  import type { Endpoint } from "#imports/Endpoint.ts";
3
+ import { BoundaryFailure } from "#imports/fences/BoundaryFailure.ts";
2
4
  import { type CompiledFence, compileFence, type FenceGraph } from "#imports/fences/evaluate.ts";
3
5
  import type { PolicyScope } from "#imports/fences/match.ts";
4
6
  import type { Chain, ExampleStep, Fence } from "#imports/fences/model.ts";
@@ -24,7 +26,7 @@ function graphOf(chain: Chain): FenceGraph | undefined {
24
26
  const edges = files.map(
25
27
  (from, index): ImportEdge => ({ from, kind: "import", line: 1, specifier: "", to: endpointOf(chain[index + 1] ?? from), type: false }),
26
28
  );
27
- return { edges, modules: files };
29
+ return { edges, ignoredEdges: [], modules: files };
28
30
  }
29
31
 
30
32
  function crossedBy(policy: readonly CompiledFence[], graph: FenceGraph): readonly string[] {
@@ -66,14 +68,14 @@ function declarationIssues(fences: readonly Fence[]): readonly string[] {
66
68
  ]);
67
69
  }
68
70
 
69
- export function compilePolicy(fences: readonly Fence[], scope: PolicyScope): readonly CompiledFence[] {
71
+ export function compilePolicy(fences: readonly Fence[], scope: PolicyScope): Result.Result<readonly CompiledFence[], BoundaryFailure> {
70
72
  const issues = [...declarationIssues(fences)];
71
73
  const policy = fences.map((fence) => compileFence({ issues, scope }, fence));
72
74
  if (issues.length === 0) {
73
75
  issues.push(...fences.flatMap((fence) => exampleIssues(policy, fence, scope)));
74
76
  }
75
77
  if (issues.length > 0) {
76
- throw new Error(`the fence policy is invalid:\n${issues.map((issue) => ` - ${issue}`).join("\n")}`);
78
+ return Result.fail(new BoundaryFailure({ message: `the fence policy is invalid:\n${issues.map((issue) => ` - ${issue}`).join("\n")}` }));
77
79
  }
78
- return policy;
80
+ return Result.succeed(policy);
79
81
  }
@@ -6,7 +6,7 @@ import type { ImportEdge, ImportGraph } from "#imports/graph.ts";
6
6
  import { isTestCode } from "#naming/testName.ts";
7
7
  import type { Finding } from "#rule.ts";
8
8
 
9
- export type FenceGraph = Pick<ImportGraph, "edges" | "modules">;
9
+ export type FenceGraph = Pick<ImportGraph, "edges" | "ignoredEdges" | "modules">;
10
10
 
11
11
  export type Evaluate = (graph: FenceGraph) => readonly Finding[];
12
12
 
@@ -49,7 +49,7 @@ function importFindings(fence: Fence, importer: (path: string) => boolean, to: M
49
49
 
50
50
  function reachFindings(fence: Fence, importer: (path: string) => boolean, to: Matcher): Evaluate {
51
51
  return (graph) => {
52
- const edgesFrom = outgoing(graph.edges);
52
+ const edgesFrom = outgoing([...graph.edges, ...graph.ignoredEdges]);
53
53
  return graph.modules.filter(importer).flatMap((module) =>
54
54
  reachedFrom(module, edgesFrom, to).map((reached) => ({
55
55
  file: module,
@@ -36,8 +36,8 @@ function charSource(char: string): string {
36
36
  return REGEX_SYNTAX.test(char) ? `\\${char}` : char;
37
37
  }
38
38
 
39
- function unreadable(pattern: string, problem: string): Error {
40
- return new Error(`cannot read the workspace pattern "${pattern}": ${problem}`);
39
+ function unreadable(pattern: string, problem: string): GlobFailure {
40
+ return new GlobFailure({ message: `cannot read the workspace pattern "${pattern}": ${problem}` });
41
41
  }
42
42
 
43
43
  function closingBrace(text: string, open: number): number {
@@ -65,72 +65,79 @@ function choices(body: string): readonly string[] {
65
65
  return parts;
66
66
  }
67
67
 
68
- function expanded(pattern: string, whole: string): readonly string[] {
68
+ function expanded(pattern: string, whole: string): Result.Result<readonly string[], GlobFailure> {
69
69
  const open = pattern.indexOf("{");
70
70
  if (open === -1) {
71
- return [pattern];
71
+ return Result.succeed([pattern]);
72
72
  }
73
73
  const close = closingBrace(pattern, open);
74
74
  if (close === -1) {
75
- throw unreadable(whole, "a { never closes");
75
+ return Result.fail(unreadable(whole, "a { never closes"));
76
76
  }
77
77
  const body = pattern.slice(open + 1, close);
78
78
  if (BRACE_RANGE.test(body)) {
79
- throw unreadable(whole, "brace ranges are not supported");
79
+ return Result.fail(unreadable(whole, "brace ranges are not supported"));
80
80
  }
81
81
  const options = choices(body);
82
82
  if (options.length < 2) {
83
- throw unreadable(whole, "a { } needs two or more choices");
83
+ return Result.fail(unreadable(whole, "a { } needs two or more choices"));
84
84
  }
85
- return options.flatMap((option) => expanded(`${pattern.slice(0, open)}${option}${pattern.slice(close + 1)}`, whole));
85
+ return Result.map(Result.all(options.map((option) => expanded(`${pattern.slice(0, open)}${option}${pattern.slice(close + 1)}`, whole))), (found) =>
86
+ found.flat(),
87
+ );
86
88
  }
87
89
 
88
- function characterClass(segment: string, start: number, whole: string): { readonly end: number; readonly source: string } {
90
+ function characterClass(
91
+ segment: string,
92
+ start: number,
93
+ whole: string,
94
+ ): Result.Result<{ readonly end: number; readonly source: string }, GlobFailure> {
89
95
  const negated = segment[start + 1] === "!" || segment[start + 1] === "^";
90
96
  const first = start + (negated ? 2 : 1);
91
97
  const end = segment.indexOf("]", segment[first] === "]" ? first + 1 : first);
92
98
  if (end === -1) {
93
- throw unreadable(whole, "a [ never closes");
99
+ return Result.fail(unreadable(whole, "a [ never closes"));
94
100
  }
95
101
  const body = segment.slice(first, end);
96
102
  if (body.includes("[:")) {
97
- throw unreadable(whole, "character class names are not supported");
103
+ return Result.fail(unreadable(whole, "character class names are not supported"));
98
104
  }
99
- return { end, source: `[${negated ? "^" : ""}${body.replace(CLASS_SYNTAX, "\\$&")}]` };
105
+ return Result.succeed({ end, source: `[${negated ? "^" : ""}${body.replace(CLASS_SYNTAX, "\\$&")}]` });
100
106
  }
101
107
 
102
- function segmentOf(segment: string, whole: string): Segment {
108
+ function segmentOf(segment: string, whole: string): Result.Result<Segment, GlobFailure> {
103
109
  if (segment === GLOBSTAR) {
104
- return GLOBSTAR;
110
+ return Result.succeed(GLOBSTAR);
105
111
  }
106
112
  if (EXTGLOB.test(segment)) {
107
- throw unreadable(whole, "extended globs are not supported");
113
+ return Result.fail(unreadable(whole, "extended globs are not supported"));
108
114
  }
109
- let source = "";
110
- for (let index = 0; index < segment.length; index += 1) {
111
- const char = segment[index] ?? "";
112
- if (char === "[") {
113
- const found = characterClass(segment, index, whole);
114
- source += found.source;
115
- index = found.end;
116
- } else {
117
- source += charSource(char);
115
+ return Result.gen(function* () {
116
+ let source = "";
117
+ for (let index = 0; index < segment.length; index += 1) {
118
+ const char = segment[index] ?? "";
119
+ if (char === "[") {
120
+ const found = yield* characterClass(segment, index, whole);
121
+ source += found.source;
122
+ index = found.end;
123
+ } else {
124
+ source += charSource(char);
125
+ }
118
126
  }
119
- }
120
- return new RegExp(`^${segment.startsWith(DOT) ? "" : NO_DOT}${source}$`, "u");
121
- }
122
-
123
- function matcherOf(pattern: string): (path: string) => boolean {
124
- const alternatives = expanded(pattern, pattern).map((alternative) => alternative.split("/").map((segment) => segmentOf(segment, pattern)));
125
- return (path) => alternatives.some((segments) => segmentsMatch(segments, path.split("/")));
127
+ return yield* Result.try({
128
+ catch: (cause) => new GlobFailure({ message: cause instanceof Error ? cause.message : String(cause) }),
129
+ try: (): Segment => new RegExp(`^${segment.startsWith(DOT) ? "" : NO_DOT}${source}$`, "u"),
130
+ });
131
+ });
126
132
  }
127
133
 
128
134
  export function globMatcher(pattern: string): Result.Result<(path: string) => boolean, GlobFailure> {
129
135
  if (pattern.includes("\\")) {
130
- return Result.fail(new GlobFailure({ message: unreadable(pattern, "escapes are not supported").message }));
136
+ return Result.fail(unreadable(pattern, "escapes are not supported"));
131
137
  }
132
- return Result.try({
133
- catch: (cause) => new GlobFailure({ message: cause instanceof Error ? cause.message : String(cause) }),
134
- try: () => matcherOf(pattern),
138
+ return Result.gen(function* () {
139
+ const options = yield* expanded(pattern, pattern);
140
+ const alternatives = yield* Result.all(options.map((option) => Result.all(option.split("/").map((segment) => segmentOf(segment, pattern)))));
141
+ return (path: string) => alternatives.some((segments) => segmentsMatch(segments, path.split("/")));
135
142
  });
136
143
  }
@@ -1,8 +1,14 @@
1
+ import { relative } from "node:path";
1
2
  import { Effect } from "effect";
3
+ import type { ChildProcessSpawner } from "effect/process";
4
+ import type { ImportAnalysisFailure } from "#adapters/ImportAnalysisFailure.ts";
2
5
  import { ImportCompiler } from "#adapters/import-compiler/service.ts";
3
6
  import type { Endpoint } from "#imports/Endpoint.ts";
4
7
  import type { ImportKind } from "#imports/extract.ts";
5
8
  import { type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
9
+ import { posix } from "#inventory/ignoreScope.ts";
10
+ import { linesOf } from "#inventory/linesOf.ts";
11
+ import { ignoredAmong } from "#inventory/trackedPaths.ts";
6
12
  import type { Findings, RuleInputs, SourceFile } from "#rule.ts";
7
13
 
8
14
  export interface ImportEdge {
@@ -19,14 +25,48 @@ export type UnresolvedImport = Omit<ImportEdge, "to"> & { readonly missing: stri
19
25
  export interface ImportGraph {
20
26
  readonly configFindings: Findings;
21
27
  readonly edges: readonly ImportEdge[];
28
+ // Imports of the modules git ignores that the sources reach, such as generated output: rules follow them but never report them.
29
+ readonly ignoredEdges: readonly ImportEdge[];
30
+ readonly ignoredModules: readonly string[];
22
31
  readonly modules: readonly string[];
23
32
  readonly packages: readonly WorkspacePackage[];
24
33
  readonly unresolved: readonly UnresolvedImport[];
25
34
  }
26
35
 
36
+ const MODULE = /\.[cm]?[jt]sx?$/u;
37
+
38
+ const NODE_MODULES = /(?:^|\/)node_modules\//u;
39
+
40
+ function unlisted(listed: ReadonlySet<string>, edges: readonly ImportEdge[]): readonly string[] {
41
+ const paths = edges.flatMap((edge) => (edge.to.kind === "file" ? [edge.to.path] : []));
42
+ return [...new Set(paths)].filter((path) => !listed.has(path) && MODULE.test(path) && !NODE_MODULES.test(path) && !path.startsWith("../"));
43
+ }
44
+
45
+ const ignoredReach = Effect.fn("Imports.ignoredReach")(function* (
46
+ inputs: RuleInputs,
47
+ edges: readonly ImportEdge[],
48
+ follow: (files: readonly SourceFile[]) => Effect.Effect<readonly ImportEdge[], ImportAnalysisFailure>,
49
+ ) {
50
+ const listed = new Set(inputs.files);
51
+ const modules: string[] = [];
52
+ const followed: ImportEdge[] = [];
53
+ for (let frontier = unlisted(listed, edges); frontier.length > 0; frontier = unlisted(listed, followed)) {
54
+ const ignored = (yield* ignoredAmong(inputs.root, frontier)).map((path) => posix(relative(inputs.root, path)));
55
+ for (const path of frontier) {
56
+ listed.add(path);
57
+ }
58
+ const files = yield* Effect.forEach(ignored, (path) =>
59
+ Effect.map(inputs.readText(path), (text) => (text === undefined ? [] : [{ lines: linesOf(text), path, text }])),
60
+ );
61
+ modules.push(...ignored);
62
+ followed.push(...(yield* follow(files.flat())));
63
+ }
64
+ return { ignoredEdges: followed, ignoredModules: modules };
65
+ });
66
+
27
67
  const build = Effect.fn("Imports.build")(function* (inputs: RuleInputs) {
28
68
  const compiler = yield* ImportCompiler;
29
- const walked = yield* compiler.graph(inputs);
69
+ const { follow, ...walked } = yield* compiler.graph(inputs);
30
70
  if (walked.modules.length === 0) {
31
71
  return yield* Effect.die(
32
72
  new Error(
@@ -34,11 +74,11 @@ const build = Effect.fn("Imports.build")(function* (inputs: RuleInputs) {
34
74
  ),
35
75
  );
36
76
  }
37
- return { ...walked, packages: yield* workspacePackages(inputs) };
77
+ return { ...walked, ...(yield* ignoredReach(inputs, walked.edges, follow)), packages: yield* workspacePackages(inputs) };
38
78
  });
39
79
 
40
80
  type Graph = ReturnType<typeof build>;
41
- const graphs = new WeakMap<readonly SourceFile[], Effect.Effect<ImportGraph, Effect.Error<Graph>>>();
81
+ const graphs = new WeakMap<readonly SourceFile[], Effect.Effect<ImportGraph, Effect.Error<Graph>, ChildProcessSpawner.ChildProcessSpawner>>();
42
82
 
43
83
  // Import rules run on one scan, so they share the graph built from its sources.
44
84
  export const importGraph = Effect.fn("Imports.importGraph")(function* (inputs: RuleInputs) {
@@ -50,3 +90,7 @@ export const importGraph = Effect.fn("Imports.importGraph")(function* (inputs: R
50
90
  graphs.set(inputs.sources, graph);
51
91
  return yield* graph;
52
92
  });
93
+
94
+ export const ignoredModules = Effect.fn("Imports.ignoredModules")(function* (inputs: RuleInputs) {
95
+ return inputs.sources.some((file) => MODULE.test(file.path)) ? (yield* importGraph(inputs)).ignoredModules : [];
96
+ });
@@ -1,4 +1,9 @@
1
- import { Schema } from "effect";
1
+ import { Data, Result, Schema } from "effect";
2
+
3
+ export class PnpmWorkspaceFailure extends Data.TaggedError("PnpmWorkspaceFailure")<{
4
+ readonly cause?: unknown;
5
+ readonly message: string;
6
+ }> {}
2
7
 
3
8
  function keyPattern(key: string): RegExp {
4
9
  return new RegExp(`^(?:${key}|"${key}"|'${key}')\\s*:`, "u");
@@ -10,8 +15,8 @@ const SPACE = /\s/u;
10
15
 
11
16
  const LINE_BREAK = /\r?\n/u;
12
17
 
13
- function failure(problem: string, cause?: unknown): Error {
14
- return new Error(`pnpm-workspace.yaml: ${problem}`, { cause });
18
+ function failure(problem: string, cause?: unknown): PnpmWorkspaceFailure {
19
+ return new PnpmWorkspaceFailure({ cause, message: `pnpm-workspace.yaml: ${problem}` });
15
20
  }
16
21
 
17
22
  function withoutComment(line: string): string {
@@ -29,22 +34,20 @@ function withoutComment(line: string): string {
29
34
  return line.trimEnd();
30
35
  }
31
36
 
32
- function scalar(raw: string, key: string): string {
37
+ function scalar(raw: string, key: string): Result.Result<string, PnpmWorkspaceFailure> {
33
38
  const value = raw.trim();
34
39
  if (value.startsWith('"') && value.endsWith('"') && value.length > 1) {
35
- try {
36
- return Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String))(value);
37
- } catch (error) {
38
- throw failure(`cannot read "${value}" in ${key}`, error);
39
- }
40
+ return Result.mapError(Schema.decodeUnknownResult(Schema.fromJsonString(Schema.String))(value), (error) =>
41
+ failure(`cannot read "${value}" in ${key}`, error),
42
+ );
40
43
  }
41
44
  if (value.startsWith("'") && value.endsWith("'") && value.length > 1) {
42
- return value.slice(1, -1).replaceAll("''", "'");
45
+ return Result.succeed(value.slice(1, -1).replaceAll("''", "'"));
43
46
  }
44
47
  if (value === "" || value.includes(": ") || value.endsWith(":") || ["[", "{", "'", '"'].some((opening) => value.startsWith(opening))) {
45
- throw failure(`cannot read "${value}" in ${key}`);
48
+ return Result.fail(failure(`cannot read "${value}" in ${key}`));
46
49
  }
47
- return value;
50
+ return Result.succeed(value);
48
51
  }
49
52
 
50
53
  const FLOW_INDICATOR = /[{}[\]]/u;
@@ -55,20 +58,20 @@ interface FlowScan {
55
58
  quote: string | undefined;
56
59
  }
57
60
 
58
- function flowScalar(raw: string, key: string): string {
61
+ function flowScalar(raw: string, key: string): Result.Result<string, PnpmWorkspaceFailure> {
59
62
  const value = raw.trim();
60
63
  const quoted = value.startsWith('"') || value.startsWith("'");
61
64
  if (!quoted && FLOW_INDICATOR.test(value)) {
62
- throw failure(`cannot read "${value}" in ${key}; quote a pattern that holds { } [ ] or ,`);
65
+ return Result.fail(failure(`cannot read "${value}" in ${key}; quote a pattern that holds { } [ ] or ,`));
63
66
  }
64
67
  return scalar(value, key);
65
68
  }
66
69
 
67
- function closed(scan: FlowScan, rest: string, key: string): readonly string[] {
70
+ function closed(scan: FlowScan, rest: string, key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
68
71
  if (rest.trim() !== "") {
69
- throw failure(`cannot read "${rest.trim()}" after the ${key} list`);
72
+ return Result.fail(failure(`cannot read "${rest.trim()}" after the ${key} list`));
70
73
  }
71
- return [...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map((entry) => flowScalar(entry, key));
74
+ return Result.all([...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map((entry) => flowScalar(entry, key)));
72
75
  }
73
76
 
74
77
  function scanned(scan: FlowScan, char: string): "close" | undefined {
@@ -87,7 +90,7 @@ function scanned(scan: FlowScan, char: string): "close" | undefined {
87
90
  return undefined;
88
91
  }
89
92
 
90
- function flowList(lines: readonly string[], key: string): readonly string[] {
93
+ function flowList(lines: readonly string[], key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
91
94
  const scan: FlowScan = { current: "", entries: [], quote: undefined };
92
95
  for (const [number, line] of lines.map(withoutComment).entries()) {
93
96
  for (let index = number === 0 ? 1 : 0; index < line.length; index += 1) {
@@ -97,34 +100,36 @@ function flowList(lines: readonly string[], key: string): readonly string[] {
97
100
  }
98
101
  scan.current += " ";
99
102
  }
100
- throw failure(`the ${key} list never closes`);
103
+ return Result.fail(failure(`the ${key} list never closes`));
101
104
  }
102
105
 
103
- function blockList(lines: readonly string[], key: string): readonly string[] {
104
- const patterns: string[] = [];
105
- for (const line of lines.map(withoutComment)) {
106
- const trimmed = line.trim();
107
- if (trimmed === "") {
108
- continue;
109
- }
110
- const item = trimmed === ITEM || trimmed.startsWith(`${ITEM} `);
111
- if (!(item || line.startsWith(" ") || line.startsWith("\t"))) {
112
- break;
113
- }
114
- if (!item) {
115
- throw failure(`cannot read "${trimmed}" in ${key}`);
106
+ function blockList(lines: readonly string[], key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
107
+ return Result.gen(function* () {
108
+ const patterns: string[] = [];
109
+ for (const line of lines.map(withoutComment)) {
110
+ const trimmed = line.trim();
111
+ if (trimmed === "") {
112
+ continue;
113
+ }
114
+ const item = trimmed === ITEM || trimmed.startsWith(`${ITEM} `);
115
+ if (!(item || line.startsWith(" ") || line.startsWith("\t"))) {
116
+ break;
117
+ }
118
+ if (!item) {
119
+ return yield* Result.fail(failure(`cannot read "${trimmed}" in ${key}`));
120
+ }
121
+ patterns.push(yield* scalar(trimmed.slice(ITEM.length), key));
116
122
  }
117
- patterns.push(scalar(trimmed.slice(ITEM.length), key));
118
- }
119
- return patterns;
123
+ return patterns;
124
+ });
120
125
  }
121
126
 
122
- export function pnpmWorkspaceList(text: string, key: string): readonly string[] {
127
+ export function pnpmWorkspaceList(text: string, key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
123
128
  const pattern = keyPattern(key);
124
129
  const lines = text.split(LINE_BREAK);
125
130
  const start = lines.findIndex((line) => pattern.test(line));
126
131
  if (start === -1) {
127
- return [];
132
+ return Result.succeed([]);
128
133
  }
129
134
  const rest = withoutComment(lines[start] ?? "")
130
135
  .replace(pattern, "")
@@ -133,11 +138,11 @@ export function pnpmWorkspaceList(text: string, key: string): readonly string[]
133
138
  return flowList([rest, ...lines.slice(start + 1)], key);
134
139
  }
135
140
  if (rest !== "") {
136
- throw failure(`cannot read "${rest}" in ${key}`);
141
+ return Result.fail(failure(`cannot read "${rest}" in ${key}`));
137
142
  }
138
143
  return blockList(lines.slice(start + 1), key);
139
144
  }
140
145
 
141
- export function pnpmWorkspacePatterns(text: string): readonly string[] {
146
+ export function pnpmWorkspacePatterns(text: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
142
147
  return pnpmWorkspaceList(text, "packages");
143
148
  }
@@ -16,7 +16,7 @@ const TRAILING_SLASHES = /\/+$/u;
16
16
 
17
17
  const NODE_MODULES = "node_modules";
18
18
 
19
- const PLACEHOLDERS = new Set([".gitkeep", ".keep"]);
19
+ const PLACEHOLDERS = new Set([".gitkeep", ".keep", "README.md"]);
20
20
 
21
21
  const withIgnoreFileIn = Effect.fn("Imports.withIgnoreFileIn")(function* (reader: Reader, scope: IgnoreScope, directory: string) {
22
22
  const contents = yield* reader.readText(posix.join(directory, IGNORE_FILE));
@@ -46,7 +46,7 @@ function matchers(patterns: readonly string[]) {
46
46
  const memberOf = Effect.fn("Imports.memberOf")(function* (inputs: Reader) {
47
47
  const pnpm = yield* inputs.readText(PNPM_WORKSPACE);
48
48
  const patterns = [
49
- ...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)),
49
+ ...(pnpm === undefined ? [] : yield* Effect.fromResult(pnpmWorkspacePatterns(pnpm))),
50
50
  ...npmPatterns(yield* readPackageManifest(inputs.readText, MANIFEST)),
51
51
  ];
52
52
  const included = yield* matchers(patterns.filter((pattern) => !pattern.startsWith(NEGATION)).map(normalized));
@@ -3,10 +3,10 @@ import { Effect, Path } from "effect";
3
3
  import { SetupFailure } from "#failure.ts";
4
4
  import { run } from "#git/command.ts";
5
5
 
6
- const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[], path = ".") {
6
+ const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[], paths: readonly string[] = ["."]) {
7
7
  const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
8
8
 
9
- const result = yield* run(directory, ["ls-files", "-z", ...options, "--", path]);
9
+ const result = yield* run(directory, ["ls-files", "-z", ...options, "--", ...paths]);
10
10
  if (result.code !== 0) {
11
11
  if (result.stderr.includes("not a git repository")) {
12
12
  return undefined;
@@ -20,7 +20,7 @@ const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: str
20
20
  });
21
21
 
22
22
  export const trackedPaths = Effect.fn("Inventory.trackedPaths")(function* (directory: string, path = ".") {
23
- return (yield* listedPaths(directory, [], path)) ?? [];
23
+ return (yield* listedPaths(directory, [], [path])) ?? [];
24
24
  });
25
25
 
26
26
  export const ignoredTrackedPaths = Effect.fn("Inventory.ignoredTrackedPaths")(function* (directory: string) {
@@ -33,3 +33,10 @@ export const ignoredPaths = Effect.fn("Inventory.ignoredPaths")(function* (direc
33
33
  const paths = yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard", "--directory"]);
34
34
  return paths?.map((path) => resolve(path));
35
35
  });
36
+
37
+ export const ignoredAmong = Effect.fn("Inventory.ignoredAmong")(function* (directory: string, paths: readonly string[]) {
38
+ if (paths.length === 0) {
39
+ return [];
40
+ }
41
+ return (yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard"], paths)) ?? [];
42
+ });
@@ -0,0 +1,11 @@
1
+ import type { PackageManifest } from "#PackageManifest.ts";
2
+
3
+ const MANIFEST_EXPORT = "./package.json";
4
+
5
+ // A package that exports only its manifest and holds no sources ships no code: the dependencies it installs are what it delivers.
6
+ export function deliveredDependencies(manifest: PackageManifest, sources: readonly string[]): readonly string[] {
7
+ const exported = typeof manifest.exports === "object" && manifest.exports !== null ? Object.keys(manifest.exports) : [];
8
+ const shell =
9
+ sources.length === 0 && manifest.bin === undefined && manifest.main === undefined && exported.length === 1 && exported[0] === MANIFEST_EXPORT;
10
+ return shell ? Object.keys(manifest.dependencies ?? {}) : [];
11
+ }