@shivaedev/quality 0.44.1 → 0.46.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 (442) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +23 -12
  3. package/biome/preset.json +11 -2
  4. package/dist/PackageManifest.d.ts +25 -0
  5. package/dist/PackageManifest.d.ts.map +1 -0
  6. package/dist/PackageManifest.js +21 -0
  7. package/dist/PackageManifest.js.map +1 -0
  8. package/dist/adapters/TestOutput.d.ts +8 -0
  9. package/dist/adapters/TestOutput.d.ts.map +1 -0
  10. package/dist/adapters/TestOutput.js +5 -0
  11. package/dist/adapters/TestOutput.js.map +1 -0
  12. package/dist/adapters/knip/configuration.d.ts.map +1 -1
  13. package/dist/adapters/knip/configuration.js +2 -9
  14. package/dist/adapters/knip/configuration.js.map +1 -1
  15. package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
  16. package/dist/adapters/knip/entryPointFindings.js +13 -3
  17. package/dist/adapters/knip/entryPointFindings.js.map +1 -1
  18. package/dist/adapters/knip/run.d.ts +3 -1
  19. package/dist/adapters/knip/run.d.ts.map +1 -1
  20. package/dist/adapters/knip/run.js +8 -8
  21. package/dist/adapters/knip/run.js.map +1 -1
  22. package/dist/adapters/manifestInventory.d.ts +23 -0
  23. package/dist/adapters/manifestInventory.d.ts.map +1 -0
  24. package/dist/adapters/manifestInventory.js +63 -0
  25. package/dist/adapters/manifestInventory.js.map +1 -0
  26. package/dist/adapters/manifestReader.d.ts +3 -0
  27. package/dist/adapters/manifestReader.d.ts.map +1 -0
  28. package/dist/adapters/manifestReader.js +8 -0
  29. package/dist/adapters/manifestReader.js.map +1 -0
  30. package/dist/adapters/testProjects.d.ts.map +1 -0
  31. package/dist/{testProjects.js → adapters/testProjects.js} +4 -3
  32. package/dist/adapters/testProjects.js.map +1 -0
  33. package/dist/appTestConfig.d.ts +2 -1
  34. package/dist/appTestConfig.d.ts.map +1 -1
  35. package/dist/appTestConfig.js +3 -3
  36. package/dist/appTestConfig.js.map +1 -1
  37. package/dist/appViteConfig.d.ts +1 -1
  38. package/dist/appViteConfig.d.ts.map +1 -1
  39. package/dist/appViteConfig.js +2 -2
  40. package/dist/appViteConfig.js.map +1 -1
  41. package/dist/baseline/format.js +2 -2
  42. package/dist/baseline/format.js.map +1 -1
  43. package/dist/baseline/legacy.js +2 -2
  44. package/dist/baseline/legacy.js.map +1 -1
  45. package/dist/baseline/merge.js +1 -1
  46. package/dist/baseline/merge.js.map +1 -1
  47. package/dist/baseline/shards.js +1 -1
  48. package/dist/baseline/shards.js.map +1 -1
  49. package/dist/biome/exceptionConfig.d.ts +7 -1
  50. package/dist/biome/exceptionConfig.d.ts.map +1 -1
  51. package/dist/biome/exceptionConfig.js +20 -25
  52. package/dist/biome/exceptionConfig.js.map +1 -1
  53. package/dist/biome/recommendedRules.d.ts +2 -1
  54. package/dist/biome/recommendedRules.d.ts.map +1 -1
  55. package/dist/biome/recommendedRules.js +10 -13
  56. package/dist/biome/recommendedRules.js.map +1 -1
  57. package/dist/biome/relocateConfig.d.ts +6 -0
  58. package/dist/biome/relocateConfig.d.ts.map +1 -0
  59. package/dist/biome/relocateConfig.js +49 -0
  60. package/dist/biome/relocateConfig.js.map +1 -0
  61. package/dist/biome/report.d.ts +27 -3
  62. package/dist/biome/report.d.ts.map +1 -1
  63. package/dist/biome/report.js +12 -10
  64. package/dist/biome/report.js.map +1 -1
  65. package/dist/biome/run.d.ts +12 -2
  66. package/dist/biome/run.d.ts.map +1 -1
  67. package/dist/biome/run.js +18 -24
  68. package/dist/biome/run.js.map +1 -1
  69. package/dist/biome/withoutEntryPointImports.d.ts.map +1 -1
  70. package/dist/biome/withoutEntryPointImports.js +2 -12
  71. package/dist/biome/withoutEntryPointImports.js.map +1 -1
  72. package/dist/cli/args.d.ts +2 -1
  73. package/dist/cli/args.d.ts.map +1 -1
  74. package/dist/cli/args.js +4 -3
  75. package/dist/cli/args.js.map +1 -1
  76. package/dist/cli/baseline.d.ts +4 -3
  77. package/dist/cli/baseline.d.ts.map +1 -1
  78. package/dist/cli/baseline.js.map +1 -1
  79. package/dist/cli/ci.d.ts +1 -1
  80. package/dist/cli/ci.d.ts.map +1 -1
  81. package/dist/cli/ci.js +13 -2
  82. package/dist/cli/ci.js.map +1 -1
  83. package/dist/cli/fix.d.ts +2 -1
  84. package/dist/cli/fix.d.ts.map +1 -1
  85. package/dist/cli/fix.js +3 -9
  86. package/dist/cli/fix.js.map +1 -1
  87. package/dist/cli/lint.d.ts +3 -2
  88. package/dist/cli/lint.d.ts.map +1 -1
  89. package/dist/cli/lint.js.map +1 -1
  90. package/dist/cli/messages.d.ts +1 -1
  91. package/dist/cli/messages.d.ts.map +1 -1
  92. package/dist/cli/messages.js +2 -1
  93. package/dist/cli/messages.js.map +1 -1
  94. package/dist/cli/migrateBaseline.d.ts +3 -2
  95. package/dist/cli/migrateBaseline.d.ts.map +1 -1
  96. package/dist/cli/migrateBaseline.js +2 -2
  97. package/dist/cli/migrateBaseline.js.map +1 -1
  98. package/dist/cli/migrateExceptions.d.ts.map +1 -1
  99. package/dist/cli/migrateExceptions.js +6 -4
  100. package/dist/cli/migrateExceptions.js.map +1 -1
  101. package/dist/cli/program.d.ts +1 -1
  102. package/dist/cli/program.d.ts.map +1 -1
  103. package/dist/cli/program.js +1 -1
  104. package/dist/cli/program.js.map +1 -1
  105. package/dist/config/decode.d.ts +1 -1
  106. package/dist/config/decode.d.ts.map +1 -1
  107. package/dist/config/decode.js +1 -2
  108. package/dist/config/decode.js.map +1 -1
  109. package/dist/config/load.js +2 -2
  110. package/dist/config/load.js.map +1 -1
  111. package/dist/config/resolve.d.ts +1 -1
  112. package/dist/decoded.d.ts +2 -3
  113. package/dist/decoded.d.ts.map +1 -1
  114. package/dist/decoded.js +6 -4
  115. package/dist/decoded.js.map +1 -1
  116. package/dist/docs/documentedModule.d.ts +0 -2
  117. package/dist/docs/documentedModule.d.ts.map +1 -1
  118. package/dist/docs/documentedModule.js +0 -3
  119. package/dist/docs/documentedModule.js.map +1 -1
  120. package/dist/docs/importFindings.d.ts.map +1 -1
  121. package/dist/docs/importFindings.js +0 -3
  122. package/dist/docs/importFindings.js.map +1 -1
  123. package/dist/engine/baselineFile.js +2 -2
  124. package/dist/engine/baselineFile.js.map +1 -1
  125. package/dist/engine/runRules.d.ts +3 -4
  126. package/dist/engine/runRules.d.ts.map +1 -1
  127. package/dist/engine/runRules.js +23 -8
  128. package/dist/engine/runRules.js.map +1 -1
  129. package/dist/engine/session.d.ts +4 -3
  130. package/dist/engine/session.d.ts.map +1 -1
  131. package/dist/engine/session.js +6 -7
  132. package/dist/engine/session.js.map +1 -1
  133. package/dist/exceptions/declaration.js +2 -2
  134. package/dist/exceptions/declaration.js.map +1 -1
  135. package/dist/exceptions/registry.d.ts.map +1 -1
  136. package/dist/exceptions/registry.js +2 -4
  137. package/dist/exceptions/registry.js.map +1 -1
  138. package/dist/failure.d.ts +5 -0
  139. package/dist/failure.d.ts.map +1 -1
  140. package/dist/failure.js +4 -0
  141. package/dist/failure.js.map +1 -1
  142. package/dist/git/command.js +1 -1
  143. package/dist/git/command.js.map +1 -1
  144. package/dist/hooks/install.js +2 -2
  145. package/dist/hooks/install.js.map +1 -1
  146. package/dist/hooks/preCommit.d.ts +1 -2
  147. package/dist/hooks/preCommit.d.ts.map +1 -1
  148. package/dist/hooks/preCommit.js +10 -11
  149. package/dist/hooks/preCommit.js.map +1 -1
  150. package/dist/hooks/status.js +1 -1
  151. package/dist/hooks/status.js.map +1 -1
  152. package/dist/hooks/uninstall.js +3 -3
  153. package/dist/hooks/uninstall.js.map +1 -1
  154. package/dist/imports/classifyRuntime.d.ts +10 -0
  155. package/dist/imports/classifyRuntime.d.ts.map +1 -0
  156. package/dist/imports/classifyRuntime.js +22 -0
  157. package/dist/imports/classifyRuntime.js.map +1 -0
  158. package/dist/imports/fences/declarations.d.ts.map +1 -1
  159. package/dist/imports/fences/declarations.js +1 -2
  160. package/dist/imports/fences/declarations.js.map +1 -1
  161. package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
  162. package/dist/imports/pnpmWorkspacePatterns.js +2 -1
  163. package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
  164. package/dist/imports/runtime.d.ts +4 -3
  165. package/dist/imports/runtime.d.ts.map +1 -1
  166. package/dist/imports/runtime.js +35 -64
  167. package/dist/imports/runtime.js.map +1 -1
  168. package/dist/imports/workspace.d.ts.map +1 -1
  169. package/dist/imports/workspace.js +9 -19
  170. package/dist/imports/workspace.js.map +1 -1
  171. package/dist/inventory/collect.d.ts +1 -0
  172. package/dist/inventory/collect.d.ts.map +1 -1
  173. package/dist/inventory/collect.js +2 -1
  174. package/dist/inventory/collect.js.map +1 -1
  175. package/dist/inventory/filesystem.d.ts.map +1 -1
  176. package/dist/inventory/filesystem.js +2 -8
  177. package/dist/inventory/filesystem.js.map +1 -1
  178. package/dist/manifests/entryPoints.d.ts.map +1 -1
  179. package/dist/manifests/entryPoints.js +2 -12
  180. package/dist/manifests/entryPoints.js.map +1 -1
  181. package/dist/manifests/sorted.d.ts +2 -3
  182. package/dist/manifests/sorted.d.ts.map +1 -1
  183. package/dist/manifests/sorted.js +14 -8
  184. package/dist/manifests/sorted.js.map +1 -1
  185. package/dist/naming/packageLayout.d.ts.map +1 -1
  186. package/dist/naming/packageLayout.js +2 -12
  187. package/dist/naming/packageLayout.js.map +1 -1
  188. package/dist/rule.d.ts +15 -10
  189. package/dist/rule.d.ts.map +1 -1
  190. package/dist/rule.js +9 -1
  191. package/dist/rule.js.map +1 -1
  192. package/dist/rules/biome.d.ts.map +1 -1
  193. package/dist/rules/biome.js +7 -4
  194. package/dist/rules/biome.js.map +1 -1
  195. package/dist/rules/builtIn.d.ts +14 -14
  196. package/dist/rules/builtIn.d.ts.map +1 -1
  197. package/dist/rules/builtIn.js +8 -0
  198. package/dist/rules/builtIn.js.map +1 -1
  199. package/dist/rules/comments/maxPerFile.d.ts +1 -1
  200. package/dist/rules/comments/maxPerFile.d.ts.map +1 -1
  201. package/dist/rules/comments/noBanner.d.ts +1 -1
  202. package/dist/rules/comments/noBanner.d.ts.map +1 -1
  203. package/dist/rules/comments/noEnvironmentPragma.d.ts +1 -1
  204. package/dist/rules/comments/noEnvironmentPragma.d.ts.map +1 -1
  205. package/dist/rules/comments/noEnvironmentPragma.js +1 -1
  206. package/dist/rules/comments/noEnvironmentPragma.js.map +1 -1
  207. package/dist/rules/comments/noJsdoc.d.ts +1 -1
  208. package/dist/rules/comments/noJsdoc.d.ts.map +1 -1
  209. package/dist/rules/comments/noLineReference.d.ts +1 -1
  210. package/dist/rules/comments/noLineReference.d.ts.map +1 -1
  211. package/dist/rules/comments/noPrReference.d.ts +1 -1
  212. package/dist/rules/comments/noPrReference.d.ts.map +1 -1
  213. package/dist/rules/comments/noTodo.d.ts +1 -1
  214. package/dist/rules/comments/noTodo.d.ts.map +1 -1
  215. package/dist/rules/docs/references.d.ts +1 -1
  216. package/dist/rules/docs/references.d.ts.map +1 -1
  217. package/dist/rules/docs/references.js +5 -8
  218. package/dist/rules/docs/references.js.map +1 -1
  219. package/dist/rules/docs/unversionedInstalls.d.ts +1 -1
  220. package/dist/rules/docs/unversionedInstalls.d.ts.map +1 -1
  221. package/dist/rules/docs/unversionedInstalls.js +1 -1
  222. package/dist/rules/docs/unversionedInstalls.js.map +1 -1
  223. package/dist/rules/effect/boundary.d.ts +1 -1
  224. package/dist/rules/effect/boundary.d.ts.map +1 -1
  225. package/dist/rules/effect/serviceParameters.d.ts +1 -1
  226. package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
  227. package/dist/rules/effect/serviceTypes.d.ts.map +1 -1
  228. package/dist/rules/effect/serviceTypes.js +10 -0
  229. package/dist/rules/effect/serviceTypes.js.map +1 -1
  230. package/dist/rules/files/distinctCase.d.ts +1 -1
  231. package/dist/rules/files/distinctCase.d.ts.map +1 -1
  232. package/dist/rules/files/folderNames.d.ts +1 -1
  233. package/dist/rules/files/folderNames.d.ts.map +1 -1
  234. package/dist/rules/files/namedAfterExport.d.ts +1 -1
  235. package/dist/rules/files/namedAfterExport.d.ts.map +1 -1
  236. package/dist/rules/files/otherNames.d.ts +1 -1
  237. package/dist/rules/files/otherNames.d.ts.map +1 -1
  238. package/dist/rules/files/packageImports.d.ts.map +1 -1
  239. package/dist/rules/files/packageImports.js +2 -13
  240. package/dist/rules/files/packageImports.js.map +1 -1
  241. package/dist/rules/imports/aliased.d.ts +1 -1
  242. package/dist/rules/imports/aliased.d.ts.map +1 -1
  243. package/dist/rules/imports/cycles.d.ts +1 -1
  244. package/dist/rules/imports/cycles.d.ts.map +1 -1
  245. package/dist/rules/imports/fences.d.ts +1 -1
  246. package/dist/rules/imports/fences.d.ts.map +1 -1
  247. package/dist/rules/imports/manifest.d.ts +1 -1
  248. package/dist/rules/imports/manifest.d.ts.map +1 -1
  249. package/dist/rules/imports/manifest.js +14 -32
  250. package/dist/rules/imports/manifest.js.map +1 -1
  251. package/dist/rules/imports/noTestCode.d.ts +1 -1
  252. package/dist/rules/imports/noTestCode.d.ts.map +1 -1
  253. package/dist/rules/imports/resolvable.d.ts +1 -1
  254. package/dist/rules/imports/resolvable.d.ts.map +1 -1
  255. package/dist/rules/imports/runtime.d.ts +1 -1
  256. package/dist/rules/imports/runtime.d.ts.map +1 -1
  257. package/dist/rules/imports/runtime.js +29 -25
  258. package/dist/rules/imports/runtime.js.map +1 -1
  259. package/dist/rules/manifestsApplication.d.ts +1 -1
  260. package/dist/rules/manifestsApplication.d.ts.map +1 -1
  261. package/dist/rules/manifestsApplication.js +2 -12
  262. package/dist/rules/manifestsApplication.js.map +1 -1
  263. package/dist/rules/manifestsExportsShape.d.ts +1 -1
  264. package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
  265. package/dist/rules/manifestsExportsShape.js +12 -7
  266. package/dist/rules/manifestsExportsShape.js.map +1 -1
  267. package/dist/rules/manifestsSorted.d.ts +1 -1
  268. package/dist/rules/manifestsSorted.d.ts.map +1 -1
  269. package/dist/rules/manifestsSorted.js +10 -14
  270. package/dist/rules/manifestsSorted.js.map +1 -1
  271. package/dist/rules/manifestsSourceFirst.d.ts +1 -1
  272. package/dist/rules/manifestsSourceFirst.d.ts.map +1 -1
  273. package/dist/rules/manifestsSourceFirst.js +20 -23
  274. package/dist/rules/manifestsSourceFirst.js.map +1 -1
  275. package/dist/rules/manifestsValid.d.ts +2 -0
  276. package/dist/rules/manifestsValid.d.ts.map +1 -0
  277. package/dist/rules/manifestsValid.js +10 -0
  278. package/dist/rules/manifestsValid.js.map +1 -0
  279. package/dist/rules/maxDepth.d.ts +1 -1
  280. package/dist/rules/maxDepth.d.ts.map +1 -1
  281. package/dist/rules/maxLines.d.ts +1 -1
  282. package/dist/rules/maxLines.d.ts.map +1 -1
  283. package/dist/rules/noBarrel.d.ts +1 -1
  284. package/dist/rules/noBarrel.d.ts.map +1 -1
  285. package/dist/rules/react/jsxConditionals.d.ts +1 -1
  286. package/dist/rules/react/jsxConditionals.d.ts.map +1 -1
  287. package/dist/rules/stories/authSql.d.ts +1 -1
  288. package/dist/rules/stories/authSql.d.ts.map +1 -1
  289. package/dist/rules/stories/authSql.js +22 -3
  290. package/dist/rules/stories/authSql.js.map +1 -1
  291. package/dist/rules/stories/domainOutcomes.d.ts +2 -0
  292. package/dist/rules/stories/domainOutcomes.d.ts.map +1 -0
  293. package/dist/rules/stories/domainOutcomes.js +34 -0
  294. package/dist/rules/stories/domainOutcomes.js.map +1 -0
  295. package/dist/rules/stories/engine.d.ts +1 -1
  296. package/dist/rules/stories/engine.d.ts.map +1 -1
  297. package/dist/rules/stories/groupedOutcomes.d.ts +2 -0
  298. package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -0
  299. package/dist/rules/stories/groupedOutcomes.js +55 -0
  300. package/dist/rules/stories/groupedOutcomes.js.map +1 -0
  301. package/dist/rules/stories/httpStatus.d.ts +1 -1
  302. package/dist/rules/stories/httpStatus.d.ts.map +1 -1
  303. package/dist/rules/stories/importBindings.d.ts +8 -0
  304. package/dist/rules/stories/importBindings.d.ts.map +1 -0
  305. package/dist/rules/stories/importBindings.js +29 -0
  306. package/dist/rules/stories/importBindings.js.map +1 -0
  307. package/dist/rules/stories/namedValues.d.ts +1 -1
  308. package/dist/rules/stories/namedValues.d.ts.map +1 -1
  309. package/dist/rules/stories/noExpect.d.ts +1 -1
  310. package/dist/rules/stories/noExpect.d.ts.map +1 -1
  311. package/dist/rules/stories/noLimitImports.d.ts +1 -1
  312. package/dist/rules/stories/noLimitImports.d.ts.map +1 -1
  313. package/dist/rules/stories/prerequisites.d.ts.map +1 -1
  314. package/dist/rules/stories/prerequisites.js +3 -6
  315. package/dist/rules/stories/prerequisites.js.map +1 -1
  316. package/dist/rules/stories/queueSql.d.ts +1 -1
  317. package/dist/rules/stories/queueSql.d.ts.map +1 -1
  318. package/dist/rules/stories/setup.d.ts +1 -1
  319. package/dist/rules/stories/setup.d.ts.map +1 -1
  320. package/dist/rules/stories/sources.d.ts +4 -0
  321. package/dist/rules/stories/sources.d.ts.map +1 -0
  322. package/dist/rules/stories/sources.js +17 -0
  323. package/dist/rules/stories/sources.js.map +1 -0
  324. package/dist/rules/stories/specHelpers.d.ts +1 -1
  325. package/dist/rules/stories/specHelpers.d.ts.map +1 -1
  326. package/dist/rules/stories/specs.d.ts +1 -1
  327. package/dist/rules/stories/specs.d.ts.map +1 -1
  328. package/dist/rules/stories/waitOnEvents.d.ts +2 -0
  329. package/dist/rules/stories/waitOnEvents.d.ts.map +1 -0
  330. package/dist/rules/stories/waitOnEvents.js +52 -0
  331. package/dist/rules/stories/waitOnEvents.js.map +1 -0
  332. package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -1
  333. package/dist/rules/suppressions/biome/declarations.js +2 -4
  334. package/dist/rules/suppressions/biome/declarations.js.map +1 -1
  335. package/dist/rules/suppressions/biome/resolvePackage.d.ts.map +1 -1
  336. package/dist/rules/suppressions/biome/resolvePackage.js +3 -15
  337. package/dist/rules/suppressions/biome/resolvePackage.js.map +1 -1
  338. package/dist/rules/suppressions/biomeOverrides.d.ts +1 -1
  339. package/dist/rules/suppressions/biomeOverrides.d.ts.map +1 -1
  340. package/dist/rules/suppressions/biomeRecommended.d.ts +6 -3
  341. package/dist/rules/suppressions/biomeRecommended.d.ts.map +1 -1
  342. package/dist/rules/suppressions/biomeRecommended.js +10 -7
  343. package/dist/rules/suppressions/biomeRecommended.js.map +1 -1
  344. package/dist/rules/suppressions/noDoubleCast.d.ts +1 -1
  345. package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
  346. package/dist/rules/suppressions/noIgnoreDeprecations.d.ts +1 -1
  347. package/dist/rules/suppressions/noIgnoreDeprecations.d.ts.map +1 -1
  348. package/dist/rules/suppressions/noIgnoreDeprecations.js +7 -7
  349. package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
  350. package/dist/rules/suppressions/noInline.d.ts +1 -1
  351. package/dist/rules/suppressions/noInline.d.ts.map +1 -1
  352. package/dist/rules/test-names/colocated.d.ts +1 -1
  353. package/dist/rules/test-names/colocated.d.ts.map +1 -1
  354. package/dist/rules/test-names/follow.d.ts +1 -1
  355. package/dist/rules/test-names/follow.d.ts.map +1 -1
  356. package/dist/rules/unusedCode.d.ts +1 -1
  357. package/dist/rules/unusedCode.d.ts.map +1 -1
  358. package/package.json +10 -15
  359. package/src/PackageManifest.ts +24 -0
  360. package/src/adapters/TestOutput.ts +9 -0
  361. package/src/adapters/knip/configuration.ts +2 -10
  362. package/src/adapters/knip/entryPointFindings.ts +17 -3
  363. package/src/adapters/knip/run.ts +42 -44
  364. package/src/adapters/manifestInventory.ts +87 -0
  365. package/src/adapters/manifestReader.ts +11 -0
  366. package/src/{testProjects.ts → adapters/testProjects.ts} +4 -3
  367. package/src/appTestConfig.ts +3 -3
  368. package/src/appViteConfig.ts +2 -2
  369. package/src/baseline/format.ts +2 -2
  370. package/src/baseline/legacy.ts +2 -2
  371. package/src/baseline/merge.ts +1 -1
  372. package/src/baseline/shards.ts +1 -1
  373. package/src/biome/exceptionConfig.ts +22 -29
  374. package/src/biome/recommendedRules.ts +18 -16
  375. package/src/biome/relocateConfig.ts +59 -0
  376. package/src/biome/report.ts +17 -11
  377. package/src/biome/run.ts +29 -28
  378. package/src/biome/withoutEntryPointImports.ts +2 -12
  379. package/src/cli/args.ts +5 -4
  380. package/src/cli/baseline.ts +3 -2
  381. package/src/cli/ci.ts +14 -2
  382. package/src/cli/fix.ts +15 -17
  383. package/src/cli/lint.ts +3 -2
  384. package/src/cli/messages.ts +2 -1
  385. package/src/cli/migrateBaseline.ts +4 -3
  386. package/src/cli/migrateExceptions.ts +6 -4
  387. package/src/cli/program.ts +1 -1
  388. package/src/config/decode.ts +1 -3
  389. package/src/config/load.ts +2 -2
  390. package/src/decoded.ts +9 -5
  391. package/src/docs/documentedModule.ts +1 -4
  392. package/src/docs/importFindings.ts +0 -5
  393. package/src/engine/baselineFile.ts +2 -2
  394. package/src/engine/runRules.ts +34 -15
  395. package/src/engine/session.ts +11 -10
  396. package/src/exceptions/declaration.ts +2 -2
  397. package/src/exceptions/registry.ts +2 -4
  398. package/src/failure.ts +6 -1
  399. package/src/git/command.ts +1 -1
  400. package/src/hooks/install.ts +2 -2
  401. package/src/hooks/preCommit.ts +10 -16
  402. package/src/hooks/status.ts +1 -1
  403. package/src/hooks/uninstall.ts +3 -3
  404. package/src/imports/classifyRuntime.ts +30 -0
  405. package/src/imports/fences/declarations.ts +1 -3
  406. package/src/imports/pnpmWorkspacePatterns.ts +3 -1
  407. package/src/imports/runtime.ts +48 -60
  408. package/src/imports/workspace.ts +9 -20
  409. package/src/inventory/collect.ts +3 -1
  410. package/src/inventory/filesystem.ts +2 -10
  411. package/src/manifests/entryPoints.ts +2 -12
  412. package/src/manifests/sorted.ts +21 -9
  413. package/src/naming/packageLayout.ts +2 -12
  414. package/src/rule.ts +38 -19
  415. package/src/rules/biome.ts +9 -5
  416. package/src/rules/builtIn.ts +8 -0
  417. package/src/rules/comments/noEnvironmentPragma.ts +1 -1
  418. package/src/rules/docs/references.ts +8 -10
  419. package/src/rules/docs/unversionedInstalls.ts +1 -1
  420. package/src/rules/effect/serviceTypes.ts +13 -0
  421. package/src/rules/files/packageImports.ts +2 -13
  422. package/src/rules/imports/manifest.ts +15 -32
  423. package/src/rules/imports/runtime.ts +41 -35
  424. package/src/rules/manifestsApplication.ts +2 -12
  425. package/src/rules/manifestsExportsShape.ts +11 -8
  426. package/src/rules/manifestsSorted.ts +13 -16
  427. package/src/rules/manifestsSourceFirst.ts +24 -24
  428. package/src/rules/manifestsValid.ts +14 -0
  429. package/src/rules/stories/authSql.ts +25 -3
  430. package/src/rules/stories/domainOutcomes.ts +44 -0
  431. package/src/rules/stories/groupedOutcomes.ts +66 -0
  432. package/src/rules/stories/importBindings.ts +37 -0
  433. package/src/rules/stories/prerequisites.ts +4 -8
  434. package/src/rules/stories/sources.ts +20 -0
  435. package/src/rules/stories/waitOnEvents.ts +61 -0
  436. package/src/rules/suppressions/biome/declarations.ts +2 -4
  437. package/src/rules/suppressions/biome/resolvePackage.ts +5 -21
  438. package/src/rules/suppressions/biomeRecommended.ts +14 -9
  439. package/src/rules/suppressions/noIgnoreDeprecations.ts +11 -8
  440. package/dist/testProjects.d.ts.map +0 -1
  441. package/dist/testProjects.js.map +0 -1
  442. /package/dist/{testProjects.d.ts → adapters/testProjects.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  export const USAGE = `Usage:
2
2
  quality lint [--config <file>]
3
- quality ci
3
+ quality ci [--coverage]
4
4
  quality setup [--config <file>]
5
5
  quality fix [--config <file>]
6
6
  quality exceptions migrate [--config <file>] [--from <registry>]
@@ -35,6 +35,7 @@ hooks pre-commit What the hook runs: lint, then package.json scripts typecheck
35
35
 
36
36
  --config <file> Config file; its directory is the repository root. Without this option, uses ./quality.config.ts when present, otherwise defaults.
37
37
  --against <ref> The branch the work merges into, whose merge base prune follows moves from. Defaults to origin/HEAD, then origin/main, then origin/master.
38
+ --coverage Collect V8 coverage and JUnit from ci's single test run into coverage/, including failed tests.
38
39
  Exit codes: 0 passed, 1 failed the gate, 2 could not run.`;
39
40
 
40
41
  export const SUBCOMMANDS: Readonly<Record<string, string>> = {
@@ -9,15 +9,16 @@ import { readInput } from "#engine/baselineFile.ts";
9
9
  import { scan } from "#engine/session.ts";
10
10
  import { SetupFailure } from "#failure.ts";
11
11
  import { plural } from "#report/plural.ts";
12
+ import type { RuleServices } from "#rule.ts";
12
13
 
13
14
  export const migrateBaseline = Effect.fn("Cli.migrateBaseline")(function* (
14
15
  cwd: string,
15
16
  configPath: string | undefined,
16
17
  from: string | undefined,
17
- ): Effect.fn.Return<void, SetupFailure, FileSystem.FileSystem> {
18
+ ): Effect.fn.Return<void, SetupFailure, RuleServices> {
18
19
  const config = yield* loadConfig(cwd, configPath);
19
20
  const source = from ?? LEGACY_BASELINE;
20
- const paths = yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
21
+ const paths = yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
21
22
  const existing = yield* Effect.forEach(paths, (path) => readInput(config.root, path));
22
23
  if (source === config.baseline || existing.some((text) => text !== undefined)) {
23
24
  return yield* new SetupFailure({ message: `${config.baseline} already exists. Migrate into a baseline file that does not exist yet.` });
@@ -32,7 +33,7 @@ export const migrateBaseline = Effect.fn("Cli.migrateBaseline")(function* (
32
33
  const entries = source.endsWith(".jsonl") ? legacy : convertLegacy(legacy, (yield* scan(config)).violations);
33
34
  const fs = yield* FileSystem.FileSystem;
34
35
  const written = Effect.andThen(saveShards(config, new Map(), entries), fs.remove(join(config.root, source)));
35
- yield* Effect.mapError(written, (failure) => new SetupFailure({ message: failure.message }));
36
+ yield* Effect.mapError(written, (failure) => new SetupFailure({ cause: failure, message: failure.message }));
36
37
  const fixed = legacy.length - entries.length;
37
38
  const dropped = fixed > 0 ? `, dropping ${plural(fixed, "fixed entry", "fixed entries")}` : "";
38
39
  yield* Console.log(`quality: moved ${plural(entries.length, "entry", "entries")} from ${source} to ${config.baseline}${dropped}.`);
@@ -60,7 +60,7 @@ export const migrateExceptions = Effect.fnUntraced(function* (
60
60
  yield* validOrFail(config.file, yield* Effect.promise(() => decodeExceptions(entries)));
61
61
  const text = yield* readInput("", config.file);
62
62
  const next = yield* Effect.try({
63
- catch: (cause) => new SetupFailure({ message: String(cause) }),
63
+ catch: (cause) => new SetupFailure({ cause, message: String(cause) }),
64
64
  try: () => migrateConfig(text, config.file, entries, config.biomeDeclarations.length > 0),
65
65
  });
66
66
  const updates: Array<{ readonly path: string; readonly text: string }> = [{ path: config.file, text: next }];
@@ -69,7 +69,7 @@ export const migrateExceptions = Effect.fnUntraced(function* (
69
69
  const biome = yield* readInput(config.root, file);
70
70
  if (biome !== undefined) {
71
71
  const updated = yield* Effect.try({
72
- catch: (cause) => new SetupFailure({ message: String(cause) }),
72
+ catch: (cause) => new SetupFailure({ cause, message: String(cause) }),
73
73
  try: () => migrateBiome(biome, file, config.biomeDeclarations),
74
74
  });
75
75
  updates.push({ path: join(config.root, file), text: updated });
@@ -77,11 +77,13 @@ export const migrateExceptions = Effect.fnUntraced(function* (
77
77
  }
78
78
  }
79
79
  for (const update of updates) {
80
- yield* writeText(update.path, update.text).pipe(Effect.mapError((failure) => new SetupFailure({ message: failure.message })));
80
+ yield* writeText(update.path, update.text).pipe(Effect.mapError((failure) => new SetupFailure({ cause: failure, message: failure.message })));
81
81
  }
82
82
  if (raw !== undefined) {
83
83
  const fs = yield* FileSystem.FileSystem;
84
- yield* fs.remove(join(config.root, registryPath)).pipe(Effect.mapError((failure) => new SetupFailure({ message: failure.message })));
84
+ yield* fs
85
+ .remove(join(config.root, registryPath))
86
+ .pipe(Effect.mapError((failure) => new SetupFailure({ cause: failure, message: failure.message })));
85
87
  }
86
88
  yield* Console.log(`quality: moved exceptions to ${config.file}. Run quality fix and review the changes; remove unused declaration imports.`);
87
89
  });
@@ -32,7 +32,7 @@ export const program = Effect.fn("Cli.program")(function* (args: readonly string
32
32
  case "Help":
33
33
  return yield* Console.log(USAGE);
34
34
  case "Ci":
35
- return yield* ci(cwd);
35
+ return yield* ci(cwd, command.coverage);
36
36
  case "Setup":
37
37
  return yield* setupHook({ config: command.config, cwd, launch });
38
38
  case "Lint":
@@ -34,8 +34,6 @@ const ConfigInput = Schema.Struct({
34
34
 
35
35
  export type ConfigInput = typeof ConfigInput.Type;
36
36
 
37
- const standard = Schema.toStandardSchemaV1(ConfigInput, { parseOptions: { errors: "all", onExcessProperty: "error" } });
38
-
39
37
  export function decodeConfig(value: unknown): Promise<Decoded<ConfigInput>> {
40
- return decodeWith(standard, value);
38
+ return decodeWith(ConfigInput, value);
41
39
  }
@@ -27,7 +27,7 @@ function messageOf(cause: unknown): string {
27
27
  function importDefault(file: string): Effect.Effect<unknown, SetupFailure> {
28
28
  return Effect.flatMap(
29
29
  Effect.tryPromise({
30
- catch: (cause) => new SetupFailure({ message: `cannot load ${file}: ${messageOf(cause)}` }),
30
+ catch: (cause) => new SetupFailure({ cause, message: `cannot load ${file}: ${messageOf(cause)}` }),
31
31
  try: async (): Promise<unknown> => import(pathToFileURL(file).href),
32
32
  }),
33
33
  (loaded) =>
@@ -71,7 +71,7 @@ export const loadConfig = Effect.fn("Config.loadConfig")(function* (
71
71
  Effect.catchTag("PlatformError", (error) =>
72
72
  error.reason._tag === "NotFound"
73
73
  ? Effect.succeed<string[]>([])
74
- : Effect.fail(new SetupFailure({ message: `cannot inspect ${file}: ${error.message}` })),
74
+ : Effect.fail(new SetupFailure({ cause: error, message: `cannot inspect ${file}: ${error.message}` })),
75
75
  ),
76
76
  );
77
77
  const present = entries.includes(basename(file));
package/src/decoded.ts CHANGED
@@ -1,12 +1,16 @@
1
- import { Effect } from "effect";
1
+ import { Effect, Result, Schema, SchemaIssue } from "effect";
2
2
  import { SetupFailure } from "./failure.ts";
3
- import { describeIssue, type StandardSchemaV1 } from "./standardSchema.ts";
3
+ import { describeIssue } from "./standardSchema.ts";
4
4
 
5
5
  export type Decoded<TValue> = { readonly _tag: "Valid"; readonly value: TValue } | { readonly _tag: "Invalid"; readonly issues: readonly string[] };
6
6
 
7
- export async function decodeWith<TOutput>(schema: StandardSchemaV1<unknown, TOutput>, value: unknown): Promise<Decoded<TOutput>> {
8
- const result = await schema["~standard"].validate(value);
9
- return result.issues === undefined ? { _tag: "Valid", value: result.value } : { _tag: "Invalid", issues: result.issues.map(describeIssue) };
7
+ export function decodeWith<TSchema extends Schema.ConstraintDecoder<unknown>>(schema: TSchema, value: unknown): Promise<Decoded<TSchema["Type"]>> {
8
+ const result = Schema.decodeUnknownResult(schema, { errors: "all", onExcessProperty: "error" })(value);
9
+ return Promise.resolve(
10
+ Result.isSuccess(result)
11
+ ? { _tag: "Valid", value: result.success }
12
+ : { _tag: "Invalid", issues: SchemaIssue.makeFormatterStandardSchemaV1()(result.failure.issue).issues.map(describeIssue) },
13
+ );
10
14
  }
11
15
 
12
16
  export function validOrFail<TValue>(file: string, decoded: Decoded<TValue>): Effect.Effect<TValue, SetupFailure> {
@@ -3,7 +3,7 @@ import ts from "typescript";
3
3
  import { exportEntry, exportTargets } from "#imports/packageExports.ts";
4
4
  import type { WorkspacePackage } from "#imports/workspace.ts";
5
5
 
6
- export type DocumentedModule = { readonly kind: "missing" } | { readonly kind: "private" } | { readonly kind: "source"; readonly path: string };
6
+ export type DocumentedModule = { readonly kind: "missing" } | { readonly kind: "source"; readonly path: string };
7
7
 
8
8
  const BUILT = /^\.\/dist\/(?<path>.+?)(?:\.d)?\.[cm]?[jt]s$/u;
9
9
 
@@ -31,9 +31,6 @@ export function documentedModule(root: string, owner: WorkspacePackage, exports:
31
31
  if (entry === undefined) {
32
32
  return MISSING;
33
33
  }
34
- if (entry[1] === null) {
35
- return { kind: "private" };
36
- }
37
34
  const [prefix = "", suffix = ""] = entry[0].split("*");
38
35
  const star = subpath.slice(prefix.length, subpath.length - suffix.length);
39
36
  return found(
@@ -29,11 +29,6 @@ function problem(
29
29
  if (module.kind === "missing") {
30
30
  return Effect.succeed(`"${entry.specifier}" names no module of ${owner.name}. Use the path of a module its package.json "exports" maps.`);
31
31
  }
32
- if (module.kind === "private") {
33
- return Effect.succeed(
34
- `"${entry.specifier}" is private: the package.json "exports" of ${owner.name} blocks it. Document a module the package exports.`,
35
- );
36
- }
37
32
  const name = entry.name;
38
33
  if (name === undefined) {
39
34
  return Effect.succeed(undefined);
@@ -14,14 +14,14 @@ export interface BaselineFile {
14
14
  }
15
15
 
16
16
  export function readInput(root: string, path: string): Effect.Effect<string | undefined, SetupFailure, FileSystem.FileSystem> {
17
- return Effect.mapError(readOptionalText(join(root, path)), (failure) => new SetupFailure({ message: failure.message }));
17
+ return Effect.mapError(readOptionalText(join(root, path)), (failure) => new SetupFailure({ cause: failure, message: failure.message }));
18
18
  }
19
19
 
20
20
  export const readBaseline = Effect.fn("Engine.readBaseline")(function* (
21
21
  config: ResolvedConfig,
22
22
  ): Effect.fn.Return<BaselineFile, SetupFailure, FileSystem.FileSystem> {
23
23
  const files = new Map<string, Shard>();
24
- for (const path of yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })))) {
24
+ for (const path of yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })))) {
25
25
  const raw = yield* readInput(config.root, path);
26
26
  if (raw === undefined) {
27
27
  continue;
@@ -1,12 +1,12 @@
1
1
  import { isAbsolute, relative } from "node:path";
2
2
  import { Effect } from "effect";
3
- import { SetupFailure } from "#failure.ts";
3
+ import { ManifestFailure } from "#adapters/manifestInventory.ts";
4
4
  import { posix } from "#inventory/ignoreScope.ts";
5
- import type { Finding, Findings, RuleInputs } from "#rule.ts";
5
+ import type { Finding, RuleCheck, RuleInputs, RuleServices } from "#rule.ts";
6
6
  import type { ActiveLevel, Violation } from "./violation.ts";
7
7
 
8
8
  export interface ActiveRule {
9
- readonly check: (inputs: RuleInputs) => Promise<Findings>;
9
+ readonly check: RuleCheck;
10
10
  readonly description: string;
11
11
  readonly family: boolean;
12
12
  readonly id: string;
@@ -48,19 +48,38 @@ function violationOf(rule: ActiveRule, root: string, finding: Finding, exception
48
48
  };
49
49
  }
50
50
 
51
- function runRule(rule: ActiveRule, inputs: RuleInputs, exceptionFile: string): Effect.Effect<readonly Violation[], SetupFailure> {
52
- return Effect.map(
53
- Effect.tryPromise({
54
- catch: (cause) => new SetupFailure({ message: `rule ${rule.id} failed: ${messageOf(cause)}` }),
55
- try: () => rule.check(inputs),
56
- }),
57
- (findings) => findings.map((finding) => violationOf(rule, inputs.root, finding, exceptionFile)),
51
+ function runRule(rule: ActiveRule, inputs: RuleInputs, exceptionFile: string): Effect.Effect<readonly Violation[], never, RuleServices> {
52
+ return Effect.suspend(() => rule.check(inputs)).pipe(
53
+ Effect.orDie,
54
+ Effect.map((findings) => findings.map((finding) => violationOf(rule, inputs.root, finding, exceptionFile))),
55
+ Effect.catchDefect((cause) =>
56
+ cause instanceof ManifestFailure
57
+ ? Effect.succeed([{ file: cause.path, level: "error" as const, message: cause.message, rule: "manifests/valid" }])
58
+ : Effect.die(new Error(`rule ${rule.id} failed: ${messageOf(cause)}`, { cause })),
59
+ ),
58
60
  );
59
61
  }
60
62
 
61
- export function runRules(rules: readonly ActiveRule[], inputs: RuleInputs): Effect.Effect<readonly Violation[], SetupFailure> {
62
- return Effect.map(
63
- Effect.forEach(rules, (rule) => runRule(rule, inputs, inputs.configFile ?? "quality.config.ts"), { concurrency: "unbounded" }),
64
- (results) => results.flat(),
63
+ export const runRules = Effect.fn("Engine.runRules")(function* (rules: readonly ActiveRule[], inputs: RuleInputs) {
64
+ const validation = rules.find((rule) => rule.id === "manifests/valid");
65
+ if (validation !== undefined) {
66
+ const failures = yield* runRule(validation, inputs, inputs.configFile ?? "quality.config.ts");
67
+ if (failures.length > 0) {
68
+ return failures;
69
+ }
70
+ }
71
+ const results = yield* Effect.forEach(
72
+ rules.filter((rule) => rule !== validation),
73
+ (rule) => runRule(rule, inputs, inputs.configFile ?? "quality.config.ts"),
74
+ { concurrency: "unbounded" },
65
75
  );
66
- }
76
+ const seen = new Set<string>();
77
+ return results.flat().filter((finding) => {
78
+ if (finding.rule !== "manifests/valid") {
79
+ return true;
80
+ }
81
+ const duplicate = seen.has(finding.file);
82
+ seen.add(finding.file);
83
+ return !duplicate;
84
+ });
85
+ });
@@ -1,12 +1,15 @@
1
- import { relative, resolve } from "node:path";
2
- import { Effect, type FileSystem } from "effect";
1
+ import { relative } from "node:path";
2
+ import { Effect } from "effect";
3
+ import { setManifestFiles } from "#adapters/manifestInventory.ts";
4
+ import { manifestReader } from "#adapters/manifestReader.ts";
3
5
  import { loadConfig, type ResolvedConfig } from "#config/load.ts";
4
6
  import { validOrFail } from "#decoded.ts";
5
7
  import { decodeRegistry, type RegistryEntry } from "#exceptions/registry.ts";
6
8
  import { registryEntries } from "#exceptions/registryEntries.ts";
7
9
  import { SetupFailure } from "#failure.ts";
8
10
  import { collectInventory, type Inventory } from "#inventory/collect.ts";
9
- import { type FilesystemFailure, readOptionalText } from "#inventory/filesystem.ts";
11
+ import type { FilesystemFailure } from "#inventory/filesystem.ts";
12
+ import type { RuleServices } from "#rule.ts";
10
13
  import { type BaselineFile, readBaseline, readInput } from "./baselineFile.ts";
11
14
  import { runRules } from "./runRules.ts";
12
15
  import type { Violation } from "./violation.ts";
@@ -22,17 +25,15 @@ export interface Session {
22
25
  function setup<TValue, TRequirements>(
23
26
  effect: Effect.Effect<TValue, FilesystemFailure, TRequirements>,
24
27
  ): Effect.Effect<TValue, SetupFailure, TRequirements> {
25
- return Effect.mapError(effect, (failure) => new SetupFailure({ message: failure.message }));
28
+ return Effect.mapError(effect, (failure) => new SetupFailure({ cause: failure, message: failure.message }));
26
29
  }
27
30
 
28
31
  export const scan = Effect.fn("Engine.scan")(function* (
29
32
  config: ResolvedConfig,
30
- ): Effect.fn.Return<Pick<Session, "inventory" | "violations">, SetupFailure, FileSystem.FileSystem> {
33
+ ): Effect.fn.Return<Pick<Session, "inventory" | "violations">, SetupFailure, RuleServices> {
31
34
  const inventory = yield* setup(collectInventory(config.root, config));
32
- const services = yield* Effect.context<FileSystem.FileSystem>();
33
- function readText(path: string): Promise<string | undefined> {
34
- return Effect.runPromiseWith(services)(readOptionalText(resolve(config.root, path)));
35
- }
35
+ const readText = yield* manifestReader(config.root);
36
+ setManifestFiles(readText, inventory.manifestFiles);
36
37
  const violations = yield* runRules(config.active, {
37
38
  configFile: relative(config.root, config.file),
38
39
  exceptions: config.exceptions,
@@ -47,7 +48,7 @@ export const scan = Effect.fn("Engine.scan")(function* (
47
48
  export const openSession = Effect.fn("Engine.openSession")(function* (
48
49
  cwd: string,
49
50
  configPath: string | undefined,
50
- ): Effect.fn.Return<Session, SetupFailure, FileSystem.FileSystem> {
51
+ ): Effect.fn.Return<Session, SetupFailure, RuleServices> {
51
52
  const config = yield* loadConfig(cwd, configPath);
52
53
  const registryRaw = yield* readInput(config.root, config.registry);
53
54
  const registry = yield* validOrFail(config.registry, yield* Effect.promise(() => decodeRegistry(registryRaw)));
@@ -31,8 +31,8 @@ export const ExceptionDeclaration = Schema.Struct({
31
31
 
32
32
  export type ExceptionDeclaration = typeof ExceptionDeclaration.Type;
33
33
 
34
- const standard = Schema.toStandardSchemaV1(Schema.Array(ExceptionDeclaration), { parseOptions: { errors: "all", onExcessProperty: "error" } });
34
+ const ExceptionDeclarations = Schema.Array(ExceptionDeclaration);
35
35
 
36
36
  export function decodeExceptions(value: unknown): Promise<Decoded<readonly ExceptionDeclaration[]>> {
37
- return decodeWith(standard, value);
37
+ return decodeWith(ExceptionDeclarations, value);
38
38
  }
@@ -11,12 +11,10 @@ const RegistryEntry = Schema.Struct({
11
11
 
12
12
  export type RegistryEntry = typeof RegistryEntry.Type;
13
13
 
14
- const standard = Schema.toStandardSchemaV1(Schema.fromJsonString(Schema.Array(RegistryEntry)), {
15
- parseOptions: { errors: "all", onExcessProperty: "error" },
16
- });
14
+ const RegistryFile = Schema.fromJsonString(Schema.Array(RegistryEntry));
17
15
 
18
16
  export function decodeRegistry(raw: string | undefined): Promise<Decoded<readonly RegistryEntry[]>> {
19
- return raw === undefined ? Promise.resolve({ _tag: "Valid", value: [] }) : decodeWith(standard, raw);
17
+ return raw === undefined ? Promise.resolve({ _tag: "Valid", value: [] }) : decodeWith(RegistryFile, raw);
20
18
  }
21
19
 
22
20
  export interface StaleRegistryEntry {
package/src/failure.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Data, Runtime } from "effect";
2
2
 
3
- export class SetupFailure extends Data.TaggedError("SetupFailure")<{ readonly message: string }> {
3
+ export class SetupFailure extends Data.TaggedError("SetupFailure")<{ readonly message: string; readonly cause?: unknown }> {
4
+ constructor(options: { readonly message: string; readonly cause?: unknown }) {
5
+ super({ message: options.message });
6
+ Object.defineProperty(this, "cause", { enumerable: false, value: options.cause });
7
+ }
8
+
4
9
  override readonly [Runtime.errorReported] = false;
5
10
  override readonly [Runtime.errorExitCode] = 2;
6
11
  }
@@ -21,7 +21,7 @@ export function git(cwd: string, args: readonly string[]): Effect.Effect<GitResu
21
21
  );
22
22
  return { code: Number(code), stderr, stdout };
23
23
  }),
24
- ).pipe(Effect.mapError((error) => new SetupFailure({ message: `cannot run git: ${error.message}` })));
24
+ ).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run git: ${error.message}` })));
25
25
  }
26
26
 
27
27
  export function gitOrFail(cwd: string, args: readonly string[]): Effect.Effect<string, SetupFailure, Git> {
@@ -19,7 +19,7 @@ export interface HookInstall {
19
19
  }
20
20
 
21
21
  function failed(error: { readonly message: string }): SetupFailure {
22
- return new SetupFailure({ message: error.message });
22
+ return new SetupFailure({ cause: error, message: error.message });
23
23
  }
24
24
 
25
25
  const realPath = Effect.fnUntraced(function* (path: string) {
@@ -32,7 +32,7 @@ const write = Effect.fnUntraced(function* (file: string, text: string) {
32
32
  yield* fs.makeDirectory(dirname(file), { recursive: true }).pipe(
33
33
  Effect.andThen(fs.writeFileString(file, text)),
34
34
  Effect.andThen(fs.chmod(file, 0o755)),
35
- Effect.mapError((error) => new SetupFailure({ message: `cannot write ${file}: ${error.message}` })),
35
+ Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot write ${file}: ${error.message}` })),
36
36
  );
37
37
  });
38
38
 
@@ -1,31 +1,25 @@
1
1
  import { join } from "node:path";
2
- import { Console, Effect, Schema } from "effect";
2
+ import { Console, Effect } from "effect";
3
3
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
5
+ import { manifestReader } from "#adapters/manifestReader.ts";
4
6
  import { lint } from "#cli/lint.ts";
5
7
  import { loadConfig } from "#config/load.ts";
6
- import { decodeWith, validOrFail } from "#decoded.ts";
7
8
  import { GateFailed, SetupFailure } from "#failure.ts";
8
- import { readOptionalText } from "#inventory/filesystem.ts";
9
9
 
10
10
  const COMMIT_AGAIN =
11
11
  "help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.";
12
12
 
13
- const Manifest = Schema.toStandardSchemaV1(
14
- Schema.fromJsonString(
15
- Schema.Struct({
16
- packageManager: Schema.optionalKey(Schema.String),
17
- scripts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
18
- }),
19
- ),
20
- );
21
-
22
13
  const commitScripts = Effect.fnUntraced(function* (root: string) {
23
14
  const file = join(root, "package.json");
24
- const text = yield* readOptionalText(file).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
25
- if (text === undefined) {
15
+ const readText = yield* manifestReader(root);
16
+ const manifest = yield* Effect.tryPromise({
17
+ catch: (cause) => new SetupFailure({ cause, message: `${file} is invalid: ${cause instanceof Error ? cause.message : String(cause)}` }),
18
+ try: () => readPackageManifest(readText, file),
19
+ });
20
+ if (manifest === undefined) {
26
21
  return { manager: "npm", scripts: [] };
27
22
  }
28
- const manifest = yield* validOrFail(file, yield* Effect.promise(() => decodeWith(Manifest, text)));
29
23
  const manager = manifest.packageManager?.split("@")[0] ?? "npm";
30
24
  if (!["npm", "pnpm", "yarn", "bun"].includes(manager)) {
31
25
  return yield* new SetupFailure({ message: `${file}: unsupported packageManager "${manager}". Use npm, pnpm, yarn or bun.` });
@@ -42,7 +36,7 @@ const runScript = Effect.fnUntraced(
42
36
  return Number(yield* child.exitCode);
43
37
  },
44
38
  Effect.scoped,
45
- Effect.mapError((error) => new SetupFailure({ message: `cannot run a pre-commit script: ${error.message}` })),
39
+ Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run a pre-commit script: ${error.message}` })),
46
40
  );
47
41
 
48
42
  export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: string, path: string | undefined) {
@@ -35,7 +35,7 @@ export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (l
35
35
  export const hookStatus = Effect.fn("Hooks.hookStatus")(function* (cwd: string) {
36
36
  const location = yield* hookLocation(cwd);
37
37
  const path = (yield* gitOrFail(cwd, ["rev-parse", "--path-format=absolute", "--git-path", "hooks/pre-commit"])).trim();
38
- const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
38
+ const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
39
39
  if (text === undefined || !isHookShim(text) || (yield* executable(path)) === undefined) {
40
40
  yield* Console.error(
41
41
  `quality: the effective hooks path ${dirname(path)} does not run Quality's pre-commit hook.\nhelp: run \`quality hooks install\` to check commits.`,
@@ -10,16 +10,16 @@ import { isHookShim } from "./shim.ts";
10
10
  export const uninstallHook = Effect.fn("Hooks.uninstallHook")(function* (cwd: string) {
11
11
  const fs = yield* FileSystem.FileSystem;
12
12
  const { file } = yield* hookLocation(cwd);
13
- const existing = yield* Effect.mapError(readOptionalText(file), (failure) => new SetupFailure({ message: failure.message }));
13
+ const existing = yield* Effect.mapError(readOptionalText(file), (failure) => new SetupFailure({ cause: failure, message: failure.message }));
14
14
  if (existing === undefined) {
15
15
  return yield* Console.log(`quality: there is no pre-commit hook at ${file}.`);
16
16
  }
17
17
  if (!isHookShim(existing)) {
18
18
  return yield* Console.error(`quality: kept ${file}: it is not quality's pre-commit hook.`);
19
19
  }
20
- yield* Effect.mapError(fs.remove(file), (error) => new SetupFailure({ message: `cannot remove ${file}: ${error.message}` }));
20
+ yield* Effect.mapError(fs.remove(file), (error) => new SetupFailure({ cause: error, message: `cannot remove ${file}: ${error.message}` }));
21
21
  const local = yield* git(cwd, ["config", "--local", "--get", "core.hooksPath"]);
22
- yield* removeForwarding(file).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
22
+ yield* removeForwarding(file).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
23
23
  if ([dirname(file), forwardingPath(file)].includes(local.stdout.trim())) {
24
24
  yield* gitOrFail(cwd, ["config", "--local", "--unset-all", "core.hooksPath"]);
25
25
  }
@@ -0,0 +1,30 @@
1
+ import { posix } from "node:path";
2
+ import { isTooling } from "./isTooling.ts";
3
+ import type { DeclaredRuntime, Runtime } from "./runtime.ts";
4
+ import { packageOf, type WorkspacePackage } from "./workspace.ts";
5
+
6
+ export interface RuntimePolicy {
7
+ readonly adopted: ReadonlySet<string>;
8
+ readonly declared: ReadonlyMap<string, DeclaredRuntime>;
9
+ readonly executable: ReadonlySet<string>;
10
+ readonly packages: readonly WorkspacePackage[];
11
+ }
12
+
13
+ export function classifyRuntime(policy: RuntimePolicy, path: string): Runtime | undefined {
14
+ const owner = packageOf(policy.packages, path)?.directory ?? ".";
15
+ if (isTooling(owner, path)) {
16
+ return "server";
17
+ }
18
+ const whole = policy.declared.get(owner);
19
+ if (whole !== undefined) {
20
+ return whole;
21
+ }
22
+ if (!policy.adopted.has(owner)) {
23
+ return policy.executable.has(owner) ? "server" : undefined;
24
+ }
25
+ const local = posix.relative(owner, path).replace(/^src\/modules\/[^/]+\//u, "src/");
26
+ if (local.startsWith("src/client/")) {
27
+ return "client";
28
+ }
29
+ return local.startsWith("src/server/") ? "server" : "shared";
30
+ }
@@ -31,8 +31,6 @@ const FenceInput: Schema.Codec<Fence> = Schema.Struct({
31
31
 
32
32
  export const Declarations = Schema.Array(FenceInput);
33
33
 
34
- const standard = Schema.toStandardSchemaV1(Declarations, { parseOptions: { errors: "all", onExcessProperty: "error" } });
35
-
36
34
  export function decodeDeclarations(value: unknown) {
37
- return decodeWith(standard, value);
35
+ return decodeWith(Declarations, value);
38
36
  }
@@ -1,3 +1,5 @@
1
+ import { Schema } from "effect";
2
+
1
3
  function keyPattern(key: string): RegExp {
2
4
  return new RegExp(`^(?:${key}|"${key}"|'${key}')\\s*:`, "u");
3
5
  }
@@ -31,7 +33,7 @@ function scalar(raw: string, key: string): string {
31
33
  const value = raw.trim();
32
34
  if (value.startsWith('"') && value.endsWith('"') && value.length > 1) {
33
35
  try {
34
- return String(JSON.parse(value));
36
+ return Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String))(value);
35
37
  } catch (error) {
36
38
  throw failure(`cannot read "${value}" in ${key}`, error);
37
39
  }