@shivaedev/quality 0.7.2 → 0.8.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 (350) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +102 -8
  3. package/biome/plugins/constant-names.grit +17 -0
  4. package/biome/plugins/effect-fn-spans.grit +13 -3
  5. package/biome/plugins/handler-names.grit +10 -0
  6. package/biome/plugins/schema-names.grit +13 -0
  7. package/biome/plugins/schema-struct-keys.grit +7 -0
  8. package/biome/plugins/service-layers.grit +13 -0
  9. package/biome/plugins/type-re-exports.grit +8 -0
  10. package/biome/preset.json +48 -1
  11. package/dist/baseline/compare.d.ts +1 -1
  12. package/dist/baseline/compare.d.ts.map +1 -1
  13. package/dist/baseline/compare.js +1 -1
  14. package/dist/baseline/compare.js.map +1 -1
  15. package/dist/baseline/format.d.ts +1 -1
  16. package/dist/baseline/format.d.ts.map +1 -1
  17. package/dist/baseline/format.js +2 -2
  18. package/dist/baseline/format.js.map +1 -1
  19. package/dist/baseline/legacy.d.ts +2 -2
  20. package/dist/baseline/legacy.d.ts.map +1 -1
  21. package/dist/baseline/legacy.js +2 -2
  22. package/dist/baseline/legacy.js.map +1 -1
  23. package/dist/baseline/rewrite.js +1 -1
  24. package/dist/baseline/rewrite.js.map +1 -1
  25. package/dist/baseline/update.d.ts +1 -1
  26. package/dist/baseline/update.d.ts.map +1 -1
  27. package/dist/baseline/update.js +1 -1
  28. package/dist/baseline/update.js.map +1 -1
  29. package/dist/cli/args.d.ts +1 -1
  30. package/dist/cli/args.d.ts.map +1 -1
  31. package/dist/cli/baseline.d.ts +3 -3
  32. package/dist/cli/baseline.d.ts.map +1 -1
  33. package/dist/cli/baseline.js +7 -7
  34. package/dist/cli/baseline.js.map +1 -1
  35. package/dist/cli/fix.d.ts +1 -1
  36. package/dist/cli/fix.d.ts.map +1 -1
  37. package/dist/cli/fix.js +7 -7
  38. package/dist/cli/fix.js.map +1 -1
  39. package/dist/cli/lint.d.ts +2 -2
  40. package/dist/cli/lint.d.ts.map +1 -1
  41. package/dist/cli/lint.js +4 -4
  42. package/dist/cli/lint.js.map +1 -1
  43. package/dist/cli/migrate.d.ts +1 -1
  44. package/dist/cli/migrate.d.ts.map +1 -1
  45. package/dist/cli/migrate.js +9 -9
  46. package/dist/cli/migrate.js.map +1 -1
  47. package/dist/cli/run-main.d.ts +1 -1
  48. package/dist/cli/run-main.d.ts.map +1 -1
  49. package/dist/cli/run-main.js +1 -1
  50. package/dist/cli/run-main.js.map +1 -1
  51. package/dist/cli/shrink.d.ts +2 -2
  52. package/dist/cli/shrink.d.ts.map +1 -1
  53. package/dist/cli/shrink.js +2 -2
  54. package/dist/cli/shrink.js.map +1 -1
  55. package/dist/cli.js +7 -7
  56. package/dist/cli.js.map +1 -1
  57. package/dist/config/decode.d.ts +2 -2
  58. package/dist/config/decode.d.ts.map +1 -1
  59. package/dist/config/decode.js +1 -1
  60. package/dist/config/decode.js.map +1 -1
  61. package/dist/config/load.d.ts +2 -2
  62. package/dist/config/load.d.ts.map +1 -1
  63. package/dist/config/load.js +2 -2
  64. package/dist/config/load.js.map +1 -1
  65. package/dist/config/resolve.d.ts +3 -3
  66. package/dist/config/resolve.d.ts.map +1 -1
  67. package/dist/config/resolve.js +1 -1
  68. package/dist/config/resolve.js.map +1 -1
  69. package/dist/config.d.ts +1 -1
  70. package/dist/config.d.ts.map +1 -1
  71. package/dist/engine/baseline-file.d.ts +3 -3
  72. package/dist/engine/baseline-file.d.ts.map +1 -1
  73. package/dist/engine/baseline-file.js +5 -5
  74. package/dist/engine/baseline-file.js.map +1 -1
  75. package/dist/engine/evaluate.d.ts +3 -3
  76. package/dist/engine/evaluate.d.ts.map +1 -1
  77. package/dist/engine/evaluate.js +2 -2
  78. package/dist/engine/evaluate.js.map +1 -1
  79. package/dist/engine/run-rules.d.ts +2 -2
  80. package/dist/engine/run-rules.d.ts.map +1 -1
  81. package/dist/engine/run-rules.js +2 -2
  82. package/dist/engine/run-rules.js.map +1 -1
  83. package/dist/engine/session.d.ts +4 -4
  84. package/dist/engine/session.d.ts.map +1 -1
  85. package/dist/engine/session.js +6 -6
  86. package/dist/engine/session.js.map +1 -1
  87. package/dist/engine/violation.d.ts +2 -2
  88. package/dist/engine/violation.d.ts.map +1 -1
  89. package/dist/exceptions/registry.d.ts +2 -2
  90. package/dist/exceptions/registry.d.ts.map +1 -1
  91. package/dist/exceptions/registry.js +2 -2
  92. package/dist/exceptions/registry.js.map +1 -1
  93. package/dist/git/base.d.ts +1 -1
  94. package/dist/git/base.d.ts.map +1 -1
  95. package/dist/git/base.js +1 -1
  96. package/dist/git/base.js.map +1 -1
  97. package/dist/git/command.d.ts +1 -1
  98. package/dist/git/command.d.ts.map +1 -1
  99. package/dist/git/command.js +1 -1
  100. package/dist/git/command.js.map +1 -1
  101. package/dist/git/history.d.ts +1 -1
  102. package/dist/git/history.d.ts.map +1 -1
  103. package/dist/imports/departures.d.ts +1 -1
  104. package/dist/imports/departures.d.ts.map +1 -1
  105. package/dist/imports/departures.js +1 -1
  106. package/dist/imports/departures.js.map +1 -1
  107. package/dist/imports/fences/evaluate.d.ts +2 -2
  108. package/dist/imports/fences/evaluate.d.ts.map +1 -1
  109. package/dist/imports/fences/match.d.ts +2 -2
  110. package/dist/imports/fences/match.d.ts.map +1 -1
  111. package/dist/imports/fences/match.js +2 -2
  112. package/dist/imports/fences/match.js.map +1 -1
  113. package/dist/imports/fences/policy.js +1 -1
  114. package/dist/imports/fences/policy.js.map +1 -1
  115. package/dist/imports/fences/reach.d.ts +2 -2
  116. package/dist/imports/fences/reach.d.ts.map +1 -1
  117. package/dist/imports/fences/vocabulary.d.ts +1 -1
  118. package/dist/imports/fences/vocabulary.d.ts.map +1 -1
  119. package/dist/imports/generated.d.ts +1 -1
  120. package/dist/imports/generated.d.ts.map +1 -1
  121. package/dist/imports/generated.js +1 -1
  122. package/dist/imports/generated.js.map +1 -1
  123. package/dist/imports/graph.d.ts +1 -1
  124. package/dist/imports/graph.d.ts.map +1 -1
  125. package/dist/imports/graph.js +1 -1
  126. package/dist/imports/graph.js.map +1 -1
  127. package/dist/imports/resolve.js +1 -1
  128. package/dist/imports/resolve.js.map +1 -1
  129. package/dist/imports/workspace.d.ts +1 -1
  130. package/dist/imports/workspace.d.ts.map +1 -1
  131. package/dist/index.d.ts +3 -3
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +2 -2
  134. package/dist/index.js.map +1 -1
  135. package/dist/inventory/collect.d.ts +1 -1
  136. package/dist/inventory/collect.d.ts.map +1 -1
  137. package/dist/manifests/sorted.d.ts +1 -1
  138. package/dist/manifests/sorted.d.ts.map +1 -1
  139. package/dist/manifests/sorted.js +3 -3
  140. package/dist/manifests/sorted.js.map +1 -1
  141. package/dist/naming/exportFits.d.ts +2 -0
  142. package/dist/naming/exportFits.d.ts.map +1 -0
  143. package/dist/naming/exportFits.js +20 -0
  144. package/dist/naming/exportFits.js.map +1 -0
  145. package/dist/naming/mainExport.d.ts +3 -0
  146. package/dist/naming/mainExport.d.ts.map +1 -0
  147. package/dist/naming/mainExport.js +10 -0
  148. package/dist/naming/mainExport.js.map +1 -0
  149. package/dist/naming/ownExports.d.ts +8 -0
  150. package/dist/naming/ownExports.d.ts.map +1 -0
  151. package/dist/naming/ownExports.js +78 -0
  152. package/dist/naming/ownExports.js.map +1 -0
  153. package/dist/naming/packageLayout.d.ts +8 -0
  154. package/dist/naming/packageLayout.d.ts.map +1 -0
  155. package/dist/naming/packageLayout.js +57 -0
  156. package/dist/naming/packageLayout.js.map +1 -0
  157. package/dist/naming/testName.d.ts +11 -0
  158. package/dist/naming/testName.d.ts.map +1 -0
  159. package/dist/naming/testName.js +13 -0
  160. package/dist/naming/testName.js.map +1 -0
  161. package/dist/naming/words.d.ts +8 -0
  162. package/dist/naming/words.d.ts.map +1 -0
  163. package/dist/naming/words.js +21 -0
  164. package/dist/naming/words.js.map +1 -0
  165. package/dist/report/render.d.ts +1 -1
  166. package/dist/report/render.d.ts.map +1 -1
  167. package/dist/report/render.js +2 -2
  168. package/dist/report/render.js.map +1 -1
  169. package/dist/report/stale.d.ts +1 -1
  170. package/dist/report/stale.d.ts.map +1 -1
  171. package/dist/rules/biome.d.ts +1 -1
  172. package/dist/rules/biome.d.ts.map +1 -1
  173. package/dist/rules/biome.js +3 -3
  174. package/dist/rules/biome.js.map +1 -1
  175. package/dist/rules/built-in.d.ts +13 -1
  176. package/dist/rules/built-in.d.ts.map +1 -1
  177. package/dist/rules/built-in.js +24 -14
  178. package/dist/rules/built-in.js.map +1 -1
  179. package/dist/rules/comments/kinds.js +1 -1
  180. package/dist/rules/comments/kinds.js.map +1 -1
  181. package/dist/rules/comments/max-per-file.d.ts +1 -1
  182. package/dist/rules/comments/max-per-file.js +2 -2
  183. package/dist/rules/comments/max-per-file.js.map +1 -1
  184. package/dist/rules/comments/no-jsdoc.d.ts +1 -1
  185. package/dist/rules/comments/no-jsdoc.js +1 -1
  186. package/dist/rules/comments/no-jsdoc.js.map +1 -1
  187. package/dist/rules/comments/pattern-rule.d.ts +1 -1
  188. package/dist/rules/comments/pattern-rule.d.ts.map +1 -1
  189. package/dist/rules/comments/pattern-rule.js +1 -1
  190. package/dist/rules/comments/pattern-rule.js.map +1 -1
  191. package/dist/rules/comments/scan.d.ts +1 -1
  192. package/dist/rules/comments/scan.d.ts.map +1 -1
  193. package/dist/rules/comments/scan.js +1 -1
  194. package/dist/rules/comments/scan.js.map +1 -1
  195. package/dist/rules/files/folderNames.d.ts +5 -0
  196. package/dist/rules/files/folderNames.d.ts.map +1 -0
  197. package/dist/rules/files/folderNames.js +74 -0
  198. package/dist/rules/files/folderNames.js.map +1 -0
  199. package/dist/rules/files/namedAfterExport.d.ts +4 -0
  200. package/dist/rules/files/namedAfterExport.d.ts.map +1 -0
  201. package/dist/rules/files/namedAfterExport.js +76 -0
  202. package/dist/rules/files/namedAfterExport.js.map +1 -0
  203. package/dist/rules/files/otherNames.d.ts +5 -0
  204. package/dist/rules/files/otherNames.d.ts.map +1 -0
  205. package/dist/rules/files/otherNames.js +99 -0
  206. package/dist/rules/files/otherNames.js.map +1 -0
  207. package/dist/rules/imports/aliased.d.ts +1 -1
  208. package/dist/rules/imports/aliased.d.ts.map +1 -1
  209. package/dist/rules/imports/aliased.js +2 -2
  210. package/dist/rules/imports/aliased.js.map +1 -1
  211. package/dist/rules/imports/cycles.d.ts +1 -1
  212. package/dist/rules/imports/cycles.d.ts.map +1 -1
  213. package/dist/rules/imports/cycles.js +4 -4
  214. package/dist/rules/imports/cycles.js.map +1 -1
  215. package/dist/rules/imports/fences.d.ts +2 -2
  216. package/dist/rules/imports/fences.d.ts.map +1 -1
  217. package/dist/rules/imports/fences.js +3 -3
  218. package/dist/rules/imports/fences.js.map +1 -1
  219. package/dist/rules/imports/resolvable.d.ts +1 -1
  220. package/dist/rules/imports/resolvable.js +3 -3
  221. package/dist/rules/imports/resolvable.js.map +1 -1
  222. package/dist/rules/manifests-sorted.d.ts +1 -1
  223. package/dist/rules/manifests-sorted.d.ts.map +1 -1
  224. package/dist/rules/manifests-sorted.js +2 -2
  225. package/dist/rules/manifests-sorted.js.map +1 -1
  226. package/dist/rules/max-lines.d.ts +1 -1
  227. package/dist/rules/max-lines.js +1 -1
  228. package/dist/rules/max-lines.js.map +1 -1
  229. package/dist/rules/suppressions/biome/configs.d.ts +1 -1
  230. package/dist/rules/suppressions/biome/configs.d.ts.map +1 -1
  231. package/dist/rules/suppressions/biome/declarations.d.ts +1 -1
  232. package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -1
  233. package/dist/rules/suppressions/biome/declarations.js +1 -1
  234. package/dist/rules/suppressions/biome/declarations.js.map +1 -1
  235. package/dist/rules/suppressions/biome/resolve.d.ts +1 -1
  236. package/dist/rules/suppressions/biome/resolve.d.ts.map +1 -1
  237. package/dist/rules/suppressions/biome/resolve.js +1 -1
  238. package/dist/rules/suppressions/biome/resolve.js.map +1 -1
  239. package/dist/rules/suppressions/biome-overrides.d.ts +1 -1
  240. package/dist/rules/suppressions/biome-overrides.js +4 -4
  241. package/dist/rules/suppressions/biome-overrides.js.map +1 -1
  242. package/dist/rules/suppressions/directives.d.ts +1 -1
  243. package/dist/rules/suppressions/directives.d.ts.map +1 -1
  244. package/dist/rules/suppressions/no-double-cast.d.ts +1 -1
  245. package/dist/rules/suppressions/no-double-cast.d.ts.map +1 -1
  246. package/dist/rules/suppressions/no-double-cast.js +2 -2
  247. package/dist/rules/suppressions/no-double-cast.js.map +1 -1
  248. package/dist/rules/suppressions/no-inline.d.ts +1 -1
  249. package/dist/rules/suppressions/no-inline.d.ts.map +1 -1
  250. package/dist/rules/suppressions/no-inline.js +2 -2
  251. package/dist/rules/suppressions/no-inline.js.map +1 -1
  252. package/dist/rules/suppressions/stylesheet-comments.d.ts +1 -1
  253. package/dist/rules/suppressions/stylesheet-comments.d.ts.map +1 -1
  254. package/dist/rules/suppressions/stylesheet-comments.js +1 -1
  255. package/dist/rules/suppressions/stylesheet-comments.js.map +1 -1
  256. package/dist/rules/syntax.d.ts +1 -1
  257. package/dist/rules/syntax.d.ts.map +1 -1
  258. package/dist/rules/test-names/colocated.d.ts +4 -0
  259. package/dist/rules/test-names/colocated.d.ts.map +1 -0
  260. package/dist/rules/test-names/colocated.js +31 -0
  261. package/dist/rules/test-names/colocated.js.map +1 -0
  262. package/dist/rules/test-names/follow.d.ts +4 -0
  263. package/dist/rules/test-names/follow.d.ts.map +1 -0
  264. package/dist/rules/test-names/follow.js +66 -0
  265. package/dist/rules/test-names/follow.js.map +1 -0
  266. package/dist/rules/test-names/usesDom.d.ts +3 -0
  267. package/dist/rules/test-names/usesDom.d.ts.map +1 -0
  268. package/dist/rules/test-names/usesDom.js +18 -0
  269. package/dist/rules/test-names/usesDom.js.map +1 -0
  270. package/dist/vitest.d.ts +3 -1
  271. package/dist/vitest.d.ts.map +1 -1
  272. package/dist/vitest.js +11 -11
  273. package/dist/vitest.js.map +1 -1
  274. package/package.json +10 -2
  275. package/src/baseline/compare.ts +1 -1
  276. package/src/baseline/format.ts +2 -2
  277. package/src/baseline/legacy.ts +2 -2
  278. package/src/baseline/rewrite.ts +1 -1
  279. package/src/baseline/update.ts +1 -1
  280. package/src/cli/args.ts +1 -1
  281. package/src/cli/baseline.ts +8 -8
  282. package/src/cli/fix.ts +7 -7
  283. package/src/cli/lint.ts +4 -4
  284. package/src/cli/migrate.ts +9 -9
  285. package/src/cli/run-main.ts +2 -2
  286. package/src/cli/shrink.ts +5 -5
  287. package/src/cli.ts +7 -7
  288. package/src/config/decode.ts +2 -2
  289. package/src/config/load.ts +3 -3
  290. package/src/config/resolve.ts +6 -6
  291. package/src/config.ts +1 -1
  292. package/src/engine/baseline-file.ts +6 -6
  293. package/src/engine/evaluate.ts +3 -3
  294. package/src/engine/run-rules.ts +3 -3
  295. package/src/engine/session.ts +6 -6
  296. package/src/engine/violation.ts +2 -2
  297. package/src/exceptions/registry.ts +2 -2
  298. package/src/git/base.ts +1 -1
  299. package/src/git/command.ts +1 -1
  300. package/src/git/history.ts +1 -1
  301. package/src/imports/departures.ts +2 -2
  302. package/src/imports/fences/evaluate.ts +2 -2
  303. package/src/imports/fences/match.ts +2 -2
  304. package/src/imports/fences/policy.ts +2 -2
  305. package/src/imports/fences/reach.ts +2 -2
  306. package/src/imports/fences/vocabulary.ts +1 -1
  307. package/src/imports/generated.ts +2 -2
  308. package/src/imports/graph.ts +2 -2
  309. package/src/imports/resolve.ts +1 -1
  310. package/src/imports/workspace.ts +1 -1
  311. package/src/index.ts +3 -3
  312. package/src/inventory/collect.ts +1 -1
  313. package/src/manifests/sorted.ts +3 -3
  314. package/src/naming/exportFits.ts +21 -0
  315. package/src/naming/mainExport.ts +11 -0
  316. package/src/naming/ownExports.ts +95 -0
  317. package/src/naming/packageLayout.ts +75 -0
  318. package/src/naming/testName.ts +25 -0
  319. package/src/naming/words.ts +28 -0
  320. package/src/report/render.ts +3 -3
  321. package/src/report/stale.ts +3 -3
  322. package/src/rules/biome.ts +3 -3
  323. package/src/rules/built-in.ts +24 -14
  324. package/src/rules/comments/kinds.ts +1 -1
  325. package/src/rules/comments/max-per-file.ts +2 -2
  326. package/src/rules/comments/no-jsdoc.ts +1 -1
  327. package/src/rules/comments/pattern-rule.ts +1 -1
  328. package/src/rules/comments/scan.ts +2 -2
  329. package/src/rules/files/folderNames.ts +92 -0
  330. package/src/rules/files/namedAfterExport.ts +87 -0
  331. package/src/rules/files/otherNames.ts +118 -0
  332. package/src/rules/imports/aliased.ts +2 -2
  333. package/src/rules/imports/cycles.ts +4 -4
  334. package/src/rules/imports/fences.ts +4 -4
  335. package/src/rules/imports/resolvable.ts +3 -3
  336. package/src/rules/manifests-sorted.ts +2 -2
  337. package/src/rules/max-lines.ts +1 -1
  338. package/src/rules/suppressions/biome/configs.ts +1 -1
  339. package/src/rules/suppressions/biome/declarations.ts +1 -1
  340. package/src/rules/suppressions/biome/resolve.ts +2 -2
  341. package/src/rules/suppressions/biome-overrides.ts +4 -4
  342. package/src/rules/suppressions/directives.ts +1 -1
  343. package/src/rules/suppressions/no-double-cast.ts +2 -2
  344. package/src/rules/suppressions/no-inline.ts +2 -2
  345. package/src/rules/suppressions/stylesheet-comments.ts +1 -1
  346. package/src/rules/syntax.ts +1 -1
  347. package/src/rules/test-names/colocated.ts +34 -0
  348. package/src/rules/test-names/follow.ts +78 -0
  349. package/src/rules/test-names/usesDom.ts +22 -0
  350. package/src/vitest.ts +14 -11
