@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,9 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** Multipart buffers are never the API's upload contract. */
3
+ export declare const noBufferedUpload: RuleModule;
4
+ /** The transport buffering rule's published name. */
5
+ export declare const rules: {
6
+ "no-buffered-upload": RuleModule;
7
+ };
8
+ /** Upload buffering is an error in every backend. */
9
+ export declare const recommended: Recommended;
@@ -3,10 +3,9 @@
3
3
  * exchanges metadata. An actual byte-stream route remains a separate transport case, so `StreamableFile` stays legal.
4
4
  * This rule does not prove a storage policy's principal, key, expiry or byte bound; the integration's behavior specs do.
5
5
  */
6
- import { keyName, staticText } from "./lib/ast.mjs"
7
- import { importOf, moduleReferences } from "./lib/import-source.mjs"
8
- import { resolveVariable } from "./lib/transactions.mjs"
9
-
6
+ import { keyName, staticText } from "./lib/ast.js";
7
+ import { importOf, moduleReferences } from "./lib/import-source.js";
8
+ import { resolveVariable } from "./lib/transactions.js";
10
9
  /** Libraries that implement API-side multipart uploads instead of a storage grant. */
11
10
  const UPLOAD_PACKAGES = [
12
11
  "multer",
@@ -19,51 +18,57 @@ const UPLOAD_PACKAGES = [
19
18
  "formidable",
20
19
  "multiparty",
21
20
  "connect-multiparty",
22
- ]
23
-
21
+ ];
24
22
  /** Selected Nest exports consume multipart files; other exports of these packages remain usable. */
25
23
  const NEST_UPLOADS = {
26
24
  "@nestjs/common": ["UploadedFile", "UploadedFiles"],
27
25
  "@nestjs/platform-express": ["MulterModule", "FileInterceptor", "FilesInterceptor", "AnyFilesInterceptor", "FileFieldsInterceptor"],
28
- }
29
-
26
+ };
30
27
  /** The statement block in which this expression is evaluated. */
31
28
  const statementBlock = (expression) => {
32
- let statement = expression
33
- while (statement.parent && !["Program", "BlockStatement"].includes(statement.parent.type)) statement = statement.parent
34
- return statement.parent
35
- }
36
-
29
+ let statement = expression;
30
+ while (statement.parent && !["Program", "BlockStatement"].includes(statement.parent.type))
31
+ statement = statement.parent;
32
+ return statement.parent;
33
+ };
37
34
  /**
38
35
  * The namespace source at one read, following completed standalone writes in that statement block.
39
36
  * Branches, destructuring assignments and closure execution require dataflow beyond this rule's supported alias shape.
40
37
  */
41
38
  const namespaceSource = (context, expression, seen = new Set()) => {
42
- if (!expression || seen.has(expression)) return null
43
- seen.add(expression)
39
+ if (!expression || seen.has(expression))
40
+ return null;
41
+ seen.add(expression);
44
42
  if (expression?.type === "Identifier") {
45
- const found = importOf(context, expression)
46
- if (found?.imported === "*") return found.source
47
- const variable = resolveVariable(context.sourceCode, expression)
48
- if (!variable) return null
49
- const definition = variable.defs[0]
50
- if (definition?.type !== "Variable" || definition.node.type !== "VariableDeclarator" || definition.node.id.type !== "Identifier") return null
51
- const writes = variable.references.filter((reference) => reference.isWrite() && !reference.init
52
- && reference.writeExpr?.range[1] <= expression.range[0])
53
- .sort((left, right) => right.identifier.range[0] - left.identifier.range[0])
54
- const write = writes[0]
55
- if (!write) return namespaceSource(context, definition.node.init, seen)
56
- const assignment = write.identifier.parent
43
+ const found = importOf(context, expression);
44
+ if (found?.imported === "*")
45
+ return found.source;
46
+ const variable = resolveVariable(context.sourceCode, expression);
47
+ if (!variable)
48
+ return null;
49
+ const definition = variable.defs[0];
50
+ if (definition?.type !== "Variable" || definition.node.type !== "VariableDeclarator" || definition.node.id.type !== "Identifier")
51
+ return null;
52
+ const writes = variable.references.filter((reference) => {
53
+ const end = reference.writeExpr?.range[1];
54
+ return reference.isWrite() && !reference.init && end !== undefined && end <= expression.range[0];
55
+ })
56
+ .sort((left, right) => right.identifier.range[0] - left.identifier.range[0]);
57
+ const write = writes[0];
58
+ if (!write)
59
+ return namespaceSource(context, definition.node.init, seen);
60
+ const assignment = write.identifier.parent;
57
61
  if (assignment.type !== "AssignmentExpression" || assignment.operator !== "=" || assignment.left !== write.identifier
58
- || assignment.parent.type !== "ExpressionStatement" || assignment.parent.parent !== statementBlock(expression)) return null
59
- return namespaceSource(context, write.writeExpr, seen)
62
+ || assignment.parent.type !== "ExpressionStatement" || assignment.parent.parent !== statementBlock(expression))
63
+ return null;
64
+ return namespaceSource(context, write.writeExpr, seen);
60
65
  }
