@starci/eslint-canon-be 3.4.57 → 3.6.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 (197) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +11 -2
  3. package/dist/ambient-id.d.ts +9 -0
  4. package/{ambient-id.mjs → dist/ambient-id.js} +43 -39
  5. package/dist/app-composition.d.ts +21 -0
  6. package/{app-composition.mjs → dist/app-composition.js} +396 -300
  7. package/dist/async-discipline.d.ts +9 -0
  8. package/dist/async-discipline.js +77 -0
  9. package/dist/authorization.d.ts +12 -0
  10. package/{authorization.mjs → dist/authorization.js} +53 -59
  11. package/dist/boundary-schema.d.ts +15 -0
  12. package/{boundary-schema.mjs → dist/boundary-schema.js} +120 -105
  13. package/dist/builders.d.ts +21 -0
  14. package/{builders.mjs → dist/builders.js} +162 -146
  15. package/dist/cli.d.ts +15 -0
  16. package/{cli.mjs → dist/cli.js} +97 -82
  17. package/dist/comments.d.ts +52 -0
  18. package/dist/comments.js +412 -0
  19. package/dist/config-owner.d.ts +24 -0
  20. package/{config-owner.mjs → dist/config-owner.js} +256 -219
  21. package/dist/connections.d.ts +12 -0
  22. package/{connections.mjs → dist/connections.js} +138 -140
  23. package/dist/cookies.d.ts +9 -0
  24. package/{cookies.mjs → dist/cookies.js} +58 -58
  25. package/dist/cqrs.d.ts +27 -0
  26. package/{cqrs.mjs → dist/cqrs.js} +341 -282
  27. package/dist/data-access.d.ts +50 -0
  28. package/{data-access.mjs → dist/data-access.js} +238 -243
  29. package/dist/default-deny.d.ts +15 -0
  30. package/{default-deny.mjs → dist/default-deny.js} +103 -88
  31. package/dist/e2e-flow.d.ts +25 -0
  32. package/{e2e-flow.mjs → dist/e2e-flow.js} +113 -112
  33. package/dist/edge-hardening.d.ts +10 -0
  34. package/dist/edge-hardening.js +173 -0
  35. package/dist/error-handling.d.ts +21 -0
  36. package/{error-handling.mjs → dist/error-handling.js} +289 -239
  37. package/dist/event-bus.d.ts +14 -0
  38. package/{event-bus.mjs → dist/event-bus.js} +146 -129
  39. package/dist/feature-thin.d.ts +12 -0
  40. package/{feature-thin.mjs → dist/feature-thin.js} +208 -191
  41. package/dist/function-budget.d.ts +7 -0
  42. package/{function-budget.mjs → dist/function-budget.js} +24 -27
  43. package/dist/health-ready.d.ts +10 -0
  44. package/dist/health-ready.js +703 -0
  45. package/dist/idempotency.d.ts +10 -0
  46. package/{idempotency.mjs → dist/idempotency.js} +296 -226
  47. package/dist/index.d.ts +54 -0
  48. package/{index.mjs → dist/index.js} +91 -109
  49. package/dist/infra-owner.d.ts +18 -0
  50. package/{infra-owner.mjs → dist/infra-owner.js} +58 -51
  51. package/dist/injection.d.ts +30 -0
  52. package/{injection.mjs → dist/injection.js} +397 -344
  53. package/dist/input-bounds.d.ts +15 -0
  54. package/{input-bounds.mjs → dist/input-bounds.js} +143 -132
  55. package/dist/jobs.d.ts +17 -0
  56. package/{jobs.mjs → dist/jobs.js} +116 -99
  57. package/dist/jwt-alg.d.ts +6 -0
  58. package/dist/jwt-alg.js +49 -0
  59. package/dist/lib/app-roles.d.ts +25 -0
  60. package/{lib/app-roles.mjs → dist/lib/app-roles.js} +15 -17
  61. package/dist/lib/ast.d.ts +40 -0
  62. package/dist/lib/ast.js +100 -0
  63. package/dist/lib/client-idempotency.d.ts +3 -0
  64. package/{lib/client-idempotency.mjs → dist/lib/client-idempotency.js} +316 -268
  65. package/dist/lib/config.d.ts +36 -0
  66. package/{lib/config.mjs → dist/lib/config.js} +24 -27
  67. package/dist/lib/db-writes.d.ts +29 -0
  68. package/{lib/db-writes.mjs → dist/lib/db-writes.js} +27 -27
  69. package/dist/lib/declared.d.ts +77 -0
  70. package/{lib/declared.mjs → dist/lib/declared.js} +83 -78
  71. package/dist/lib/doors.d.ts +50 -0
  72. package/{lib/doors.mjs → dist/lib/doors.js} +45 -50
  73. package/dist/lib/edition.d.ts +25 -0
  74. package/{lib/edition.mjs → dist/lib/edition.js} +15 -20
  75. package/dist/lib/entity-writes.d.ts +7 -0
  76. package/{lib/entity-writes.mjs → dist/lib/entity-writes.js} +31 -22
  77. package/dist/lib/hfs.d.ts +34 -0
  78. package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
  79. package/dist/lib/import-source.d.ts +63 -0
  80. package/dist/lib/import-source.js +134 -0
  81. package/dist/lib/path.d.ts +8 -0
  82. package/{lib/path.mjs → dist/lib/path.js} +4 -7
  83. package/dist/lib/persistence.d.ts +115 -0
  84. package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
  85. package/dist/lib/ports.d.ts +70 -0
  86. package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
  87. package/dist/lib/rule.d.ts +31 -0
  88. package/dist/lib/rule.js +2 -0
  89. package/dist/lib/runtime-root.d.ts +4 -0
  90. package/dist/lib/runtime-root.js +10 -0
  91. package/dist/lib/schema-values.d.ts +13 -0
  92. package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
  93. package/dist/lib/specifier.d.ts +12 -0
  94. package/dist/lib/specifier.js +29 -0
  95. package/dist/lib/subject-values.d.ts +4 -0
  96. package/dist/lib/subject-values.js +61 -0
  97. package/dist/lib/transactions.d.ts +18 -0
  98. package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
  99. package/dist/lib/transport-slots.d.ts +17 -0
  100. package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
  101. package/dist/lib/types.d.ts +96 -0
  102. package/dist/lib/types.js +150 -0
  103. package/dist/lib/unit-spec.d.ts +48 -0
  104. package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
  105. package/dist/lib/webhook-ack.d.ts +4 -0
  106. package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
  107. package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
  108. package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
  109. package/dist/lib/webhook-handoff-intake.d.ts +4 -0
  110. package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
  111. package/dist/lib/webhook-handoff.d.ts +15 -0
  112. package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
  113. package/dist/lib/webhook-verifiers.d.ts +20 -0
  114. package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
  115. package/dist/lib/why.d.ts +9 -0
  116. package/{lib/why.mjs → dist/lib/why.js} +6 -6
  117. package/dist/log-safety.d.ts +20 -0
  118. package/dist/log-safety.js +308 -0
  119. package/dist/module-layering.d.ts +42 -0
  120. package/dist/module-layering.js +257 -0
  121. package/dist/module-shape.d.ts +47 -0
  122. package/{module-shape.mjs → dist/module-shape.js} +278 -236
  123. package/dist/naming.d.ts +49 -0
  124. package/dist/naming.js +246 -0
  125. package/dist/observability.d.ts +25 -0
  126. package/dist/observability.js +245 -0
  127. package/dist/operations.d.ts +23 -0
  128. package/{operations.mjs → dist/operations.js} +410 -332
  129. package/dist/project-graph.d.ts +9 -0
  130. package/{project-graph.mjs → dist/project-graph.js} +8 -13
  131. package/dist/projections.d.ts +11 -0
  132. package/{projections.mjs → dist/projections.js} +60 -57
  133. package/dist/query-safety.d.ts +21 -0
  134. package/{query-safety.mjs → dist/query-safety.js} +92 -108
  135. package/dist/realtime.d.ts +15 -0
  136. package/{realtime.mjs → dist/realtime.js} +108 -106
  137. package/dist/resilience.d.ts +15 -0
  138. package/dist/resilience.js +319 -0
  139. package/dist/schema-authority.d.ts +15 -0
  140. package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
  141. package/dist/service-deps.d.ts +17 -0
  142. package/{service-deps.mjs → dist/service-deps.js} +133 -130
  143. package/dist/service-isolation.d.ts +8 -0
  144. package/dist/service-isolation.js +76 -0
  145. package/dist/size-budget.d.ts +9 -0
  146. package/{size-budget.mjs → dist/size-budget.js} +27 -27
  147. package/dist/sonar-parity.d.ts +5 -0
  148. package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
  149. package/dist/spec-no-skip.d.ts +9 -0
  150. package/dist/spec-no-skip.js +81 -0
  151. package/dist/spec-quality.d.ts +10 -0
  152. package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
  153. package/dist/suppression.d.ts +26 -0
  154. package/{suppression.mjs → dist/suppression.js} +30 -45
  155. package/dist/temporal.d.ts +9 -0
  156. package/{temporal.mjs → dist/temporal.js} +75 -65
  157. package/dist/test-world.d.ts +28 -0
  158. package/{test-world.mjs → dist/test-world.js} +102 -83
  159. package/dist/testing.d.ts +51 -0
  160. package/dist/testing.js +368 -0
  161. package/dist/third-party-owner.d.ts +8 -0
  162. package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
  163. package/dist/transport.d.ts +24 -0
  164. package/{transport.mjs → dist/transport.js} +279 -240
  165. package/dist/type-safety.d.ts +25 -0
  166. package/dist/type-safety.js +297 -0
  167. package/dist/unit-spec.d.ts +30 -0
  168. package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
  169. package/dist/uploads.d.ts +9 -0
  170. package/{uploads.mjs → dist/uploads.js} +62 -54
  171. package/dist/user-copy.d.ts +9 -0
  172. package/{user-copy.mjs → dist/user-copy.js} +76 -67
  173. package/dist/webhooks.d.ts +16 -0
  174. package/{webhooks.mjs → dist/webhooks.js} +243 -231
  175. package/package.json +17 -8
  176. package/runtime/knowledge/hfs/canon-pins.yaml +22 -14
  177. package/runtime/knowledge/hfs/rules.yaml +23 -0
  178. package/runtime/scripts/lib/package-at.mjs +5 -5
  179. package/async-discipline.mjs +0 -83
  180. package/comments.mjs +0 -416
  181. package/edge-hardening.mjs +0 -139
  182. package/health-ready.mjs +0 -539
  183. package/jwt-alg.mjs +0 -45
  184. package/lib/ast.mjs +0 -88
  185. package/lib/import-source.mjs +0 -104
  186. package/lib/specifier.mjs +0 -27
  187. package/lib/subject-values.mjs +0 -55
  188. package/lib/types.mjs +0 -133
  189. package/log-safety.mjs +0 -303
  190. package/module-layering.mjs +0 -270
  191. package/naming.mjs +0 -251
  192. package/observability.mjs +0 -241
  193. package/resilience.mjs +0 -304
  194. package/service-isolation.mjs +0 -75
  195. package/spec-no-skip.mjs +0 -85
  196. package/testing.mjs +0 -384
  197. package/type-safety.mjs +0 -323