package/src/cli/args.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { Result } from "effect";
3
- import type { WarningDetail } from "../report/render.ts";
3
+ import type { WarningDetail } from "#report/render.ts";
4
4
 
5
5
  export type Command =
6
6
  | { readonly _tag: "Lint"; readonly config: string | undefined; readonly warnings: WarningDetail }
@@ -1,13 +1,13 @@
1
1
  import { join } from "node:path";
2
2
  import { Console, Effect, type FileSystem } from "effect";
3
- import type { BaselineEntry } from "../baseline/format.ts";
4
- import { rewriteBaseline } from "../baseline/rewrite.ts";
5
- import { adopt, type Pruned, prune, type Scope } from "../baseline/update.ts";
6
- import { openSession, type Session } from "../engine/session.ts";
7
- import { applyRegistry } from "../exceptions/registry.ts";
8
- import { SetupFailure } from "../failure.ts";
9
- import { writeText } from "../inventory/filesystem.ts";
10
- import { plural } from "../report/plural.ts";
3
+ import type { BaselineEntry } from "#baseline/format.ts";
4
+ import { rewriteBaseline } from "#baseline/rewrite.ts";
5
+ import { adopt, type Pruned, prune, type Scope } from "#baseline/update.ts";
6
+ import { openSession, type Session } from "#engine/session.ts";
7
+ import { applyRegistry } from "#exceptions/registry.ts";
8
+ import { SetupFailure } from "#failure.ts";
9
+ import { writeText } from "#inventory/filesystem.ts";
10
+ import { plural } from "#report/plural.ts";
11
11
 
