@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
@@ -20,39 +20,34 @@
20
20
  * `<C>_ERROR_KINDS: Record<<C>ErrorCode, ErrorKind>` table, and an empty `<C>Error extends DomainError<<C>ErrorCode>`.
21
21
  * Code uniqueness across the repository is the architecture machine's job, not a single file's.
22
22
  */
23
- import { some, walk } from "./lib/ast.mjs"
24
- import {
25
- derives,
26
- derivesFromBuiltinError,
27
- derivesFromDomainError,
28
- errorHomeOf,
29
- isOwnedBy,
30
- isOwnedType,
31
- ownerName,
32
- partsOf,
33
- typeOf,
34
- } from "./lib/declared.mjs"
35
- import { hfsOf } from "./lib/hfs.mjs"
36
- import { normalizePath } from "./lib/path.mjs"
37
- import { typed } from "./lib/types.mjs"
38
-
23
+ import { nameOrValue, some, walk } from "./lib/ast.js";
24
+ import { derives, derivesFromBuiltinError, derivesFromDomainError, errorHomeOf, isOwnedBy, isOwnedType, ownerName, partsOf, typeOf, } from "./lib/declared.js";
25
+ import { hfsOf } from "./lib/hfs.js";
26
+ import { normalizePath } from "./lib/path.js";
27
+ import { typed } from "./lib/types.js";
28
+ import { isNode } from "./lib/rule.js";
39
29
  /** True when `name` is used as a value in `node` (not just as the object of `name.message`). */
40
30
  const carriesCaught = (node, name) => {
41
- if (!name) return false
42
- let carried = false
31
+ if (!name)
32
+ return false;
33
+ let carried = false;
43
34
  walk(node, (child) => {
44
- if (child.type !== "Identifier" || child.name !== name) return
45
- let inner = child
46
- while (inner.parent && (inner.parent.type === "TSAsExpression" || inner.parent.type === "TSNonNullExpression" || inner.parent.type === "TSTypeAssertion")) inner = inner.parent
47
- const parent = inner.parent
48
- if (parent?.type === "MemberExpression" && parent.object === inner) return
49
- carried = true
50
- })
51
- return carried
52
- }
53
-
54
- const paramName = (fn) => (fn.params?.[0]?.type === "Identifier" ? fn.params[0].name : null)
55
-
35
+ if (child.type !== "Identifier" || child.name !== name)
36
+ return;
37
+ let inner = child;
38
+ while (inner.parent && (inner.parent.type === "TSAsExpression" || inner.parent.type === "TSNonNullExpression" || inner.parent.type === "TSTypeAssertion"))
39
+ inner = inner.parent;
40
+ const parent = inner.parent;
41
+ if (parent?.type === "MemberExpression" && parent.object === inner)
42
+ return;
43
+ carried = true;
44
+ });
45
+ return carried;
46
+ };
47
+ const paramName = (fn) => {
48
+ const first = fn.params?.[0];
49
+ return first?.type === "Identifier" ? first.name : null;
50
+ };
56
51
  /** Every failure is rethrown, logged through the logger port, or returned as an outcome carrying its cause. */
