@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,29 @@
1
+ import type { Outcome } from "#engine/evaluate.ts";
2
+ import { groupBy } from "#engine/violation.ts";
3
+ import { plural } from "#report/plural.ts";
4
+ import { failures, type ReportContext } from "#report/render.ts";
5
+
6
+ const FILES_SHOWN = 3;
7
+
8
+ function firstFiles(files: readonly string[]): string {
9
+ const distinct = [...new Set(files)];
10
+ const shown = distinct.slice(0, FILES_SHOWN).join(", ");
11
+ return distinct.length > FILES_SHOWN ? `${shown} and ${plural(distinct.length - FILES_SHOWN, "more file")}` : shown;
12
+ }
13
+
14
+ function staleLine(file: string, entries: readonly { readonly entry: { readonly file: string } }[]): readonly string[] {
15
+ return entries.length === 0
16
+ ? []
17
+ : [` error ${file} (${plural(entries.length, "stale entry", "stale entries")}): ${firstFiles(entries.map(({ entry }) => entry.file))}`];
18
+ }
19
+
20
+ export function recap(outcome: Outcome, context: ReportContext): string {
21
+ return [
22
+ `quality lint failed with ${failures(outcome)}:`,
23
+ ...[...groupBy(outcome.errors, (violation) => violation.rule).entries()].map(
24
+ ([rule, inRule]) => ` error ${rule} (${inRule.length}): ${firstFiles(inRule.map((violation) => violation.file))}`,
25
+ ),
26
+ ...staleLine(context.baseline, outcome.staleBaseline),
27
+ ...staleLine(context.registry, outcome.staleRegistry),
28
+ ].join("\n");
29
+ }
@@ -16,7 +16,8 @@ function locate(violation: Violation): string {
16
16
  }
17
17
 
18
18
  function regressionNote(regression: Regression): string {
19
- return ` ${regression.entry.file} is over its baseline: ${regression.count} against ${regression.entry.count} baselined.`;
19
+ const share = regression.allowed === undefined ? `${regression.entry.count} baselined` : `${regression.allowed} baselined for its fast half`;
20
+ return ` ${regression.entry.file} is over its baseline: ${regression.count} against ${share}.`;
20
21
  }
21
22
 
22
23
  function heading(rule: string, violations: readonly Violation[], context: ReportContext): readonly string[] {
@@ -41,7 +42,7 @@ function ruleSections(violations: readonly Violation[], context: ReportContext,
41
42
  );
42
43
  }
43
44
 