61
- if (expression?.type === "AwaitExpression") return namespaceSource(context, expression.argument, seen)
66
+ if (expression?.type === "AwaitExpression")
67
+ return namespaceSource(context, expression.argument, seen);
62
68
  const source = expression?.type === "ImportExpression" ? expression.source
63
- : expression?.type === "CallExpression" && expression.callee.type === "Identifier" && expression.callee.name === "require" ? expression.arguments[0] : null
64
- return staticText(source)
65
- }
66
-
69
+ : expression?.type === "CallExpression" && expression.callee.type === "Identifier" && expression.callee.name === "require" ? expression.arguments[0] : null;
70
+ return staticText(source);
71
+ };
67
72
  /** Multipart buffers are never the API's upload contract. */
68
73
  export const noBufferedUpload = {
69
74
  meta: {
@@ -75,38 +80,41 @@ export const noBufferedUpload = {
75
80
  },
76
81
  },
77
82
  create(context) {
78
- const report = (node, name) => context.report({ node, messageId: "buffered", data: { name } })
83
+ const report = (node, name) => context.report({ node, messageId: "buffered", data: { name } });
79
84
  const selected = (source, name) => typeof source === "string" && Object.entries(NEST_UPLOADS)
80
- .some(([pkg, names]) => (source === pkg || source.startsWith(`${pkg}/`)) && names.includes(name))
85
+ .some(([pkg, names]) => (source === pkg || source.startsWith(`${pkg}/`)) && name !== null && names.includes(name));
81
86
  return {
82
87
  ...moduleReferences(({ source, value, names }) => {
83
88
  if (UPLOAD_PACKAGES.some((pkg) => value === pkg || value.startsWith(`${pkg}/`))) {
84
- report(source, value)
85
- return
89
+ report(source, value);
90
+ return;
86
91
  }
87
- const forbidden = names.filter((name) => selected(value, name))
88
- if (forbidden.length > 0) report(source, forbidden.join(", "))
92
+ const forbidden = names.filter((name) => selected(value, name));
93
+ if (forbidden.length > 0)
94
+ report(source, forbidden.join(", "));
89
95
  }),
90
96
  MemberExpression(node) {
91
- const source = namespaceSource(context, node.object)
92
- const name = node.computed ? staticText(node.property) : keyName(node.property)
93
- if (selected(source, name)) report(node, name)
97
+ const source = namespaceSource(context, node.object);
98
+ const name = node.computed ? staticText(node.property) : keyName(node.property);
99
+ if (name !== null && selected(source, name))
100
+ report(node, name);
94
101
  },
95
102
  VariableDeclarator(node) {
96
- if (node.id.type !== "ObjectPattern") return
97
- const source = namespaceSource(context, node.init)
103
+ if (node.id.type !== "ObjectPattern")
104
+ return;
105
+ const source = namespaceSource(context, node.init);
98
106
  for (const property of node.id.properties) {
99
- if (property.type !== "Property") continue
100
- const name = property.computed ? staticText(property.key) : keyName(property.key)
101
- if (selected(source, name)) report(property, name)
107
+ if (property.type !== "Property")
108
+ continue;
109
+ const name = property.computed ? staticText(property.key) : keyName(property.key);
110
+ if (name !== null && selected(source, name))
111
+ report(property, name);
102
112
  }
103
113
  },
104
- }
114
+ };
105
115
  },