57
52
  export const catchMustAccount = {
58
53
  meta: {
@@ -61,101 +56,112 @@ export const catchMustAccount = {
61
56
  schema: [],
62
57
  messages: {
63
58
  empty: "This `catch` is empty, so the failure vanishes. Rethrow it, log it through the `Logger` of `platform/logging`, or return a typed outcome carrying it as `cause`.",
64
- swallowed:
65
- "This `catch` neither rethrows, logs through the `Logger` of `platform/logging`, nor returns an outcome carrying the caught error, so the failure leaves no trace. Rethrow it, log it through the `Logger`, or return a typed outcome with `cause`.",
59
+ swallowed: "This `catch` neither rethrows, logs through the `Logger` of `platform/logging`, nor returns an outcome carrying the caught error, so the failure leaves no trace. Rethrow it, log it through the `Logger`, or return a typed outcome with `cause`.",
66
60
  },
67
61
  },
68
62
  create(context) {
69
63
  /** A call of a method on a receiver whose type is the `Logger` port declared by `platform/logging`. */
70
- const isLoggerCall = (node) =>
71
- node.type === "CallExpression" &&
64
+ const isLoggerCall = (node) => node.type === "CallExpression" &&
72
65
  node.callee.type === "MemberExpression" &&
73
- isOwnedType(context, node.callee.object, "Logger", "platform", "logging")
74
- const accounts = (body, param) =>
75
- some(
76
- body,
77
- (node) =>
78
- node.type === "ThrowStatement" ||
79
- isLoggerCall(node) ||
80
- (node.type === "ReturnStatement" && node.argument !== null && carriesCaught(node.argument, param)),
81
- { intoFunctions: false },
82
- )
66
+ isOwnedType(context, node.callee.object, "Logger", "platform", "logging");
67
+ const accounts = (body, param) => some(body, (node) => node.type === "ThrowStatement" ||
68
+ isLoggerCall(node) ||
69
+ (node.type === "ReturnStatement" && node.argument !== null && carriesCaught(node.argument, param)), { intoFunctions: false });
83
70
  const checkBlock = (reportNode, body, param) => {
84
- if (body.body.length === 0) context.report({ node: reportNode, messageId: "empty" })
85
- else if (!accounts(body, param)) context.report({ node: reportNode, messageId: "swallowed" })
86
- }
71
+ if (body.body.length === 0)
72
+ context.report({ node: reportNode, messageId: "empty" });
73
+ else if (!accounts(body, param))
74
+ context.report({ node: reportNode, messageId: "swallowed" });
75
+ };
87
76
  return {
88
77
  CatchClause(node) {
89
- checkBlock(node, node.body, node.param?.type === "Identifier" ? node.param.name : null)
78
+ checkBlock(node, node.body, node.param?.type === "Identifier" ? node.param.name : null);
90
79
  },
91
80
  CallExpression(node) {
92
- if (node.callee.type !== "MemberExpression" || node.callee.computed) return
93
- if (node.callee.property.type !== "Identifier" || node.callee.property.name !== "catch") return
94
- const handler = node.arguments[0]
95
- if (!handler || (handler.type !== "ArrowFunctionExpression" && handler.type !== "FunctionExpression")) return
81
+ if (node.callee.type !== "MemberExpression" || node.callee.computed)
82
+ return;
83
+ if (node.callee.property.type !== "Identifier" || node.callee.property.name !== "catch")
84
+ return;
85
+ const handler = node.arguments[0];
86
+ if (!handler || (handler.type !== "ArrowFunctionExpression" && handler.type !== "FunctionExpression"))
87
+ return;
96
88
  if (handler.body.type === "BlockStatement") {
97
- checkBlock(handler, handler.body, paramName(handler))
98
- } else if (!isLoggerCall(handler.body) && !carriesCaught(handler.body, paramName(handler))) {
99
- context.report({ node: handler, messageId: "swallowed" })
89
+ checkBlock(handler, handler.body, paramName(handler));
90
+ }
91
+ else if (!isLoggerCall(handler.body) && !carriesCaught(handler.body, paramName(handler))) {
92
+ context.report({ node: handler, messageId: "swallowed" });
100
93
  }
101
94
  },
102
- }
95
+ };
103
96
  },
104
- }
105
-
97
+ };
106
98
  /** The statements of a catch body that escape it: nested functions, nested handlers and guarded `try` blocks are not. */
107
99
  const escapingThrows = (body) => {
108
- const found = []
100
+ const found = [];
109
101
  const visit = (node) => {
110
- if (!node || typeof node !== "object" || typeof node.type !== "string") return
111
- if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") return
112
- if (node.type === "CatchClause") return
113
- if (node.type === "ThrowStatement") found.push(node)
102
+ if (!isNode(node))
103
+ return;
104
+ if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression")
105
+ return;
106
+ if (node.type === "CatchClause")
107
+ return;
108
+ if (node.type === "ThrowStatement")
109
+ found.push(node);
114
110
  if (node.type === "TryStatement") {
115
111
  // a throw of the guarded block lands in the nested handler, which is judged on its own
116
- if (!node.handler) visit(node.block)
117
- visit(node.finalizer)
118
- return
112
+ if (!node.handler)
113
+ visit(node.block);
114
+ visit(node.finalizer);
115
+ return;
119
116
  }
120
- for (const [key, value] of Object.entries(node)) {
121
- if (key === "parent" || key === "loc" || key === "range") continue
122
- if (Array.isArray(value)) value.forEach(visit)
123
- else visit(value)
117
+ const entries = Object.entries(node);
118
+ for (const [key, value] of entries) {
119
+ if (key === "parent" || key === "loc" || key === "range")
120
+ continue;
121
+ if (Array.isArray(value)) {
122
+ const items = value;
123
+ items.forEach(visit);
124
+ }
125
+ else
126
+ visit(value);
124
127
  }
125
- }
126
- body.body.forEach(visit)
127
- return found
128
- }
129
-
128
+ };
129
+ body.body.forEach(visit);
130
+ return found;
131
+ };
130
132
  /** The variable `identifier` names at its position, or null. */
131
133
  const variableOf = (sourceCode, identifier) => {
132
134
  for (let scope = sourceCode.getScope(identifier); scope; scope = scope.upper) {
133
- const variable = scope.set.get(identifier.name)
134
- if (variable) return variable
135
+ const variable = scope.set.get(identifier.name);
136
+ if (variable)
137
+ return variable;
135
138
  }
136
- return null
137
- }
138
-
139
+ return null;
140
+ };
139
141
  /**
140
142
  * True when the thrown value carries the caught one: it is the caught binding, it uses it as a value, or it is a variable
141
143
  * whose initializer or an assignment uses it. Anything the rule cannot see through is taken as carrying, so it never
142
144
  * reports a throw that might keep the cause.
143
145
  */
