@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
@@ -1,8 +1,10 @@
1
- import { readFileSync, statSync } from "node:fs";
1
+ import { statSync } from "node:fs";
2
2
  import { join, posix } from "node:path";
3
+ import { Effect } from "effect";
4
+ import { readPackageManifest } from "#adapters/manifestInventory.ts";
3
5
  import type { RuleInputs } from "#rule.ts";
4
- import { isTooling } from "./isTooling.ts";
5
- import { packageOf, type WorkspacePackage } from "./workspace.ts";
6
+ import { classifyRuntime } from "./classifyRuntime.ts";
7
+ import type { WorkspacePackage } from "./workspace.ts";
6
8
 
7
9
  export type Runtime = "client" | "server" | "shared";
8
10
 
@@ -12,22 +14,6 @@ function executablePath(value: unknown): boolean {
12
14
  return typeof value === "string" && value.trim().length > 0;
13
15
  }
14
16
 
15
- function readManifest(root: string, directory: string): object | undefined {
16
- const path = join(root, directory, "package.json");
17
- try {
18
- const manifest: unknown = JSON.parse(readFileSync(path, "utf8"));
19
- if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
20
- throw new Error("the manifest must be an object");
21
- }
22
- return manifest;
23
- } catch (cause) {
24
- if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
25
- return undefined;
26
- }
27
- throw new Error(`cannot read runtime policy at ${path}`, { cause });
28
- }
29
- }
30
-
31
17
  function hasExecutable(manifest: object | undefined): boolean {
32
18
  const bin: unknown = manifest === undefined ? undefined : Reflect.get(manifest, "bin");
33
19
  return executablePath(bin) || (typeof bin === "object" && bin !== null && !Array.isArray(bin) && Object.values(bin).some(executablePath));
@@ -65,35 +51,53 @@ export interface RuntimeDeclarationProblem {
65
51
  readonly message: string;
66
52
  }
67
53
 
68
- export function runtimeDeclarationProblems(inputs: RuleInputs, packages: readonly WorkspacePackage[]): readonly RuntimeDeclarationProblem[] {
69
- return [...packages, { directory: ".", name: "." }].flatMap((owner) => {
70
- const value = declaredValue(readManifest(inputs.root, owner.directory));
71
- if (value === undefined) {
72
- return [];
73
- }
74
- if (value !== "client" && value !== "server") {
75
- return [
54
+ function problemsFor(root: string, owner: Owner, manifest: object | undefined): readonly RuntimeDeclarationProblem[] {
55
+ const value = declaredValue(manifest);
56
+ if (value === undefined) {
57
+ return [];
58
+ }
59
+ if (value !== "client" && value !== "server") {
60
+ return [
61
+ {
62
+ directory: owner.directory,
63
+ message: `"quality.runtime" is ${JSON.stringify(value)}. Declare "client" or "server" for a package whose code runs in one runtime, or remove the field and use src/client/ and src/server/.`,
64
+ },
65
+ ];
66
+ }
67
+ const folders = runtimeFoldersOf(root, owner);
68
+ return folders.length === 0
69
+ ? []
70
+ : [
76
71
  {
77
72
  directory: owner.directory,
78
- message: `"quality.runtime" is ${JSON.stringify(value)}. Declare "client" or "server" for a package whose code runs in one runtime, or remove the field and use src/client/ and src/server/.`,
73
+ message: `"quality.runtime" declares the whole package ${value} code, but it also has ${folders.map((folder) => `src/${folder}/`).join(" and ")}. Keep one convention: remove the declaration and classify code by runtime folders, or move the code out of the runtime folders.`,
79
74
  },
80
75
  ];
81
- }
82
- const folders = runtimeFoldersOf(inputs.root, owner);
83
- return folders.length === 0
84
- ? []
85
- : [
86
- {
87
- directory: owner.directory,
88
- message: `"quality.runtime" declares the whole package ${value} code, but it also has ${folders.map((folder) => `src/${folder}/`).join(" and ")}. Keep one convention: remove the declaration and classify code by runtime folders, or move the code out of the runtime folders.`,
89
- },
90
- ];
91
- });
92
76
  }
93
77
 
94
- export function runtimeOf(inputs: RuleInputs, packages: readonly WorkspacePackage[]): (path: string) => Runtime | undefined {
78
+ export const runtimeDeclarationProblems = Effect.fn("Imports.runtimeDeclarationProblems")(function* (
79
+ inputs: RuleInputs,
80
+ packages: readonly WorkspacePackage[],
81
+ ) {
82
+ const problems = yield* Effect.forEach([...packages, { directory: ".", name: "." }], (owner) =>
83
+ Effect.map(
84
+ Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
85
+ (manifest) => problemsFor(inputs.root, owner, manifest),
86
+ ),
87
+ );
88
+ return problems.flat();
89
+ });
90
+
91
+ export const runtimeOf = Effect.fn("Imports.runtimeOf")(function* (inputs: RuleInputs, packages: readonly WorkspacePackage[]) {
95
92
  const owners = [...packages, { directory: ".", name: "." }];
96
- const manifests = new Map(owners.map((owner) => [owner.directory, readManifest(inputs.root, owner.directory)]));
93
+ const manifests = new Map(
94
+ yield* Effect.forEach(owners, (owner) =>
95
+ Effect.map(
96
+ Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
97
+ (manifest) => [owner.directory, manifest] as const,
98
+ ),
99
+ ),
100
+ );
97
101
  const adopted = new Set(owners.filter((owner) => runtimeFoldersOf(inputs.root, owner).length > 0).map((owner) => owner.directory));
98
102
  const declared = new Map(
99
103
  owners.flatMap((owner) => {
@@ -102,22 +106,6 @@ export function runtimeOf(inputs: RuleInputs, packages: readonly WorkspacePackag
102
106
  }),
103
107
  );
104
108
  const executable = new Set(owners.filter((owner) => hasExecutable(manifests.get(owner.directory))).map((owner) => owner.directory));
105
- return (path) => {
106
- const owner = packageOf(packages, path)?.directory ?? ".";
107
- if (isTooling(owner, path)) {
108
- return "server";
109
- }
110
- const whole = declared.get(owner);
111
- if (whole !== undefined) {
112
- return whole;
113
- }
114
- if (!adopted.has(owner)) {
115
- return executable.has(owner) ? "server" : undefined;
116
- }
117
- const local = posix.relative(owner, path).replace(/^src\/modules\/[^/]+\//u, "src/");
118
- if (local.startsWith("src/client/")) {
119
- return "client";
120
- }
121
- return local.startsWith("src/server/") ? "server" : "shared";
122
- };
123
- }
109
+ const policy = { adopted, declared, executable, packages };
110
+ return (path: string) => classifyRuntime(policy, path);
111
+ });
@@ -1,9 +1,10 @@
1
- import { execFile } from "node:child_process";
2
- import { posix } from "node:path";
3
- import { promisify } from "node:util";
1
+ import { basename, posix, relative } from "node:path";
2
+ import { Effect } from "effect";
3
+ import { SetupFailure } from "#failure.ts";
4
4
  import { emptyScope, type IgnoreScope, verdictFor, withIgnoreFile } from "#inventory/ignoreScope.ts";
5
+ import { trackedPaths } from "#inventory/trackedPaths.ts";
5
6
  import type { RuleInputs } from "#rule.ts";
6
- import type { ImportGraph, UnresolvedImport } from "./graph.ts";
7
+ import type { ImportGraph } from "./graph.ts";
7
8
 
8
9
  type Reader = Pick<RuleInputs, "readText" | "root">;
9
10
 
@@ -15,53 +16,37 @@ const TRAILING_SLASHES = /\/+$/u;
15
16
 
16
17
  const NODE_MODULES = "node_modules";
17
18
 
18
- const NOT_A_REPOSITORY = "not a git repository";
19
-
20
19
  const PLACEHOLDERS = new Set([".gitkeep", ".keep"]);
21
20
 
22
- const run = promisify(execFile);
23
-
24
- async function withIgnoreFileIn(reader: Reader, scope: IgnoreScope, directory: string): Promise<IgnoreScope> {
25
- const contents = await reader.readText(posix.join(directory, IGNORE_FILE));
21
+ const withIgnoreFileIn = Effect.fn("Imports.withIgnoreFileIn")(function* (reader: Reader, scope: IgnoreScope, directory: string) {
22
+ const contents = yield* Effect.promise(() => reader.readText(posix.join(directory, IGNORE_FILE)));
26
23
  return contents === undefined || contents === "" ? scope : withIgnoreFile(scope, posix.join(reader.root, directory), contents);
27
- }
24
+ });
28
25
 
29
- async function ignored(reader: Reader, file: string): Promise<boolean> {
26
+ const ignored = Effect.fn("Imports.ignored")(function* (reader: Reader, file: string) {
30
27
  const parts = file.split("/");
31
28
  let scope = emptyScope;
32
29
  for (const index of parts.keys()) {
33
- scope = await withIgnoreFileIn(reader, scope, parts.slice(0, index).join("/") || ".");
30
+ scope = yield* withIgnoreFileIn(reader, scope, parts.slice(0, index).join("/") || ".");
34
31
  if (verdictFor(scope, posix.join(reader.root, ...parts.slice(0, index + 1)), index < parts.length - 1) === "ignored") {
35
32
  return true;
36
33
  }
37
34
  }
38
35
  return false;
39
- }
40
-
41
- async function tracked(root: string, folder: string): Promise<readonly string[]> {
42
- try {
43
- const { stdout } = await run("git", ["ls-files", "-z", "--", folder], { cwd: root });
44
- return stdout.split("\0").filter(Boolean);
45
- } catch (error) {
46
- if (error instanceof Error && "stderr" in error && String(error.stderr).includes(NOT_A_REPOSITORY)) {
47
- return [];
48
- }
49
- throw error;
50
- }
51
- }
36
+ });
52
37
 
53
38
  function under(folder: string, path: string | undefined): boolean {
54
39
  return path?.startsWith(`${folder}/`) === true;
55
40
  }
56
41
 
57
- async function contentIssue(reader: Reader, folder: string, named: readonly string[]): Promise<string | undefined> {
58
- const verdicts = await Promise.all(named.map((file) => ignored(reader, file)));
42
+ const contentIssue = Effect.fn("Imports.contentIssue")(function* (reader: Reader, folder: string, named: readonly string[]) {
43
+ const verdicts = yield* Effect.forEach(named, (file) => ignored(reader, file), { concurrency: "unbounded" });
59
44
  if (verdicts.includes(false)) {
60
45
  return `"${folder}" is not ignored by git, so it holds source, not generated output`;
61
46
  }
62
- const kept = (await tracked(reader.root, folder)).find((file) => !PLACEHOLDERS.has(posix.basename(file)));
63
- return kept === undefined ? undefined : `"${folder}" holds files git tracks, such as ${kept}, so it is not generated output`;
64
- }
47
+ const kept = (yield* trackedPaths(reader.root, folder)).find((file) => !PLACEHOLDERS.has(basename(file)));
48
+ return kept === undefined ? undefined : `"${folder}" holds files git tracks, such as ${relative(reader.root, kept)}, so it is not generated output`;
49
+ });
65
50
 
66
51
  function placeIssue(graph: ImportGraph, folder: string): string | undefined {
67
52
  if (folder === "" || folder.startsWith("../") || posix.isAbsolute(folder)) {
@@ -75,21 +60,23 @@ function placeIssue(graph: ImportGraph, folder: string): string | undefined {
75
60
  : `"${folder}" holds no file that an import names`;
76
61
  }
77
62
 
78
- async function issueOf(reader: Reader, graph: ImportGraph, folder: string): Promise<string | undefined> {
63
+ const issueOf = Effect.fn("Imports.issueOf")(function* (reader: Reader, graph: ImportGraph, folder: string) {
79
64
  const misplaced = placeIssue(graph, folder);
80
65
  if (misplaced !== undefined) {
81
66
  return misplaced;
82
67
  }
83
68
  const named = [...new Set(graph.edges.flatMap((edge) => (edge.to.kind === "file" && under(folder, edge.to.path) ? [edge.to.path] : [])))];
84
- return await contentIssue(reader, folder, named);
85
- }
69
+ return yield* contentIssue(reader, folder, named);
70
+ });
86
71
 
87
72
  // A generated folder may be empty until its generator runs, so a relative import of a missing file in it resolves.
88
- export async function withoutGenerated(reader: Reader, graph: ImportGraph, declared: readonly string[]): Promise<readonly UnresolvedImport[]> {
73
+ export const withoutGenerated = Effect.fn("Imports.withoutGenerated")(function* (reader: Reader, graph: ImportGraph, declared: readonly string[]) {
89
74
  const folders = declared.map((folder) => posix.normalize(folder).replace(LEADING_DOT, "").replace(TRAILING_SLASHES, ""));
90
- const issues = (await Promise.all(folders.map((folder) => issueOf(reader, graph, folder)))).flatMap((issue) => issue ?? []);
75
+ const issues = (yield* Effect.forEach(folders, (folder) => issueOf(reader, graph, folder), { concurrency: "unbounded" })).flatMap(
76
+ (issue) => issue ?? [],
77
+ );
91
78
  if (issues.length > 0) {
92
- throw new Error(`the generated folders are invalid:\n${issues.map((issue) => ` - ${issue}`).join("\n")}`);
79
+ return yield* new SetupFailure({ message: `the generated folders are invalid:\n${issues.map((issue) => ` - ${issue}`).join("\n")}` });
93
80
  }
94
81
  return graph.unresolved.filter((request) => !folders.some((folder) => under(folder, request.missing)));
95
- }
82
+ });
@@ -1,7 +1,5 @@
1
1
  import { posix } from "node:path";
2
- import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
3
- import { Effect } from "effect";
4
- import { manifestsIn } from "#manifests/sorted.ts";
2
+ import { manifestFiles, readPackageManifest } from "#adapters/manifestInventory.ts";
5
3
  import type { RuleInputs } from "#rule.ts";
6
4
  import { globMatcher } from "./globMatcher.ts";
7
5
  import { pnpmWorkspacePatterns } from "./pnpmWorkspacePatterns.ts";
@@ -23,17 +21,6 @@ const LEADING_DOT = /^\.\//u;
23
21
 
24
22
  const TRAILING_SLASHES = /\/+$/u;
25
23
 
26
- function parsed(text: string | undefined): unknown {
27
- if (text === undefined) {
28
- return undefined;
29
- }
30
- try {
31
- return JSON.parse(text);
32
- } catch {
33
- return undefined;
34
- }
35
- }
36
-
37
24
  function field(value: unknown, key: string): unknown {
38
25
  return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
39
26
  }
@@ -42,8 +29,8 @@ function strings(value: unknown): readonly string[] {
42
29
  return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === "string") : [];
43
30
  }
44
31
 
45
- function npmPatterns(text: string | undefined): readonly string[] {
46
- const workspaces = field(parsed(text), "workspaces");
32
+ function npmPatterns(manifest: unknown): readonly string[] {
33
+ const workspaces = field(manifest, "workspaces");
47
34
  return Array.isArray(workspaces) ? strings(workspaces) : strings(field(workspaces, "packages"));
48
35
  }
49
36
 
@@ -53,7 +40,7 @@ function normalized(pattern: string): string {
53
40
 
54
41
  async function memberOf(inputs: Reader): Promise<(directory: string) => boolean> {
55
42
  const pnpm = await inputs.readText(PNPM_WORKSPACE);
56
- const patterns = [...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)), ...npmPatterns(await inputs.readText(MANIFEST))];
43
+ const patterns = [...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)), ...npmPatterns(await readPackageManifest(inputs.readText, MANIFEST))];
57
44
  const included = patterns.filter((pattern) => !pattern.startsWith(NEGATION)).map((pattern) => globMatcher(normalized(pattern)));
58
45
  const excluded = patterns
59
46
  .filter((pattern) => pattern.startsWith(NEGATION))
@@ -63,14 +50,16 @@ async function memberOf(inputs: Reader): Promise<(directory: string) => boolean>
63
50
 
64
51
  export async function workspacePackages(inputs: Reader): Promise<readonly WorkspacePackage[]> {
65
52
  const member = await memberOf(inputs);
66
- const manifests =
67
- inputs.root === undefined ? inputs.files : await Effect.runPromise(manifestsIn(inputs.root).pipe(Effect.provide(NodeFileSystem.layer)));
53
+ const manifests = manifestFiles(inputs);
68
54
  const directories = manifests
69
55
  .filter((file) => posix.basename(file) === MANIFEST && file !== MANIFEST)
70
56
  .map((manifest) => posix.dirname(manifest))
71
57
  .filter(member);
72
58
  const named = await Promise.all(
73
- directories.map(async (directory) => ({ directory, name: field(parsed(await inputs.readText(posix.join(directory, MANIFEST))), "name") })),
59
+ directories.map(async (directory) => ({
60
+ directory,
61
+ name: field(await readPackageManifest(inputs.readText, posix.join(directory, MANIFEST)), "name"),
62
+ })),
74
63
  );
75
64
  return named.flatMap(({ directory, name }) => (typeof name === "string" ? [{ directory, name }] : []));
76
65
  }
@@ -1,7 +1,9 @@
1
1
  import { join, relative } from "node:path";
2
2
  import { Effect, FileSystem } from "effect";
3
3
  import ignore from "ignore";
4
- import type { SourceFile } from "#rule.ts";
4
+ import type { SetupFailure } from "#failure.ts";
5
+ import { manifestsIn } from "#manifests/sorted.ts";
6
+ import type { RuleServices, SourceFile } from "#rule.ts";
5
7
  import { FilesystemFailure, orWhenAbsent, readRequiredText } from "./filesystem.ts";
6
8
  import { posix } from "./ignoreScope.ts";
7
9
  import { linesOf } from "./linesOf.ts";
@@ -16,6 +18,7 @@ export interface InventoryScope {
16
18
 
17
19
  export interface Inventory {
18
20
  readonly files: readonly string[];
21
+ readonly manifestFiles: readonly string[];
19
22
  readonly sources: readonly SourceFile[];
20
23
  }
21
24
 
@@ -24,7 +27,7 @@ const READ_CONCURRENCY = 16;
24
27
  const zoneFiles = Effect.fn("Inventory.zoneFiles")(function* (
25
28
  root: string,
26
29
  zone: string,
27
- ): Effect.fn.Return<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
30
+ ): Effect.fn.Return<readonly string[], FilesystemFailure | SetupFailure, RuleServices> {
28
31
  const fs = yield* FileSystem.FileSystem;
29
32
  const path = join(root, zone);
30
33
  if (posix(relative(root, path)).startsWith("..")) {
@@ -44,7 +47,7 @@ function readSource(root: string, path: string): Effect.Effect<SourceFile, Files
44
47
  export const collectInventory = Effect.fn("Inventory.collectInventory")(function* (
45
48
  root: string,
46
49
  scope: InventoryScope,
47
- ): Effect.fn.Return<Inventory, FilesystemFailure, FileSystem.FileSystem> {
50
+ ): Effect.fn.Return<Inventory, FilesystemFailure | SetupFailure, RuleServices> {
48
51
  const excluded = ignore().add([...scope.exclude]);
49
52
  const toolOwned = yield* shadcnFolders(root);
50
53
  const zones = yield* Effect.forEach(scope.sources, (zone) => zoneFiles(root, zone), { concurrency: READ_CONCURRENCY });
@@ -60,5 +63,5 @@ export const collectInventory = Effect.fn("Inventory.collectInventory")(function
60
63
  });
61
64
  const sourcePaths = files.filter((path) => scope.extensions.some((extension) => path.endsWith(extension)));
62
65
  const sources = yield* Effect.forEach(sourcePaths, (path) => readSource(root, path), { concurrency: READ_CONCURRENCY });
63
- return { files, sources };
66
+ return { files, manifestFiles: yield* manifestsIn(root), sources };
64
67
  });
@@ -2,19 +2,11 @@ import { dirname } from "node:path";
2
2
  import { Data, Effect, FileSystem } from "effect";
3
3
  import type { PlatformError } from "effect/PlatformError";
4
4
 
5
- const ABSENT = new Set(["ENOENT", "ENOTDIR"]);
6
-
7
5
  export class FilesystemFailure extends Data.TaggedError("FilesystemFailure")<{
8
6
  readonly message: string;
9
7
  readonly path: string;
10
8
  }> {}
11
9
 
12
- // Effect maps ENOTDIR and EISDIR to BadResource; the original errno remains on the cause.
13
- function errnoOf(error: PlatformError): string {
14
- const cause: unknown = error.reason.cause;
15
- return typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
16
- }
17
-
18
10
  function failure(path: string, error: PlatformError): FilesystemFailure {
19
11
  return new FilesystemFailure({ message: `cannot read ${path}: ${error.message}`, path });
20
12
  }
@@ -25,7 +17,7 @@ export function orWhenAbsent<TValue>(
25
17
  whenAbsent: TValue,
26
18
  ): Effect.Effect<TValue, FilesystemFailure, FileSystem.FileSystem> {
27
19
  return Effect.catchTag(action, "PlatformError", (error) =>
28
- ABSENT.has(errnoOf(error)) ? Effect.succeed(whenAbsent) : Effect.fail(failure(path, error)),
20
+ error.reason._tag === "NotFound" ? Effect.succeed(whenAbsent) : Effect.fail(failure(path, error)),
29
21
  );
30
22
  }
31
23
 
@@ -41,7 +33,7 @@ export const readRequiredText = Effect.fn("Inventory.readRequiredText")(function
41
33
  ): Effect.fn.Return<string, FilesystemFailure, FileSystem.FileSystem> {
42
34
  const fs = yield* FileSystem.FileSystem;
43
35
  return yield* Effect.mapError(fs.readFileString(path), (error) =>
44
- ABSENT.has(errnoOf(error)) ? new FilesystemFailure({ message: `required input is missing: ${path}`, path }) : failure(path, error),
36
+ error.reason._tag === "NotFound" ? new FilesystemFailure({ message: `required input is missing: ${path}`, path }) : failure(path, error),
45
37
  );
46
38
  });
47
39
 
@@ -1,5 +1,7 @@
1
1
  import { basename, dirname, relative } from "node:path";
2
- import { Effect, type FileSystem, Schema } from "effect";
2
+ import { Effect, Schema } from "effect";
3
+ import type { SetupFailure } from "#failure.ts";
4
+ import type { RuleServices } from "#rule.ts";
3
5
  import { FilesystemFailure, readRequiredText } from "./filesystem.ts";
4
6
  import { posix } from "./ignoreScope.ts";
5
7
  import { shadcnAlias } from "./shadcnAlias.ts";
@@ -9,7 +11,7 @@ const Components = Schema.fromJsonString(Schema.Struct({ aliases: Schema.Struct(
9
11
 
10
12
  export const shadcnFolders = Effect.fn("Inventory.shadcnFolders")(function* (
11
13
  root: string,
12
- ): Effect.fn.Return<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
14
+ ): Effect.fn.Return<readonly string[], FilesystemFailure | SetupFailure, RuleServices> {
13
15
  const paths = (yield* walk(root)).filter((path) => basename(path) === "components.json");
14
16
  return yield* Effect.forEach(paths, (path) =>
15
17
  Effect.gen(function* () {
@@ -1,33 +1,31 @@
1
- import { execFile } from "node:child_process";
2
1
  import { join, resolve } from "node:path";
3
- import { promisify } from "node:util";
2
+ import { Effect } from "effect";
3
+ import { SetupFailure } from "#failure.ts";
4
+ import { run } from "#git/command.ts";
4
5
 
5
- const run = promisify(execFile);
6
-
7
- async function listedPaths(directory: string, options: readonly string[]): Promise<readonly string[] | undefined> {
8
- try {
9
- const { stdout } = await run("git", ["ls-files", "-z", ...options, "--", "."], { cwd: directory, maxBuffer: 2 ** 30 });
10
- return stdout
11
- .split("\0")
12
- .filter(Boolean)
13
- .map((path) => join(directory, path));
14
- } catch (error) {
15
- if (error instanceof Error && "stderr" in error && String(error.stderr).includes("not a git repository")) {
6
+ const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[], path = ".") {
7
+ const result = yield* run(directory, ["ls-files", "-z", ...options, "--", path]);
8
+ if (result.code !== 0) {
9
+ if (result.stderr.includes("not a git repository")) {
16
10
  return undefined;
17
11
  }
18
- throw error;
12
+ return yield* new SetupFailure({ message: `git ls-files exited ${result.code}: ${result.stderr.trim()}` });
19
13
  }
20
- }
14
+ return result.stdout
15
+ .split("\0")
16
+ .filter(Boolean)
17
+ .map((file) => join(directory, file));
18
+ });
21
19
 
22
- export async function trackedPaths(directory: string): Promise<readonly string[]> {
23
- return (await listedPaths(directory, [])) ?? [];
24
- }
20
+ export const trackedPaths = Effect.fn("Inventory.trackedPaths")(function* (directory: string, path = ".") {
21
+ return (yield* listedPaths(directory, [], path)) ?? [];
22
+ });
25
23
 
26
- export async function ignoredTrackedPaths(directory: string): Promise<readonly string[]> {
27
- return (await listedPaths(directory, ["--cached", "--ignored", "--exclude-standard"])) ?? [];
28
- }
24
+ export const ignoredTrackedPaths = Effect.fn("Inventory.ignoredTrackedPaths")(function* (directory: string) {
25
+ return (yield* listedPaths(directory, ["--cached", "--ignored", "--exclude-standard"])) ?? [];
26
+ });
29
27
 
30
- export async function ignoredPaths(directory: string): Promise<readonly string[] | undefined> {
31
- const paths = await listedPaths(directory, ["--others", "--ignored", "--exclude-standard", "--directory"]);
28
+ export const ignoredPaths = Effect.fn("Inventory.ignoredPaths")(function* (directory: string) {
29
+ const paths = yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard", "--directory"]);
32
30
  return paths?.map((path) => resolve(path));
33
- }
31
+ });
@@ -1,6 +1,8 @@
1
1
  import { dirname, join, relative, sep } from "node:path";
2
2
  import { Effect, FileSystem } from "effect";
3
- import { FilesystemFailure, orWhenAbsent, readOptionalText } from "./filesystem.ts";
3
+ import type { SetupFailure } from "#failure.ts";
4
+ import type { RuleServices } from "#rule.ts";
5
+ import { type FilesystemFailure, orWhenAbsent, readOptionalText } from "./filesystem.ts";
4
6
  import { emptyScope, type IgnoreScope, insideKept, verdictFor, withIgnoreFile } from "./ignoreScope.ts";
5
7
  import { ignoredPaths, trackedPaths } from "./trackedPaths.ts";
6
8
 
@@ -21,11 +23,8 @@ export function ignoreScopeAt(
21
23
  export const scopeAbove = Effect.fnUntraced(function* (
22
24
  root: string,
23
25
  dir: string,
24
- ): Effect.fn.Return<IgnoreScope, FilesystemFailure, FileSystem.FileSystem> {
25
- const ignored = yield* Effect.tryPromise({
26
- catch: (cause) => new FilesystemFailure({ message: `cannot list ignored files in ${dir}: ${String(cause)}`, path: dir }),
27
- try: () => ignoredPaths(dir),
28
- });
26
+ ): Effect.fn.Return<IgnoreScope, FilesystemFailure | SetupFailure, RuleServices> {
27
+ const ignored = yield* ignoredPaths(dir);
29
28
  if (ignored !== undefined) {
30
29
  return { ...emptyScope, ignored: new Set(ignored) };
31
30
  }
@@ -43,15 +42,12 @@ export const scopeAbove = Effect.fnUntraced(function* (
43
42
  export const walk = Effect.fnUntraced(function* (
44
43
  dir: string,
45
44
  inherited?: IgnoreScope,
46
- ): Effect.fn.Return<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
45
+ ): Effect.fn.Return<readonly string[], FilesystemFailure | SetupFailure, RuleServices> {
47
46
  const fs = yield* FileSystem.FileSystem;
48
47
  if ((yield* orWhenAbsent<FileSystem.File.Info | undefined>(dir, fs.stat(dir), undefined)) === undefined) {
49
48
  return [];
50
49
  }
51
- const paths = yield* Effect.tryPromise({
52
- catch: (cause) => new FilesystemFailure({ message: `cannot list tracked files in ${dir}: ${String(cause)}`, path: dir }),
53
- try: () => trackedPaths(dir),
54
- });
50
+ const paths = yield* trackedPaths(dir);
55
51
  const tracked = new Set(paths);
56
52
  for (const path of paths) {
57
53
  for (let folder = dirname(path); folder !== dir && folder !== dirname(folder); folder = dirname(folder)) {
@@ -1,4 +1,5 @@
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 const SHIPPED_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"] as const;
@@ -24,17 +25,6 @@ export function dependencyNames(manifest: unknown, field: string): readonly stri
24
25
  return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.keys(value) : [];
25
26
  }
26
27
 
27
- function parsed(text: string | undefined): unknown {
28
- if (text === undefined) {
29
- return undefined;
30
- }
31
- try {
32
- return JSON.parse(text);
33
- } catch {
34
- return undefined;
35
- }
36
- }
37
-
38
28
  async function installedManifest(inputs: Pick<RuleInputs, "readText">, directory: string, name: string, workspace: ReadonlyMap<string, string>) {
39
29
  const candidates = [
40
30
  ...(workspace.has(name) ? [posix.join(workspace.get(name) ?? ".", "package.json")] : []),
@@ -42,7 +32,7 @@ async function installedManifest(inputs: Pick<RuleInputs, "readText">, directory
42
32
  posix.join("node_modules", name, "package.json"),
43
33
  ];
44
34
  for (const candidate of candidates) {
45
- const manifest = parsed(await inputs.readText(candidate));
35
+ const manifest = await readPackageManifest(inputs.readText, candidate);
46
36
  if (manifest !== undefined) {
47
37
  return manifest;
48
38
  }
@@ -1,13 +1,17 @@
1
1
  import { basename, join, relative } from "node:path";
2
2
  import { Effect, FileSystem } from "effect";
3
3
  import { sortPackageJson } from "sort-package-json";
4
+ import { ManifestFailure, manifestEntry } from "#adapters/manifestInventory.ts";
5
+ import { manifestReader } from "#adapters/manifestReader.ts";
6
+ import type { SetupFailure } from "#failure.ts";
4
7
  import { FilesystemFailure } from "#inventory/filesystem.ts";
5
8
  import { posix } from "#inventory/ignoreScope.ts";
6
9
  import { walk } from "#inventory/walk.ts";
10
+ import type { RuleServices } from "#rule.ts";
7
11
 
8
- export type Sorting = { readonly _tag: "Invalid" } | { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
12
+ export type Sorting = { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
9
13
 
10
- export function manifestsIn(root: string): Effect.Effect<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
14
+ export function manifestsIn(root: string): Effect.Effect<readonly string[], FilesystemFailure | SetupFailure, RuleServices> {
11
15
  return Effect.map(walk(root), (paths) =>
12
16
  paths
13
17
  .filter((path) => basename(path) === "package.json")
@@ -17,30 +21,40 @@ export function manifestsIn(root: string): Effect.Effect<readonly string[], File
17
21
  }
18
22
 
19
23
  export function sortingOf(text: string): Sorting {
20
- try {
21
- JSON.parse(text);
22
- } catch {
23
- return { _tag: "Invalid" };
24
- }
25
24
  const sorted = sortPackageJson(text);
26
25
  return sorted === text ? { _tag: "Sorted" } : { _tag: "Unsorted", sorted };
27
26
  }
28
27
 
29
28
  export const sortManifests = Effect.fn("Manifests.sortManifests")(function* (
30
29
  root: string,
31
- ): Effect.fn.Return<number, FilesystemFailure, FileSystem.FileSystem> {
30
+ ): Effect.fn.Return<number, FilesystemFailure | ManifestFailure | SetupFailure, RuleServices> {
32
31
  const fs = yield* FileSystem.FileSystem;
33
32
  const manifests = yield* manifestsIn(root);
33
+ const readText = yield* manifestReader(root);
34
34
  const written = yield* Effect.forEach(manifests, (path) =>
35
35
  Effect.gen(function* () {
36
36
  const absolute = join(root, path);
37
- const sorting = sortingOf(yield* fs.readFileString(absolute));
37
+ const entry = yield* Effect.tryPromise({
38
+ catch: (cause) =>
39
+ cause instanceof ManifestFailure ? cause : new FilesystemFailure({ message: cause instanceof Error ? cause.message : String(cause), path }),
40
+ try: () => manifestEntry(readText, path),
41
+ });
42
+ if (entry === undefined) {
43
+ return false;
44
+ }
45
+ const sorting = sortingOf(entry.text);
38
46
  if (sorting._tag !== "Unsorted") {
39
47
  return false;
40
48
  }
41
49
  yield* fs.writeFileString(absolute, sorting.sorted);
42
50
  return true;
43
- }).pipe(Effect.mapError((error) => new FilesystemFailure({ message: `cannot sort ${path}: ${error.message}`, path }))),
51
+ }).pipe(
52
+ Effect.mapError((error) =>
53
+ error instanceof ManifestFailure
54
+ ? new ManifestFailure({ message: `cannot sort ${path}: ${error.message}`, path })
55
+ : new FilesystemFailure({ message: `cannot sort ${path}: ${error.message}`, path }),
56
+ ),
57
+ ),
44
58
  );
45
59
  return written.filter(Boolean).length;
46
60
  });
@@ -1,4 +1,5 @@
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 interface PackageLayout {
@@ -15,17 +16,6 @@ const RUNNABLE = /\.[cm]?[jt]sx?$/u;
15
16
 
16
17
  const BUILT = /^dist\/(?<entry>.+)\.[cm]?js$/u;
17
18
 
18
- function parsed(text: string | undefined): unknown {
19
- if (text === undefined) {
20
- return undefined;
21
- }
22
- try {
23
- return JSON.parse(text);
24
- } catch {
25
- return undefined;
26
- }
27
- }
28
-
29
19
  function field(value: unknown, key: string): unknown {
30
20
  return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
31
21
  }
@@ -57,7 +47,7 @@ export async function packageLayout({ files, readText }: Pick<RuleInputs, "files
57
47
  const manifests = await Promise.all(
58
48
  [...new Set(directories)].map(async (directory) => ({
59
49
  directory: directory === "." ? "" : directory,
60
- manifest: parsed(await readText(directory === "" ? MANIFEST : `${directory}/${MANIFEST}`)),
50
+ manifest: await readPackageManifest(readText, directory === "" ? MANIFEST : `${directory}/${MANIFEST}`),
61
51
  })),
62
52
  );
63
53
  const present = manifests.filter((entry) => entry.manifest !== undefined);