106
- }
107
-
116
+ };
108
117
  /** The transport buffering rule's published name. */
109
- export const rules = { "no-buffered-upload": noBufferedUpload }
110
-
118
+ export const rules = { "no-buffered-upload": noBufferedUpload };
111
119
  /** Upload buffering is an error in every backend. */
112
- export const recommended = { "starci-be/no-buffered-upload": "error" }
120
+ export const recommended = { "starci-be/no-buffered-upload": "error" };
@@ -0,0 +1,9 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** User-facing text is looked up in the catalog by key, never written where it is used. */
3
+ export declare const userCopyThroughCatalog: RuleModule;
4
+ /** The rule this law contributes to the plugin. */
5
+ export declare const rules: {
6
+ "user-copy-through-catalog": RuleModule;
7
+ };
8
+ /** Starts at error: a hand-written user-facing string is never a warning. */
9
+ export declare const recommended: Recommended;
@@ -20,43 +20,43 @@
20
20
  * file's syntax for and cannot split into its static and interpolated halves without guessing. Specs get the same
21
21
  * law: fixture text is a `messages` catalog key or lives in a fixture.
22
22
  */
23
- import { isTransportSlot } from "./lib/transport-slots.mjs"
24
- import { keyName, staticText } from "./lib/ast.mjs"
25
- import { hfsOf } from "./lib/hfs.mjs"
26
- import { ownerNameOf } from "./lib/ports.mjs"
27
- import { typeOrigins, typed } from "./lib/types.mjs"
28
- import { isDeclarationFile } from "./lib/path.mjs"
29
-
30
- const NOTIFY_TEXT_PROPS = new Set(["subject", "title", "body", "text", "message"])
31
- const RESPONSE_TEXT_PROPS = new Set(["message", "description", "title"])
32
-
23
+ import { isTransportSlot } from "./lib/transport-slots.js";
24
+ import { keyName, staticText } from "./lib/ast.js";
25
+ import { hfsOf } from "./lib/hfs.js";
26
+ import { ownerNameOf } from "./lib/ports.js";
27
+ import { typeOrigins, typed } from "./lib/types.js";
28
+ import { isDeclarationFile } from "./lib/path.js";
29
+ const NOTIFY_TEXT_PROPS = new Set(["subject", "title", "body", "text", "message"]);
30
+ const RESPONSE_TEXT_PROPS = new Set(["message", "description", "title"]);
33
31
  /** A literal that reads as prose rather than a code, an enum value or a key. */
34
32
  const looksLikeCopy = (text) => {
35
- const trimmed = text.trim()
36
- if (!trimmed) return false
37
- if (/^[A-Z][A-Z0-9_]*$/.test(trimmed)) return false // a code: PLAN_NOT_FOUND
38
- if (/^[A-Za-z][A-Za-z0-9_-]*$/.test(trimmed)) return false // a single bare word: pending, plan-not-found
39
- return true
40
- }
41
-
33
+ const trimmed = text.trim();
34
+ if (!trimmed)
35
+ return false;
36
+ if (/^[A-Z][A-Z0-9_]*$/.test(trimmed))
37
+ return false; // a code: PLAN_NOT_FOUND
38
+ if (/^[A-Za-z][A-Za-z0-9_-]*$/.test(trimmed))
39
+ return false; // a single bare word: pending, plan-not-found
40
+ return true;
41
+ };
42
42
  /** Whether a TypeScript type is a class the repository or a package declares that extends the language `Error`. */