144
146
  const throwCarriesCaught = (sourceCode, argument, caught) => {
145
- if (carriesCaught(argument, caught)) return true
146
- let value = argument
147
- while (value.type === "TSAsExpression" || value.type === "TSNonNullExpression" || value.type === "TSTypeAssertion") value = value.expression
147
+ if (carriesCaught(argument, caught))
148
+ return true;
149
+ let value = argument;
150
+ while (value.type === "TSAsExpression" || value.type === "TSNonNullExpression" || value.type === "TSTypeAssertion")
151
+ value = value.expression;
148
152
  if (value.type === "Identifier") {
149
- const variable = variableOf(sourceCode, value)
153
+ const variable = variableOf(sourceCode, value);
150
154
  // an unresolved global or an import cannot carry this catch's value, but a parameter may hold anything
151
- if (!variable) return false
152
- if (variable.defs.some((def) => def.type === "Parameter")) return true
153
- if (variable.defs.some((def) => def.node.type === "VariableDeclarator" && def.node.init && carriesCaught(def.node.init, caught))) return true
154
- return variable.references.some((reference) => reference.isWrite() && reference.writeExpr && carriesCaught(reference.writeExpr, caught))
155
+ if (!variable)
156
+ return false;
157
+ if (variable.defs.some((def) => def.type === "Parameter"))
158
+ return true;
159
+ if (variable.defs.some((def) => def.node.type === "VariableDeclarator" && def.node.init && carriesCaught(def.node.init, caught)))
160
+ return true;
161
+ return variable.references.some((reference) => reference.isWrite() && reference.writeExpr && carriesCaught(reference.writeExpr, caught));
155
162
  }
156
- return false
157
- }
158
-
163
+ return false;
164
+ };
159
165
  /** A catch that replaces the caught failure passes the caught value on as the replacement's `cause` (BE-ERROR-4). */
160
166
  export const replacementThrowCarriesCause = {
161
167
  meta: {
@@ -163,64 +169,70 @@ export const replacementThrowCarriesCause = {
163
169
  docs: { description: "A throw that escapes a catch rethrows the caught value or carries it (as `cause`) in the replacement." },
164
170
  schema: [],
165
171
  messages: {
166
- dropped:
167
- "This `throw` replaces the caught failure without carrying it, so the stack and the original error are lost. Pass the exact caught value as `cause` of the capability error (`new <C>Error({ code, cause: {{name}} })`) or rethrow it.",
168
- unbound:
169
- "This `throw` replaces a failure its `catch` never bound, so the original error is lost. Bind it (`catch (error)`) and pass it as `cause` of the capability error, or rethrow it.",
172
+ dropped: "This `throw` replaces the caught failure without carrying it, so the stack and the original error are lost. Pass the exact caught value as `cause` of the capability error (`new <C>Error({ code, cause: {{name}} })`) or rethrow it.",
173
+ unbound: "This `throw` replaces a failure its `catch` never bound, so the original error is lost. Bind it (`catch (error)`) and pass it as `cause` of the capability error, or rethrow it.",
170
174
  },
171
175
  },
172
176
  create(context) {
173
- const sourceCode = context.sourceCode || context.getSourceCode()
177
+ const sourceCode = context.sourceCode || context.getSourceCode();
174
178
  const check = (body, param) => {
175
- const caught = param?.type === "Identifier" ? param.name : null
179
+ const caught = param?.type === "Identifier" ? param.name : null;
176
180
  for (const statement of escapingThrows(body)) {
177
- const argument = statement.argument
181
+ const argument = statement.argument;
178
182
  if (caught === null) {
179
- context.report({ node: statement, messageId: "unbound" })
180
- continue
183
+ context.report({ node: statement, messageId: "unbound" });
184
+ continue;
181
185
  }
182
- if (throwCarriesCaught(sourceCode, argument, caught)) continue
183
- context.report({ node: statement, messageId: "dropped", data: { name: caught } })
186
+ if (throwCarriesCaught(sourceCode, argument, caught))
187
+ continue;
188
+ context.report({ node: statement, messageId: "dropped", data: { name: caught } });
184
189
  }
185
- }
190
+ };
186
191
  return {
187
192
  CatchClause(node) {
188
193
  // a destructured binding names parts of the failure, not the failure itself; the rule cannot tell which part is kept
189
- if (node.param && node.param.type !== "Identifier") return
190
- check(node.body, node.param)
194
+ if (node.param && node.param.type !== "Identifier")
195
+ return;
196
+ check(node.body, node.param);
191
197
  },
192
198
  CallExpression(node) {
193
- if (node.callee.type !== "MemberExpression" || node.callee.computed) return
194
- if (node.callee.property.type !== "Identifier" || node.callee.property.name !== "catch") return
195
- const handler = node.arguments[0]
196
- if (!handler || (handler.type !== "ArrowFunctionExpression" && handler.type !== "FunctionExpression")) return
197
- if (handler.body.type !== "BlockStatement") return
198
- if (handler.params[0] && handler.params[0].type !== "Identifier") return
199
- check(handler.body, handler.params[0])
199
+ if (node.callee.type !== "MemberExpression" || node.callee.computed)
200
+ return;
201
+ if (node.callee.property.type !== "Identifier" || node.callee.property.name !== "catch")
202
+ return;
203
+ const handler = node.arguments[0];
204
+ if (!handler || (handler.type !== "ArrowFunctionExpression" && handler.type !== "FunctionExpression"))
205
+ return;
206
+ if (handler.body.type !== "BlockStatement")
207
+ return;
208
+ if (handler.params[0] && handler.params[0].type !== "Identifier")
209
+ return;
210
+ check(handler.body, handler.params[0]);
200
211
  },
201
- }
212
+ };
202
213
  },