@@ -0,0 +1,42 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /**
3
+ * A cross-owner import targets the owner's public entry: the alias and the owner, nothing deeper. A same-owner import
4
+ * is relative and never goes through the owner's own `index.ts` (BE-CONVENTION 2.4).
5
+ */
6
+ export declare const importOwnerEntry: RuleModule;
7
+ /** Inside an owner, imports are relative -- never the owner's own public alias. */
8
+ export declare const noSelfModuleAlias: RuleModule;
9
+ /**
10
+ * No file re-exports a folder, and an owner's index lists a bounded set of named exports.
11
+ *
12
+ * The public entry of an owner is a short, explicit list, one per owner root:
13
+ * - a bare-dot or trailing-slash specifier names a directory by construction, in any file;
14
+ * - an `index` file that is not at its owner's root is a nested barrel;
15
+ * - in an `index` file: `export *` hides the surface instead of listing it, anything but a named `export { } from` /
16
+ * `export type { } from` line (an import, a declaration, a default export, a local export) is refused, and more
17
+ * than the manifest's `indexExports` names is not a public surface but the inside of the owner.
18
+ *
19
+ * What this accepts: `export { PlanModule } from "./plan.module"` and `export type { PlanSummary } from "./plan.contracts"`.
20
+ */
21
+ export declare const noFolderReexport: RuleModule;
22
+ /**
23
+ * A relative specifier may never leave the owner it is written in. The public-entry rule already says an import from
24
+ * another owner goes through its `index.ts`; a relative path can just as easily walk OUT (`../../other-owner/thing`),
25
+ * reaching a sibling owner without ever naming it. A file doing that could not be moved with its owner and still
26
+ * resolve, because the path assumes the sibling is sitting right there on disk.
27
+ */
28
+ export declare const noRelativeCapabilityEscape: RuleModule;
29
+ /** The rules this law contributes to the plugin. */
30
+ export declare const rules: {
31
+ "import-owner-entry": RuleModule;
32
+ "no-self-module-alias": RuleModule;
33
+ "no-folder-reexport": RuleModule;
34
+ "no-relative-capability-escape": RuleModule;
35
+ };
36
+ /**
37
+ * The level this law asks for, as the plugin's own opinion.
38
+ *
39
+ * All four are `error`. HFS keeps no baseline: a repository adopts them after its migration lane has moved its imports
40
+ * onto owner entries, and `starciBeConfig` states them at `error` with none switched off.
41
+ */
42
+ export declare const recommended: Recommended;
@@ -0,0 +1,257 @@
1
+ /**
2
+ * The rules that hold the public surface of an owner (catalog R30 `BE_PUBLIC_SURFACE`, BE-CONVENTION 1.15 and 2.4).
3
+ *
4
+ * Every owner (a feature, a domain or platform capability, an integration) has exactly ONE `index.ts` at its root and
5
+ * that file is its public surface. Four rules read import specifiers and the shape of index files against the HFS slot
6
+ * view; none of them reads a path pattern, and an alias is resolved through the program's own `compilerOptions.paths`:
7
+ *
8
+ * - `import-owner-entry` - a cross-owner import targets the owner's `index.ts` (`@modules/domain/plan`,
9
+ * `@features/api/plan`), never a file inside it, and an alias that names a tier but no owner (`@modules/domain`) names
10
+ * nothing importable. A same-owner import is relative and never goes through the owner's own `index.ts`.
11
+ * - `no-self-module-alias` - inside an owner, imports are relative, never the owner's own alias.
12
+ * - `no-relative-capability-escape` - a relative import never walks out of its own owner.
13
+ * - `no-folder-reexport` - a specifier that names a directory is refused; a nested `index.ts` (any index that is not
14
+ * at its owner's root) is refused; an owner's `index.ts` holds only named `export { }` / `export type { }` lines
15
+ * re-exporting from files, never `export *`, never a declaration, and at most `budget.indexExports` names.
16
+ *
17
+ * "Which owner does this file belong to" is `hfs.ownerOf`; "which owner does this specifier reach" is the same question
18
+ * asked of the file the specifier resolves to. Nothing here touches disk.
19
+ */
20
+ import { posix } from "node:path";
21
+ import { hfsOf } from "./lib/hfs.js";
22
+ import { baseName } from "./lib/ports.js";
23
+ import { resolveAlias } from "./lib/specifier.js";
24
+ /** The tiers whose files belong to an owner with a root `index.ts`. */
25
+ const OWNER_TIERS = new Set(["feature", "domain", "platform", "integrations"]);
26
+ /**
27
+ * The owner directory (repository-relative) a file belongs to, or null.
28
+ *
29
+ * A slot whose "root" is the file itself (a stray file directly in a tier folder) owns nothing.
30
+ *
31
+ * @param {object} hfs - The HFS view.
32
+ * @param {string} file - An absolute or repository-relative file path.
33
+ * @returns {string | null} The owner's root directory.
34
+ */
35
+ const ownerDirOf = (hfs, file) => {
36
+ const root = hfs.ownerOf(file);
37
+ return root && root !== hfs.relative(file) ? root : null;
38
+ };
39
+ /** The forward-slash absolute path of a repository-relative path. */
40
+ const absolute = (hfs, rel) => `${hfs.repoRoot.replace(/\\/g, "/")}/${rel}`;
41
+ /** The owner an import path (no extension, absolute) reaches: the owner of `<path>/index.ts`, which any file or folder of that owner shares. */
42
+ const ownerOfTarget = (hfs, target) => ownerDirOf(hfs, `${target}/index.ts`);
43
+ /** A specifier that names a directory by construction: `.`, `./`, `..`, `../`, or a trailing `/`. */
44
+ const isBareFolderSpecifier = (specifier) => specifier === "." || specifier === "./" || specifier === ".." || specifier === "../" || specifier.endsWith("/");
45
+ const isRelative = (specifier) => specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
46
+ /** The absolute path a relative specifier names from a file, without touching disk. */
47
+ const resolveRelative = (filename, specifier) => posix.normalize(`${posix.dirname(filename.replace(/\\/g, "/"))}/${specifier}`);
48
+ /** Calls `check(node, specifier)` for every import and re-export that names a module. */
49
+ const onSpecifiers = (check) => ({
50
+ ImportDeclaration(node) {
51
+ check(node.source, node.source.value);
52
+ },
53
+ ExportNamedDeclaration(node) {
54
+ if (node.source)
55
+ check(node.source, node.source.value);
56
+ },
57
+ ExportAllDeclaration(node) {
58
+ if (node.source)
59
+ check(node.source, node.source.value);
60
+ },
61
+ });
62
+ /** The public-surface width: the file's slot budget, else its tier's owner-slot budget, else a back-end owner default. */
63
+ const indexExportBudget = (hfs, filename) => [hfs.slotOf(filename), `be.${hfs.tierOf(filename)}`, "be.domain", "be.feature"].map((id) => (id ? hfs.slot(id)?.budget?.indexExports : undefined)).find(Number.isInteger);
64
+ // -- R30: import-owner-entry -----------------------------------------------------------------------
65
+ /**
66
+ * A cross-owner import targets the owner's public entry: the alias and the owner, nothing deeper. A same-owner import
67
+ * is relative and never goes through the owner's own `index.ts` (BE-CONVENTION 2.4).
68
+ */
69
+ export const importOwnerEntry = {
70
+ meta: {
71
+ type: "problem",
72
+ docs: { description: "Import another owner through its public entry (`index.ts`); import inside an owner relatively and never through its own `index.ts`." },
73
+ schema: [],
74
+ messages: {
75
+ barrel: "`{{specifier}}` names a tier, not an owner. Import an owner's public entry, for example `@modules/domain/plan` or `@features/api/plan`.",
76
+ deep: "`{{specifier}}` reaches into a file of another owner. Import the owner's public entry (its `index.ts`) and export what you need from there.",
77
+ ownIndex: "`{{specifier}}` goes through this owner's own `index.ts`. The index is the surface other owners see; inside the owner import the file that declares the symbol, relatively.",
78
+ },
79
+ },
80
+ create(context) {
81
+ const filename = context.filename || context.getFilename();
82
+ const hfs = hfsOf(context);
83
+ const self = ownerDirOf(hfs, filename);
84
+ return onSpecifiers((node, specifier) => {
85
+ if (typeof specifier !== "string")
86
+ return;
87
+ if (isRelative(specifier)) {
88
+ if (isBareFolderSpecifier(specifier) || !self)
89
+ return;
90
+ const target = resolveRelative(filename, specifier);
91
+ if (posix.basename(target) === "index" && posix.dirname(target) === absolute(hfs, self)) {
92
+ context.report({ node, messageId: "ownIndex", data: { specifier } });
93
+ }
94
+ return;
95
+ }
96
+ const alias = resolveAlias(context, specifier);
97
+ if (!alias)
98
+ return;
99
+ const owner = ownerOfTarget(hfs, alias.target);
100
+ if (!owner) {
101
+ // an alias that reaches a tier folder but no owner in it: nothing importable is named
102
+ if (OWNER_TIERS.has(hfs.tierOf(`${alias.target}/index.ts`) ?? "") || OWNER_TIERS.has(hfs.tierOf(`${alias.target}.ts`) ?? "")) {
103
+ context.report({ node, messageId: "barrel", data: { specifier } });
104
+ }
105
+ return;
106
+ }
107
+ // reaching one's own owner through its alias is no-self-module-alias's finding
108
+ if (owner === self)
109
+ return;
110
+ const ownerAbsolute = absolute(hfs, owner);
111
+ const inside = alias.target === ownerAbsolute ? "" : alias.target.slice(ownerAbsolute.length + 1);
112
+ if (inside !== "" && inside !== "index")
113
+ context.report({ node, messageId: "deep", data: { specifier } });
114
+ });
115
+ },
116
+ };
117
+ // -- no-self-module-alias --------------------------------------------------------------------------
118
+ /** Inside an owner, imports are relative -- never the owner's own public alias. */
119
+ export const noSelfModuleAlias = {
120
+ meta: {
121
+ type: "problem",
122
+ docs: { description: "Inside an owner, import relatively rather than through its own alias." },
123
+ schema: [],
124
+ messages: {
125
+ self: "`{{specifier}}` reaches this owner through its own public alias. That is the owner talking to itself through its front door: a cycle magnet, and a lie about the boundary - the alias exists to say \"this comes from elsewhere\". Use a relative import.",
126
+ },
127
+ },
128
+ create(context) {
129
+ const hfs = hfsOf(context);
130
+ const self = ownerDirOf(hfs, context.filename || context.getFilename());
131
+ if (!self)
132
+ return {};
133
+ return onSpecifiers((node, specifier) => {
134
+ if (typeof specifier !== "string" || isRelative(specifier))
135
+ return;
136
+ const alias = resolveAlias(context, specifier);
137
+ if (alias && ownerOfTarget(hfs, alias.target) === self)
138
+ context.report({ node, messageId: "self", data: { specifier } });
139
+ });
140
+ },
141
+ };
142
+ // -- no-folder-reexport ----------------------------------------------------------------------------
143
+ /** Whether a file is an index by its role name. */
144
+ const isIndexFile = (filename) => /^index\.[cm]?[jt]sx?$/.test(baseName(filename));
145
+ /**
146
+ * No file re-exports a folder, and an owner's index lists a bounded set of named exports.
147
+ *
148
+ * The public entry of an owner is a short, explicit list, one per owner root:
149
+ * - a bare-dot or trailing-slash specifier names a directory by construction, in any file;
150
+ * - an `index` file that is not at its owner's root is a nested barrel;
151
+ * - in an `index` file: `export *` hides the surface instead of listing it, anything but a named `export { } from` /
152
+ * `export type { } from` line (an import, a declaration, a default export, a local export) is refused, and more
153
+ * than the manifest's `indexExports` names is not a public surface but the inside of the owner.
154
+ *
155
+ * What this accepts: `export { PlanModule } from "./plan.module"` and `export type { PlanSummary } from "./plan.contracts"`.
156
+ */
157
+ export const noFolderReexport = {
158
+ meta: {
159
+ type: "problem",
160
+ docs: { description: "No file re-exports a folder, no `index.ts` is nested, and an owner's `index.ts` lists a bounded set of named exports." },
161
+ schema: [],
162
+ messages: {
163
+ bareSpecifier: "`{{specifier}}` names a directory, not a file. An owner's public surface is the files call sites actually import - re-exporting a whole folder makes that surface a list nobody reads instead. Export the specific file.",
164
+ indexBarrel: "`{{name}}` is a public entry and must list explicit named exports. Replace export-star with the symbols this owner exposes.",
165
+ nestedIndex: "This `index.ts` is not at its owner's root ({{owner}}). An owner has exactly one `index.ts`, the public surface; a nested barrel is a second surface. Delete it and import the files directly, relatively.",
166
+ onlyNamedExports: "An owner's `index.ts` holds only named `export { } from \"./file\"` and `export type { } from \"./file\"` lines. Move this out of the index into the file that owns it and re-export the name.",
167
+ tooWide: "This public entry exports {{count}} names, above the budget of {{max}}. An entry that wide is the inside of the owner: split the owner, or export fewer, narrower contracts.",
168
+ },
169
+ },
170
+ create(context) {
171
+ const filename = context.filename || context.getFilename();
172
+ const hfs = hfsOf(context);
173
+ const isIndex = isIndexFile(filename);
174
+ const max = indexExportBudget(hfs, filename);
175
+ let count = 0;
176
+ return {
177
+ ...onSpecifiers((node, specifier) => {
178
+ if (typeof specifier === "string" && isBareFolderSpecifier(specifier))
179
+ context.report({ node, messageId: "bareSpecifier", data: { specifier } });
180
+ }),
181
+ Program(node) {
182
+ if (!isIndex)
183
+ return;
184
+ const owner = ownerDirOf(hfs, filename);
185
+ if (owner && posix.dirname(hfs.relative(filename)) !== owner)
186
+ context.report({ node, messageId: "nestedIndex", data: { owner } });
187
+ for (const statement of node.body) {
188
+ const named = statement.type === "ExportNamedDeclaration" && statement.source && !statement.declaration;
189
+ if (statement.type === "ExportAllDeclaration") {
190
+ count += 1;
191
+ context.report({ node: statement, messageId: "indexBarrel", data: { name: baseName(filename) } });
192
+ }
193
+ else if (!named) {
194
+ context.report({ node: statement, messageId: "onlyNamedExports" });
195
+ }
196
+ else {
197
+ count += statement.specifiers.length;
198
+ }
199
+ }
200
+ },
201
+ "Program:exit"(node) {
202
+ if (isIndex && typeof max === "number" && Number.isInteger(max) && count > max)
203
+ context.report({ node, messageId: "tooWide", data: { count, max } });
204
+ },
205
+ };
206
+ },
207
+ };
208
+ // -- no-relative-capability-escape -----------------------------------------------------------------
209
+ /**
210
+ * A relative specifier may never leave the owner it is written in. The public-entry rule already says an import from
211
+ * another owner goes through its `index.ts`; a relative path can just as easily walk OUT (`../../other-owner/thing`),
212
+ * reaching a sibling owner without ever naming it. A file doing that could not be moved with its owner and still
213
+ * resolve, because the path assumes the sibling is sitting right there on disk.
214
+ */
215
+ export const noRelativeCapabilityEscape = {
216
+ meta: {
217
+ type: "problem",
218
+ docs: { description: "A relative import may not walk out of its own owner." },
219
+ schema: [],
220
+ messages: {
221
+ escape: "`{{specifier}}` is a relative import that leaves the `{{from}}` owner and reaches `{{to}}`. Cross an owner boundary through the other owner's public entry (its alias), never by walking out with `../`.",
222
+ },
223
+ },
224
+ create(context) {
225
+ const filename = context.filename || context.getFilename();
226
+ const hfs = hfsOf(context);
227
+ const self = ownerDirOf(hfs, filename);
228
+ if (!self)
229
+ return {};
230
+ return onSpecifiers((node, specifier) => {
231
+ if (typeof specifier !== "string" || !isRelative(specifier))
232
+ return;
233
+ const target = ownerOfTarget(hfs, resolveRelative(filename, specifier));
234
+ if (target && target !== self)
235
+ context.report({ node, messageId: "escape", data: { specifier, from: self, to: target } });
236
+ });
237
+ },
238
+ };
239
+ /** The rules this law contributes to the plugin. */
240
+ export const rules = {
241
+ "import-owner-entry": importOwnerEntry,
242
+ "no-self-module-alias": noSelfModuleAlias,
243
+ "no-folder-reexport": noFolderReexport,
244
+ "no-relative-capability-escape": noRelativeCapabilityEscape,
245
+ };
246
+ /**
247
+ * The level this law asks for, as the plugin's own opinion.
248
+ *
249
+ * All four are `error`. HFS keeps no baseline: a repository adopts them after its migration lane has moved its imports
250
+ * onto owner entries, and `starciBeConfig` states them at `error` with none switched off.
251
+ */
252
+ export const recommended = {
253
+ "starci-be/import-owner-entry": "error",
254
+ "starci-be/no-self-module-alias": "error",
255
+ "starci-be/no-folder-reexport": "error",
256
+ "starci-be/no-relative-capability-escape": "error",
257
+ };
@@ -0,0 +1,47 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** `@Global()` is banned everywhere: globality is decided at the app root. */
3
+ export declare const noGlobalDecorator: RuleModule;
4
+ /** `isGlobal: true` appears only in the app's `app.module.ts`. */
5
+ export declare const isGlobalOnlyInApp: RuleModule;
6
+ /** A module never imports another owner's module: a capability is reached through its `Inject*()` decorators. */
7
+ export declare const noCrossOwnerModuleImport: RuleModule;
8
+ /** A configurable module builder names its options type. */
9
+ export declare const typedModuleDefinition: RuleModule;
10
+ /** The one dynamic-module factory is `static register`. */
11
+ export declare const staticModuleRegister: RuleModule;
12
+ /** Providers are built by the container, not by `new` (a spec constructs its subject with typed doubles). */
13
+ export declare const noNewInjectable: RuleModule;
14
+ /** No mutable state at module scope. */
15
+ export declare const noModuleLet: RuleModule;
16
+ /** One `@Module` class per file. */
17
+ export declare const oneModulePerFile: RuleModule;
18
+ /**
19
+ * The shape of a module's definition (BE-CONVENTION 1.2, owner ruling module-definition-everywhere): the representative
20
+ * module of a capability builds `new ConfigurableModuleBuilder<XOptions>().setExtras({ isGlobal: false }, ...).build()` and
21
+ * may override only `static register(options: typeof OPTIONS_TYPE): DynamicModule`; every other module (a sub-module, a feature,
22
+ * a transport, a cli group) builds `new ConfigurableModuleBuilder<XOptions>().setClassMethodName("register").build()` and
23
+ * declares nothing but its `@Module` metadata.
24
+ */
25
+ export declare const capabilityModuleShape: RuleModule;
26
+ /**
27
+ * Every Nest module has a module definition and is registered through it (owner ruling module-definition-everywhere): its
28
+ * `<x>.module.ts` has a sibling `<x>.module-definition.ts` and `<x>.options.ts`, its class extends the `ConfigurableModuleClass`
29
+ * of that definition, and a module of the product is listed in an `imports` array only as `X.register(...)`, never as a bare
30
+ * class. The `AppModule` of an app root and the test world are composition roots and are not judged here.
31
+ */
32
+ export declare const moduleDefinitionRequired: RuleModule;
33
+ /** The rules this law contributes to the plugin. */
34
+ export declare const rules: {
35
+ "no-global-decorator": RuleModule;
36
+ "is-global-only-in-app": RuleModule;
37
+ "no-cross-owner-module-import": RuleModule;
38
+ "capability-module-shape": RuleModule;
39
+ "module-definition-required": RuleModule;
40
+ "typed-module-definition": RuleModule;
41
+ "static-module-register": RuleModule;
42
+ "no-new-injectable": RuleModule;
43
+ "no-module-let": RuleModule;
44
+ "one-module-per-file": RuleModule;
45
+ };
46
+ /** All start at error: HFS has one module shape and no baseline. */
47
+ export declare const recommended: Recommended;