12
12
  const save = (session: Session, entries: readonly BaselineEntry[]): Effect.Effect<void, SetupFailure, FileSystem.FileSystem> =>
13
13
  Effect.mapError(
package/src/cli/fix.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { relative } from "node:path";
2
2
  import { Console, Effect, FileSystem } from "effect";
3
- import { biomeReport, type Report } from "../biome/report.ts";
4
- import { loadConfig } from "../config/load.ts";
5
- import { SetupFailure } from "../failure.ts";
6
- import { posix } from "../inventory/ignore-scope.ts";
7
- import { walk } from "../inventory/walk.ts";
8
- import { sortManifests } from "../manifests/sorted.ts";
9
- import { plural } from "../report/plural.ts";
3
+ import { biomeReport, type Report } from "#biome/report.ts";
4
+ import { loadConfig } from "#config/load.ts";
5
+ import { SetupFailure } from "#failure.ts";
6
+ import { posix } from "#inventory/ignore-scope.ts";
7
+ import { walk } from "#inventory/walk.ts";
8
+ import { sortManifests } from "#manifests/sorted.ts";
9
+ import { plural } from "#report/plural.ts";
10
10
 
11
11
  export const MAX_FIX_ROUNDS = 5;
12
12
 
package/src/cli/lint.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Console, Effect, type FileSystem } from "effect";
2
- import { evaluate, passes } from "../engine/evaluate.ts";
3
- import { openSession } from "../engine/session.ts";
4
- import { GateFailed, type SetupFailure } from "../failure.ts";
5
- import { render, type WarningDetail } from "../report/render.ts";
2
+ import { evaluate, passes } from "#engine/evaluate.ts";
3
+ import { openSession } from "#engine/session.ts";
4
+ import { GateFailed, type SetupFailure } from "#failure.ts";
5
+ import { render, type WarningDetail } from "#report/render.ts";
6
6
 
