@md-code/follow-architecture 0.1.0 → 0.3.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 (436) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +597 -126
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +62 -19
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -82
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -95
  435. package/report.js +0 -73
  436. package/utils.js +0 -104
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relationOf = exports.assignmentsFact = void 0;
4
+ const tree_1 = require("./tree");
5
+ const assignments_raw_1 = require("./assignments-raw");
6
+ const assignments_tagged_1 = require("./assignments-tagged");
7
+ const kinds_1 = require("../kinds");
8
+ // Is a resolved file the one this code lives in? The checker answers with a path
9
+ // relative to the repo root when it knows it, and with the absolute one it read
10
+ // otherwise, so both spellings name the same file.
11
+ const isSameFile = (file, rel) => file != null && rel != null && (file === rel || file.endsWith(`/${rel}`));
12
+ // Which RELATION a write forms. One rule, read by the edge producers and
13
+ // available to a filter — so "does this code write into anything that is not
14
+ // its own?" is asked the same way everywhere.
15
+ // mutate — the value belongs to another module, or to the code that owns this
16
+ // file (`this.x`): somebody else's state changes.
17
+ // assign — the value was HANDED IN (a parameter) or its type is declared by
18
+ // ANOTHER file: the piece writes into state it does not own.
19
+ // null — this file's own state: private, and no role has a say in it.
20
+ const relationOf = (entry, rel) => {
21
+ if (!entry.performed)
22
+ return null;
23
+ if (entry.param)
24
+ return kinds_1.RELATION.ASSIGN;
25
+ if (entry.onThis)
26
+ return kinds_1.RELATION.MUTATE;
27
+ if (entry.module && !isSameFile(entry.module, rel))
28
+ return kinds_1.RELATION.MUTATE;
29
+ if (entry.type && !isSameFile(entry.type, rel))
30
+ return kinds_1.RELATION.ASSIGN;
31
+ return null;
32
+ };
33
+ exports.relationOf = relationOf;
34
+ // A defined incoming facet wins over the one an earlier pass wrote; a missing
35
+ // one keeps the earlier pass's answer.
36
+ const pick = (next, prev) => (next !== undefined && next !== null ? next : prev);
37
+ // Merge one write's facets over a previous entry for the same (line, root): the
38
+ // syntax gives `target`/`local`, the binding gives `module`/`onThis`, the checker
39
+ // gives `type`/`param`.
40
+ const mergeWrite = (prev, entry) => {
41
+ const base = prev ?? { line: entry.line, target: entry.target, via: entry.via };
42
+ return {
43
+ line: entry.line,
44
+ target: entry.target,
45
+ via: entry.via,
46
+ value: pick(entry.value, base.value),
47
+ method: pick(entry.method, base.method),
48
+ performed: pick(entry.performed, base.performed),
49
+ module: pick(entry.module, base.module),
50
+ onThis: pick(entry.onThis, base.onThis),
51
+ param: pick(entry.param, base.param),
52
+ local: pick(entry.local, base.local),
53
+ type: pick(entry.type, base.type),
54
+ };
55
+ };
56
+ // ── The one fact ────────────────────────────────────────────────────────────
57
+ // The three passes describe the same line, so they merge into one entry per
58
+ // (line, root), then each gets its single `relation` word.
59
+ const assignmentsFact = (node, sf, importMap, ctx) => {
60
+ const byKey = new Map();
61
+ const add = (entry) => {
62
+ // `line:value:method` — two mutating calls of the same value on one line are
63
+ // two writes, and the three passes merge on the same write because they
64
+ // agree on all three. Keyed by the ROOT, not the target spelling: one pass
65
+ // rewrites the target into the alias's initializer, and keying by target
66
+ // split one write into two.
67
+ const key = `${entry.line}:${entry.value ?? entry.target}:${entry.method ?? ""}`;
68
+ byKey.set(key, mergeWrite(byKey.get(key), entry));
69
+ };
70
+ if ((0, tree_1.isFunctionNode)(node))
71
+ (0, assignments_raw_1.plainAssignments)(node, importMap).forEach(add);
72
+ if ((0, tree_1.isFunctionNode)(node) || (0, tree_1.isClassNode)(node))
73
+ (0, assignments_raw_1.collectMutations)(node, importMap).forEach(add);
74
+ if ((0, tree_1.isFunctionNode)(node))
75
+ (0, assignments_tagged_1.taggedWrites)(node, sf, importMap, ctx.repoRoot).forEach(add);
76
+ return [...byKey.values()].map((entry) => ({ ...entry, relation: relationOf(entry, ctx.rel) })).sort((a, b) => a.line - b.line);
77
+ };
78
+ exports.assignmentsFact = assignmentsFact;
@@ -0,0 +1,4 @@
1
+ import type { Node } from "ts-morph";
2
+ import type { BranchFact } from "../facts";
3
+ declare const branchesFact: (node: Node) => BranchFact[];
4
+ export { branchesFact };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.branchesFact = void 0;
4
+ // Control flow inside ONE piece: `if`, `?:`, `switch`/`case`, `try`/`catch`,
5
+ // `throw`, `break`/`continue`, `await`/`yield`. Facts, not verdicts — "does this
6
+ // branch?" is a query over the list.
7
+ //
8
+ // A branch is what a name can hide: `if (!ok) return;` and `return ok;` have the
9
+ // same `returns` count, and only the branch fact tells them apart.
10
+ const tree_1 = require("./tree");
11
+ const CONTROL_KINDS = new Map([
12
+ [tree_1.SK.IfStatement, "IfStatement"],
13
+ [tree_1.SK.ConditionalExpression, "ConditionalExpression"],
14
+ [tree_1.SK.SwitchStatement, "SwitchStatement"],
15
+ [tree_1.SK.CaseClause, "CaseClause"],
16
+ [tree_1.SK.DefaultClause, "DefaultClause"],
17
+ [tree_1.SK.TryStatement, "TryStatement"],
18
+ [tree_1.SK.CatchClause, "CatchClause"],
19
+ [tree_1.SK.ThrowStatement, "ThrowStatement"],
20
+ [tree_1.SK.BreakStatement, "BreakStatement"],
21
+ [tree_1.SK.ContinueStatement, "ContinueStatement"],
22
+ [tree_1.SK.AwaitExpression, "AwaitExpression"],
23
+ [tree_1.SK.YieldExpression, "YieldExpression"],
24
+ [tree_1.SK.VoidExpression, "VoidExpression"],
25
+ ]);
26
+ // `{ is, line }` per control-flow node the piece runs itself. `is` is the parser's
27
+ // kind name, so a rule says `branches: { any: { is: { in: [IfStatement, …] } } }`.
28
+ const branchesFact = (node) => node
29
+ .getDescendants()
30
+ .filter((d) => CONTROL_KINDS.has(d.getKind()) && (0, tree_1.inThisPiece)(node, d))
31
+ .map((d) => ({ is: CONTROL_KINDS.get(d.getKind()), line: d.getStartLineNumber() }));
32
+ exports.branchesFact = branchesFact;
@@ -0,0 +1,6 @@
1
+ import { type SourceFile } from "ts-morph";
2
+ import type { LooseNode } from "./loose";
3
+ import type { CallFact } from "../facts";
4
+ type ImportMap = ReadonlyMap<string, string>;
5
+ declare const callsFact: (node: LooseNode, importMap: ImportMap, sf: SourceFile | null, repoRoot: string) => CallFact[];
6
+ export { callsFact };
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callsFact = void 0;
4
+ // Call expressions — `f()`, `new F()`, ``tag`…` ``. One entity for all three
5
+ // shapes: what is called, what it acts on, which module it comes from, and
6
+ // whether it hands the caller's own parameters straight through.
7
+ const ts_morph_1 = require("ts-morph");
8
+ const tree_1 = require("./tree");
9
+ const properties_1 = require("./properties");
10
+ const resolve_1 = require("./resolve");
11
+ // WHAT IS HANDED OVER. A call is the one place a value LEAVES the piece that
12
+ // owns it. `type` is the file declaring the argument's type; a literal has no
13
+ // such file, so it is not listed. An object literal is listed through its
14
+ // SPREADS — `f({ ...state })` hands the state over just as `f(state)` does.
15
+ const ARGUMENTLESS = new Set([
16
+ "StringLiteral",
17
+ "NumericLiteral",
18
+ "BigIntLiteral",
19
+ "RegularExpressionLiteral",
20
+ "NoSubstitutionTemplateLiteral",
21
+ "TemplateExpression",
22
+ "TrueKeyword",
23
+ "FalseKeyword",
24
+ "NullKeyword",
25
+ "UndefinedKeyword",
26
+ "ArrayLiteralExpression",
27
+ "ArrowFunction",
28
+ "FunctionExpression",
29
+ "ClassExpression",
30
+ ]);
31
+ const spreadHandover = (s) => {
32
+ const expr = ts_morph_1.Node.isSpreadAssignment(s) || ts_morph_1.Node.isSpreadElement(s) ? s.getExpression() : s;
33
+ return { node: expr, text: `{ ...${expr.getText()} }` };
34
+ };
35
+ // `{ ...state }` / `[..., ...state]` — one entry per spread source; a bare
36
+ // `...state` element is its own; a literal hands nothing over.
37
+ const handoversOf = (arg) => {
38
+ const kind = (0, tree_1.kindName)(arg);
39
+ if (kind === "ObjectLiteralExpression" || kind === "ArrayLiteralExpression") {
40
+ const spreads = arg.getDescendants().filter((d) => ["SpreadAssignment", "SpreadElement"].includes((0, tree_1.kindName)(d)));
41
+ return spreads.map(spreadHandover);
42
+ }
43
+ if (kind === "SpreadElement" && ts_morph_1.Node.isSpreadElement(arg))
44
+ return [{ node: arg.getExpression(), text: `...${arg.getExpression().getText()}` }];
45
+ if (ARGUMENTLESS.has(kind))
46
+ return [];
47
+ return [{ node: arg, text: arg.getText() }];
48
+ };
49
+ // One argument fact, when the checker can name the repo file declaring its
50
+ // type; a literal (no such file) is not listed.
51
+ const argumentFact = (entry, position, checker, repoRoot) => {
52
+ const file = (0, resolve_1.declaredFileOfExpr)(entry.node, checker, repoRoot)?.file ?? null;
53
+ if (!file || !(0, resolve_1.inRepo)(file, repoRoot))
54
+ return null;
55
+ return { index: position, text: entry.text, kind: (0, tree_1.kindName)(entry.node), root: (0, properties_1.leftmostOrigin)(entry.node), type: file };
56
+ };
57
+ // The arguments a call hands over; a tagged template's are its template's.
58
+ const callArguments = (call) => {
59
+ if (ts_morph_1.Node.isCallExpression(call) || ts_morph_1.Node.isNewExpression(call))
60
+ return call.getArguments();
61
+ return [];
62
+ };
63
+ const argumentsOf = (call, checker, repoRoot) => callArguments(call)
64
+ .flatMap(handoversOf)
65
+ .map((entry, position) => argumentFact(entry, position, checker, repoRoot))
66
+ .filter((a) => a != null);
67
+ // origin = the base of the chain, action = the member actually invoked:
68
+ // `store.doX()` → origin "store", action "doX";
69
+ // `getRoot(self).store.doAction()` → origin "getRoot", action "doAction";
70
+ // `new F()` → origin "new F", action "F".
71
+ const originActionOf = (expr) => {
72
+ if (expr && (0, properties_1.isPurePropertyPath)(expr)) {
73
+ const chain = (0, tree_1.nodeText)(expr).split(".");
74
+ return { origin: chain[0], action: chain[chain.length - 1] };
75
+ }
76
+ return { origin: (0, properties_1.leftmostOrigin)(expr), action: (0, properties_1.lastMemberName)(expr) ?? ((0, tree_1.nodeText)(expr) || null) };
77
+ };
78
+ // The expression actually invoked: a tagged template calls its TAG.
79
+ const calleeOf = (c) => {
80
+ if (ts_morph_1.Node.isTaggedTemplateExpression(c))
81
+ return c.getTag();
82
+ return c.getExpression();
83
+ };
84
+ // Every call the candidate makes:
85
+ // kind — the parser's kind of the call node
86
+ // origin — the origin of the called chain (`store.doX()` → "store",
87
+ // `new F()` → "new F", `t.model(...)` → "t.model"); null when
88
+ // the chain has no identifier root
89
+ // action — the member actually invoked (`doX` in `store.doX()`), or the
90
+ // full expression text for a bare-identifier call
91
+ // module — the module the callee resolves to: for a bare identifier the
92
+ // import it came from, for a member access the module of the
93
+ // origin object
94
+ // target — `{ path, name }` when the call names an imported SYMBOL
95
+ const callFactOf = (c, importMap, checker, repoRoot) => {
96
+ const expr = calleeOf(c);
97
+ // The module the callee was imported from — one implementation, in
98
+ // `properties.js`, where "what is this chain rooted in" already lives.
99
+ const module = expr ? (0, properties_1.importModuleOf)(expr, importMap) : null;
100
+ const { origin, action } = originActionOf(expr);
101
+ // `target` addresses the callee the same way `location` addresses
102
+ // anything else in the architecture: `{ path }` is the module the symbol
103
+ // was imported from, so a filter can say
104
+ // `calls: { some: { target: { location: { node: "…" } } } }`.
105
+ // Only a bare-identifier call names an imported SYMBOL; a member call
106
+ // (`store.doX()`) names a property of an object, so its module says
107
+ // nothing about where the member is declared.
108
+ const target = module && origin === action ? { path: module, name: action } : null;
109
+ return { kind: (0, tree_1.kindName)(c), origin, action, module, target, receiverOnly: isReceiverOnly(c), bare: origin === action, arguments: argumentsOf(c, checker, repoRoot) };
110
+ };
111
+ const callsFact = (node, importMap, sf, repoRoot) => {
112
+ const checker = sf?.getProject?.().getTypeChecker?.();
113
+ if (!checker)
114
+ return [];
115
+ return node
116
+ .getDescendants()
117
+ .filter(tree_1.isCallNode)
118
+ .filter((c) => ts_morph_1.Node.isCallExpression(c) || ts_morph_1.Node.isNewExpression(c) || ts_morph_1.Node.isTaggedTemplateExpression(c))
119
+ .map((c) => callFactOf(c, importMap, checker, repoRoot));
120
+ };
121
+ exports.callsFact = callsFact;
122
+ // Is the call's RESULT used only as the object of a member access — `f().x`,
123
+ // `f()[i]`? Then the call is the RECEIVER of a read, not a use of its own:
124
+ // `requireRootStore().settings` reads `settings`, it does not call anything of
125
+ // the store's. Without this flag one line produced two edges to the same file.
126
+ const isReceiverOnly = (call) => {
127
+ const parent = call.getParent();
128
+ if (!parent)
129
+ return false;
130
+ const kind = parent.getKind();
131
+ if (kind !== tree_1.SK.PropertyAccessExpression && kind !== tree_1.SK.ElementAccessExpression)
132
+ return false;
133
+ return (ts_morph_1.Node.isPropertyAccessExpression(parent) || ts_morph_1.Node.isElementAccessExpression(parent)) && parent.getExpression() === call;
134
+ };
@@ -0,0 +1,5 @@
1
+ import { type ClassDeclaration, type ClassExpression } from "ts-morph";
2
+ import type { Candidate } from "../facts";
3
+ type ClassNode = ClassDeclaration | ClassExpression;
4
+ declare const classFact: (node: ClassNode, base: Candidate) => Candidate;
5
+ export { classFact };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classFact = void 0;
4
+ const tree_1 = require("./tree");
5
+ const modifiers_1 = require("./modifiers");
6
+ // The declared type of a member, else the text of its initializer — what a
7
+ // filter reads as the member's `type`.
8
+ const memberType = (m) => {
9
+ const typeNode = typeof m.getTypeNode === "function" ? m.getTypeNode() : null;
10
+ if (typeNode)
11
+ return typeNode.getText();
12
+ const initializer = typeof m.getInitializer === "function" ? m.getInitializer() : null;
13
+ return initializer ? initializer.getText() : null;
14
+ };
15
+ // The visibility word a member carries, when it carries one.
16
+ const VISIBILITY = ["private", "protected", "public"];
17
+ // What a member IS, beyond its name: a `#private` field, a `static` one, a
18
+ // `readonly`/`accessor` one, the visibility word, its type and the fact that a
19
+ // `static {}` block runs at class definition.
20
+ const memberFact = (m) => {
21
+ const name = m.getName?.() ?? null;
22
+ const words = (typeof m.getModifiers === "function" ? m.getModifiers() : []).map((x) => x.getText());
23
+ return {
24
+ name,
25
+ is: (0, tree_1.kindName)(m),
26
+ // `#value` is a name the language keeps private: `name` starts with `#`.
27
+ private: Boolean(name?.startsWith("#")),
28
+ static: Boolean(m.isStatic?.()),
29
+ readonly: words.includes("readonly"),
30
+ accessor: words.includes("accessor"),
31
+ visibility: words.find((w) => VISIBILITY.includes(w)) ?? null,
32
+ type: memberType(m),
33
+ decorators: (0, modifiers_1.decoratorsOf)(m),
34
+ line: (0, tree_1.startLine)(m),
35
+ };
36
+ };
37
+ const constructorParamsOf = (ctor) => (ctor?.getParameters?.() ?? []).map((p) => ({ name: p.getName?.() ?? "", type: p.getTypeNode?.()?.getText() ?? null, decorators: (0, modifiers_1.decoratorsOf)(p) }));
38
+ // A class is a candidate like any other, so it receives every generic candidate
39
+ // fact (location, lines, kind, calls, assignments …) and adds only what a
40
+ // class has and nothing else does.
41
+ const classFact = (node, base) => {
42
+ const ctor = node.getConstructors()[0] ?? null;
43
+ const members = node.getMembers();
44
+ const baseExpr = node.getExtends();
45
+ return {
46
+ ...base,
47
+ members: members.map(memberFact),
48
+ // `static { … }` runs once, at class definition — not a member, but code.
49
+ // The parser spells it `ClassStaticBlockDeclaration`.
50
+ staticBlocks: members.filter((m) => (0, tree_1.kindName)(m).includes("StaticBlock")).length,
51
+ extends: baseExpr ? (0, tree_1.nodeText)(baseExpr) : null,
52
+ implements: node.getImplements().map(tree_1.nodeText),
53
+ constructorParams: constructorParamsOf(ctor),
54
+ hasConstructor: Boolean(ctor),
55
+ };
56
+ };
57
+ exports.classFact = classFact;
@@ -0,0 +1,12 @@
1
+ import type { Node } from "ts-morph";
2
+ interface ClimbVerdicts {
3
+ isHolder: (node: Node) => boolean;
4
+ passesThrough?: (node: Node) => boolean;
5
+ }
6
+ type ClimbStop = {
7
+ node: Node;
8
+ found: boolean;
9
+ };
10
+ declare const climbFrom: (start: Node, { isHolder, passesThrough }: ClimbVerdicts) => ClimbStop;
11
+ export { climbFrom };
12
+ export type { ClimbVerdicts, ClimbStop };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.climbFrom = void 0;
4
+ const climbFrom = (start, { isHolder, passesThrough }) => {
5
+ let current = start;
6
+ for (;;) {
7
+ if (isHolder(current))
8
+ return { node: current, found: true };
9
+ if (passesThrough && !passesThrough(current))
10
+ return { node: current, found: false };
11
+ const parent = current.getParent();
12
+ if (!parent)
13
+ return { node: current, found: false };
14
+ current = parent;
15
+ }
16
+ };
17
+ exports.climbFrom = climbFrom;
@@ -0,0 +1,4 @@
1
+ import type { SourceFile } from "ts-morph";
2
+ import type { Candidate } from "../facts";
3
+ declare const commentsOf: (sf: SourceFile, rel: string | null) => Candidate[];
4
+ export { commentsOf };
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commentsOf = void 0;
4
+ const tree_1 = require("./tree");
5
+ const kind_1 = require("./kind");
6
+ const functions_1 = require("./functions");
7
+ // The three forms the language distinguishes. The doc form is not a separate
8
+ // trivia kind to the compiler — it is a block comment whose text opens with
9
+ // `*` — but it is a separate thing to every reader and to the tooling, so it is
10
+ // named as its own kind instead of leaving the YAML to slice strings.
11
+ const kindOf = (range, text) => {
12
+ if (range.getKind() === tree_1.SK.SingleLineCommentTrivia)
13
+ return "SingleLineCommentTrivia";
14
+ return text.startsWith("/**") ? "JSDocComment" : "MultiLineCommentTrivia";
15
+ };
16
+ // Every comment in the file, each once, in document order. A comment is trivia
17
+ // of the token that follows it, so the walk asks every node for the comments
18
+ // around it and keeps them by position — the file itself carries the ones above
19
+ // the first token.
20
+ const rangesOf = (sf) => {
21
+ const text = sf.getFullText();
22
+ const byPos = new Map();
23
+ for (const node of [sf, ...sf.getDescendants()]) {
24
+ const ranges = [...(node.getLeadingCommentRanges?.() ?? []), ...(node.getTrailingCommentRanges?.() ?? [])];
25
+ for (const range of ranges)
26
+ if (!byPos.has(range.getPos()))
27
+ byPos.set(range.getPos(), range);
28
+ }
29
+ return [...byPos.values()].sort((a, b) => a.getPos() - b.getPos()).map((range) => ({ pos: range.getPos(), end: range.getEnd(), kind: kindOf(range, text.slice(range.getPos(), range.getEnd())) }));
30
+ };
31
+ // A comment is TRIVIA — text between tokens — but the parser still builds a node
32
+ // for a doc block, and that node has a subtree of its own: `JSDocParameterTag`
33
+ // (with the parameter's name), `JSDocReturnTag`, `JSDocTypeExpression`… So the
34
+ // inside of a doc block is described by the SAME machinery as any other node —
35
+ // no `tags` field, no list of known tag names, nothing to keep in sync with the
36
+ // language. Any comment that has no node of its own simply has no subtree.
37
+ const nodesByPos = (sf) => {
38
+ const byPos = new Map();
39
+ for (const node of sf.getDescendants())
40
+ if (!byPos.has(node.getStart()))
41
+ byPos.set(node.getStart(), node);
42
+ return byPos;
43
+ };
44
+ // The lines a comment covers. `end` is exclusive, so the last line is the one
45
+ // the last character sits on — a block that ends with `*/` belongs to its own
46
+ // last line, not to the one after it.
47
+ const linesOfRange = (sf, pos, end) => {
48
+ const first = sf.getLineAndColumnAtPos(pos).line;
49
+ const last = sf.getLineAndColumnAtPos(Math.max(pos, end - 1)).line;
50
+ return (0, tree_1.rangeLines)(first, last);
51
+ };
52
+ // The deepest function or class a comment sits inside. A doc block above a
53
+ // declaration is NOT inside it (it starts before the declaration does), which is
54
+ // the distinction a rule needs to say "no comments outside the action".
55
+ const pieceAt = (sf, pos) => {
56
+ let best = null;
57
+ for (const node of sf.getDescendants()) {
58
+ if (!(0, tree_1.isFunctionNode)(node) && !(0, tree_1.isClassNode)(node))
59
+ continue;
60
+ if (node.getStart() > pos || node.getEnd() < pos)
61
+ continue;
62
+ if (!best || node.getStart() > best.getStart())
63
+ best = node;
64
+ }
65
+ return best;
66
+ };
67
+ // The comment's `kind`: its own syntactic form, and — when the parser has a
68
+ // node for it — the node's whole neighbourhood and subtree, read through `is`
69
+ // like any other code.
70
+ const commentKind = (node, kind) => (node ? { ...(0, tree_1.kindFact)(node), ...(0, kind_1.spelled)(kind), own: { is: kind } } : (0, kind_1.spelled)(kind));
71
+ // The candidates. Each one carries the same facts every other candidate carries
72
+ // (where it is, the lines it spans, what kind it is) plus what only a comment
73
+ // has: its text, markers included — the markers are what tells a doc block from
74
+ // a plain block, and stripping them would throw that away.
75
+ const commentCandidate = (sf, rel, nodes, span) => {
76
+ const piece = pieceAt(sf, span.pos);
77
+ return {
78
+ name: null,
79
+ location: { path: rel ?? null, piece: piece ? ((0, functions_1.nameOf)(piece) ?? null) : null, nested: Boolean(piece) },
80
+ lines: linesOfRange(sf, span.pos, span.end),
81
+ kind: commentKind(nodes.get(span.pos), span.kind),
82
+ text: sf.getFullText().slice(span.pos, span.end),
83
+ // A comment has no actions: it runs nothing, writes nothing, yields
84
+ // nothing. Stated, because every candidate answers every question.
85
+ returns: [],
86
+ calls: [],
87
+ branches: [],
88
+ assignments: [],
89
+ parameters: [],
90
+ exported: false,
91
+ mutable: false,
92
+ references: null,
93
+ implementations: null,
94
+ };
95
+ };
96
+ const commentsOf = (sf, rel) => {
97
+ const nodes = nodesByPos(sf);
98
+ return rangesOf(sf).map((span) => commentCandidate(sf, rel, nodes, span));
99
+ };
100
+ exports.commentsOf = commentsOf;
@@ -0,0 +1,4 @@
1
+ import type { LooseNode } from "./loose";
2
+ import type { Candidate, AnyMember } from "../facts";
3
+ declare const declarationFact: (node: LooseNode, rel: string, members: AnyMember[]) => Candidate;
4
+ export { declarationFact };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.declarationFact = void 0;
4
+ // The candidate fact every "declares a name with no code inside it" node shares:
5
+ // an `enum` and a `type`/`interface` are candidates like any other, so they
6
+ // carry the same generic fields (kind, name, location, lines, the empty action
7
+ // lists, whether they are published) and add only their own `members`. The
8
+ // shape lives here once; `enums.js` and `types.js` supply the members their
9
+ // syntax actually has.
10
+ const tree_1 = require("./tree");
11
+ const kind_1 = require("./kind");
12
+ const declarationFact = (node, rel, members) => ({
13
+ kind: (0, kind_1.kindOf)(node),
14
+ name: node.getName?.() ?? null,
15
+ location: { path: rel ?? null, piece: null },
16
+ lines: (0, tree_1.linesOf)(node),
17
+ returns: [],
18
+ calls: [],
19
+ branches: [],
20
+ assignments: [],
21
+ parameters: [],
22
+ members,
23
+ exported: (0, tree_1.isExported)(node),
24
+ mutable: false,
25
+ });
26
+ exports.declarationFact = declarationFact;
@@ -0,0 +1,17 @@
1
+ import type { Candidate } from "../facts";
2
+ import type { ScanContext } from "../context";
3
+ type Chain = {
4
+ depth: number;
5
+ chain: string[];
6
+ };
7
+ type DepthCache = {
8
+ memo: Map<string, Chain>;
9
+ files: Map<string, Candidate[]>;
10
+ };
11
+ type DepthWalk = ScanContext & {
12
+ rel: string;
13
+ cache?: DepthCache;
14
+ };
15
+ declare const attachCallDepth: (candidates: Candidate[], ctx: DepthWalk) => Candidate[];
16
+ export { attachCallDepth };
17
+ export type { DepthCache, Chain };