203
- }
204
-
214
+ };
205
215
  /**
206
216
  * The test world (slot `be.tests.world`) is the TEST COMPOSITION ROOT and owns no capability folder: its one error class
207
217
  * `TestWorldError` lives in `test-world.error.ts` at the world root, which is the world's `errors/<capability>.error.ts`.
208
218
  * Only that file is a home; a nested `fakes/**` file, a spec and every other owner stay judged by `errors/<c>.error.ts`.
209
219
  */
210
220
  const isWorldErrorHome = (hfs, filename) => {
211
- const placed = hfs.classify(filename)
212
- return placed.slot === "be.tests.world" && placed.path === `${placed.root}/test-world.error.ts`
213
- }
214
-
221
+ const placed = hfs.classify(filename);
222
+ return placed.slot === "be.tests.world" && placed.path === `${placed.root}/test-world.error.ts`;
223
+ };
215
224
  /** True when a class of a unit spec (`<name>.spec.ts`) is local to it: neither exported by declaration nor by an `export { Name }` list. */
216
225
  const isSpecLocalClass = (filename, node) => {
217
- if (!/\.spec\.[cm]?ts$/.test(filename) || !node.id) return false
218
- if (node.parent?.type === "ExportNamedDeclaration" || node.parent?.type === "ExportDefaultDeclaration") return false
219
- const program = node.parent?.type === "Program" ? node.parent : null
220
- if (!program) return node.type === "ClassDeclaration" || node.type === "ClassExpression"
221
- return !program.body.some((statement) => statement.type === "ExportNamedDeclaration" && !statement.source && statement.specifiers.some((specifier) => (specifier.local.name ?? specifier.local.value) === node.id.name))
222
- }
223
-
226
+ const id = node.id;
227
+ if (!/\.spec\.[cm]?ts$/.test(filename) || !id)
228
+ return false;
229
+ if (node.parent?.type === "ExportNamedDeclaration" || node.parent?.type === "ExportDefaultDeclaration")
230
+ return false;
231
+ const program = node.parent?.type === "Program" ? node.parent : null;
232
+ if (!program)
233
+ return node.type === "ClassDeclaration" || node.type === "ClassExpression";
234
+ return !program.body.some((statement) => statement.type === "ExportNamedDeclaration" && !statement.source && statement.specifiers.some((specifier) => nameOrValue(specifier.local) === id.name));
235
+ };
224
236
  /** An error class is declared at its owner in `errors/<capability>.error.ts` and derives from `DomainError`. */