44
- function failures(outcome: Outcome): string {
45
+ export function failures(outcome: Outcome): string {
45
46
  const stale = outcome.staleBaseline.length + outcome.staleRegistry.length;
46
47
  return [
47
48
  ...(outcome.errors.length > 0 ? [plural(outcome.errors.length, "error")] : []),
@@ -64,12 +65,20 @@ function movedDebt(outcome: Outcome): readonly string[] {
64
65
  return passes(outcome) ? [] : ["For moved files, carry their existing debt with `quality baseline prune --against <base>`."];
65
66
  }
66
67
 
68
+ function regressionsOf(outcome: Outcome): ReadonlyMap<string, Regression> {
69
+ return new Map(outcome.regressions.map((regression) => [keyOf(regression.entry.rule, regression.entry.file), regression]));
70
+ }
71
+
67
72
  export function render(outcome: Outcome, context: ReportContext): string {
68
- const regressions = new Map(outcome.regressions.map((regression) => [keyOf(regression.entry.rule, regression.entry.file), regression]));
69
73
  return [
70
- ...ruleSections(outcome.errors, context, regressions),
74
+ ...ruleSections(outcome.errors, context, regressionsOf(outcome)),
71
75
  ...staleSections(outcome, context),
72
76
  summary(outcome, context),
73
77
  ...movedDebt(outcome),
74
78
  ].join("\n\n");
75
79
  }
80
+
81
+ // A check of some files cannot judge baseline entries or moved debt, so it reports only the findings it made.
82
+ export function renderFindings(outcome: Outcome, context: ReportContext): string {
83
+ return [...ruleSections(outcome.errors, context, regressionsOf(outcome)), summary(outcome, context)].join("\n\n");
84
+ }
@@ -0,0 +1,14 @@
1
+ import type { RunSet } from "#engine/session.ts";
2
+ import { plural } from "#report/plural.ts";
3
+
4
+ export function runSetLine(set: RunSet, deep: readonly string[], configPath: string | undefined): readonly string[] {
5
+ if (deep.length === 0) {
6
+ return [];
7
+ }
8
+ const rules = `${plural(deep.length, "deep check")} (${deep.toSorted((left, right) => left.localeCompare(right)).join(", ")})`;
9
+ if (set === "full") {
10
+ return [`quality: full run ran ${rules}.`];
11
+ }
12
+ const selection = configPath === undefined ? "" : ` --config ${configPath}`;
13
+ return [`quality: fast run skipped ${rules}; CI runs ${deep.length === 1 ? "it" : "them"}. Run \`quality lint --full${selection}\` to check now.`];
14
+ }
@@ -1,5 +1,6 @@
1
1
  import type { StaleBaselineEntry } from "#baseline/compare.ts";
2
2
  import type { Outcome } from "#engine/evaluate.ts";
3
+ import { groupBy } from "#engine/violation.ts";
3
4
  import type { StaleRegistryEntry } from "#exceptions/registry.ts";
4
5
  import { plural } from "#report/plural.ts";
5
6
 
@@ -14,6 +15,18 @@ function section(label: string, file: string, guidance: string, lines: readonly
14
15
  : [[`${label} ${file}: ${plural(lines.length, "stale entry", "stale entries")}`, ` ${guidance}`, ...lines].join("\n")];
15
16
  }
16
17
 
18
+ function unsplitSection(file: string, unsplit: readonly StaleBaselineEntry[]): readonly string[] {
19
+ if (unsplit.length === 0) {
20
+ return [];
21
+ }
22
+ const rules = [...groupBy(unsplit, ({ entry }) => entry.rule)]
23
+ .map(([rule, entries]) => `${rule} ${entries.length}`)
24
+ .sort((left, right) => left.localeCompare(right));
25
+ return [
26
+ `note ${file}: ${plural(unsplit.length, "entry does", "entries do")} not record how many findings the deep half reports (${rules.join(", ")}). Run \`quality baseline prune\` once to record it, so a local lint locks in fixed debt of the fast half.`,
27
+ ];
28
+ }
29
+
17
30
  function baselineLine({ entry, problem }: StaleBaselineEntry): string {
18
31
  return ` ${entry.rule} ${entry.file} ${problem}.`;
19
32
  }
@@ -36,6 +49,7 @@ export function staleSections(outcome: Outcome, files: StaleFiles): readonly str
36
49
  "These pass, and `quality baseline tighten` lowers them when their files change. `quality baseline prune` lowers them all.",
37
50
  outcome.looseBaseline.map(baselineLine),
38
51
  ),
52
+ ...unsplitSection(files.baseline, outcome.unsplitBaseline),
39
53
  ...section(
40
54
  "error",
41
55
  files.registry,
package/src/rule.ts CHANGED
@@ -1,5 +1,7 @@
1
- import type { Effect, FileSystem } from "effect";
1
+ import type { Context, Effect, FileSystem } from "effect";
2
2
  import type { ChildProcessSpawner } from "effect/process";
3
+ import type ts from "typescript";
4
+ import type { DeclarationFiles } from "#adapters/declaration-files/service.ts";
3
5
  import { configureWith, noOptions, type RuleCheckResult, ruleConfiguration } from "#adapters/rule.ts";
4
6
  import type { StandardSchemaV1 } from "#adapters/standardSchema.ts";
5
7
  import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
@@ -23,6 +25,13 @@ export interface SourceFile {
23
25
  readonly text: string;
24
26
  }
25
27
 
28
+ export interface TypeScriptProgram {
29
+ readonly checker: ts.TypeChecker;
30
+ readonly program: ts.Program;
31
+ readonly sourceFile: (path: string) => ts.SourceFile | undefined;
32
+ readonly ts: typeof ts;
33
+ }
34
+
26
35
  export interface RuleInputs {
27
36
  readonly configFile?: string;
28
37
  readonly entries?: readonly string[];
@@ -32,24 +41,39 @@ export interface RuleInputs {
32
41
  readonly readText: (path: string) => Effect.Effect<string | undefined, FilesystemFailure>;
33
42
  readonly root: string;
34
43
  readonly sources: readonly SourceFile[];
44
+ readonly typeScript: Effect.Effect<TypeScriptProgram>;
35
45
  }
36
46
 
37
47
  export interface RuleContext<TOptions> extends RuleInputs {
38
48
  readonly options: TOptions;
39
49
  }
40
50
 
41
- export type RuleServices = FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner;
51
+ export type RuleServices = ChildProcessSpawner.ChildProcessSpawner | Context.Service.Identifier<typeof DeclarationFiles> | FileSystem.FileSystem;
42
52
 
43
- export type RuleCheck<TServices = RuleServices> = (inputs: RuleInputs) => Effect.Effect<Findings, unknown, TServices>;
53
+ export type RuleCheck<TServices = RuleServices> = (
54
+ inputs: Omit<RuleInputs, "typeScript"> & Partial<Pick<RuleInputs, "typeScript">>,
55
+ ) => Effect.Effect<Findings, unknown, TServices>;
56
+
57
+ export interface Halves<TServices = RuleServices> {
58
+ readonly deep: RuleCheck<TServices>;
59
+ readonly fast: RuleCheck<TServices>;
60
+ readonly name: string;
61
+ }
44
62
 
45
63
  export type Configured<TServices = RuleServices> =
46
64
  | { readonly _tag: "Invalid"; readonly issues: readonly string[] }
47
- | { readonly _tag: "Ready"; readonly check: RuleCheck<TServices> };
65
+ | { readonly _tag: "Ready"; readonly check: RuleCheck<TServices>; readonly halves?: Halves<TServices> };
66
+
67
+ export type Depth = "deep";
68
+
69
+ export type Need = "child-process" | "story-program";
48
70
 
49
71
  export interface RegisteredRule<TServices = RuleServices> {
72
+ readonly depth?: Depth;
50
73
  readonly description: string;
51
74
  readonly family?: boolean;
52
75
  readonly id: string;
76
+ readonly needs?: Need;
53
77
  readonly registrable?: boolean;
54
78
  readonly [ruleConfiguration]: (options: unknown) => Promise<Configured<TServices>>;
55
79
  }
@@ -59,10 +83,15 @@ export interface Rule<TId extends string = string, TInput = unknown, TServices =
59
83
  readonly id: TId;
60
84
  }
61
85
 
86
+ type DefinedCheck<TOptions, TServices> = (context: RuleContext<NoInfer<TOptions>>) => RuleCheckResult<TServices>;
87
+
62
88
  interface RuleDefinition<TId extends string, TOptions, TServices> {
63
- readonly check: (context: RuleContext<NoInfer<TOptions>>) => RuleCheckResult<TServices>;
89
+ readonly check: DefinedCheck<TOptions, TServices>;
90
+ readonly deepHalf?: { readonly check: DefinedCheck<TOptions, TServices>; readonly name: string };
91
+ readonly depth?: Depth;
64
92
  readonly description: string;
65
93
  readonly id: TId;
94
+ readonly needs?: Need;
66
95
  readonly registrable?: false;
67
96
  readonly validate?: (context: RuleContext<NoInfer<TOptions>>) => readonly string[];
68
97
  }
@@ -86,13 +115,15 @@ export function defineRule<const TId extends string, TInput, TOptions, TServices
86
115
  ): Rule<TId, TInput, TServices> | Rule<TId, undefined, TServices> {
87
116
  const configure =
88
117
  definition.options === undefined
89
- ? configureWith(noOptions, definition.check, definition.id, undefined, definition.validate)
90
- : configureWith(definition.options, definition.check, definition.id, {}, definition.validate);
118
+ ? configureWith(noOptions, definition, definition.id, undefined, definition.validate)
119
+ : configureWith(definition.options, definition, definition.id, {}, definition.validate);
91
120
  return {
92
121
  [ruleConfiguration]: configure,
93
122
  configure,
123
+ ...(definition.depth === undefined ? {} : { depth: definition.depth }),
94
124
  description: definition.description,
95
125
  id: definition.id,
126
+ ...(definition.needs === undefined ? {} : { needs: definition.needs }),
96
127
  registrable: definition.registrable ?? true,
97
128
  };
98
129
  }
@@ -1,7 +1,10 @@
1
1
  import { Effect } from "effect";
2
2
  import { PRESET, rootConfig } from "#adapters/biome/rootConfig.ts";
3
+ import { fileExclusions } from "#biome/exceptionConfig.ts";
3
4
  import { biomeReport, type Diagnostic, FAILING } from "#biome/report.ts";
5
+ import { needsScanner, SCANNER_RULES } from "#biome/scannerRules.ts";
4
6
  import { withoutEntryPointImports } from "#biome/withoutEntryPointImports.ts";
7
+ import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
5
8
  import { defineRule, type Finding, type Rule, type RuleInputs } from "#rule.ts";
6
9
 
7
10
  function messageOf(diagnostic: Diagnostic): string {
@@ -23,23 +26,66 @@ function findingOf(diagnostic: Diagnostic): Finding {
23
26
  };
24
27
  }
25
28
 
29
+ export const failingFindings = Effect.fn("Biome.failingFindings")(function* (
30
+ inputs: Pick<RuleInputs, "readText">,
31
+ diagnostics: readonly Diagnostic[],
32
+ ) {
33
+ const failing = diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
34
+ return (yield* withoutEntryPointImports(inputs, failing)).map(findingOf);
35
+ });
36
+
37
+ function excepted(exceptions: readonly ExceptionDeclaration[], diagnostic: Diagnostic): boolean {
38
+ const path = diagnostic.location.path;
39
+ return path !== undefined && exceptions.some((entry) => entry.rules.includes(`biome/${diagnostic.category}`) && entry.files.includes(path));
40
+ }
41
+
42
+ // An excepted diagnostic reaches the session at any severity, which drops it and judges each exception by whether one arrived.
43
+ const halfFindings = Effect.fn("Biome.halfFindings")(function* (
44
+ inputs: Pick<RuleInputs, "exceptions" | "readText">,
45
+ diagnostics: readonly Diagnostic[],
46
+ scanned: boolean,
47
+ ) {
48
+ const reported = diagnostics.filter(
49
+ (diagnostic) =>
50
+ needsScanner(diagnostic.category) === scanned && (FAILING.has(diagnostic.severity) || excepted(inputs.exceptions ?? [], diagnostic)),
51
+ );
52
+ return (yield* withoutEntryPointImports(inputs, reported)).map(findingOf);
53
+ });
54
+
26
55
  const presetFinding = Effect.fn("Biome.presetFinding")(function* (inputs: Pick<RuleInputs, "readText">) {
27
56
  const { extendsPreset, path } = yield* rootConfig(inputs.readText);
28
57
  return extendsPreset ? [] : [{ file: path, message: `Extend "${PRESET}" from the root Biome config.`, subject: "preset" }];
29
58
  });
30
59
 
60
+ const WITHOUT_SCANNER: readonly ExceptionDeclaration[] = [...SCANNER_RULES].map(
61
+ (category): ExceptionDeclaration => ({
62
+ files: ["**"],
63
+ reason: "The scanner half checks the rules that need Biome's project scanner.",
64
+ rules: [`biome/${category}`],
65
+ }),
66
+ );
67
+
31
68
  const bridge = defineRule({
32
- check: ({ exceptions, nonEffectFolders, readText, root }) =>
69
+ check: ({ exceptions = [], nonEffectFolders, readText, root }) =>
33
70
  Effect.gen(function* () {
34
- const [preset, report] = yield* Effect.all([presetFinding({ readText }), biomeReport(root, ["check"], exceptions, ["."], nonEffectFolders)], {
35
- concurrency: "unbounded",
36
- });
37
- const failing = report.diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
38
- return [...preset, ...(yield* withoutEntryPointImports({ readText }, failing)).map(findingOf)];
71
+ const [preset, report] = yield* Effect.all(
72
+ [presetFinding({ readText }), biomeReport(root, ["check"], [...fileExclusions(exceptions), ...WITHOUT_SCANNER], ["."], nonEffectFolders)],
73
+ { concurrency: "unbounded" },
74
+ );
75
+ return [...preset, ...(yield* halfFindings({ exceptions, readText }, report.diagnostics, false))];
39
76
  }),
77
+ deepHalf: {
78
+ check: ({ exceptions = [], nonEffectFolders, readText, root }) =>
79
+ Effect.gen(function* () {
80
+ const report = yield* biomeReport(root, ["lint", "--skip=plugin"], fileExclusions(exceptions), ["."], nonEffectFolders);
81
+ return yield* halfFindings({ exceptions, readText }, report.diagnostics, true);
82
+ }),
83
+ name: "scanner half",
84
+ },
40
85
  description:
41
- "Biome's lint, format and assist findings under the shared preset, except undeclared-dependency findings for a piece that an application's entry point brings. `quality fix` applies Biome's lint fixes, unsafe ones included, its assist actions and formatting.",
86
+ "Biome's lint, format and assist findings under the shared preset, except undeclared-dependency findings for a piece that an application's entry point brings. The rules that need Biome's project scanner (its project and types domains) run as the scanner half, in CI and with `quality lint --full`. `quality fix` applies Biome's lint fixes, unsafe ones included, its assist actions and formatting.",
42
87
  id: "biome",
88
+ needs: "child-process",
43
89
  registrable: false,
44
90
  });
45
91
 
@@ -55,7 +55,6 @@ import { specHelpers } from "#rules/stories/specHelpers.ts";
55
55
  import { storySpecs } from "#rules/stories/specs.ts";
56
56
  import { waitOnEvents } from "#rules/stories/waitOnEvents.ts";
57
57
  import { biomeOverrides } from "#rules/suppressions/biomeOverrides.ts";
58
- import { biomeRecommended } from "#rules/suppressions/biomeRecommended.ts";
59
58
  import { noDoubleCast } from "#rules/suppressions/noDoubleCast.ts";
60
59
  import { noIgnoreDeprecations } from "#rules/suppressions/noIgnoreDeprecations.ts";
61
60
  import { noInline } from "#rules/suppressions/noInline.ts";
@@ -87,7 +86,6 @@ export const builtInRules = [
87
86
  noDoubleCast,
88
87
  noIgnoreDeprecations,
89
88
  biomeOverrides,
90
- biomeRecommended,
91
89
  biome,
92
90
  importCycles,
93
91
  importFences,
@@ -4,7 +4,7 @@ import { defineRule } from "#rule.ts";
4
4
  export const adapterImports = defineRule({
5
5
  check: outsideImportFindings,
6
6
  description:
7
- "Keep value imports of non-Effect runtime dependencies, peers, optional dependencies and Node builtins in adapters/. Type-only imports, pure node:path calls (including node:path/posix and node:path/win32) anywhere, workspace modules, test-support/ kits, tool configs directly in a package's folder, Effect and @shivaedev packages, supported UI, routing and styling libraries in client/ folders, Vitest in tests and specs, and node:process in entry modules (cli/main/entry files, runMain callers and the import.meta.url === process.argv[1] guard) are accepted. Recharts is the stack's charting library, accepted in client/ folders; build charts with shadcn's Chart component (ChartContainer and friends) rather than raw recharts primitives where shadcn covers the case. Libraries that perform I/O or manage external state, and file-system and process builtins, still need adapters/. Move integrations into adapters/ and expose Effect values. No config exceptions or inline suppressions; baseline existing debt.",
7
+ "Keep value imports of Node builtins in adapters/: file-system, process and other host access goes through Effect's platform services. Importing an outside library needs no adapter. Type-only imports, pure node:path calls (including node:path/posix and node:path/win32) anywhere, test-support/ kits, tool configs directly in a package's folder, and node:process in entry modules (cli/main/entry files, runMain callers and the import.meta.url === process.argv[1] guard) are accepted. No config exceptions or inline suppressions; baseline existing debt.",
8
8
  id: "effect/adapter-imports",
9
9
  registrable: false,
10
10
  });
@@ -1,104 +1,103 @@
1
1
  import { join } from "node:path";
2
2
  import { Effect } from "effect";
3
- import ts from "typescript";
4
3
  import { isPackageRootConfig } from "#imports/isTooling.ts";
5
- import { packageOf, workspacePackages } from "#imports/workspace.ts";
6
- import { defineRule, type Finding, type RuleInputs } from "#rule.ts";
7
- import { boundaryCalls } from "#rules/effect/boundaryCalls.ts";
8
- import { boundaryEntryPoint } from "#rules/effect/boundaryReference.ts";
9
- import { effectProgram } from "#rules/effect/program.ts";
10
- import { promiseParameter } from "#rules/effect/promiseParameter.ts";
11
- import { parse } from "#rules/parse.ts";
4
+ import { packageOf, type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
5
+ import { defineRule, type Finding, type RuleInputs, type SourceFile } from "#rule.ts";
6
+ import { boundaryFindings } from "#rules/effect/boundaryFindings.ts";
7
+ import { moduleBinder } from "#rules/effect/boundaryReference.ts";
8
+ import { workspaceProgram } from "#rules/effect/workspaceProgram.ts";
9
+ import { parses } from "#rules/parse.ts";
12
10
 
13
- function asyncConstruct(node: ts.Node): string | undefined {
14
- if (
15
- !(ts.isFunctionLike(node) && ts.canHaveModifiers(node) && ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword))
16
- ) {
17
- return undefined;
18
- }
19
- if (ts.isArrowFunction(node)) {
20
- return "async arrow";
11
+ function groupsOf(inputs: RuleInputs, packages: readonly WorkspacePackage[]): readonly (readonly SourceFile[])[] {
12
+ const groups = new Map<string, SourceFile[]>();
13
+ for (const source of inputs.sources) {
14
+ if (
15
+ /(?:^|\/)(?:adapters|test-support)\//u.test(source.path)
16
+ || !/\.[cm]?[jt]sx?$/u.test(source.path)
17
+ || isPackageRootConfig(packageOf(packages, source.path)?.directory ?? ".", source.path)
18
+ ) {
19
+ continue;
20
+ }
21
+ const group = /^(?:packages|examples)\/[^/]+/u.exec(source.path)?.[0] ?? ".";
22
+ const sources = groups.get(group) ?? [];
23
+ sources.push(source);
24
+ groups.set(group, sources);
21
25
  }
22
- return ts.isMethodDeclaration(node) ? "async method" : "async function";
26
+ return [...groups.values()];
23
27
  }
24
28
 
25
- function thenCall(node: ts.Node): boolean {
26
- if (!ts.isCallExpression(node)) {
27
- return false;
28
- }
29
- const callee = node.expression;
30
- return (
31
- (ts.isPropertyAccessExpression(callee) && callee.name.text === "then")
32
- || (ts.isElementAccessExpression(callee) && ts.isStringLiteral(callee.argumentExpression) && callee.argumentExpression.text === "then")
29
+ function syntaxFindings(sources: readonly SourceFile[], workspace: ReadonlySet<string>): readonly Finding[] {
30
+ const { checker, parsed } = moduleBinder(sources);
31
+ const found = boundaryFindings(checker, workspace, false);
32
+ return [...parsed].flatMap(([path, source]) => found(path, source));
33
+ }
34
+
35
+ const everyFinding = Effect.fn("Boundary.everyFinding")(function* (inputs: RuleInputs, workspace: ReadonlySet<string>) {
36
+ const program = yield* workspaceProgram(inputs);
37
+ const found = boundaryFindings(program.getTypeChecker(), workspace, true);
38
+ return inputs.sources.flatMap((file) => {
39
+ const source = parses(file) ? program.getSourceFile(join(inputs.root, file.path)) : undefined;
40
+ return source === undefined ? [] : found(file.path, source);
41
+ });
42
+ });
43
+
44
+ function eachGroup<TError, TServices>(
45
+ inputs: RuleInputs,
46
+ check: (sources: readonly SourceFile[], workspace: ReadonlySet<string>) => Effect.Effect<readonly Finding[], TError, TServices>,
47
+ ) {
48
+ return Effect.flatMap(workspacePackages(inputs), (packages) => {
49
+ const workspace = new Set(packages.map((owner) => owner.name));
50
+ return Effect.map(
51
+ Effect.forEach(groupsOf(inputs, packages), (sources) => check(sources, workspace)),
52
+ (found) => found.flat(),
53
+ );
54
+ });
55
+ }
56
+
57
+ const syntaxRuns = new WeakMap<readonly SourceFile[], readonly Finding[]>();
58
+
59
+ function syntaxHalf(inputs: RuleInputs) {
60
+ return Effect.tap(
61
+ eachGroup(inputs, (sources, workspace) => Effect.sync(() => syntaxFindings(sources, workspace))),
62
+ (found) => Effect.sync(() => syntaxRuns.set(inputs.sources, found)),
33
63
  );
34
64
  }
35
65
 
36
- function construct(node: ts.Node): string | undefined {
37
- if (ts.isVariableDeclarationList(node) && (node.flags & ts.NodeFlags.AwaitUsing) === ts.NodeFlags.AwaitUsing) {
38
- return "await";
39
- }
40
- if (ts.isAwaitExpression(node) || (ts.isForOfStatement(node) && node.awaitModifier !== undefined)) {
41
- return "await";
42
- }
43
- if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Promise") {
44
- return "new Promise(...)";
45
- }
46
- if (thenCall(node)) {
47
- return ".then(...)";
48
- }
49
- if (ts.isTryStatement(node)) {
50
- return "try statement";
66
+ function keyOf(finding: Finding): string {
67
+ return `${finding.file}\u0000${String(finding.line)}\u0000${finding.message}`;
68
+ }
69
+
70
+ function without(found: readonly Finding[], syntax: readonly Finding[]): readonly Finding[] {
71
+ const left = new Map<string, number>();
72
+ for (const finding of syntax) {
73
+ left.set(keyOf(finding), (left.get(keyOf(finding)) ?? 0) + 1);
51
74
  }
52
- return ts.isThrowStatement(node) ? "throw statement" : asyncConstruct(node);
75
+ return found.filter((finding) => {
76
+ const count = left.get(keyOf(finding)) ?? 0;
77
+ left.set(keyOf(finding), count - 1);
78
+ return count <= 0;
79
+ });
53
80
  }
54
81
 
55
- function checkBoundary(inputs: RuleInputs): readonly Finding[] {
56
- const program = effectProgram(inputs, false);
57
- const checker = program.getTypeChecker();
58
- const call = boundaryCalls(checker);
59
- return inputs.sources.flatMap((file) => {
60
- const source = parse(file) === undefined ? undefined : program.getSourceFile(join(inputs.root, file.path));
61
- const findings: Finding[] = [];
62
- const entryPoint = source !== undefined && boundaryEntryPoint(file.path, source, checker);
63
- function visit(node: ts.Node): void {
64
- const name = construct(node) ?? call(node, entryPoint) ?? promiseParameter(checker, node);
65
- if (name !== undefined && source !== undefined) {
66
- findings.push({
67
- file: file.path,
68
- line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1,
69
- message: `Uses ${name}. Model the work with Effect; fail with a tagged error (or Effect.die for a defect). Move a bridge to an outside library into an adapters/ folder, returning Effect values.`,
70
- });
71
- }
72
- ts.forEachChild(node, visit);
73
- }
74
- if (source !== undefined) {
75
- visit(source);
76
- }
77
- return findings;
82
+ // The typed half reports what the whole rule finds beyond the syntax half, whose findings a full run reuses.
83
+ function typedHalf(inputs: RuleInputs) {
84
+ const syntax = Effect.suspend(() => {
85
+ const done = syntaxRuns.get(inputs.sources);
86
+ return done === undefined ? syntaxHalf(inputs) : Effect.succeed(done);
78
87
  });
88
+ return Effect.flatMap(syntax, (found) =>
89
+ Effect.map(
90
+ eachGroup(inputs, (sources, workspace) => everyFinding({ ...inputs, sources }, workspace)),
91
+ (every) => without(every, found),
92
+ ),
93
+ );
79
94
  }
80
95
 
81
96
  export const effectBoundary = defineRule({
82
- check: (inputs) =>
83
- Effect.map(workspacePackages(inputs), (packages) => {
84
- const groups = new Map<string, RuleInputs["sources"][number][]>();
85
- for (const source of inputs.sources) {
86
- if (
87
- /(?:^|\/)(?:adapters|test-support)\//u.test(source.path)
88
- || !/\.[cm]?[jt]sx?$/u.test(source.path)
89
- || isPackageRootConfig(packageOf(packages, source.path)?.directory ?? ".", source.path)
90
- ) {
91
- continue;
92
- }
93
- const group = /^(?:packages|examples)\/[^/]+/u.exec(source.path)?.[0] ?? ".";
94
- const sources = groups.get(group) ?? [];
95
- sources.push(source);
96
- groups.set(group, sources);
97
- }
98
- return [...groups.values()].flatMap((sources) => checkBoundary({ ...inputs, sources }));
99
- }),
97
+ check: syntaxHalf,
98
+ deepHalf: { check: typedHalf, name: "typed half" },
100
99
  description:
101
- "Use Effect instead of Promise syntax and parameters, synchronous Node IO, throwing helper calls or Effect.sync with throwing APIs. Runners belong at entry points (including main.tsx and entry.tsx), tool configs and tests. Within Effect code, adapters/ and test-support/ folders and tool configs directly in a package's folder, which their tool loads from that fixed path, are exempt; calls to throwing helpers defined in adapters/ are accepted. Use Effect services and tagged errors; bridge outside libraries in adapters/. No config exceptions or inline suppressions; baseline existing debt.",
100
+ "Use Effect instead of Promise syntax and parameters, Effect.promise or Effect.tryPromise bridges to an imported outside library, synchronous Node IO, throwing helper calls or Effect.sync with throwing APIs. Runners belong at entry points (including main.tsx and entry.tsx), tool configs and tests. Within Effect code, adapters/ and test-support/ folders and tool configs directly in a package's folder, which their tool loads from that fixed path, are exempt; calls to throwing helpers defined in adapters/ are accepted. Use Effect services and tagged errors; move what a library forces into a module under adapters/ that returns an Effect. No config exceptions or inline suppressions; baseline existing debt.",
102
101
  id: "effect/boundary",
103
102
  registrable: false,
104
103
  });
@@ -0,0 +1,71 @@
1
+ import ts from "typescript";
2
+ import type { Finding } from "#rule.ts";
3
+ import { boundaryCalls } from "#rules/effect/boundaryCalls.ts";
4
+ import { boundaryEntryPoint } from "#rules/effect/boundaryReference.ts";
5
+ import { promiseBridge } from "#rules/effect/promiseBridge.ts";
6
+ import { promiseParameter } from "#rules/effect/promiseParameter.ts";
7
+
8
+ function asyncConstruct(node: ts.Node): string | undefined {
9
+ if (
10
+ !(ts.isFunctionLike(node) && ts.canHaveModifiers(node) && ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword))
11
+ ) {
12
+ return undefined;
13
+ }
14
+ if (ts.isArrowFunction(node)) {
15
+ return "async arrow";
16
+ }
17
+ return ts.isMethodDeclaration(node) ? "async method" : "async function";
18
+ }
19
+
20
+ function thenCall(node: ts.Node): boolean {
21
+ if (!ts.isCallExpression(node)) {
22
+ return false;
23
+ }
24
+ const callee = node.expression;
25
+ return (
26
+ (ts.isPropertyAccessExpression(callee) && callee.name.text === "then")
27
+ || (ts.isElementAccessExpression(callee) && ts.isStringLiteral(callee.argumentExpression) && callee.argumentExpression.text === "then")
28
+ );
29
+ }
30
+
31
+ function construct(node: ts.Node): string | undefined {
32
+ if (ts.isVariableDeclarationList(node) && (node.flags & ts.NodeFlags.AwaitUsing) === ts.NodeFlags.AwaitUsing) {
33
+ return "await";
34
+ }
35
+ if (ts.isAwaitExpression(node) || (ts.isForOfStatement(node) && node.awaitModifier !== undefined)) {
36
+ return "await";
37
+ }
38
+ if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Promise") {
39
+ return "new Promise(...)";
40
+ }
41
+ if (thenCall(node)) {
42
+ return ".then(...)";
43
+ }
44
+ if (ts.isTryStatement(node)) {
45
+ return "try statement";
46
+ }
47
+ return ts.isThrowStatement(node) ? "throw statement" : asyncConstruct(node);
48
+ }
49
+
50
+ // Bound without a program, the checker resolves only names declared in the module, so helpers imported from other modules and parameter types stay with the typed half.
51
+ export function boundaryFindings(checker: ts.TypeChecker, workspace: ReadonlySet<string>, typed: boolean) {
52
+ const call = boundaryCalls(checker);
53
+ const bridge = promiseBridge(checker, workspace);
54
+ return (path: string, source: ts.SourceFile): readonly Finding[] => {
55
+ const findings: Finding[] = [];
56
+ const entryPoint = boundaryEntryPoint(path, source, checker);
57
+ function visit(node: ts.Node): void {
58
+ const name = construct(node) ?? call(node, entryPoint) ?? bridge(node) ?? (typed ? promiseParameter(checker, node) : undefined);
59
+ if (name !== undefined) {
60
+ findings.push({
61
+ file: path,
62
+ line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1,
63
+ message: `Uses ${name}. Model the work with Effect; fail with a tagged error (or Effect.die for a defect). When a library forces it, move that code into a module under adapters/ that returns an Effect.`,
64
+ });
65
+ }
66
+ ts.forEachChild(node, visit);
67
+ }
68
+ visit(source);
69
+ return findings;
70
+ };
71
+ }
@@ -97,8 +97,8 @@ export function boundaryEntryPoint(path: string, source: ts.SourceFile, checker:
97
97
  return RUNNER_HOST.test(path) || entryModule(path, source, checker);
98
98
  }
99
99
 
100
- // Entry markers name their imports, so each module binds on its own without resolving the program behind it.
101
- export function entryModules(sources: readonly SourceFile[]): ReadonlySet<string> {
100
+ // Imports name their modules, so each module binds on its own without resolving the program behind it: local names resolve, imports stay unresolved.
101
+ export function moduleBinder(sources: readonly SourceFile[]) {
102
102
  const options: ts.CompilerOptions = { allowJs: true, noLib: true, noResolve: true, types: [] };
103
103
  const host = ts.createCompilerHost(options);
104
104
  const parsed = new Map(
@@ -108,6 +108,10 @@ export function entryModules(sources: readonly SourceFile[]): ReadonlySet<string
108
108
  }),
109
109
  );
110
110
  host.getSourceFile = (path) => parsed.get(path);
111
- const checker = ts.createProgram([...parsed.keys()], options, host).getTypeChecker();
111
+ return { checker: ts.createProgram([...parsed.keys()], options, host).getTypeChecker(), parsed };
112
+ }
113
+
114
+ export function entryModules(sources: readonly SourceFile[]): ReadonlySet<string> {
115
+ const { checker, parsed } = moduleBinder(sources);
112
116
  return new Set([...parsed].flatMap(([path, source]) => (entryModule(path, source, checker) ? [path] : [])));
113
117
  }
@@ -1,8 +1,9 @@
1
- import { contextCaptureFindings } from "#adapters/contextCaptureFindings.ts";
1
+ import { contextCaptureCheck } from "#adapters/contextCaptureCheck.ts";
2
2
  import { defineRule } from "#rule.ts";
3
+ import { rootedFindings } from "#rules/rootedFindings.ts";
3
4
 
4
5
  export const contextCapture = defineRule({
5
- check: contextCaptureFindings,
6
+ check: (inputs) => rootedFindings(inputs, contextCaptureCheck),
6
7
  description:
7
8
  "Core code yields dependencies and the caller rather than re-providing captured contexts with Effect.provideContext, runPromiseWith, runForkWith or the Context overload of provide. Contexts assembled from Layers at composition roots and fully provided application harnesses are accepted. Runtime bridges belong in adapters/ or test-support/.",
8
9
  id: "effect/context-capture",