7
7
  export const lint = (
8
8
  cwd: string,
@@ -1,14 +1,14 @@
1
1
  import { join } from "node:path";
2
2
  import { Console, Effect, FileSystem } from "effect";
3
- import { encodeBaseline } from "../baseline/format.ts";
4
- import { convertLegacy, decodeLegacyBaseline, LEGACY_BASELINE } from "../baseline/legacy.ts";
5
- import { loadConfig } from "../config/load.ts";
6
- import { validOrFail } from "../decoded.ts";
7
- import { readInput } from "../engine/baseline-file.ts";
8
- import { scan } from "../engine/session.ts";
9
- import { SetupFailure } from "../failure.ts";
10
- import { writeText } from "../inventory/filesystem.ts";
11
- import { plural } from "../report/plural.ts";
3
+ import { encodeBaseline } from "#baseline/format.ts";
4
+ import { convertLegacy, decodeLegacyBaseline, LEGACY_BASELINE } from "#baseline/legacy.ts";
5
+ import { loadConfig } from "#config/load.ts";
6
+ import { validOrFail } from "#decoded.ts";
7
+ import { readInput } from "#engine/baseline-file.ts";
8
+ import { scan } from "#engine/session.ts";
9
+ import { SetupFailure } from "#failure.ts";
10
+ import { writeText } from "#inventory/filesystem.ts";
11
+ import { plural } from "#report/plural.ts";
12
12
 
13
13
  export const migrateBaseline = (
14
14
  cwd: string,
@@ -5,8 +5,8 @@ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
5
5
  import * as NodePath from "@effect/platform-node/NodePath";
6
6
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
7
7
  import { Cause, Console, Effect, Exit, type FileSystem, Layer, Runtime } from "effect";
8
- import { SetupFailure } from "../failure.ts";
9
- import type { Git } from "../git/command.ts";
8
+ import { SetupFailure } from "#failure.ts";
9
+ import type { Git } from "#git/command.ts";
10
10
 
11
11
  const INTERRUPTED = 130;
12
12
  const COULD_NOT_RUN = 2;
package/src/cli/shrink.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Console, Effect, type FileSystem } from "effect";
2
- import type { Scope } from "../baseline/update.ts";
3
- import type { SetupFailure } from "../failure.ts";
4
- import { resolveBase } from "../git/base.ts";
5
- import type { Git } from "../git/command.ts";
6
- import { changesSince } from "../git/history.ts";
2
+ import type { Scope } from "#baseline/update.ts";
3
+ import type { SetupFailure } from "#failure.ts";
4
+ import { resolveBase } from "#git/base.ts";
5
+ import type { Git } from "#git/command.ts";
6
+ import { changesSince } from "#git/history.ts";
7
7
  import { shrinkBaseline } from "./baseline.ts";
8
8
 
9
9
  const followedMoves = (root: string, against: string | undefined): Effect.Effect<Scope, SetupFailure, Git> =>
package/src/cli.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import process from "node:process";
3
3
  import { Console, Effect } from "effect";
4
- import { parseCommand, USAGE } from "./cli/args.ts";
5
- import { writeBaseline } from "./cli/baseline.ts";
6
- import { fix } from "./cli/fix.ts";
7
- import { lint } from "./cli/lint.ts";
8
- import { migrateBaseline } from "./cli/migrate.ts";
9
- import { runMain } from "./cli/run-main.ts";
10
- import { pruneBaseline, tightenBaseline } from "./cli/shrink.ts";
4
+ import { parseCommand, USAGE } from "#cli/args.ts";
5
+ import { writeBaseline } from "#cli/baseline.ts";
6
+ import { fix } from "#cli/fix.ts";
7
+ import { lint } from "#cli/lint.ts";
8
+ import { migrateBaseline } from "#cli/migrate.ts";
9
+ import { runMain } from "#cli/run-main.ts";
10
+ import { pruneBaseline, tightenBaseline } from "#cli/shrink.ts";
11
11
  import { SetupFailure } from "./failure.ts";
12
12
 
13
13
  const parsed = parseCommand(process.argv.slice(2));
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
- import { type Decoded, decodeWith } from "../decoded.ts";
3
- import type { Rule } from "../rule.ts";
2
+ import { type Decoded, decodeWith } from "#decoded.ts";
3
+ import type { Rule } from "#rule.ts";
4
4
 
5
5
  const isRule = (value: unknown): value is Rule =>
6
6
  typeof value === "object"
@@ -1,9 +1,9 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { Effect, FileSystem } from "effect";
4
- import { validOrFail } from "../decoded.ts";
5
- import { SetupFailure } from "../failure.ts";
6
- import type { InventoryScope } from "../inventory/collect.ts";
4
+ import { validOrFail } from "#decoded.ts";
5
+ import { SetupFailure } from "#failure.ts";
6
+ import type { InventoryScope } from "#inventory/collect.ts";
7
7
  import { type ConfigInput, decodeConfig } from "./decode.ts";
8
8
  import { CONFIG_FILE } from "./file.ts";
9
9
  import { type ResolvedRules, resolveRules } from "./resolve.ts";
@@ -1,10 +1,10 @@
1
1
  import { Effect } from "effect";
2
- import type { Level } from "../config.ts";
3
- import type { Decoded } from "../decoded.ts";
4
- import type { ActiveRule } from "../engine/run-rules.ts";
5
- import type { RuleIndex } from "../engine/violation.ts";
6
- import type { Rule } from "../rule.ts";
7
- import { builtInRules } from "../rules/built-in.ts";
2
+ import type { Level } from "#config.ts";
3
+ import type { Decoded } from "#decoded.ts";
4
+ import type { ActiveRule } from "#engine/run-rules.ts";
5
+ import type { RuleIndex } from "#engine/violation.ts";
6
+ import type { Rule } from "#rule.ts";
7
+ import { builtInRules } from "#rules/built-in.ts";
8
8
  import type { ConfigInput } from "./decode.ts";
9
9
 
10
10
  export interface ResolvedRules extends RuleIndex {
package/src/config.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { builtInRules } from "#rules/built-in.ts";
1
2
  import type { Rule } from "./rule.ts";
2
- import type { builtInRules } from "./rules/built-in.ts";
3
3
 
4
4
  export type Level = "error" | "warn" | "off";
5
5
 
@@ -1,11 +1,11 @@
1
1
  import { join } from "node:path";
2
2
  import { Effect, type FileSystem } from "effect";
3
- import { type BaselineEntry, decodeBaseline } from "../baseline/format.ts";
4
- import { LEGACY_BASELINE } from "../baseline/legacy.ts";
5
- import type { ResolvedConfig } from "../config/load.ts";
6
- import { validOrFail } from "../decoded.ts";
7
- import { SetupFailure } from "../failure.ts";
8
- import { readOptionalText } from "../inventory/filesystem.ts";
3
+ import { type BaselineEntry, decodeBaseline } from "#baseline/format.ts";
4
+ import { LEGACY_BASELINE } from "#baseline/legacy.ts";
5
+ import type { ResolvedConfig } from "#config/load.ts";
6
+ import { validOrFail } from "#decoded.ts";
7
+ import { SetupFailure } from "#failure.ts";
8
+ import { readOptionalText } from "#inventory/filesystem.ts";
9
9
 
10
10
  export interface BaselineFile {
11
11
  readonly entries: readonly BaselineEntry[];
@@ -1,6 +1,6 @@
1
- import { applyBaseline, type Regression, type StaleBaselineEntry } from "../baseline/compare.ts";
2
- import type { BaselineEntry } from "../baseline/format.ts";
3
- import { applyRegistry, type RegistryEntry, type StaleRegistryEntry } from "../exceptions/registry.ts";
1
+ import { applyBaseline, type Regression, type StaleBaselineEntry } from "#baseline/compare.ts";
2
+ import type { BaselineEntry } from "#baseline/format.ts";
3
+ import { applyRegistry, type RegistryEntry, type StaleRegistryEntry } from "#exceptions/registry.ts";
4
4
  import { byLocation, type RuleIndex, type Violation } from "./violation.ts";
5
5
 
6
6
  export interface Outcome {
@@ -1,8 +1,8 @@
1
1
  import { isAbsolute, relative } from "node:path";
2
2
  import { Effect } from "effect";
3
- import { SetupFailure } from "../failure.ts";
4
- import { posix } from "../inventory/ignore-scope.ts";
5
- import type { Finding, Findings, RuleInputs } from "../rule.ts";
3
+ import { SetupFailure } from "#failure.ts";
4
+ import { posix } from "#inventory/ignore-scope.ts";
5
+ import type { Finding, Findings, RuleInputs } from "#rule.ts";
6
6
  import type { ActiveLevel, Violation } from "./violation.ts";
7
7
 
8
8
  export interface ActiveRule {
@@ -1,11 +1,11 @@
1
1
  import { resolve } from "node:path";
2
2
  import { Effect, type FileSystem } from "effect";
3
- import { loadConfig, type ResolvedConfig } from "../config/load.ts";
4
- import { validOrFail } from "../decoded.ts";
5
- import { decodeRegistry, type RegistryEntry } from "../exceptions/registry.ts";
6
- import { SetupFailure } from "../failure.ts";
7
- import { collectInventory, type Inventory } from "../inventory/collect.ts";
8
- import { type FilesystemFailure, readOptionalText } from "../inventory/filesystem.ts";
3
+ import { loadConfig, type ResolvedConfig } from "#config/load.ts";
4
+ import { validOrFail } from "#decoded.ts";
5
+ import { decodeRegistry, type RegistryEntry } from "#exceptions/registry.ts";
6
+ import { SetupFailure } from "#failure.ts";
7
+ import { collectInventory, type Inventory } from "#inventory/collect.ts";
8
+ import { type FilesystemFailure, readOptionalText } from "#inventory/filesystem.ts";
9
9
  import { type BaselineFile, readBaseline, readInput } from "./baseline-file.ts";
10
10
  import { runRules } from "./run-rules.ts";
11
11
  import type { Violation } from "./violation.ts";
@@ -1,5 +1,5 @@
1
- import type { Level } from "../config.ts";
2
- import type { Finding } from "../rule.ts";
1
+ import type { Level } from "#config.ts";
2
+ import type { Finding } from "#rule.ts";
3
3
 
4
4
  export type ActiveLevel = "error" | "warn";
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
- import { type Decoded, decodeWith } from "../decoded.ts";
3
- import { type RuleIndex, registrable, unusedEntryProblem, type Violation } from "../engine/violation.ts";
2
+ import { type Decoded, decodeWith } from "#decoded.ts";
3
+ import { type RuleIndex, registrable, unusedEntryProblem, type Violation } from "#engine/violation.ts";
4
4
 
5
5
  const RegistryEntry = Schema.Struct({
6
6
  file: Schema.NonEmptyString,
package/src/git/base.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { SetupFailure } from "../failure.ts";
2
+ import { SetupFailure } from "#failure.ts";
3
3
  import { type Git, git } from "./command.ts";
4
4
 
5
5
  export interface Base {
@@ -1,6 +1,6 @@
1
1
  import { Effect, Stream } from "effect";
2
2
  import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
3
- import { SetupFailure } from "../failure.ts";
3
+ import { SetupFailure } from "#failure.ts";
4
4
 
5
5
  export interface GitResult {
6
6
  readonly code: number;
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import type { SetupFailure } from "../failure.ts";
2
+ import type { SetupFailure } from "#failure.ts";
3
3
  import { type Git, gitOrFail } from "./command.ts";
4
4
 
5
5
  export interface Changes {
@@ -1,7 +1,7 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { posix } from "node:path";
3
- import type { RuleInputs } from "../rule.ts";
4
- import { parse } from "../rules/syntax.ts";
3
+ import type { RuleInputs } from "#rule.ts";
4
+ import { parse } from "#rules/syntax.ts";
5
5
  import type { ImportRequest } from "./extract.ts";
6
6
  import { type Project, projectsFor } from "./projects.ts";
7
7
  import { resolveImport } from "./resolve.ts";
@@ -1,5 +1,5 @@
1
- import type { Finding } from "../../rule.ts";
2
- import type { ImportEdge, ImportGraph } from "../graph.ts";
1
+ import type { ImportEdge, ImportGraph } from "#imports/graph.ts";
2
+ import type { Finding } from "#rule.ts";
3
3
  import { type Compiler, compile, type Matcher } from "./match.ts";
4
4
  import type { Fence } from "./model.ts";
5
5
  import { labelOf, outgoing, reachedFrom } from "./reach.ts";
@@ -1,5 +1,5 @@
1
- import { builtinName, type Endpoint, packageNameOf } from "../resolve.ts";
2
- import { packageOf, type WorkspacePackage } from "../workspace.ts";
1
+ import { builtinName, type Endpoint, packageNameOf } from "#imports/resolve.ts";
2
+ import { packageOf, type WorkspacePackage } from "#imports/workspace.ts";
3
3
  import type { Selector } from "./model.ts";
4
4
 
5
5
  export interface PolicyScope {
@@ -1,5 +1,5 @@
1
- import type { ImportEdge } from "../graph.ts";
2
- import { type Endpoint, packageNameOf } from "../resolve.ts";
1
+ import type { ImportEdge } from "#imports/graph.ts";
2
+ import { type Endpoint, packageNameOf } from "#imports/resolve.ts";
3
3
  import { type CompiledFence, compileFence, type FenceGraph } from "./evaluate.ts";
4
4
  import type { PolicyScope } from "./match.ts";
5
5
  import type { Chain, ExampleStep, Fence } from "./model.ts";
@@ -1,5 +1,5 @@
1
- import type { ImportEdge } from "../graph.ts";
2
- import type { Endpoint } from "../resolve.ts";
1
+ import type { ImportEdge } from "#imports/graph.ts";
2
+ import type { Endpoint } from "#imports/resolve.ts";
3
3
  import type { Matcher } from "./match.ts";
4
4
 
5
5
  export interface Reached {
@@ -1,4 +1,4 @@
1
- import type { Endpoint } from "../resolve.ts";
1
+ import type { Endpoint } from "#imports/resolve.ts";
2
2
  import { type Compiler, holdsFiles, packageNamed, trimmed } from "./match.ts";
3
3
  import type { Selector } from "./model.ts";
4
4
 
@@ -1,8 +1,8 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { posix } from "node:path";
3
3
  import { promisify } from "node:util";
4
- import { emptyScope, type IgnoreScope, verdictFor, withIgnoreFile } from "../inventory/ignore-scope.ts";
5
- import type { RuleInputs } from "../rule.ts";
4
+ import { emptyScope, type IgnoreScope, verdictFor, withIgnoreFile } from "#inventory/ignore-scope.ts";
5
+ import type { RuleInputs } from "#rule.ts";
6
6
  import type { ImportGraph, UnresolvedImport } from "./graph.ts";
7
7
 
8
8
  type Reader = Pick<RuleInputs, "readText" | "root">;
@@ -1,7 +1,7 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { join, posix } from "node:path";
3
- import type { RuleInputs, SourceFile } from "../rule.ts";
4
- import { parse } from "../rules/syntax.ts";
3
+ import type { RuleInputs, SourceFile } from "#rule.ts";
4
+ import { parse } from "#rules/syntax.ts";
5
5
  import { ambientModules } from "./ambient.ts";
6
6
  import { type ImportKind, type ImportRequest, importsOf } from "./extract.ts";
7
7
  import { projectsFor } from "./projects.ts";
@@ -2,7 +2,7 @@ import { realpathSync } from "node:fs";
2
2
  import { isBuiltin } from "node:module";
3
3
  import { dirname, join, relative } from "node:path";
4
4
  import ts from "typescript";
5
- import { posix } from "../inventory/ignore-scope.ts";
5
+ import { posix } from "#inventory/ignore-scope.ts";
6
6
  import type { Ambient } from "./ambient.ts";
7
7
  import type { ImportRequest } from "./extract.ts";
8
8
  import type { Project } from "./projects.ts";
@@ -1,5 +1,5 @@
1
1
  import { posix } from "node:path";
2
- import type { RuleInputs } from "../rule.ts";
2
+ import type { RuleInputs } from "#rule.ts";
3
3
  import { globMatcher } from "./glob.ts";
4
4
  import { pnpmWorkspacePatterns } from "./pnpm-workspace.ts";
5
5
 
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
+ export { fence } from "#imports/fences/dsl.ts";
2
+ export type { Chain, ExampleStep, Examples, External, Fence, Target } from "#imports/fences/model.ts";
3
+ export { anyOf, anything, external, files, folders, modules, packages, scopes, workspace } from "#imports/fences/selectors.ts";
1
4
  export type { BuiltInRules, Level, QualityConfig, RuleSetting, RuleSettings } from "./config.ts";
2
5
  export { defineConfig } from "./config.ts";
3
- export { fence } from "./imports/fences/dsl.ts";
4
- export type { Chain, ExampleStep, Examples, External, Fence, Target } from "./imports/fences/model.ts";
5
- export { anyOf, anything, external, files, folders, modules, packages, scopes, workspace } from "./imports/fences/selectors.ts";
6
6
  export type { Configured, Finding, Findings, Rule, RuleContext, RuleInputs, SourceFile } from "./rule.ts";
7
7
  export { defineRule } from "./rule.ts";
8
8
  export type { StandardIssue, StandardResult, StandardSchemaV1 } from "./standard-schema.ts";
@@ -1,7 +1,7 @@
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 { SourceFile } from "#rule.ts";
5
5
  import { FilesystemFailure, orWhenAbsent, readRequiredText } from "./filesystem.ts";
6
6
  import { posix } from "./ignore-scope.ts";
7
7
  import { scopeAbove, walk } from "./walk.ts";
@@ -1,9 +1,9 @@
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 { FilesystemFailure } from "../inventory/filesystem.ts";
5
- import { posix } from "../inventory/ignore-scope.ts";
6
- import { walk } from "../inventory/walk.ts";
4
+ import { FilesystemFailure } from "#inventory/filesystem.ts";
5
+ import { posix } from "#inventory/ignore-scope.ts";
6
+ import { walk } from "#inventory/walk.ts";
7
7
 
8
8
  export type Sorting = { readonly _tag: "Invalid" } | { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
9
9
 
@@ -0,0 +1,21 @@
1
+ import { CAMEL, isUpper, PASCAL, sameWord, wordsOf } from "#naming/words.ts";
2
+
3
+ function restIsFolders(rest: readonly string[], folders: readonly string[]): boolean {
4
+ const folderWords = folders.flatMap(wordsOf);
5
+ return rest.every((word) => folderWords.some((folder) => sameWord(word, folder)));
6
+ }
7
+
8
+ export function exportFits(name: string, stem: string, folders: readonly string[]): boolean {
9
+ if (!(CAMEL.test(stem) || PASCAL.test(stem)) || isUpper(stem) !== isUpper(name)) {
10
+ return false;
11
+ }
12
+ const named = wordsOf(name);
13
+ const filed = wordsOf(stem);
14
+ for (let start = 0; start + filed.length <= named.length; start += 1) {
15
+ const matches = filed.every((word, offset) => word === named[start + offset]);
16
+ if (matches && restIsFolders([...named.slice(0, start), ...named.slice(start + filed.length)], folders)) {
17
+ return true;
18
+ }
19
+ }
20
+ return false;
21
+ }
@@ -0,0 +1,11 @@
1
+ import type { OwnExport } from "#naming/ownExports.ts";
2
+
3
+ export function mainExport(exports: readonly OwnExport[]): OwnExport | undefined {
4
+ const values = exports.filter((entry) => entry.kind === "value");
5
+ const types = exports.filter((entry) => entry.kind === "type");
6
+ const [value] = values;
7
+ if (values.length === 1 && value !== undefined && types.every((type) => type.name.startsWith(value.name))) {
8
+ return value;
9
+ }
10
+ return values.length === 0 && types.length === 1 ? types[0] : undefined;
11
+ }
@@ -0,0 +1,95 @@
1
+ import ts from "typescript";
2
+
3
+ export interface OwnExport {
4
+ readonly constant: boolean;
5
+ readonly kind: "type" | "value";
6
+ readonly name: string;
7
+ }
8
+
9
+ const CONSTANT_CASE = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/u;
10
+
11
+ const PRIMITIVE_LITERALS: ReadonlySet<ts.SyntaxKind> = new Set([
12
+ ts.SyntaxKind.BigIntLiteral,
13
+ ts.SyntaxKind.FalseKeyword,
14
+ ts.SyntaxKind.NoSubstitutionTemplateLiteral,
15
+ ts.SyntaxKind.NumericLiteral,
16
+ ts.SyntaxKind.StringLiteral,
17
+ ts.SyntaxKind.TrueKeyword,
18
+ ]);
19
+
20
+ function isPrimitiveLiteral(node: ts.Expression | undefined): boolean {
21
+ if (node === undefined) {
22
+ return false;
23
+ }
24
+ if (ts.isPrefixUnaryExpression(node)) {
25
+ return isPrimitiveLiteral(node.operand);
26
+ }
27
+ return PRIMITIVE_LITERALS.has(node.kind);
28
+ }
29
+
30
+ function isExported(statement: ts.Statement): boolean {
31
+ const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;
32
+ const exported = modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
33
+ const isDefault = modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword) ?? false;
34
+ return exported && !isDefault;
35
+ }
36
+
37
+ function variables(statement: ts.VariableStatement): readonly OwnExport[] {
38
+ const constant = (statement.declarationList.flags & ts.NodeFlags.Const) !== 0;
39
+ return statement.declarationList.declarations.flatMap((declaration) =>
40
+ ts.isIdentifier(declaration.name)
41
+ ? [
42
+ {
43
+ constant: constant && (CONSTANT_CASE.test(declaration.name.text) || isPrimitiveLiteral(declaration.initializer)),
44
+ kind: "value" as const,
45
+ name: declaration.name.text,
46
+ },
47
+ ]
48
+ : [],
49
+ );
50
+ }
51
+
52
+ function declared(statement: ts.Statement): readonly OwnExport[] {
53
+ if (ts.isVariableStatement(statement)) {
54
+ return variables(statement);
55
+ }
56
+ if (ts.isInterfaceDeclaration(statement) || ts.isTypeAliasDeclaration(statement)) {
57
+ return [{ constant: false, kind: "type", name: statement.name.text }];
58
+ }
59
+ const named =
60
+ ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement)
61
+ ? statement.name
62
+ : undefined;
63
+ return named !== undefined && ts.isIdentifier(named) ? [{ constant: false, kind: "value", name: named.text }] : [];
64
+ }
65
+
66
+ function locals(source: ts.SourceFile): ReadonlyMap<string, OwnExport> {
67
+ const all = source.statements.flatMap(declared);
68
+ return new Map(all.map((local) => [local.name, local]));
69
+ }
70
+
71
+ function listed(statement: ts.ExportDeclaration, known: ReadonlyMap<string, OwnExport>): readonly OwnExport[] {
72
+ const clause = statement.exportClause;
73
+ if (statement.moduleSpecifier !== undefined || clause === undefined || !ts.isNamedExports(clause)) {
74
+ return [];
75
+ }
76
+ return clause.elements.flatMap((element) => {
77
+ const name = element.name.text;
78
+ const local = known.get((element.propertyName ?? element.name).text);
79
+ if (name === "default" || local === undefined) {
80
+ return [];
81
+ }
82
+ const typeOnly = statement.isTypeOnly || element.isTypeOnly;
83
+ return [{ constant: local.constant, kind: typeOnly ? ("type" as const) : local.kind, name }];
84
+ });
85
+ }
86
+
87
+ export function ownExports(source: ts.SourceFile): readonly OwnExport[] {
88
+ const known = locals(source);
89
+ return source.statements.flatMap((statement) => {
90
+ if (ts.isExportDeclaration(statement)) {
91
+ return listed(statement, known);
92
+ }
93
+ return isExported(statement) ? declared(statement) : [];
94
+ });
95
+ }