@starci/eslint-canon-be 3.5.0 → 3.6.1

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 (198) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +13 -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-view.d.ts +127 -0
  78. package/dist/lib/hfs-view.js +1 -0
  79. package/dist/lib/hfs.d.ts +34 -0
  80. package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
  81. package/dist/lib/import-source.d.ts +63 -0
  82. package/dist/lib/import-source.js +134 -0
  83. package/dist/lib/path.d.ts +8 -0
  84. package/{lib/path.mjs → dist/lib/path.js} +4 -7
  85. package/dist/lib/persistence.d.ts +115 -0
  86. package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
  87. package/dist/lib/ports.d.ts +70 -0
  88. package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
  89. package/dist/lib/rule.d.ts +31 -0
  90. package/dist/lib/rule.js +2 -0
  91. package/dist/lib/runtime-root.d.ts +4 -0
  92. package/dist/lib/runtime-root.js +10 -0
  93. package/dist/lib/schema-values.d.ts +13 -0
  94. package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
  95. package/dist/lib/specifier.d.ts +12 -0
  96. package/dist/lib/specifier.js +29 -0
  97. package/dist/lib/subject-values.d.ts +4 -0
  98. package/dist/lib/subject-values.js +61 -0
  99. package/dist/lib/transactions.d.ts +18 -0
  100. package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
  101. package/dist/lib/transport-slots.d.ts +17 -0
  102. package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
  103. package/dist/lib/types.d.ts +96 -0
  104. package/dist/lib/types.js +150 -0
  105. package/dist/lib/unit-spec.d.ts +48 -0
  106. package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
  107. package/dist/lib/webhook-ack.d.ts +4 -0
  108. package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
  109. package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
  110. package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
  111. package/dist/lib/webhook-handoff-intake.d.ts +4 -0
  112. package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
  113. package/dist/lib/webhook-handoff.d.ts +15 -0
  114. package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
  115. package/dist/lib/webhook-verifiers.d.ts +20 -0
  116. package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
  117. package/dist/lib/why.d.ts +9 -0
  118. package/{lib/why.mjs → dist/lib/why.js} +6 -6
  119. package/dist/log-safety.d.ts +20 -0
  120. package/dist/log-safety.js +308 -0
  121. package/dist/module-layering.d.ts +42 -0
  122. package/dist/module-layering.js +257 -0
  123. package/dist/module-shape.d.ts +47 -0
  124. package/{module-shape.mjs → dist/module-shape.js} +278 -236
  125. package/dist/naming.d.ts +49 -0
  126. package/dist/naming.js +246 -0
  127. package/dist/observability.d.ts +25 -0
  128. package/dist/observability.js +245 -0
  129. package/dist/operations.d.ts +23 -0
  130. package/{operations.mjs → dist/operations.js} +410 -332
  131. package/dist/project-graph.d.ts +9 -0
  132. package/{project-graph.mjs → dist/project-graph.js} +8 -13
  133. package/dist/projections.d.ts +11 -0
  134. package/{projections.mjs → dist/projections.js} +60 -57
  135. package/dist/query-safety.d.ts +21 -0
  136. package/{query-safety.mjs → dist/query-safety.js} +92 -108
  137. package/dist/realtime.d.ts +15 -0
  138. package/{realtime.mjs → dist/realtime.js} +108 -106
  139. package/dist/resilience.d.ts +15 -0
  140. package/dist/resilience.js +319 -0
  141. package/dist/schema-authority.d.ts +15 -0
  142. package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
  143. package/dist/service-deps.d.ts +17 -0
  144. package/{service-deps.mjs → dist/service-deps.js} +133 -130
  145. package/dist/service-isolation.d.ts +8 -0
  146. package/dist/service-isolation.js +76 -0
  147. package/dist/size-budget.d.ts +9 -0
  148. package/{size-budget.mjs → dist/size-budget.js} +27 -27
  149. package/dist/sonar-parity.d.ts +5 -0
  150. package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
  151. package/dist/spec-no-skip.d.ts +9 -0
  152. package/dist/spec-no-skip.js +81 -0
  153. package/dist/spec-quality.d.ts +10 -0
  154. package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
  155. package/dist/suppression.d.ts +26 -0
  156. package/{suppression.mjs → dist/suppression.js} +30 -45
  157. package/dist/temporal.d.ts +9 -0
  158. package/{temporal.mjs → dist/temporal.js} +75 -65
  159. package/dist/test-world.d.ts +28 -0
  160. package/{test-world.mjs → dist/test-world.js} +102 -83
  161. package/dist/testing.d.ts +51 -0
  162. package/dist/testing.js +368 -0
  163. package/dist/third-party-owner.d.ts +8 -0
  164. package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
  165. package/dist/transport.d.ts +24 -0
  166. package/{transport.mjs → dist/transport.js} +279 -240
  167. package/dist/type-safety.d.ts +25 -0
  168. package/dist/type-safety.js +297 -0
  169. package/dist/unit-spec.d.ts +30 -0
  170. package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
  171. package/dist/uploads.d.ts +9 -0
  172. package/{uploads.mjs → dist/uploads.js} +62 -54
  173. package/dist/user-copy.d.ts +9 -0
  174. package/{user-copy.mjs → dist/user-copy.js} +76 -67
  175. package/dist/webhooks.d.ts +16 -0
  176. package/{webhooks.mjs → dist/webhooks.js} +243 -231
  177. package/package.json +23 -8
  178. package/runtime/knowledge/hfs/canon-pins.yaml +18 -11
  179. package/runtime/scripts/hfs/repo-identity.mjs +5 -4
  180. package/async-discipline.mjs +0 -83
  181. package/comments.mjs +0 -416
  182. package/edge-hardening.mjs +0 -139
  183. package/health-ready.mjs +0 -539
  184. package/jwt-alg.mjs +0 -45
  185. package/lib/ast.mjs +0 -88
  186. package/lib/import-source.mjs +0 -104
  187. package/lib/specifier.mjs +0 -27
  188. package/lib/subject-values.mjs +0 -55
  189. package/lib/types.mjs +0 -133
  190. package/log-safety.mjs +0 -303
  191. package/module-layering.mjs +0 -270
  192. package/naming.mjs +0 -251
  193. package/observability.mjs +0 -241
  194. package/resilience.mjs +0 -304
  195. package/service-isolation.mjs +0 -75
  196. package/spec-no-skip.mjs +0 -85
  197. package/testing.mjs +0 -384
  198. package/type-safety.mjs +0 -323