225
237
  export const errorHome = {
226
238
  meta: {
@@ -229,59 +241,64 @@ export const errorHome = {
229
241
  schema: [],
230
242
  messages: {
231
243
  place: "`{{name}}` derives from `DomainError` but is not declared in `errors/{{owner}}.error.ts` of its owner. An owner has one error class, in that file; move it there.",
232
- mustExtendDomainError:
233
- "`{{name}}` derives from the built-in `Error` without deriving from `DomainError` (`AbstractException`, a framework exception or a bare `extends Error`). Extend `DomainError` from `platform/errors` in the owner's `errors/<capability>.error.ts`.",
244
+ mustExtendDomainError: "`{{name}}` derives from the built-in `Error` without deriving from `DomainError` (`AbstractException`, a framework exception or a bare `extends Error`). Extend `DomainError` from `platform/errors` in the owner's `errors/<capability>.error.ts`.",
234
245
  },
235
246
  },
236
247
  create(context) {
237
- const hfs = hfsOf(context)
238
- const filename = normalizePath(context.filename)
248
+ const hfs = hfsOf(context);
249
+ const filename = normalizePath(context.filename);
239
250
  const check = (node) => {
240
- if (!node.id) return
241
- const type = typeOf(context, node.id)
242
- if (!type) return
243
- const isDomainErrorHost = node.id.name === "DomainError" && isOwnedBy(hfs, filename, "platform", "errors")
244
- if (isDomainErrorHost) return
251
+ if (!node.id)
252
+ return;
253
+ const type = typeOf(context, node.id);
254
+ if (!type)
255
+ return;
256
+ const isDomainErrorHost = node.id.name === "DomainError" && isOwnedBy(hfs, filename, "platform", "errors");
257
+ if (isDomainErrorHost)
258
+ return;
245
259
  if (derivesFromDomainError(context, type)) {
246
- if (isWorldErrorHome(hfs, filename)) return
260
+ if (isWorldErrorHome(hfs, filename))
261
+ return;
247
262
  // A spec-local subclass of the abstract base is a test double for code that takes any DomainError, not an error family.
248
- if (isSpecLocalClass(filename, node)) return
249
- const home = errorHomeOf(hfs, filename)
250
- const owner = ownerName(hfs.ownerOf(filename))
251
- if (!home || home.capability !== owner) context.report({ node: node.id, messageId: "place", data: { name: node.id.name, owner: owner ?? "<capability>" } })
252
- } else if (derivesFromBuiltinError(context, type)) {
253
- context.report({ node: node.id, messageId: "mustExtendDomainError", data: { name: node.id.name } })
263
+ if (isSpecLocalClass(filename, node))
264
+ return;
265
+ const home = errorHomeOf(hfs, filename);
266
+ const owner = ownerName(hfs.ownerOf(filename));
267
+ if (!home || home.capability !== owner)
268
+ context.report({ node: node.id, messageId: "place", data: { name: node.id.name, owner: owner ?? "<capability>" } });
254
269
  }
255
- }
256
- return { ClassDeclaration: check, ClassExpression: check }
270
+ else if (derivesFromBuiltinError(context, type)) {
271
+ context.report({ node: node.id, messageId: "mustExtendDomainError", data: { name: node.id.name } });
272
+ }
273
+ };
274
+ return { ClassDeclaration: check, ClassExpression: check };
257
275
  },
258
- }
259
-
276
+ };
260
277
  /** The variable a thrown identifier names is the parameter of a `catch` clause or of a promise `.catch` handler. */
261
278
  const isCaughtValue = (context, identifier) => {
262
279
  for (let scope = context.sourceCode.getScope(identifier); scope; scope = scope.upper) {
263
- const variable = scope.set.get(identifier.name)
264
- if (!variable) continue
280
+ const variable = scope.set.get(identifier.name);
281
+ if (!variable)
282
+ continue;
265
283
  return variable.defs.some((definition) => {
266
- if (definition.type === "CatchClause") return true
267
- if (definition.type !== "Parameter") return false
268
- const fn = definition.node
269
- const call = fn.parent
270
- return (
271
- (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") &&
284
+ if (definition.type === "CatchClause")
285
+ return true;
286
+ if (definition.type !== "Parameter")
287
+ return false;
288
+ const fn = definition.node;
289
+ const call = fn.parent;
290
+ return ((fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") &&
272
291
  call?.type === "CallExpression" &&
273
292
  call.arguments[0] === fn &&
274
293
  call.callee.type === "MemberExpression" &&
275
294
  !call.callee.computed &&
276
295
  call.callee.property.type === "Identifier" &&
277
296
  call.callee.property.name === "catch" &&
278
- fn.params[0] === definition.name
279
- )
280
- })
297
+ fn.params[0] === definition.name);
298
+ });
281
299
  }
282
- return false
283
- }
284
-
300
+ return false;
301
+ };
285
302
  /** Every thrown value is a `DomainError` of the owner that throws it. */