43
43
  const isCustomError = (program, checker, type) => {
44
- const declaredByLanguage = (candidate) => (candidate.getSymbol()?.getDeclarations() ?? []).some((declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()))
45
- if (declaredByLanguage(type)) return false
46
- const seen = new Set()
44
+ const declaredByLanguage = (candidate) => (candidate.getSymbol()?.getDeclarations() ?? []).some((declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()));
45
+ if (declaredByLanguage(type))
46
+ return false;
47
+ const seen = new Set();
47
48
  const extendsError = (candidate) => {
48
- if (seen.has(candidate)) return false
49
- seen.add(candidate)
50
- if (!candidate.isClassOrInterface()) return false
51
- return checker.getBaseTypes(candidate).some((base) => (declaredByLanguage(base) && base.getSymbol()?.name === "Error") || extendsError(base))
52
- }
53
- return extendsError(type)
54
- }
55
-
49
+ if (seen.has(candidate))
50
+ return false;
51
+ seen.add(candidate);
52
+ if (!candidate.isClassOrInterface())
53
+ return false;
54
+ return checker.getBaseTypes(candidate).some((base) => (declaredByLanguage(base) && base.getSymbol()?.name === "Error") || extendsError(base));
55
+ };
56
+ return extendsError(type);
57
+ };
56
58
  /** Whether a receiver's type is declared by an `integrations` owner or by `platform/event-bus` or `platform/queue`: an outbound port. */
57
- const isOutboundPort = (context, hfs, node) =>
58
- typeOrigins(context, node).some((origin) => origin.module === null && (hfs.tierOf(origin.file) === "integrations" || (hfs.tierOf(origin.file) === "platform" && ["event-bus", "queue"].includes(ownerNameOf(hfs, origin.file) ?? ""))))
59
-
59
+ const isOutboundPort = (context, hfs, node) => typeOrigins(context, node).some((origin) => origin.module === null && (hfs.tierOf(origin.file) === "integrations" || (hfs.tierOf(origin.file) === "platform" && ["event-bus", "queue"].includes(ownerNameOf(hfs, origin.file) ?? ""))));
60
60
  /** User-facing text is looked up in the catalog by key, never written where it is used. */
