@shivaedev/quality 0.45.0 → 0.47.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 (467) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +13 -7
  3. package/dist/PackageManifest.d.ts +25 -0
  4. package/dist/PackageManifest.d.ts.map +1 -0
  5. package/dist/PackageManifest.js +21 -0
  6. package/dist/PackageManifest.js.map +1 -0
  7. package/dist/adapters/TestOutput.d.ts +8 -0
  8. package/dist/adapters/TestOutput.d.ts.map +1 -0
  9. package/dist/adapters/TestOutput.js +5 -0
  10. package/dist/adapters/TestOutput.js.map +1 -0
  11. package/dist/adapters/biome/run.d.ts +17 -0
  12. package/dist/adapters/biome/run.d.ts.map +1 -0
  13. package/dist/adapters/biome/run.js +24 -0
  14. package/dist/adapters/biome/run.js.map +1 -0
  15. package/dist/adapters/knip/configuration.d.ts.map +1 -1
  16. package/dist/adapters/knip/configuration.js +2 -9
  17. package/dist/adapters/knip/configuration.js.map +1 -1
  18. package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
  19. package/dist/adapters/knip/entryPointFindings.js +2 -1
  20. package/dist/adapters/knip/entryPointFindings.js.map +1 -1
  21. package/dist/adapters/knip/run.d.ts +3 -1
  22. package/dist/adapters/knip/run.d.ts.map +1 -1
  23. package/dist/adapters/knip/run.js +8 -8
  24. package/dist/adapters/knip/run.js.map +1 -1
  25. package/dist/adapters/manifestInventory.d.ts +23 -0
  26. package/dist/adapters/manifestInventory.d.ts.map +1 -0
  27. package/dist/adapters/manifestInventory.js +63 -0
  28. package/dist/adapters/manifestInventory.js.map +1 -0
  29. package/dist/adapters/manifestReader.d.ts +3 -0
  30. package/dist/adapters/manifestReader.d.ts.map +1 -0
  31. package/dist/adapters/manifestReader.js +8 -0
  32. package/dist/adapters/manifestReader.js.map +1 -0
  33. package/dist/adapters/testProjects.d.ts.map +1 -0
  34. package/dist/{testProjects.js → adapters/testProjects.js} +4 -3
  35. package/dist/adapters/testProjects.js.map +1 -0
  36. package/dist/appTestConfig.d.ts +1 -1
  37. package/dist/appTestConfig.d.ts.map +1 -1
  38. package/dist/appTestConfig.js +1 -1
  39. package/dist/appTestConfig.js.map +1 -1
  40. package/dist/baseline/format.js +2 -2
  41. package/dist/baseline/format.js.map +1 -1
  42. package/dist/baseline/installDriver.d.ts +2 -1
  43. package/dist/baseline/installDriver.d.ts.map +1 -1
  44. package/dist/baseline/installDriver.js.map +1 -1
  45. package/dist/baseline/legacy.js +2 -2
  46. package/dist/baseline/legacy.js.map +1 -1
  47. package/dist/baseline/merge.js +1 -1
  48. package/dist/baseline/merge.js.map +1 -1
  49. package/dist/baseline/shards.js +1 -1
  50. package/dist/baseline/shards.js.map +1 -1
  51. package/dist/biome/exceptionConfig.d.ts +7 -1
  52. package/dist/biome/exceptionConfig.d.ts.map +1 -1
  53. package/dist/biome/exceptionConfig.js +11 -25
  54. package/dist/biome/exceptionConfig.js.map +1 -1
  55. package/dist/biome/recommendedRules.d.ts +2 -1
  56. package/dist/biome/recommendedRules.d.ts.map +1 -1
  57. package/dist/biome/recommendedRules.js +11 -14
  58. package/dist/biome/recommendedRules.js.map +1 -1
  59. package/dist/biome/relocateConfig.d.ts +6 -0
  60. package/dist/biome/relocateConfig.d.ts.map +1 -0
  61. package/dist/biome/relocateConfig.js +49 -0
  62. package/dist/biome/relocateConfig.js.map +1 -0
  63. package/dist/biome/report.d.ts +28 -3
  64. package/dist/biome/report.d.ts.map +1 -1
  65. package/dist/biome/report.js +15 -12
  66. package/dist/biome/report.js.map +1 -1
  67. package/dist/biome/withoutEntryPointImports.d.ts.map +1 -1
  68. package/dist/biome/withoutEntryPointImports.js +2 -12
  69. package/dist/biome/withoutEntryPointImports.js.map +1 -1
  70. package/dist/cli/baseline.d.ts +4 -3
  71. package/dist/cli/baseline.d.ts.map +1 -1
  72. package/dist/cli/baseline.js.map +1 -1
  73. package/dist/cli/fix.d.ts +4 -3
  74. package/dist/cli/fix.d.ts.map +1 -1
  75. package/dist/cli/fix.js +3 -9
  76. package/dist/cli/fix.js.map +1 -1
  77. package/dist/cli/lint.d.ts +3 -2
  78. package/dist/cli/lint.d.ts.map +1 -1
  79. package/dist/cli/lint.js.map +1 -1
  80. package/dist/cli/migrateBaseline.d.ts +3 -2
  81. package/dist/cli/migrateBaseline.d.ts.map +1 -1
  82. package/dist/cli/migrateBaseline.js +2 -2
  83. package/dist/cli/migrateBaseline.js.map +1 -1
  84. package/dist/cli/migrateExceptions.d.ts.map +1 -1
  85. package/dist/cli/migrateExceptions.js +6 -4
  86. package/dist/cli/migrateExceptions.js.map +1 -1
  87. package/dist/cli/program.d.ts +1 -1
  88. package/dist/cli/program.d.ts.map +1 -1
  89. package/dist/cli/runMain.d.ts +3 -3
  90. package/dist/cli/runMain.d.ts.map +1 -1
  91. package/dist/cli/runMain.js.map +1 -1
  92. package/dist/cli/shrink.d.ts +3 -3
  93. package/dist/cli/shrink.d.ts.map +1 -1
  94. package/dist/cli/shrink.js.map +1 -1
  95. package/dist/config/decode.d.ts +1 -1
  96. package/dist/config/decode.d.ts.map +1 -1
  97. package/dist/config/decode.js +1 -2
  98. package/dist/config/decode.js.map +1 -1
  99. package/dist/config/load.js +2 -2
  100. package/dist/config/load.js.map +1 -1
  101. package/dist/config/resolve.d.ts +1 -1
  102. package/dist/decoded.d.ts +2 -3
  103. package/dist/decoded.d.ts.map +1 -1
  104. package/dist/decoded.js +6 -4
  105. package/dist/decoded.js.map +1 -1
  106. package/dist/docs/documentedModule.d.ts +0 -2
  107. package/dist/docs/documentedModule.d.ts.map +1 -1
  108. package/dist/docs/documentedModule.js +0 -3
  109. package/dist/docs/documentedModule.js.map +1 -1
  110. package/dist/docs/importFindings.d.ts.map +1 -1
  111. package/dist/docs/importFindings.js +0 -3
  112. package/dist/docs/importFindings.js.map +1 -1
  113. package/dist/engine/baselineFile.js +2 -2
  114. package/dist/engine/baselineFile.js.map +1 -1
  115. package/dist/engine/runRules.d.ts +3 -4
  116. package/dist/engine/runRules.d.ts.map +1 -1
  117. package/dist/engine/runRules.js +23 -8
  118. package/dist/engine/runRules.js.map +1 -1
  119. package/dist/engine/session.d.ts +4 -3
  120. package/dist/engine/session.d.ts.map +1 -1
  121. package/dist/engine/session.js +6 -7
  122. package/dist/engine/session.js.map +1 -1
  123. package/dist/exceptions/declaration.js +2 -2
  124. package/dist/exceptions/declaration.js.map +1 -1
  125. package/dist/exceptions/registry.d.ts.map +1 -1
  126. package/dist/exceptions/registry.js +2 -4
  127. package/dist/exceptions/registry.js.map +1 -1
  128. package/dist/failure.d.ts +5 -0
  129. package/dist/failure.d.ts.map +1 -1
  130. package/dist/failure.js +4 -0
  131. package/dist/failure.js.map +1 -1
  132. package/dist/git/base.d.ts +2 -1
  133. package/dist/git/base.d.ts.map +1 -1
  134. package/dist/git/base.js +6 -6
  135. package/dist/git/base.js.map +1 -1
  136. package/dist/git/command.d.ts +2 -3
  137. package/dist/git/command.d.ts.map +1 -1
  138. package/dist/git/command.js +6 -6
  139. package/dist/git/command.js.map +1 -1
  140. package/dist/git/history.d.ts +2 -2
  141. package/dist/git/history.d.ts.map +1 -1
  142. package/dist/git/history.js.map +1 -1
  143. package/dist/hooks/forwarding.js +2 -2
  144. package/dist/hooks/install.js +2 -2
  145. package/dist/hooks/install.js.map +1 -1
  146. package/dist/hooks/location.js +3 -3
  147. package/dist/hooks/preCommit.d.ts +1 -2
  148. package/dist/hooks/preCommit.d.ts.map +1 -1
  149. package/dist/hooks/preCommit.js +10 -11
  150. package/dist/hooks/preCommit.js.map +1 -1
  151. package/dist/hooks/status.js +1 -1
  152. package/dist/hooks/status.js.map +1 -1
  153. package/dist/hooks/uninstall.js +5 -5
  154. package/dist/hooks/uninstall.js.map +1 -1
  155. package/dist/imports/classifyRuntime.d.ts +10 -0
  156. package/dist/imports/classifyRuntime.d.ts.map +1 -0
  157. package/dist/imports/classifyRuntime.js +22 -0
  158. package/dist/imports/classifyRuntime.js.map +1 -0
  159. package/dist/imports/fences/declarations.d.ts.map +1 -1
  160. package/dist/imports/fences/declarations.js +1 -2
  161. package/dist/imports/fences/declarations.js.map +1 -1
  162. package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
  163. package/dist/imports/pnpmWorkspacePatterns.js +2 -1
  164. package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
  165. package/dist/imports/runtime.d.ts +4 -3
  166. package/dist/imports/runtime.d.ts.map +1 -1
  167. package/dist/imports/runtime.js +35 -64
  168. package/dist/imports/runtime.js.map +1 -1
  169. package/dist/imports/withoutGenerated.d.ts +4 -2
  170. package/dist/imports/withoutGenerated.d.ts.map +1 -1
  171. package/dist/imports/withoutGenerated.js +22 -35
  172. package/dist/imports/withoutGenerated.js.map +1 -1
  173. package/dist/imports/workspace.d.ts.map +1 -1
  174. package/dist/imports/workspace.js +9 -19
  175. package/dist/imports/workspace.js.map +1 -1
  176. package/dist/inventory/collect.d.ts +5 -3
  177. package/dist/inventory/collect.d.ts.map +1 -1
  178. package/dist/inventory/collect.js +2 -1
  179. package/dist/inventory/collect.js.map +1 -1
  180. package/dist/inventory/filesystem.d.ts.map +1 -1
  181. package/dist/inventory/filesystem.js +2 -8
  182. package/dist/inventory/filesystem.js.map +1 -1
  183. package/dist/inventory/shadcnFolders.d.ts +4 -2
  184. package/dist/inventory/shadcnFolders.d.ts.map +1 -1
  185. package/dist/inventory/shadcnFolders.js.map +1 -1
  186. package/dist/inventory/trackedPaths.d.ts +5 -3
  187. package/dist/inventory/trackedPaths.d.ts.map +1 -1
  188. package/dist/inventory/trackedPaths.js +22 -24
  189. package/dist/inventory/trackedPaths.js.map +1 -1
  190. package/dist/inventory/walk.d.ts +5 -3
  191. package/dist/inventory/walk.d.ts.map +1 -1
  192. package/dist/inventory/walk.js +3 -9
  193. package/dist/inventory/walk.js.map +1 -1
  194. package/dist/manifests/entryPoints.d.ts.map +1 -1
  195. package/dist/manifests/entryPoints.js +2 -12
  196. package/dist/manifests/entryPoints.js.map +1 -1
  197. package/dist/manifests/sorted.d.ts +6 -5
  198. package/dist/manifests/sorted.d.ts.map +1 -1
  199. package/dist/manifests/sorted.js +14 -8
  200. package/dist/manifests/sorted.js.map +1 -1
  201. package/dist/naming/packageLayout.d.ts.map +1 -1
  202. package/dist/naming/packageLayout.js +2 -12
  203. package/dist/naming/packageLayout.js.map +1 -1
  204. package/dist/rule.d.ts +15 -10
  205. package/dist/rule.d.ts.map +1 -1
  206. package/dist/rule.js +9 -1
  207. package/dist/rule.js.map +1 -1
  208. package/dist/rules/biome.d.ts.map +1 -1
  209. package/dist/rules/biome.js +7 -4
  210. package/dist/rules/biome.js.map +1 -1
  211. package/dist/rules/builtIn.d.ts +14 -14
  212. package/dist/rules/builtIn.d.ts.map +1 -1
  213. package/dist/rules/builtIn.js +2 -0
  214. package/dist/rules/builtIn.js.map +1 -1
  215. package/dist/rules/comments/maxPerFile.d.ts +1 -1
  216. package/dist/rules/comments/maxPerFile.d.ts.map +1 -1
  217. package/dist/rules/comments/noBanner.d.ts +1 -1
  218. package/dist/rules/comments/noBanner.d.ts.map +1 -1
  219. package/dist/rules/comments/noEnvironmentPragma.d.ts +1 -1
  220. package/dist/rules/comments/noEnvironmentPragma.d.ts.map +1 -1
  221. package/dist/rules/comments/noEnvironmentPragma.js +1 -1
  222. package/dist/rules/comments/noEnvironmentPragma.js.map +1 -1
  223. package/dist/rules/comments/noJsdoc.d.ts +1 -1
  224. package/dist/rules/comments/noJsdoc.d.ts.map +1 -1
  225. package/dist/rules/comments/noLineReference.d.ts +1 -1
  226. package/dist/rules/comments/noLineReference.d.ts.map +1 -1
  227. package/dist/rules/comments/noPrReference.d.ts +1 -1
  228. package/dist/rules/comments/noPrReference.d.ts.map +1 -1
  229. package/dist/rules/comments/noTodo.d.ts +1 -1
  230. package/dist/rules/comments/noTodo.d.ts.map +1 -1
  231. package/dist/rules/docs/references.d.ts +1 -1
  232. package/dist/rules/docs/references.d.ts.map +1 -1
  233. package/dist/rules/docs/references.js +5 -8
  234. package/dist/rules/docs/references.js.map +1 -1
  235. package/dist/rules/docs/unversionedInstalls.d.ts +1 -1
  236. package/dist/rules/docs/unversionedInstalls.d.ts.map +1 -1
  237. package/dist/rules/docs/unversionedInstalls.js +1 -1
  238. package/dist/rules/docs/unversionedInstalls.js.map +1 -1
  239. package/dist/rules/effect/boundary.d.ts +1 -1
  240. package/dist/rules/effect/boundary.d.ts.map +1 -1
  241. package/dist/rules/effect/serviceParameters.d.ts +1 -1
  242. package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
  243. package/dist/rules/effect/serviceTypes.d.ts.map +1 -1
  244. package/dist/rules/effect/serviceTypes.js +10 -0
  245. package/dist/rules/effect/serviceTypes.js.map +1 -1
  246. package/dist/rules/files/distinctCase.d.ts +1 -1
  247. package/dist/rules/files/distinctCase.d.ts.map +1 -1
  248. package/dist/rules/files/folderNames.d.ts +1 -1
  249. package/dist/rules/files/folderNames.d.ts.map +1 -1
  250. package/dist/rules/files/namedAfterExport.d.ts +1 -1
  251. package/dist/rules/files/namedAfterExport.d.ts.map +1 -1
  252. package/dist/rules/files/otherNames.d.ts +1 -1
  253. package/dist/rules/files/otherNames.d.ts.map +1 -1
  254. package/dist/rules/files/packageImports.d.ts.map +1 -1
  255. package/dist/rules/files/packageImports.js +2 -13
  256. package/dist/rules/files/packageImports.js.map +1 -1
  257. package/dist/rules/imports/aliased.d.ts +1 -1
  258. package/dist/rules/imports/aliased.d.ts.map +1 -1
  259. package/dist/rules/imports/cycles.d.ts +1 -1
  260. package/dist/rules/imports/cycles.d.ts.map +1 -1
  261. package/dist/rules/imports/fences.d.ts +1 -1
  262. package/dist/rules/imports/fences.d.ts.map +1 -1
  263. package/dist/rules/imports/manifest.d.ts +1 -1
  264. package/dist/rules/imports/manifest.d.ts.map +1 -1
  265. package/dist/rules/imports/manifest.js +14 -32
  266. package/dist/rules/imports/manifest.js.map +1 -1
  267. package/dist/rules/imports/noTestCode.d.ts +1 -1
  268. package/dist/rules/imports/noTestCode.d.ts.map +1 -1
  269. package/dist/rules/imports/resolvable.d.ts +1 -1
  270. package/dist/rules/imports/resolvable.d.ts.map +1 -1
  271. package/dist/rules/imports/resolvable.js +4 -3
  272. package/dist/rules/imports/resolvable.js.map +1 -1
  273. package/dist/rules/imports/runtime.d.ts +1 -1
  274. package/dist/rules/imports/runtime.d.ts.map +1 -1
  275. package/dist/rules/imports/runtime.js +29 -25
  276. package/dist/rules/imports/runtime.js.map +1 -1
  277. package/dist/rules/manifestsApplication.d.ts +1 -1
  278. package/dist/rules/manifestsApplication.d.ts.map +1 -1
  279. package/dist/rules/manifestsApplication.js +2 -12
  280. package/dist/rules/manifestsApplication.js.map +1 -1
  281. package/dist/rules/manifestsExportsShape.d.ts +1 -1
  282. package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
  283. package/dist/rules/manifestsExportsShape.js +12 -7
  284. package/dist/rules/manifestsExportsShape.js.map +1 -1
  285. package/dist/rules/manifestsSorted.d.ts +1 -1
  286. package/dist/rules/manifestsSorted.d.ts.map +1 -1
  287. package/dist/rules/manifestsSorted.js +10 -14
  288. package/dist/rules/manifestsSorted.js.map +1 -1
  289. package/dist/rules/manifestsSourceFirst.d.ts +1 -1
  290. package/dist/rules/manifestsSourceFirst.d.ts.map +1 -1
  291. package/dist/rules/manifestsSourceFirst.js +20 -23
  292. package/dist/rules/manifestsSourceFirst.js.map +1 -1
  293. package/dist/rules/manifestsValid.d.ts +2 -0
  294. package/dist/rules/manifestsValid.d.ts.map +1 -0
  295. package/dist/rules/manifestsValid.js +10 -0
  296. package/dist/rules/manifestsValid.js.map +1 -0
  297. package/dist/rules/maxDepth.d.ts +1 -1
  298. package/dist/rules/maxDepth.d.ts.map +1 -1
  299. package/dist/rules/maxLines.d.ts +1 -1
  300. package/dist/rules/maxLines.d.ts.map +1 -1
  301. package/dist/rules/noBarrel.d.ts +1 -1
  302. package/dist/rules/noBarrel.d.ts.map +1 -1
  303. package/dist/rules/react/jsxConditionals.d.ts +1 -1
  304. package/dist/rules/react/jsxConditionals.d.ts.map +1 -1
  305. package/dist/rules/stories/authSql.d.ts +1 -1
  306. package/dist/rules/stories/authSql.d.ts.map +1 -1
  307. package/dist/rules/stories/domainOutcomes.d.ts +1 -1
  308. package/dist/rules/stories/domainOutcomes.d.ts.map +1 -1
  309. package/dist/rules/stories/domainOutcomes.js +3 -3
  310. package/dist/rules/stories/domainOutcomes.js.map +1 -1
  311. package/dist/rules/stories/engine.d.ts +1 -1
  312. package/dist/rules/stories/engine.d.ts.map +1 -1
  313. package/dist/rules/stories/groupedOutcomes.d.ts +1 -1
  314. package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -1
  315. package/dist/rules/stories/groupedOutcomes.js +2 -2
  316. package/dist/rules/stories/groupedOutcomes.js.map +1 -1
  317. package/dist/rules/stories/httpStatus.d.ts +1 -1
  318. package/dist/rules/stories/httpStatus.d.ts.map +1 -1
  319. package/dist/rules/stories/namedValues.d.ts +1 -1
  320. package/dist/rules/stories/namedValues.d.ts.map +1 -1
  321. package/dist/rules/stories/noExpect.d.ts +1 -1
  322. package/dist/rules/stories/noExpect.d.ts.map +1 -1
  323. package/dist/rules/stories/noLimitImports.d.ts +1 -1
  324. package/dist/rules/stories/noLimitImports.d.ts.map +1 -1
  325. package/dist/rules/stories/prerequisites.d.ts.map +1 -1
  326. package/dist/rules/stories/prerequisites.js +3 -6
  327. package/dist/rules/stories/prerequisites.js.map +1 -1
  328. package/dist/rules/stories/queueSql.d.ts +1 -1
  329. package/dist/rules/stories/queueSql.d.ts.map +1 -1
  330. package/dist/rules/stories/setup.d.ts +1 -1
  331. package/dist/rules/stories/setup.d.ts.map +1 -1
  332. package/dist/rules/stories/sources.d.ts +4 -0
  333. package/dist/rules/stories/sources.d.ts.map +1 -0
  334. package/dist/rules/stories/{specSources.js → sources.js} +6 -6
  335. package/dist/rules/stories/sources.js.map +1 -0
  336. package/dist/rules/stories/specHelpers.d.ts +1 -1
  337. package/dist/rules/stories/specHelpers.d.ts.map +1 -1
  338. package/dist/rules/stories/specs.d.ts +1 -1
  339. package/dist/rules/stories/specs.d.ts.map +1 -1
  340. package/dist/rules/stories/waitOnEvents.d.ts +1 -1
  341. package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
  342. package/dist/rules/stories/waitOnEvents.js +4 -4
  343. package/dist/rules/stories/waitOnEvents.js.map +1 -1
  344. package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -1
  345. package/dist/rules/suppressions/biome/declarations.js +2 -4
  346. package/dist/rules/suppressions/biome/declarations.js.map +1 -1
  347. package/dist/rules/suppressions/biome/resolvePackage.d.ts.map +1 -1
  348. package/dist/rules/suppressions/biome/resolvePackage.js +3 -15
  349. package/dist/rules/suppressions/biome/resolvePackage.js.map +1 -1
  350. package/dist/rules/suppressions/biomeOverrides.d.ts +1 -1
  351. package/dist/rules/suppressions/biomeOverrides.d.ts.map +1 -1
  352. package/dist/rules/suppressions/biomeRecommended.d.ts +6 -3
  353. package/dist/rules/suppressions/biomeRecommended.d.ts.map +1 -1
  354. package/dist/rules/suppressions/biomeRecommended.js +10 -7
  355. package/dist/rules/suppressions/biomeRecommended.js.map +1 -1
  356. package/dist/rules/suppressions/noDoubleCast.d.ts +1 -1
  357. package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
  358. package/dist/rules/suppressions/noIgnoreDeprecations.d.ts +1 -1
  359. package/dist/rules/suppressions/noIgnoreDeprecations.d.ts.map +1 -1
  360. package/dist/rules/suppressions/noIgnoreDeprecations.js +7 -7
  361. package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
  362. package/dist/rules/suppressions/noInline.d.ts +1 -1
  363. package/dist/rules/suppressions/noInline.d.ts.map +1 -1
  364. package/dist/rules/test-names/colocated.d.ts +1 -1
  365. package/dist/rules/test-names/colocated.d.ts.map +1 -1
  366. package/dist/rules/test-names/follow.d.ts +1 -1
  367. package/dist/rules/test-names/follow.d.ts.map +1 -1
  368. package/dist/rules/unusedCode.d.ts +1 -1
  369. package/dist/rules/unusedCode.d.ts.map +1 -1
  370. package/package.json +2 -9
  371. package/src/PackageManifest.ts +24 -0
  372. package/src/adapters/TestOutput.ts +9 -0
  373. package/src/adapters/biome/run.ts +45 -0
  374. package/src/adapters/knip/configuration.ts +2 -10
  375. package/src/adapters/knip/entryPointFindings.ts +2 -1
  376. package/src/adapters/knip/run.ts +42 -44
  377. package/src/adapters/manifestInventory.ts +87 -0
  378. package/src/adapters/manifestReader.ts +11 -0
  379. package/src/{testProjects.ts → adapters/testProjects.ts} +4 -3
  380. package/src/appTestConfig.ts +1 -1
  381. package/src/baseline/format.ts +2 -2
  382. package/src/baseline/installDriver.ts +6 -2
  383. package/src/baseline/legacy.ts +2 -2
  384. package/src/baseline/merge.ts +1 -1
  385. package/src/baseline/shards.ts +1 -1
  386. package/src/biome/exceptionConfig.ts +19 -34
  387. package/src/biome/recommendedRules.ts +19 -17
  388. package/src/biome/relocateConfig.ts +59 -0
  389. package/src/biome/report.ts +21 -14
  390. package/src/biome/withoutEntryPointImports.ts +2 -12
  391. package/src/cli/baseline.ts +3 -2
  392. package/src/cli/fix.ts +16 -18
  393. package/src/cli/lint.ts +3 -2
  394. package/src/cli/migrateBaseline.ts +4 -3
  395. package/src/cli/migrateExceptions.ts +6 -4
  396. package/src/cli/runMain.ts +4 -2
  397. package/src/cli/shrink.ts +4 -4
  398. package/src/config/decode.ts +1 -3
  399. package/src/config/load.ts +2 -2
  400. package/src/decoded.ts +9 -5
  401. package/src/docs/documentedModule.ts +1 -4
  402. package/src/docs/importFindings.ts +0 -5
  403. package/src/engine/baselineFile.ts +2 -2
  404. package/src/engine/runRules.ts +34 -15
  405. package/src/engine/session.ts +14 -11
  406. package/src/exceptions/declaration.ts +2 -2
  407. package/src/exceptions/registry.ts +2 -4
  408. package/src/failure.ts +6 -1
  409. package/src/git/base.ts +16 -13
  410. package/src/git/command.ts +10 -9
  411. package/src/git/history.ts +6 -2
  412. package/src/hooks/forwarding.ts +2 -2
  413. package/src/hooks/install.ts +2 -2
  414. package/src/hooks/location.ts +3 -3
  415. package/src/hooks/preCommit.ts +10 -16
  416. package/src/hooks/status.ts +1 -1
  417. package/src/hooks/uninstall.ts +5 -5
  418. package/src/imports/classifyRuntime.ts +30 -0
  419. package/src/imports/fences/declarations.ts +1 -3
  420. package/src/imports/pnpmWorkspacePatterns.ts +3 -1
  421. package/src/imports/runtime.ts +48 -60
  422. package/src/imports/withoutGenerated.ts +25 -38
  423. package/src/imports/workspace.ts +9 -20
  424. package/src/inventory/collect.ts +7 -4
  425. package/src/inventory/filesystem.ts +2 -10
  426. package/src/inventory/shadcnFolders.ts +4 -2
  427. package/src/inventory/trackedPaths.ts +22 -24
  428. package/src/inventory/walk.ts +7 -11
  429. package/src/manifests/entryPoints.ts +2 -12
  430. package/src/manifests/sorted.ts +24 -10
  431. package/src/naming/packageLayout.ts +2 -12
  432. package/src/rule.ts +38 -19
  433. package/src/rules/biome.ts +9 -5
  434. package/src/rules/builtIn.ts +2 -0
  435. package/src/rules/comments/noEnvironmentPragma.ts +1 -1
  436. package/src/rules/docs/references.ts +8 -10
  437. package/src/rules/docs/unversionedInstalls.ts +1 -1
  438. package/src/rules/effect/serviceTypes.ts +13 -0
  439. package/src/rules/files/packageImports.ts +2 -13
  440. package/src/rules/imports/manifest.ts +15 -32
  441. package/src/rules/imports/resolvable.ts +4 -3
  442. package/src/rules/imports/runtime.ts +41 -35
  443. package/src/rules/manifestsApplication.ts +2 -12
  444. package/src/rules/manifestsExportsShape.ts +11 -8
  445. package/src/rules/manifestsSorted.ts +13 -16
  446. package/src/rules/manifestsSourceFirst.ts +24 -24
  447. package/src/rules/manifestsValid.ts +14 -0
  448. package/src/rules/stories/domainOutcomes.ts +3 -4
  449. package/src/rules/stories/groupedOutcomes.ts +2 -3
  450. package/src/rules/stories/prerequisites.ts +4 -8
  451. package/src/rules/stories/{specSources.ts → sources.ts} +5 -5
  452. package/src/rules/stories/waitOnEvents.ts +4 -5
  453. package/src/rules/suppressions/biome/declarations.ts +2 -4
  454. package/src/rules/suppressions/biome/resolvePackage.ts +5 -21
  455. package/src/rules/suppressions/biomeRecommended.ts +14 -9
  456. package/src/rules/suppressions/noIgnoreDeprecations.ts +11 -8
  457. package/dist/biome/run.d.ts +0 -8
  458. package/dist/biome/run.d.ts.map +0 -1
  459. package/dist/biome/run.js +0 -28
  460. package/dist/biome/run.js.map +0 -1
  461. package/dist/rules/stories/specSources.d.ts +0 -4
  462. package/dist/rules/stories/specSources.d.ts.map +0 -1
  463. package/dist/rules/stories/specSources.js.map +0 -1
  464. package/dist/testProjects.d.ts.map +0 -1
  465. package/dist/testProjects.js.map +0 -1
  466. package/src/biome/run.ts +0 -41
  467. /package/dist/{testProjects.d.ts → adapters/testProjects.d.ts} +0 -0