286
303
  export const throwDomainError = {
287
304
  meta: {
@@ -296,49 +313,72 @@ export const throwDomainError = {
296
313
  },
297
314
  },
298
315
  create(context) {
299
- const hfs = hfsOf(context)
300
- const filename = normalizePath(context.filename)
301
- const { checker } = typed(context)
302
- const isHttpException = (type) => derives(checker, type, (name, file) => name === "HttpException" && /\/node_modules\/@nestjs\/common\//.test(file))
316
+ const hfs = hfsOf(context);
317
+ const filename = normalizePath(context.filename);
318
+ const { checker } = typed(context);
319
+ const isHttpException = (type) => derives(checker, type, (name, file) => name === "HttpException" && /\/node_modules\/@nestjs\/common\//.test(file));
303
320
  return {
304
321
  ThrowStatement(node) {
305
- const thrown = node.argument
306
- if (!thrown) return
307
- if (thrown.type === "Identifier" && isCaughtValue(context, thrown)) return
308
- const type = typeOf(context, thrown)
309
- const parts = partsOf(type)
310
- const foreign = parts.find((part) => !derivesFromDomainError(context, part))
322
+ const thrown = node.argument;
323
+ if (!thrown)
324
+ return;
325
+ if (thrown.type === "Identifier" && isCaughtValue(context, thrown))
326
+ return;
327
+ const type = typeOf(context, thrown);
328
+ const parts = partsOf(type);
329
+ const foreign = parts.find((part) => !derivesFromDomainError(context, part));
311
330
  if (parts.length === 0 || foreign) {
312
331
  if (foreign && isHttpException(foreign)) {
313
- context.report({ node: thrown, messageId: "framework", data: { name: foreign.getSymbol()?.name ?? "HttpException" } })
314
- } else if (foreign && derivesFromBuiltinError(context, foreign)) {
315
- context.report({ node: thrown, messageId: "bareError" })
316
- } else {
317
- context.report({ node: thrown, messageId: "notDomainError" })
332
+ context.report({ node: thrown, messageId: "framework", data: { name: foreign.getSymbol()?.name ?? "HttpException" } });
333
+ }
334
+ else if (foreign && derivesFromBuiltinError(context, foreign)) {
335
+ context.report({ node: thrown, messageId: "bareError" });
318
336
  }
319
- return
337
+ else {
338
+ context.report({ node: thrown, messageId: "notDomainError" });
339
+ }
340
+ return;
320
341
  }
321
- if (hfs.tierOf(filename) !== "domain") return
342
+ if (hfs.tierOf(filename) !== "domain")
343
+ return;
322
344
  for (const part of parts) {
323
- const declarations = part.getSymbol()?.declarations ?? []
324
- const platform = declarations.find((declaration) => hfs.tierOf(String(declaration.getSourceFile().fileName).replace(/\\/g, "/")) === "platform")
345
+ const declarations = part.getSymbol()?.declarations ?? [];
346
+ const platform = declarations.find((declaration) => hfs.tierOf(String(declaration.getSourceFile().fileName).replace(/\\/g, "/")) === "platform");
325
347
  if (platform) {
326
- context.report({ node: thrown, messageId: "platformThrown", data: { name: part.getSymbol().name } })
327
- return
348
+ context.report({ node: thrown, messageId: "platformThrown", data: { name: part.getSymbol()?.name } });
349
+ return;
328
350
  }
329
351
  }
330
352
  },
331
- }
353
+ };
332
354
  },
333
- }
334
-
335
- const words = (kebab) => kebab.split("-")
336
- const pascal = (kebab) => words(kebab).map((word) => word[0].toUpperCase() + word.slice(1)).join("")
337
- const upperSnake = (kebab) => words(kebab).join("_").toUpperCase()
338
-
355
+ };
356
+ const words = (kebab) => kebab.split("-");
357
+ /** The first letter of a word in upper case; an empty word fails as reading a missing letter does. */
358
+ const initial = (word) => {
359
+ const first = word[0];
360
+ if (first === undefined)
361
+ throw new TypeError("Cannot read properties of undefined (reading 'toUpperCase')");
362
+ return first.toUpperCase();
363
+ };
364
+ const pascal = (kebab) => words(kebab).map((word) => initial(word) + word.slice(1)).join("");
365
+ const upperSnake = (kebab) => words(kebab).join("_").toUpperCase();
339
366
  /** The exported declaration inside an `export ...` statement, else null. */
340
- const exportedDeclaration = (statement) => (statement.type === "ExportNamedDeclaration" ? statement.declaration : null)
341
-
367
+ const exportedDeclaration = (statement) => (statement.type === "ExportNamedDeclaration" ? statement.declaration : null);
368
+ /** The name a declarator binds when it binds an identifier, else undefined. */
369
+ const declaratorName = (declarator) => (declarator.id.type === "Identifier" ? declarator.id.name : undefined);
370
+ /** The name of a declaration's `id` when that id is an identifier, else undefined. */
371
+ const declaredName = (declaration) => {
372
+ const id = "id" in declaration ? declaration.id : null;
373
+ return id?.type === "Identifier" ? id.name : undefined;
374
+ };
375
+ /** The params of the type-argument list a node holds under `key` (`typeArguments`, or the older parser's `typeParameters`), else undefined. */
376
+ const typeParamsUnder = (node, key) => {
377
+ if (!node)
378
+ return undefined;
379
+ const value = Reflect.get(node, key);
380
+ return isNode(value) && value.type === "TSTypeParameterInstantiation" ? value.params : undefined;
381
+ };
342
382
  /** The one shape of an owner's `errors/<capability>.error.ts`. */