@@ -0,0 +1,25 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** A destructured parameter's type is named, so a second caller can reference it. */
3
+ export declare const noInlineParamType: RuleModule;
4
+ export declare const noInlineObjectType: RuleModule;
5
+ /** An enum keeps its runtime object. */
6
+ export declare const noConstEnum: RuleModule;
7
+ /** `Function` as a type, `eval` and `new Function` run or accept code the compiler cannot see. */
8
+ export declare const noFunctionOrEval: RuleModule;
9
+ /** A method that a caller or the framework reaches states what it returns. */
10
+ export declare const explicitHandlerReturnType: RuleModule;
11
+ /** The rules this law contributes to the plugin. */
12
+ export declare const rules: {
13
+ "no-function-or-eval": RuleModule;
14
+ "no-inline-param-type": RuleModule;
15
+ "no-inline-object-type": RuleModule;
16
+ "no-const-enum": RuleModule;
17
+ "explicit-handler-return-type": RuleModule;
18
+ };
19
+ /**
20
+ * The level this law asks for: every rule at `error`, in every file, specs included.
21
+ *
22
+ * The borrowed type-escape rules (`consistent-type-assertions` never, `no-non-null-assertion`, `no-explicit-any`)
23
+ * are added by the factory (`lib/config.mjs`), not listed here. The array spelling rule stays with this law.
24
+ */
25
+ export declare const recommended: Recommended;
@@ -0,0 +1,297 @@
1
+ /** A parameter property (`private readonly x: T`) wraps the parameter it declares. */
2
+ const unwrapParam = (param) => (param.type === "TSParameterProperty" ? param.parameter : param);
3
+ // -- TYPE-3 ----------------------------------------------------------------------------------------
4
+ /** A destructured parameter's type is named, so a second caller can reference it. */
5
+ export const noInlineParamType = {
6
+ meta: {
7
+ type: "problem",
8
+ docs: { description: "A destructured parameter takes a named type, not an inline literal." },
9
+ schema: [],
10
+ messages: {
11
+ inline: "An inline object type on a destructured parameter cannot be referenced, imported or extended - so the second caller writes it again, and when a third field arrives only one of the two copies gets it. Move it to a named interface in the module's `types/`.",
12
+ },
13
+ },
14
+ create(context) {
15
+ const check = (params) => {
16
+ for (const raw of params || []) {
17
+ const param = unwrapParam(raw);
18
+ if (param.type !== "ObjectPattern" || !param.typeAnnotation)
19
+ continue;
20
+ const annotation = param.typeAnnotation.typeAnnotation;
21
+ if (annotation && annotation.type === "TSTypeLiteral") {
22
+ context.report({ node: param.typeAnnotation, messageId: "inline" });
23
+ }
24
+ }
25
+ };
26
+ return {
27
+ FunctionDeclaration(node) {
28
+ check(node.params);
29
+ },
30
+ FunctionExpression(node) {
31
+ check(node.params);
32
+ },
33
+ ArrowFunctionExpression(node) {
34
+ check(node.params);
35
+ },
36
+ };
37
+ },
38
+ };
39
+ // -- TYPE-3, extended (law 4) ------------------------------------------------------------------------
40
+ /**
41
+ * `no-inline-param-type` holds only the destructured-parameter half of law 4: "a destructured
42
+ * parameter's type has a name and a home a second caller can import from." The same sentence, read
43
+ * without the word "destructured", covers every inline object type -- a positional parameter, a
44
+ * property signature, a function return, a variable -- because the failure is identical in all four:
45
+ * the shape cannot be referenced, imported or extended, so a second site retypes it and the two
46
+ * copies drift apart in silence.
47
+ *
48
+ * Three things are deliberately left alone, and each is a different reason:
49
+ *
50
+ * - An EMPTY `{}` means "no properties", not "an unnamed shape". That is a different smell (the
51
+ * fix is a stricter type, not a name) and this rule does not touch it.
52
+ * - A type literal inside a `declare module` / module augmentation describes a vendor's own shape.
53
+ * It cannot be pulled into a named type this repository owns without the two drifting the moment
54
+ * the vendor changes theirs, so the ambient lane is out of scope.
55
+ * - A type literal that is already the right-hand side of a named type alias (`type Foo = { ... }`)
56
+ * IS the fix this rule asks for. Flagging it would make the rule unsatisfiable -- there would be no
57
+ * way to hold an object type by name that this rule accepted. A type literal declared elsewhere is
58
+ * still checked in the ordinary way; only the exact node a type alias names is exempt.
59
+ */
60
+ /** A type literal with no members means "no properties" -- a different smell with a different fix. */
61
+ const isEmptyTypeLiteral = (typeLiteral) => !typeLiteral.members || typeLiteral.members.length === 0;
62
+ /** A vendor's own declaration lives in a `declare module` / module augmentation and cannot be named separately. */
63
+ const isInsideAmbientModule = (node) => {
64
+ let current = node.parent;
65
+ while (current) {
66
+ if (current.type === "TSModuleDeclaration" && current.declare)
67
+ return true;
68
+ current = current.parent;
69
+ }
70
+ return false;
71
+ };
72
+ /** The non-empty inline object type at `typeAnnotation.typeAnnotation`, or null if this is out of scope. */
73
+ const inlineObjectTypeOf = (typeAnnotation, scopeNode) => {
74
+ if (!typeAnnotation)
75
+ return null;
76
+ const literal = typeAnnotation.typeAnnotation;
77
+ if (!literal || literal.type !== "TSTypeLiteral")
78
+ return null;
79
+ if (isEmptyTypeLiteral(literal))
80
+ return null;
81
+ if (isInsideAmbientModule(scopeNode))
82
+ return null;
83
+ return literal;
84
+ };
85
+ export const noInlineObjectType = {
86
+ meta: {
87
+ type: "problem",
88
+ docs: {
89
+ description: "A TypeScript object type written inline takes a named type instead, in every position (TYPE-3, law 4).",
90
+ },
91
+ schema: [],
92
+ messages: {
93
+ inlineObjectType: "This inline object type ({{position}}) cannot be referenced, imported or extended, so a second site retypes it and the two copies drift apart in silence the moment a third field arrives on only one of them. Give it a name in the module's `types/` and reference that name here instead.",
94
+ },
95
+ },
96
+ create(context) {
97
+ const reportLiteral = (node, position) => {
98
+ context.report({ node, messageId: "inlineObjectType", data: { position } });
99
+ };
100
+ const checkParams = (fnNode) => {
101
+ for (const raw of fnNode.params || []) {
102
+ const param = unwrapParam(raw);
103
+ const annotation = param.typeAnnotation;
104
+ if (annotation && inlineObjectTypeOf(annotation, param)) {
105
+ reportLiteral(annotation, "parameter");
106
+ }
107
+ }
108
+ };
109
+ const checkReturnType = (fnNode) => {
110
+ const annotation = fnNode.returnType;
111
+ if (annotation && inlineObjectTypeOf(annotation, fnNode)) {
112
+ reportLiteral(annotation, "return type");
113
+ }
114
+ };
115
+ return {
116
+ FunctionDeclaration(node) {
117
+ checkParams(node);
118
+ checkReturnType(node);
119
+ },
120
+ FunctionExpression(node) {
121
+ checkParams(node);
122
+ checkReturnType(node);
123
+ },
124
+ ArrowFunctionExpression(node) {
125
+ checkParams(node);
126
+ checkReturnType(node);
127
+ },
128
+ TSPropertySignature(node) {
129
+ const annotation = node.typeAnnotation;
130
+ if (annotation && inlineObjectTypeOf(annotation, node)) {
131
+ reportLiteral(annotation, "property signature");
132
+ }
133
+ },
134
+ VariableDeclarator(node) {
135
+ if (node.id.type !== "Identifier")
136
+ return;
137
+ const annotation = node.id.typeAnnotation;
138
+ if (annotation && inlineObjectTypeOf(annotation, node)) {
139
+ reportLiteral(annotation, "variable");
140
+ }
141
+ },
142
+ };
143
+ },
144
+ };
145
+ // -- TYPE-4 ----------------------------------------------------------------------------------------
146
+ /** An enum keeps its runtime object. */
147
+ export const noConstEnum = {
148
+ meta: {
149
+ type: "problem",
150
+ docs: { description: "Enums are declared plain, never `const enum`." },
151
+ schema: [],
152
+ messages: {
153
+ constEnum: "`const enum {{name}}` is inlined at compile time and has no runtime object: it cannot be iterated, cannot be reverse-mapped, and cannot cross the isolated-modules boundary this repository compiles under. It saves a few bytes and costs a family of things that simply do not work. Declare a plain `enum`.",
154
+ },
155
+ },
156
+ create(context) {
157
+ return {
158
+ TSEnumDeclaration(node) {
159
+ if (!node.const)
160
+ return;
161
+ context.report({ node, messageId: "constEnum", data: { name: node.id.name } });
162
+ },
163
+ };
164
+ },
165
+ };
166
+ // -- R72 -------------------------------------------------------------------------------------------
167
+ /** A global name (`Function`, `eval`) that no declaration of this file shadows. */
168
+ const isGlobalName = (context, node, name) => {
169
+ let scope = (context.sourceCode || context.getSourceCode()).getScope(node);
170
+ while (scope) {
171
+ const variable = scope.set.get(name);
172
+ if (variable)
173
+ return variable.defs.length === 0;
174
+ scope = scope.upper;
175
+ }
176
+ return true;
177
+ };
178
+ /** `Function` as a type, `eval` and `new Function` run or accept code the compiler cannot see. */
179
+ export const noFunctionOrEval = {
180
+ meta: {
181
+ type: "problem",
182
+ docs: { description: "No `Function` type, no `eval`, no `new Function` (the type escapes the borrowed assertion rules do not cover)." },
183
+ schema: [],
184
+ messages: {
185
+ functionType: "The `Function` type accepts any callable and returns `any`, so the compiler stops checking every call through it. Write the signature: `(input: Input) => Result`.",
186
+ evaluated: "`{{name}}` builds code from a string, which the compiler cannot type and a reader cannot follow. Call a real function, or map a key to a function in a typed record.",
187
+ },
188
+ },
189
+ create(context) {
190
+ return {
191
+ TSTypeReference(node) {
192
+ if (node.typeName.type === "Identifier" && node.typeName.name === "Function" && isGlobalName(context, node, "Function")) {
193
+ context.report({ node, messageId: "functionType" });
194
+ }
195
+ },
196
+ CallExpression(node) {
197
+ const callee = node.callee;
198
+ if (callee.type !== "Identifier" || (callee.name !== "eval" && callee.name !== "Function"))
199
+ return;
200
+ if (isGlobalName(context, node, callee.name))
201
+ context.report({ node, messageId: "evaluated", data: { name: callee.name } });
202
+ },
203
+ NewExpression(node) {
204
+ if (node.callee.type === "Identifier" && node.callee.name === "Function" && isGlobalName(context, node, "Function")) {
205
+ context.report({ node, messageId: "evaluated", data: { name: "new Function" } });
206
+ }
207
+ },
208
+ };
209
+ },
210
+ };
211
+ // -- R75 -------------------------------------------------------------------------------------------
212
+ const HANDLER_DECORATORS = new Set(["Query", "Mutation", "Subscription", "ResolveField", "Get", "Post", "Put", "Patch", "Delete", "MessagePattern", "EventPattern", "Cron", "Interval"]);
213
+ const SURFACE_CLASS_DECORATORS = new Set(["Injectable", "Resolver", "Controller"]);
214
+ /** The decorators a node carries, or none when it carries no such list. */
215
+ const decoratorsOf = (node) => (node && "decorators" in node ? node.decorators ?? [] : []);
216
+ const decoratorIdentifier = (decorator) => {
217
+ const expression = decorator?.expression;
218
+ if (!expression)
219
+ return null;
220
+ if (expression.type === "Identifier")
221
+ return expression.name;
222
+ if (expression.type === "CallExpression" && expression.callee.type === "Identifier")
223
+ return expression.callee.name;
224
+ return null;
225
+ };
226
+ /** A method that a caller or the framework reaches states what it returns. */
227
+ export const explicitHandlerReturnType = {
228
+ meta: {
229
+ type: "problem",
230
+ docs: { description: "Handlers and public methods of an Injectable, Resolver or Controller declare a return type." },
231
+ schema: [],
232
+ messages: {
233
+ handler: "This handler declares no return type, so the transport contract is whatever the body happens to return today and a change of the body silently changes the wire. Declare the return type (`Promise<Type>`).",
234
+ publicMethod: "This public method declares no return type, so its callers depend on an inferred shape that changes with the body. Declare the return type.",
235
+ },
236
+ },
237
+ create(context) {
238
+ return {
239
+ MethodDefinition(node) {
240
+ if (node.kind !== "method" || node.static || !node.value.body || node.value.returnType)
241
+ return;
242
+ if (node.computed || node.key.type !== "Identifier")
243
+ return;
244
+ const isHandler = (node.decorators ?? []).some((decorator) => HANDLER_DECORATORS.has(decoratorIdentifier(decorator)));
245
+ if (isHandler) {
246
+ context.report({ node: node.key, messageId: "handler" });
247
+ return;
248
+ }
249
+ if (node.accessibility === "private" || node.accessibility === "protected" || node.override)
250
+ return;
251
+ const klass = node.parent?.parent;
252
+ if (!klass || klass.type !== "ClassDeclaration")
253
+ return;
254
+ const exported = klass.parent?.type === "ExportNamedDeclaration" || klass.parent?.type === "ExportDefaultDeclaration";
255
+ const decorators = [...(klass.decorators ?? []), ...decoratorsOf(klass.parent)].map(decoratorIdentifier);
256
+ if (!exported || !decorators.some((name) => SURFACE_CLASS_DECORATORS.has(name)))
257
+ return;
258
+ context.report({ node: node.key, messageId: "publicMethod" });
259
+ },
260
+ };
261
+ },
262
+ };
263
+ // -- TYPE-5 (rule 6) -- ATTEMPTED, NOT SHIPPED ------------------------------------------------------
264
+ //
265
+ // A rule was written here: two-or-more `is`/`has`-prefixed booleans sharing a type literal with a
266
+ // field that is optional and not itself boolean. It was measured against the reference backend
267
+ // before shipping, per this canon's own standard -- and both of its two real firings were wrong.
268
+ // `GlobalSearchItem` (`isEnrolled` / `isFree` / `isPremium` beside an unrelated optional
269
+ // `parentPath`) and `AdvertisementSeedItem` (`isHouseAd` / `isActive` beside an unrelated optional
270
+ // `ctaText`) are both genuinely independent facts about one entity, not a product of states -- the
271
+ // exact "transport type" and "independent booleans" exceptions `type-safety.md` already names. A
272
+ // rule reporting a defect on 2 of its 2 real firings is not a rule with debt to burn down; it is
273
+ // wrong, and shipping it at any level would teach a reader to distrust the machine rather than the
274
+ // code. TYPE-5 stays `documented`, exactly as the law's own `Layer held` table already says: seeing
275
+ // past a transport DTO to whether its flags are truly one situation needs the meaning of the code,
276
+ // which is a reader's job, not a decidable question of syntax.
277
+ /** The rules this law contributes to the plugin. */
278
+ export const rules = {
279
+ "no-function-or-eval": noFunctionOrEval,
280
+ "no-inline-param-type": noInlineParamType,
281
+ "no-inline-object-type": noInlineObjectType,
282
+ "no-const-enum": noConstEnum,
283
+ "explicit-handler-return-type": explicitHandlerReturnType,
284
+ };
285
+ /**
286
+ * The level this law asks for: every rule at `error`, in every file, specs included.
287
+ *
288
+ * The borrowed type-escape rules (`consistent-type-assertions` never, `no-non-null-assertion`, `no-explicit-any`)
289
+ * are added by the factory (`lib/config.mjs`), not listed here. The array spelling rule stays with this law.
290
+ */
291
+ export const recommended = {
292
+ "starci-be/no-function-or-eval": "error",
293
+ "starci-be/no-inline-param-type": "error",
294
+ "starci-be/no-inline-object-type": "error",
295
+ "starci-be/no-const-enum": "error",
296
+ "starci-be/explicit-handler-return-type": "error",
297
+ };
@@ -0,0 +1,30 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** A logic-role spec builds its subject through the Nest testing module. */
3
+ export declare const specBuildsWithTestingModule: RuleModule;
4
+ /** The logic-role subject is never constructed by hand. */
5
+ export declare const specNoNewSubject: RuleModule;
6
+ /** The testing module lists providers and nothing else. */
7
+ export declare const specModuleDefinitionOnlyProviders: RuleModule;
8
+ /** A unit spec replaces no module, its own or a library's. */
9
+ export declare const specNoModuleMock: RuleModule;
10
+ /** A helper of a spec or of the fixtures is not a cast with a name. */
11
+ export declare const noReturnOnlyGeneric: RuleModule;
12
+ /** The double a token's provider value must come from. */
13
+ export declare const specInfraDoubleFromKit: RuleModule;
14
+ /** A unit spec asserts the exact id and the exact date, never "some string" or "some date". */
15
+ export declare const specExactValues: RuleModule;
16
+ /** Presence alone does not prove the behavior of a logic-role subject. */
17
+ export declare const specBehaviorAssertion: RuleModule;
18
+ /** The rules this law contributes to the plugin. */
19
+ export declare const rules: {
20
+ "spec-builds-with-testing-module": RuleModule;
21
+ "spec-no-new-subject": RuleModule;
22
+ "spec-module-definition-only-providers": RuleModule;
23
+ "spec-no-module-mock": RuleModule;
24
+ "no-return-only-generic": RuleModule;
25
+ "spec-infra-double-from-kit": RuleModule;
26
+ "spec-exact-values": RuleModule;
27
+ "spec-behavior-assertion": RuleModule;
28
+ };
29
+ /** Every rule of this law ships at `error`. */
30
+ export declare const recommended: Recommended;