package/src/rule.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Effect, type FileSystem } from "effect";
2
+ import type { ChildProcessSpawner } from "effect/process";
1
3
  import type { Bivariant } from "@shivaedev/types/Bivariant.ts";
2
4
  import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
3
5
  import { describeIssue, type StandardSchemaV1 } from "./standardSchema.ts";
@@ -25,6 +27,7 @@ export interface RuleInputs {
25
27
  readonly files: readonly string[];
26
28
  readonly readText: (path: string) => Promise<string | undefined>;
27
29
  readonly root: string;
30
+ readonly signal?: AbortSignal;
28
31
  readonly sources: readonly SourceFile[];
29
32
  }
30
33
 
@@ -32,31 +35,35 @@ export interface RuleContext<TOptions> extends RuleInputs {
32
35
  readonly options: TOptions;
33
36
  }
34
37
 
35
- export type Configured =
38
+ export type RuleServices = FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner;
39
+
40
+ export type RuleCheck<TServices = RuleServices> = (inputs: RuleInputs) => Effect.Effect<Findings, unknown, TServices>;
41
+
42
+ export type Configured<TServices = RuleServices> =
36
43
  | { readonly _tag: "Invalid"; readonly issues: readonly string[] }
37
- | { readonly _tag: "Ready"; readonly check: (inputs: RuleInputs) => Promise<Findings> };
44
+ | { readonly _tag: "Ready"; readonly check: RuleCheck<TServices> };
38
45
 