343
383
  export const errorFamilyShape = {
344
384
  meta: {
@@ -356,70 +396,81 @@ export const errorFamilyShape = {
356
396
  },
357
397
  },
358
398
  create(context) {
359
- const hfs = hfsOf(context)
360
- const home = errorHomeOf(hfs, normalizePath(context.filename))
361
- if (!home) return {}
362
- const data = { pascal: pascal(home.capability), upper: upperSnake(home.capability) }
363
- const codeName = `${data.pascal}ErrorCode`
364
- const kindsName = `${data.upper}_ERROR_KINDS`
365
- const className = `${data.pascal}Error`
399
+ const hfs = hfsOf(context);
400
+ const home = errorHomeOf(hfs, normalizePath(context.filename));
401
+ // the home's capability is the required group of its pattern, so it is always present
402
+ if (!home || home.capability === undefined)
403
+ return {};
404
+ const data = { pascal: pascal(home.capability), upper: upperSnake(home.capability) };
405
+ const codeName = `${data.pascal}ErrorCode`;
406
+ const kindsName = `${data.upper}_ERROR_KINDS`;
407
+ const className = `${data.pascal}Error`;
366
408
  return {
367
409
  Program(program) {
368
- const declared = program.body.map(exportedDeclaration).filter(Boolean)
369
- const enums = declared.filter((declaration) => declaration.type === "TSEnumDeclaration")
370
- const code = enums.find((declaration) => declaration.id.name === codeName)
371
- if (!code) context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noCode", data })
410
+ const declared = program.body.map(exportedDeclaration).filter((declaration) => Boolean(declaration));
411
+ const enums = declared.filter((declaration) => declaration.type === "TSEnumDeclaration");
412
+ const code = enums.find((declaration) => declaration.id.name === codeName);
413
+ if (!code)
414
+ context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noCode", data });
372
415
  else {
373
- const prefix = new RegExp(`^${data.upper}_[A-Z0-9]+(?:_[A-Z0-9]+)*$`)
416
+ const prefix = new RegExp(`^${data.upper}_[A-Z0-9]+(?:_[A-Z0-9]+)*$`);
374
417
  for (const member of code.body?.members ?? code.members) {
375
- const value = member.initializer
376
- const text = value?.type === "Literal" && typeof value.value === "string" ? value.value : null
418
+ const value = member.initializer;
419
+ const text = value?.type === "Literal" && typeof value.value === "string" ? value.value : null;
377
420
  if (text === null || !prefix.test(text) || /_(?:EXCEPTION|ERROR)$/.test(text)) {
378
- context.report({ node: member, messageId: "memberValue", data: { ...data, member: member.id.name ?? member.id.value } })
421
+ context.report({ node: member, messageId: "memberValue", data: { ...data, member: nameOrValue(member.id) } });
379
422
  }
380
423
  }
381
424
  }
382
- const kinds = declared.find((declaration) => declaration.type === "VariableDeclaration" && declaration.declarations.some((d) => d.id.name === kindsName))
383
- if (!kinds) context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noKinds", data })
425
+ const kinds = declared.find((declaration) => declaration.type === "VariableDeclaration" && declaration.declarations.some((d) => declaratorName(d) === kindsName));
426
+ // the declarator is found whenever `kinds` is, since `kinds` is the declaration holding it
427
+ const declarator = kinds?.declarations.find((d) => declaratorName(d) === kindsName);
428
+ if (!declarator)
429
+ context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noKinds", data });
384
430
  else {
385
- const declarator = kinds.declarations.find((d) => d.id.name === kindsName)
386
- const annotation = declarator.id.typeAnnotation?.typeAnnotation
387
- const args = annotation?.typeArguments?.params ?? annotation?.typeParameters?.params ?? []
388
- const isRecord = annotation?.type === "TSTypeReference" && annotation.typeName.type === "Identifier" && annotation.typeName.name === "Record"
389
- const keyOk = args[0]?.type === "TSTypeReference" && args[0].typeName.type === "Identifier" && args[0].typeName.name === codeName
390
- const valueOk = args.length === 2 && args[1].type === "TSTypeReference" && isOwnedType(context, args[1], "ErrorKind", "platform", "errors")
391
- if (!isRecord || args.length !== 2 || !keyOk || !valueOk) context.report({ node: declarator.id, messageId: "kindsType", data })
431
+ const annotation = declarator.id.typeAnnotation?.typeAnnotation;
432
+ const args = typeParamsUnder(annotation, "typeArguments") ?? typeParamsUnder(annotation, "typeParameters") ?? [];
433
+ const isRecord = annotation?.type === "TSTypeReference" && annotation.typeName.type === "Identifier" && annotation.typeName.name === "Record";
434
+ const [keyArg, valueArg] = args;
435
+ const keyOk = keyArg?.type === "TSTypeReference" && keyArg.typeName.type === "Identifier" && keyArg.typeName.name === codeName;
436
+ const valueOk = args.length === 2 && valueArg?.type === "TSTypeReference" && isOwnedType(context, valueArg, "ErrorKind", "platform", "errors");
437
+ if (!isRecord || args.length !== 2 || !keyOk || !valueOk)
438
+ context.report({ node: declarator.id, messageId: "kindsType", data });
392
439
  }
393
- const cls = declared.find((declaration) => declaration.type === "ClassDeclaration" && declaration.id?.name === className)
394
- if (!cls) context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noClass", data })
440
+ const cls = declared.find((declaration) => declaration.type === "ClassDeclaration" && declaration.id?.name === className);
441
+ if (!cls)
442
+ context.report({ node: program, loc: { line: 1, column: 0 }, messageId: "noClass", data });
395
443
  else {
396
- const parent = cls.superClass
397
- const args = cls.superTypeArguments?.params ?? cls.superTypeParameters?.params ?? []
398
- const parentOk = parent && isOwnedType(context, parent, "DomainError", "platform", "errors")
399
- const argOk = args.length === 1 && args[0].type === "TSTypeReference" && args[0].typeName.type === "Identifier" && args[0].typeName.name === codeName
400
- if (!parentOk || !argOk || cls.body.body.length > 0) context.report({ node: cls.id, messageId: "classShape", data })
444
+ const parent = cls.superClass;
445
+ const args = typeParamsUnder(cls, "superTypeArguments") ?? typeParamsUnder(cls, "superTypeParameters") ?? [];
446
+ const parentOk = parent && isOwnedType(context, parent, "DomainError", "platform", "errors");
447
+ const [codeArg] = args;
448
+ const argOk = args.length === 1 && codeArg?.type === "TSTypeReference" && codeArg.typeName.type === "Identifier" && codeArg.typeName.name === codeName;
449
+ if (!parentOk || !argOk || cls.body.body.length > 0)
450
+ context.report({ node: cls.id, messageId: "classShape", data });
401
451
  }
402
452
  for (const statement of program.body) {
403
- const declaration = exportedDeclaration(statement)
404
- const isExport = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" || statement.type === "ExportAllDeclaration"
405
- if (!isExport) continue
406
- const name =
407
- declaration?.type === "VariableDeclaration"
408
- ? declaration.declarations.map((d) => d.id.name).find((n) => n !== kindsName)
409
- : declaration?.id?.name
453
+ const declaration = exportedDeclaration(statement);
454
+ const isExport = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" || statement.type === "ExportAllDeclaration";
455
+ if (!isExport)
456
+ continue;
457
+ const name = declaration?.type === "VariableDeclaration"
458
+ ? declaration.declarations.map(declaratorName).find((n) => n !== kindsName)
459
+ : declaration ? declaredName(declaration) : undefined;
410
460
  if (declaration === null || declaration === undefined) {
411
- context.report({ node: statement, messageId: "extra", data: { ...data, name: statement.type } })
412
- } else if (name !== undefined && name !== codeName && name !== kindsName && name !== className) {
413
- context.report({ node: declaration, messageId: "extra", data: { ...data, name } })
414
- } else if (name === undefined && declaration.type !== "VariableDeclaration") {
415
- context.report({ node: declaration, messageId: "extra", data: { ...data, name: declaration.type } })
461
+ context.report({ node: statement, messageId: "extra", data: { ...data, name: statement.type } });
462
+ }
463
+ else if (name !== undefined && name !== codeName && name !== kindsName && name !== className) {
464
+ context.report({ node: declaration, messageId: "extra", data: { ...data, name } });
465
+ }
466
+ else if (name === undefined && declaration.type !== "VariableDeclaration") {
467
+ context.report({ node: declaration, messageId: "extra", data: { ...data, name: declaration.type } });
416
468
  }
417
469
  }
418
470
  },
419
- }
471
+ };
420
472
  },
421
- }
422
-
473
+ };
423
474
  /** The rules this law contributes to the plugin. */
424
475
  export const rules = {
425
476
  "catch-must-account": catchMustAccount,
@@ -427,8 +478,7 @@ export const rules = {
427
478
  "error-home": errorHome,
428
479
  "throw-domain-error": throwDomainError,
429
480
  "error-family-shape": errorFamilyShape,
430
- }
431
-
481
+ };
432
482
  /** All start at error: HFS has no baseline, and the migration lanes clear the debt before a repository adopts them. */
433
483
  export const recommended = {
434
484
  "starci-be/catch-must-account": "error",
@@ -436,4 +486,4 @@ export const recommended = {
436
486
  "starci-be/error-home": "error",
437
487
  "starci-be/throw-domain-error": "error",
438
488
  "starci-be/error-family-shape": "error",
439
- }
489
+ };