61
61
  export const userCopyThroughCatalog = {
62
62
  meta: {
@@ -70,57 +70,66 @@ export const userCopyThroughCatalog = {
70
70
  },
71
71
  },
72
72
  create(context) {
73
- const filename = context.filename || context.getFilename()
74
- if (isDeclarationFile(filename)) return {}
75
- const hfs = hfsOf(context)
76
- const slot = hfs.slotOf(filename) ?? ""
77
- const inTransport = isTransportSlot(slot)
78
- const { program, checker, toTs } = typed(context)
79
- const isOutboundCall = (node) =>
80
- node?.type === "CallExpression" && node.callee.type === "MemberExpression" && !node.callee.computed && isOutboundPort(context, hfs, node.callee.object)
73
+ const filename = context.filename || context.getFilename();
74
+ if (isDeclarationFile(filename))
75
+ return {};
76
+ const hfs = hfsOf(context);
77
+ const slot = hfs.slotOf(filename) ?? "";
78
+ const inTransport = isTransportSlot(slot);
79
+ const { program, checker, toTs } = typed(context);
80
+ const isOutboundCall = (node) => node?.type === "CallExpression" && node.callee.type === "MemberExpression" && !node.callee.computed && isOutboundPort(context, hfs, node.callee.object);
81
81
  return {
82
82
  NewExpression(node) {
83
- const first = node.arguments[0]
84
- if (!first) return
85
- const tsNode = toTs(node)
86
- if (!tsNode || !isCustomError(program, checker, checker.getTypeAtLocation(tsNode))) return
87
- const text = staticText(first)
83
+ const first = node.arguments[0];
84
+ if (!first)
85
+ return;
86
+ const tsNode = toTs(node);
87
+ if (!tsNode || !isCustomError(program, checker, checker.getTypeAtLocation(tsNode)))
88
+ return;
89
+ const text = staticText(first);
88
90
  if (text !== null && looksLikeCopy(text)) {
89
- const name = node.callee.type === "Identifier" ? node.callee.name : "the error"
90
- context.report({ node: first, messageId: "exception", data: { name } })
91
+ const name = node.callee.type === "Identifier" ? node.callee.name : "the error";
92
+ context.report({ node: first, messageId: "exception", data: { name } });
91
93
  }
92
94
  },
93
95
  CallExpression(node) {
94
- if (!isOutboundCall(node)) return
95
- const objectArg = node.arguments.find((argument) => argument.type === "ObjectExpression")
96
- if (!objectArg) return
96
+ if (!isOutboundCall(node))
97
+ return;
98
+ const objectArg = node.arguments.find((argument) => argument.type === "ObjectExpression");
99
+ if (!objectArg)
100
+ return;
97
101
  for (const property of objectArg.properties) {
98
- if (property.type !== "Property") continue
99
- const key = keyName(property.key)
100
- if (!key || !NOTIFY_TEXT_PROPS.has(key)) continue
101
- const text = staticText(property.value)
102
- if (text !== null && looksLikeCopy(text)) context.report({ node: property.value, messageId: "notification", data: { property: key } })
102
+ if (property.type !== "Property")
103
+ continue;
104
+ const key = keyName(property.key);
105
+ if (!key || !NOTIFY_TEXT_PROPS.has(key))
106
+ continue;
107
+ const text = staticText(property.value);
108
+ if (text !== null && looksLikeCopy(text))
109
+ context.report({ node: property.value, messageId: "notification", data: { property: key } });
103
110
  }
104
111
  },
105
112
  Property(node) {
106
- if (!inTransport) return
107
- const key = keyName(node.key)
108
- if (!key || !RESPONSE_TEXT_PROPS.has(key)) return
109
- const text = staticText(node.value)
110
- if (text === null || !looksLikeCopy(text)) return
111
- if (isOutboundCall(node.parent?.parent)) return // already judged as notification copy
112
- context.report({ node: node.value, messageId: "response", data: { property: key } })
113
+ if (!inTransport)
114
+ return;
115
+ const key = keyName(node.key);
116
+ if (!key || !RESPONSE_TEXT_PROPS.has(key))
117
+ return;
118
+ const text = staticText(node.value);
119
+ if (text === null || !looksLikeCopy(text))
120
+ return;
121
+ if (isOutboundCall(node.parent?.parent))
122
+ return; // already judged as notification copy
123
+ context.report({ node: node.value, messageId: "response", data: { property: key } });
113
124
  },
114
- }
125
+ };
115
126
  },
116
- }
117
-
127
+ };
118
128
  /** The rule this law contributes to the plugin. */
119
129
  export const rules = {
120
130
  "user-copy-through-catalog": userCopyThroughCatalog,
121
- }
122
-
131
+ };
123
132
  /** Starts at error: a hand-written user-facing string is never a warning. */
124
133
  export const recommended = {
125
134
  "starci-be/user-copy-through-catalog": "error",
126
- }
135
+ };
@@ -0,0 +1,16 @@
1
+ import type { Recommended, RuleModule } from "./lib/rule.js";
2
+ /** R263: public webhook traffic always enters the signed, verified webhook kind. */
3
+ export declare const webhookScope: RuleModule;
4
+ /** A provider webhook door: one signed `@Post`, the signature proof, one domain intake call, nothing else. */
5
+ export declare const webhookShape: RuleModule;
6
+ /** The first statement of the handler is the unconditional signature proof. */
7
+ export declare const webhookVerifyFirst: RuleModule;
8
+ /** The rules this law contributes to the plugin. */
9
+ export declare const rules: {
10
+ "webhook-shape": RuleModule;
11
+ "webhook-verify-first": RuleModule;
12
+ "webhook-scope": RuleModule;
13
+ "webhook-inbox-key": RuleModule;
14
+ };
15
+ /** Every rule of this law at `error`. */
16
+ export declare const recommended: Recommended;