39
- export interface Rule<TId extends string = string, TInput = unknown> {
46
+ export interface Rule<TId extends string = string, TInput = unknown, TServices = RuleServices> {
40
47
  // Bivariance keeps rules with different options in one list; configure validates its input at runtime.
41
- configure: Bivariant<(options: TInput | undefined) => Promise<Configured>>;
48
+ configure: Bivariant<(options: TInput | undefined) => Promise<Configured<TServices>>>;
42
49
  readonly description: string;
43
50
  readonly family?: boolean;
44
51
  readonly id: TId;
45
52
  readonly registrable?: boolean;
46
53
  }
47
54
 
48
- interface RuleDefinition<TId extends string, TOptions> {
49
- readonly check: (context: RuleContext<TOptions>) => Findings | PromiseLike<Findings>;
55
+ interface RuleDefinition<TId extends string, TOptions, TServices> {
56
+ readonly check: (context: RuleContext<TOptions>) => Findings | PromiseLike<Findings> | Effect.Effect<Findings, unknown, TServices>;
50
57
  readonly description: string;
51
58
  readonly id: TId;
52
59
  readonly registrable?: false;
53
60
  }
54
61
 
55
- interface RuleDefinitionWithOptions<TId extends string, TInput, TOptions> extends RuleDefinition<TId, TOptions> {
62
+ interface RuleDefinitionWithOptions<TId extends string, TInput, TOptions, TServices> extends RuleDefinition<TId, TOptions, TServices> {
56
63
  readonly options: StandardSchemaV1<TInput, TOptions>;
57
64
  }
58
65
 
59
- interface RuleDefinitionWithoutOptions<TId extends string> extends RuleDefinition<TId, undefined> {
66
+ interface RuleDefinitionWithoutOptions<TId extends string, TServices> extends RuleDefinition<TId, undefined, TServices> {
60
67
  readonly options?: undefined;
61
68
  }
62
69
 
@@ -68,28 +75,40 @@ const noOptions: StandardSchemaV1<undefined, undefined> = {
68
75
  },
69
76
  };
70
77
 
71
- function configureWith<TInput, TOptions>(
78
+ function configureWith<TInput, TOptions, TServices>(
72
79
  schema: StandardSchemaV1<TInput, TOptions>,
73
- check: RuleDefinition<string, TOptions>["check"],
80
+ check: RuleDefinition<string, TOptions, TServices>["check"],
74
81
  absent: unknown,
75
82
  ) {
76
- return async (options: unknown): Promise<Configured> => {
83
+ return async (options: unknown): Promise<Configured<TServices>> => {
77
84
  const result = await schema["~standard"].validate(options ?? absent);
78
85
  if (result.issues !== undefined) {
79
86
  return { _tag: "Invalid", issues: result.issues.map(describeIssue) };
80
87
  }
81
88
  const value = result.value;
82
- return { _tag: "Ready", check: async (inputs) => check({ ...inputs, options: value }) };
89
+ return {
90
+ _tag: "Ready",
91
+ check: (inputs) =>
92
+ Effect.scoped(
93
+ Effect.gen(function* () {
94
+ const signal = yield* Effect.abortSignal;
95
+ const checked = check({ ...inputs, options: value, signal });
96
+ return yield* Effect.isEffect(checked) ? checked : Effect.promise(() => Promise.resolve(checked));
97
+ }),
98
+ ),
99
+ };
83
100
  };
84
101
  }
85
102
 
86
- export function defineRule<const TId extends string, TInput, TOptions>(
87
- definition: RuleDefinitionWithOptions<TId, TInput, TOptions>,
88
- ): Rule<TId, TInput>;
89
- export function defineRule<const TId extends string>(definition: RuleDefinitionWithoutOptions<TId>): Rule<TId, undefined>;
90
- export function defineRule<const TId extends string, TInput, TOptions>(
91
- definition: RuleDefinitionWithOptions<TId, TInput, TOptions> | RuleDefinitionWithoutOptions<TId>,
92
- ): Rule<TId, TInput> | Rule<TId, undefined> {
103
+ export function defineRule<const TId extends string, TInput, TOptions, TServices = never>(
104
+ definition: RuleDefinitionWithOptions<TId, TInput, TOptions, TServices>,
105
+ ): Rule<TId, TInput, TServices>;
106
+ export function defineRule<const TId extends string, TServices = never>(
107
+ definition: RuleDefinitionWithoutOptions<TId, TServices>,
108
+ ): Rule<TId, undefined, TServices>;
109
+ export function defineRule<const TId extends string, TInput, TOptions, TServices = never>(
110
+ definition: RuleDefinitionWithOptions<TId, TInput, TOptions, TServices> | RuleDefinitionWithoutOptions<TId, TServices>,
111
+ ): Rule<TId, TInput, TServices> | Rule<TId, undefined, TServices> {
93
112
  const configure =
94
113
  definition.options === undefined
95
114
  ? configureWith(noOptions, definition.check, undefined)
@@ -1,3 +1,4 @@
1
+ import { Effect } from "effect";
1
2
  import { biomeReport, type Diagnostic, FAILING } from "#biome/report.ts";
2
3
  import { withoutEntryPointImports } from "#biome/withoutEntryPointImports.ts";
3
4
  import { defineRule, type Finding, type Rule, type RuleInputs } from "#rule.ts";
@@ -42,11 +43,14 @@ async function presetFinding(readText: RuleInputs["readText"]): Promise<readonly
42
43
  }
43
44
 
44
45
  const bridge = defineRule({
45
- check: async ({ exceptions, readText, root }) => {
46
- const [preset, report] = await Promise.all([presetFinding(readText), biomeReport(root, ["check"], exceptions)]);
47
- const failing = report.diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
48
- return [...preset, ...(await withoutEntryPointImports(readText, failing)).map(findingOf)];
49
- },
46
+ check: ({ exceptions, readText, root }) =>
47
+ Effect.gen(function* () {
48
+ const [preset, report] = yield* Effect.all([Effect.promise(() => presetFinding(readText)), biomeReport(root, ["check"], exceptions)], {
49
+ concurrency: "unbounded",
50
+ });
51
+ const failing = report.diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
52
+ return [...preset, ...(yield* Effect.promise(() => withoutEntryPointImports(readText, failing))).map(findingOf)];
53
+ }),
50
54
  description:
51
55
  "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.",
52
56
  id: "biome",
@@ -46,6 +46,7 @@ import { manifestsApplication } from "./manifestsApplication.ts";
46
46
  import { manifestsExportsShape } from "./manifestsExportsShape.ts";
47
47
  import { manifestsSorted } from "./manifestsSorted.ts";
48
48
  import { manifestsSourceFirst } from "./manifestsSourceFirst.ts";
49
+ import { manifestsValid } from "./manifestsValid.ts";
49
50
  import { maxDepth } from "./maxDepth.ts";
50
51
  import { maxLines } from "./maxLines.ts";
51
52
  import { noBarrel } from "./noBarrel.ts";
@@ -81,6 +82,7 @@ export const builtInRules = [
81
82
  importsManifest,
82
83
  importsAliased,
83
84
  noTestCode,
85
+ manifestsValid,
84
86
  manifestsSorted,
85
87
  manifestsSourceFirst,
86
88
  manifestsExportsShape,
@@ -2,7 +2,7 @@ import { definePatternRule } from "./definePattern.ts";
2
2
 
3
3
  export const noEnvironmentPragma = definePatternRule({
4
4
  description:
5
- "A test file gets its environment from its name, not from a pragma: `*.dom.test.ts` runs in a DOM, every other test in Node. `@shivaedev/quality/testProjects.ts` sets up the Vitest projects that read the name.",
5
+ "A test file gets its environment from its name, not from a pragma: `*.dom.test.ts` runs in a DOM, every other test in Node. `@shivaedev/quality/adapters/testProjects.ts` sets up the Vitest projects that read the name.",
6
6
  id: "comments/no-environment-pragma",
7
7
  message: (match) => `Sets the test environment with "${match}". Name the file *.dom.test.ts or *.dom.test.tsx instead.`,
8
8
  patterns: [/^@(?:vitest|jest)-environment(?:-options)?(?=\s|$)/mu],
@@ -1,6 +1,7 @@
1
1
  import { join, posix } from "node:path";
2
- import { Effect, Option, Schema } from "effect";
2
+ import { Effect } from "effect";
3
3
  import ts from "typescript";
4
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
4
5
  import { headingAnchors } from "#docs/headingAnchors.ts";
5
6
  import { importFindings } from "#docs/importFindings.ts";
6
7
  import { isDocument } from "#docs/isDocument.ts";
@@ -10,8 +11,6 @@ import { repositoryOf } from "#docs/repositoryLink.ts";
10
11
  import { type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
11
12
  import { defineRule, type Finding, type RuleInputs } from "#rule.ts";
12
13
 
13
- const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
14
-
15
14
  function field(value: unknown, key: string): unknown {
16
15
  return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
17
16
  }
@@ -26,10 +25,6 @@ function reader(inputs: RuleInputs): (path: string) => Effect.Effect<string | un
26
25
  return (path) => Effect.promise(() => inputs.readText(path));
27
26
  }
28
27
 
29
- function jsonAt(read: ReturnType<typeof reader>, path: string): Effect.Effect<unknown> {
30
- return Effect.map(read(path), (text) => (text === undefined ? undefined : Option.getOrUndefined(decodeJson(text))));
31
- }
32
-
33
28
  function anchorsReader(read: ReturnType<typeof reader>): (path: string) => Effect.Effect<ReadonlySet<string> | undefined> {
34
29
  const known = new Map<string, ReadonlySet<string> | undefined>();
35
30
  return (path) =>
@@ -47,7 +42,10 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
47
42
  const packages: readonly WorkspacePackage[] = yield* Effect.promise(() => workspacePackages(inputs));
48
43
  const manifests = new Map(
49
44
  yield* Effect.forEach(packages, (owner) =>
50
- Effect.map(jsonAt(read, posix.join(owner.directory, "package.json")), (manifest) => [owner.name, manifest] as const),
45
+ Effect.map(
46
+ Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
47
+ (manifest) => [owner.name, manifest] as const,
48
+ ),
51
49
  ),
52
50
  );
53
51
  const shared = {
@@ -55,7 +53,7 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
55
53
  exports: new Map([...manifests].map(([name, manifest]) => [name, field(manifest, "exports")])),
56
54
  packages: new Map(packages.map((owner) => [owner.name, owner])),
57
55
  readText: read,
58
- repository: repositoryOf(yield* jsonAt(read, "package.json")),
56
+ repository: repositoryOf(yield* Effect.promise(() => readPackageManifest(inputs.readText, "package.json"))),
59
57
  root: inputs.root,
60
58
  };
61
59
  const documents = inputs.files.filter((file) => isDocument(file) && !isLink(inputs.root, file));
@@ -76,7 +74,7 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
76
74
  });
77
75
 
78
76
  export const docsReferences = defineRule({
79
- check: (inputs) => Effect.runPromise(references(inputs)),
77
+ check: references,
80
78
  description:
81
79
  "Links, heading anchors and documented modules and exports in Markdown resolve, so documentation cannot point at a file, a heading or an API that no longer exists.",
82
80
  id: "docs/references",
@@ -46,7 +46,7 @@ const unversionedInstalls = Effect.fn("Docs.unversionedInstalls")(function* (inp
46
46
  });
47
47
 
48
48
  export const docsUnversionedInstalls = defineRule({
49
- check: (inputs) => Effect.runPromise(unversionedInstalls(inputs)),
49
+ check: unversionedInstalls,
50
50
  description:
51
51
  "Install commands in Markdown name packages without versions, so documentation never tells a reader to install a release it has already left behind.",
52
52
  id: "docs/unversioned-installs",
@@ -10,6 +10,18 @@ export function serviceTypes(checker: ts.TypeChecker) {
10
10
  const property = type.getProperty(name);
11
11
  return property === undefined ? undefined : checker.getTypeOfSymbol(property);
12
12
  }
13
+ function options(type: ts.Type): boolean {
14
+ if (type.getCallSignatures().length > 0) {
15
+ return false;
16
+ }
17
+ return type
18
+ .getProperties()
19
+ .every(
20
+ (property) =>
21
+ (property.flags & ts.SymbolFlags.Optional) !== 0
22
+ && checker.getNonNullableType(checker.getTypeOfSymbol(property)).getCallSignatures().length === 0,
23
+ );
24
+ }
13
25
  function remember(type: ts.Type): void {
14
26
  if (type.getProperty(SERVICE) === undefined) {
15
27
  return;
@@ -20,6 +32,7 @@ export function serviceTypes(checker: ts.TypeChecker) {
20
32
  && shape.flags & ts.TypeFlags.Object
21
33
  && (shape.getProperties().length > 0 || shape.getCallSignatures().length > 0)
22
34
  && checker.getIndexInfosOfType(shape).length === 0
35
+ && !options(shape)
23
36
  && (shape.getCallSignatures().length === 0 || type.getProperty("~effect/Context/Reference") === undefined)
24
37
  ) {
25
38
  shapes.add(shape);
@@ -1,22 +1,11 @@
1
1
  import { posix } from "node:path";
2
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
2
3
  import type { RuleInputs } from "#rule.ts";
3
4
 
4
5
  export type PackageImports = (importer: string, specifier: string) => string | undefined;
5
6
 
6
7
  const MANIFEST = "package.json";
7
8
 
8
- function importsField(text: string | undefined): unknown {
9
- if (text === undefined) {
10
- return undefined;
11
- }
12
- try {
13
- const manifest: unknown = JSON.parse(text);
14
- return typeof manifest === "object" && manifest !== null ? Reflect.get(manifest, "imports") : undefined;
15
- } catch {
16
- return undefined;
17
- }
18
- }
19
-
20
9
  function targetsIn(value: unknown): readonly string[] {
21
10
  if (typeof value === "string") {
22
11
  return [value];
@@ -52,7 +41,7 @@ function matched(imports: unknown, specifier: string): readonly string[] {
52
41
  export async function packageImports({ files, readText }: Pick<RuleInputs, "files" | "readText">): Promise<PackageImports> {
53
42
  const directories = files.filter((path) => posix.basename(path) === MANIFEST).map((path) => posix.dirname(path));
54
43
  const manifests = await Promise.all(
55
- directories.map(async (directory) => ({ directory, imports: importsField(await readText(posix.join(directory, MANIFEST))) })),
44
+ directories.map(async (directory) => ({ directory, imports: (await readPackageManifest(readText, posix.join(directory, MANIFEST)))?.imports })),
56
45
  );
57
46
  const deepestFirst = manifests.toSorted((left, right) => right.directory.length - left.directory.length);
58
47
  const present = new Set(files);
@@ -1,9 +1,10 @@
1
1
  import { posix } from "node:path";
2
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
2
3
  import { type ImportGraph, importGraph } from "#imports/graph.ts";
3
4
  import { isTooling } from "#imports/isTooling.ts";
4
5
  import { builtinName } from "#imports/packageName.ts";
5
6
  import { packageOf, type WorkspacePackage } from "#imports/workspace.ts";
6
- import { type EntryPoint, entryPointsOf, isApplication, provider, SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
7
+ import { dependencyNames, type EntryPoint, entryPointsOf, isApplication, provider, SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
7
8
  import { isTestCode } from "#naming/testName.ts";
8
9
  import { defineRule, type RuleInputs } from "#rule.ts";
9
10
  import { bundleInputs } from "./bundleInputs.ts";
@@ -31,17 +32,6 @@ interface ManifestDependencies {
31
32
  readonly shipped: ReadonlySet<string>;
32
33
  }
33
34
 
34
- function names(manifest: object, field: string): readonly string[] {
35
- const value: unknown = Reflect.get(manifest, field);
36
- if (value === undefined) {
37
- return [];
38
- }
39
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
40
- throw new Error(`${field} must be an object`);
41
- }
42
- return Object.keys(value);
43
- }
44
-
45
35
  async function manifestDependencies(
46
36
  inputs: RuleInputs,
47
37
  owner: WorkspacePackage,
@@ -49,26 +39,18 @@ async function manifestDependencies(
49
39
  workspace: ReadonlyMap<string, string>,
50
40
  ): Promise<ManifestDependencies> {
51
41
  const path = posix.join(owner.directory, "package.json");
52
- try {
53
- const text = await inputs.readText(path);
54
- if (text === undefined) {
55
- throw new Error("the manifest is missing");
56
- }
57
- const manifest: unknown = JSON.parse(text);
58
- if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
59
- throw new Error("the manifest must be an object");
60
- }
61
- return {
62
- ...bundleInputs(graph, owner, manifest, (candidate) => developmentFile(owner, candidate)),
63
- application: isApplication(manifest),
64
- development: new Set(names(manifest, "devDependencies")),
65
- entryPoints: await entryPointsOf(inputs, owner.directory, manifest, workspace),
66
- private: Reflect.get(manifest, "private") === true,
67
- shipped: new Set(SHIPPED_FIELDS.flatMap((field) => names(manifest, field))),
68
- };
69
- } catch (cause) {
70
- throw new Error(`cannot read dependency policy at ${path}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
42
+ const manifest = await readPackageManifest(inputs.readText, path);
43
+ if (manifest === undefined) {
44
+ throw new Error("the manifest is missing");
71
45
  }
46
+ return {
47
+ ...bundleInputs(graph, owner, manifest, (candidate) => developmentFile(owner, candidate)),
48
+ application: isApplication(manifest),
49
+ development: new Set(dependencyNames(manifest, "devDependencies")),
50
+ entryPoints: await entryPointsOf(inputs, owner.directory, manifest, workspace),
51
+ private: Reflect.get(manifest, "private") === true,
52
+ shipped: new Set(SHIPPED_FIELDS.flatMap((field) => dependencyNames(manifest, field))),
53
+ };
72
54
  }
73
55
 
74
56
  function developmentFile(owner: WorkspacePackage, path: string): boolean {
@@ -105,7 +87,8 @@ function undeclared(owner: WorkspacePackage, policy: ManifestDependencies | unde
105
87
  export const importsManifest = defineRule({
106
88
  check: async (inputs) => {
107
89
  const graph = await importGraph(inputs);
108
- const root: WorkspacePackage | undefined = (await inputs.readText("package.json")) === undefined ? undefined : { directory: ".", name: "." };
90
+ const root: WorkspacePackage | undefined =
91
+ (await readPackageManifest(inputs.readText, "package.json")) === undefined ? undefined : { directory: ".", name: "." };
109
92
  const owners = [...graph.packages, ...(root === undefined ? [] : [root])];
110
93
  const workspace = new Map(graph.packages.map((owner) => [owner.name, owner.directory]));
111
94
  const policies = new Map(
@@ -8,15 +8,16 @@ const ResolvableOptions = Schema.Struct({
8
8
  });
9
9
 
10
10
  export const importsResolvable = defineRule({
11
- check: async ({ options, ...inputs }) => {
12
- const unresolved = await withoutGenerated(inputs, await importGraph(inputs), options.generated);
11
+ check: Effect.fn("Imports.check")(function* ({ options, ...inputs }) {
12
+ const graph = yield* Effect.promise(() => importGraph(inputs));
13
+ const unresolved = yield* withoutGenerated(inputs, graph, options.generated);
13
14
  return unresolved.map((request) => ({
14
15
  file: request.from,
15
16
  line: request.line,
16
17
  message: `Cannot resolve "${request.specifier}". Fix the path, install or declare the package, or declare the module in a .d.ts file among the sources.`,
17
18
  subject: request.specifier,
18
19
  }));
19
- },
20
+ }),
20
21
  description: "Every import resolves to a file, a package or a declared module, so no edge of the import graph goes unchecked.",
21
22
  id: "imports/resolvable",
22
23
  options: Schema.toStandardSchemaV1(ResolvableOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
@@ -1,4 +1,5 @@
1
- import { importGraph } from "#imports/graph.ts";
1
+ import { Effect } from "effect";
2
+ import { type ImportGraph, importGraph } from "#imports/graph.ts";
2
3
  import { builtinName } from "#imports/packageName.ts";
3
4
  import { type Runtime, runtimeDeclarationProblems, runtimeOf } from "#imports/runtime.ts";
4
5
  import { isTestCode } from "#naming/testName.ts";
@@ -11,42 +12,47 @@ function forbiddenImport(from: Runtime, to: Runtime | undefined, builtin: boolea
11
12
  return from === "client" && (to === "server" || builtin);
12
13
  }
13
14
 
15
+ function runtimeFindings(graph: ImportGraph, runtime: (path: string) => Runtime | undefined) {
16
+ return graph.edges.flatMap((edge) => {
17
+ const from = runtime(edge.from);
18
+ if (from === undefined || isTestCode(edge.from)) {
19
+ return [];
20
+ }
21
+ const to = edge.to.kind === "file" ? runtime(edge.to.path) : undefined;
22
+ const builtin = edge.to.kind === "external" && builtinName(edge.to.specifier) !== undefined;
23
+ if (!forbiddenImport(from, to, builtin)) {
24
+ return [];
25
+ }
26
+ return [
27
+ {
28
+ file: edge.from,
29
+ line: edge.line,
30
+ message: `${from === "client" ? "Client" : "Shared"} code imports ${builtin ? "Node built-in" : `${to} code`} through "${edge.specifier}". Move runtime-dependent code into src/client/ or src/server/ and keep shared code independent of both runtimes.`,
31
+ subject: edge.specifier,
32
+ },
33
+ ];
34
+ });
35
+ }
36
+
14
37
  export const importsRuntime = defineRule({
15
- check: async (inputs) => {
16
- const graph = await importGraph(inputs);
17
- const runtime = runtimeOf(inputs, graph.packages);
18
- const imports = graph.edges.flatMap((edge) => {
19
- const from = runtime(edge.from);
20
- if (from === undefined || isTestCode(edge.from)) {
21
- return [];
22
- }
23
- const to = edge.to.kind === "file" ? runtime(edge.to.path) : undefined;
24
- const builtin = edge.to.kind === "external" && builtinName(edge.to.specifier) !== undefined;
25
- if (!forbiddenImport(from, to, builtin)) {
26
- return [];
38
+ check: (inputs) =>
39
+ Effect.gen(function* () {
40
+ const graph = yield* Effect.promise(() => importGraph(inputs));
41
+ const runtime = yield* runtimeOf(inputs, graph.packages);
42
+ const imports = runtimeFindings(graph, runtime);
43
+ const declarations = (yield* runtimeDeclarationProblems(inputs, graph.packages)).map(({ directory, message }) => ({
44
+ file: directory === "." ? "package.json" : `${directory}/package.json`,
45
+ line: 1,
46
+ message,
47
+ subject: "quality.runtime",
48
+ }));
49
+ const shared = inputs.sources.filter((file) => !isTestCode(file.path) && runtime(file.path) === "shared");
50
+ if (shared.length === 0) {
51
+ return [...imports, ...declarations];
27
52
  }
28
- return [
29
- {
30
- file: edge.from,
31
- line: edge.line,
32
- message: `${from === "client" ? "Client" : "Shared"} code imports ${builtin ? "Node built-in" : `${to} code`} through "${edge.specifier}". Move runtime-dependent code into src/client/ or src/server/ and keep shared code independent of both runtimes.`,
33
- subject: edge.specifier,
34
- },
35
- ];
36
- });
37
- const declarations = runtimeDeclarationProblems(inputs, graph.packages).map(({ directory, message }) => ({
38
- file: directory === "." ? "package.json" : `${directory}/package.json`,
39
- line: 1,
40
- message,
41
- subject: "quality.runtime",
42
- }));
43
- const shared = inputs.sources.filter((file) => !isTestCode(file.path) && runtime(file.path) === "shared");
44
- if (shared.length === 0) {
45
- return [...imports, ...declarations];
46
- }
47
- const { browserGlobals } = await import("#imports/browserGlobals.ts");
48
- return [...imports, ...declarations, ...shared.flatMap(browserGlobals)];
49
- },
53
+ const { browserGlobals } = yield* Effect.promise(() => import("#imports/browserGlobals.ts"));
54
+ return [...imports, ...declarations, ...shared.flatMap(browserGlobals)];
55
+ }),
50
56
  description:
51
57
  "Runtime folders define client, server and shared code. A manifest's quality.runtime declares a single-runtime package whole; executable packages without runtime folders and package-root tooling are server code.",
52
58
  id: "imports/runtime",
@@ -1,4 +1,5 @@
1
1
  import { dirname, posix, relative, resolve, sep } from "node:path";
2
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
2
3
  import { pnpmWorkspaceList } from "#imports/pnpmWorkspacePatterns.ts";
3
4
  import { workspacePackages } from "#imports/workspace.ts";
4
5
  import { DEPENDENCY_FIELDS, dependencyNames, entryPointsOf, isApplication, PLATFORM } from "#manifests/entryPoints.ts";
@@ -17,17 +18,6 @@ function hoists(pattern: string): boolean {
17
18
  return new RegExp(`^${source}$`, "u").test(PROBE);
18
19
  }
19
20
 
20
- function parsed(text: string | undefined): unknown {
21
- if (text === undefined) {
22
- return undefined;
23
- }
24
- try {
25
- return JSON.parse(text);
26
- } catch {
27
- return undefined;
28
- }
29
- }
30
-
31
21
  function ancestors(root: string, directory: string): readonly string[] {
32
22
  const start = resolve(root, directory);
33
23
  const parent = dirname(start);
@@ -100,7 +90,7 @@ export const manifestsApplication = defineRule({
100
90
  const findings = await Promise.all(
101
91
  directories.map(async (directory) => {
102
92
  const manifestPath = posix.join(directory, "package.json");
103
- const manifest = parsed(await inputs.readText(manifestPath));
93
+ const manifest = await readPackageManifest(inputs.readText, manifestPath);
104
94
  if (!isApplication(manifest)) {
105
95
  return [];
106
96
  }
@@ -1,4 +1,5 @@
1
1
  import { posix } from "node:path";
2
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
2
3
  import { workspacePackages } from "#imports/workspace.ts";
3
4
  import { defineRule, type Finding } from "#rule.ts";
4
5
 
@@ -52,11 +53,14 @@ function findingsIn(file: string, exports: unknown): readonly Finding[] {
52
53
  : [finding(file, "exports", `The exports field needs exactly one non-null wildcard; found ${patterns.length}.`)];
53
54
  return [
54
55
  ...count,
55
- ...entries.flatMap(([key, value]) =>
56
- value === null || key === "." || exactAsset(key, value) || standardPattern(key, value)
56
+ ...entries.flatMap(([key, value]) => {
57
+ if (value === null) {
58
+ return [finding(file, key, `Export "${key}" blocks module imports with null. Remove the null entry so callers can import each module.`)];
59
+ }
60
+ return key === "." || exactAsset(key, value) || standardPattern(key, value)
57
61
  ? []
58
- : [finding(file, key, `Export "${key}" does not preserve the module's file path.`)],
59
- ),
62
+ : [finding(file, key, `Export "${key}" does not preserve the module's file path.`)];
63
+ }),
60
64
  ];
61
65
  }
62
66
 
@@ -66,18 +70,17 @@ export const manifestsExportsShape = defineRule({
66
70
  const files = ["package.json", ...packages.map((owner) => posix.join(owner.directory, "package.json"))];
67
71
  const findings = await Promise.all(
68
72
  files.map(async (file) => {
69
- const text = await inputs.readText(file);
70
- if (file === "package.json" && text === undefined) {
73
+ const manifest = await readPackageManifest(inputs.readText, file);
74
+ if (file === "package.json" && manifest === undefined) {
71
75
  return [];
72
76
  }
73
- const manifest: unknown = JSON.parse(text ?? "");
74
77
  return findingsIn(file, isMap(manifest) ? manifest.exports : undefined);
75
78
  }),
76
79
  );
77
80
  return findings.flat();
78
81
  },
79
82
  description:
80
- "Workspace packages export modules through one file-preserving wildcard, with optional root, exact non-code assets and null blocks; a package without modules exports only exact assets.",
83
+ "Workspace packages export every module through one file-preserving wildcard, with optional root and exact non-code assets; null entries are rejected, and a package without modules exports only exact assets.",
81
84
  id: "manifests/exports-shape",
82
85
  registrable: false,
83
86
  });
@@ -1,21 +1,18 @@
1
- import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
2
- import { Effect } from "effect";
3
- import { manifestsIn, sortingOf } from "#manifests/sorted.ts";
4
- import { defineRule, type Finding } from "#rule.ts";
5
-
6
- const MESSAGES = {
7
- Invalid: "Is not valid JSON.",
8
- Unsorted: "Keys are not in sort-package-json order. Run `quality fix`.",
9
- } as const;
1
+ import { manifestFiles, manifestText } from "#adapters/manifestInventory.ts";
2
+ import { sortingOf } from "#manifests/sorted.ts";
3
+ import { defineRule } from "#rule.ts";
10
4
 
11
5
  export const manifestsSorted = defineRule({
12
- check: async ({ readText, root }) => {
13
- const manifests = await Effect.runPromise(manifestsIn(root).pipe(Effect.provide(NodeFileSystem.layer)));
14
- const texts = await Promise.all(manifests.map(async (path) => ({ path, text: (await readText(path)) ?? "" })));
15
- return texts.flatMap(({ path, text }): readonly Finding[] => {
16
- const sorting = sortingOf(text);
17
- return sorting._tag === "Sorted" ? [] : [{ file: path, message: MESSAGES[sorting._tag] }];
18
- });
6
+ check: async (inputs) => {
7
+ const findings = await Promise.all(
8
+ manifestFiles(inputs).map(async (file) => {
9
+ const text = await manifestText(inputs.readText, file);
10
+ return text === undefined || sortingOf(text)._tag === "Sorted"
11
+ ? []
12
+ : [{ file, message: "Keys are not in sort-package-json order. Run `quality fix`." }];
13
+ }),
14
+ );
15
+ return findings.flat();
19
16
  },
20
17
  description: "Every package.json in the repository keeps its keys in sort-package-json order. `quality fix` sorts them.",
21
18
  id: "manifests/sorted",