@starci/eslint-canon-be 3.4.57 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +11 -2
- package/dist/ambient-id.d.ts +9 -0
- package/{ambient-id.mjs → dist/ambient-id.js} +43 -39
- package/dist/app-composition.d.ts +21 -0
- package/{app-composition.mjs → dist/app-composition.js} +396 -300
- package/dist/async-discipline.d.ts +9 -0
- package/dist/async-discipline.js +77 -0
- package/dist/authorization.d.ts +12 -0
- package/{authorization.mjs → dist/authorization.js} +53 -59
- package/dist/boundary-schema.d.ts +15 -0
- package/{boundary-schema.mjs → dist/boundary-schema.js} +120 -105
- package/dist/builders.d.ts +21 -0
- package/{builders.mjs → dist/builders.js} +162 -146
- package/dist/cli.d.ts +15 -0
- package/{cli.mjs → dist/cli.js} +97 -82
- package/dist/comments.d.ts +52 -0
- package/dist/comments.js +412 -0
- package/dist/config-owner.d.ts +24 -0
- package/{config-owner.mjs → dist/config-owner.js} +256 -219
- package/dist/connections.d.ts +12 -0
- package/{connections.mjs → dist/connections.js} +138 -140
- package/dist/cookies.d.ts +9 -0
- package/{cookies.mjs → dist/cookies.js} +58 -58
- package/dist/cqrs.d.ts +27 -0
- package/{cqrs.mjs → dist/cqrs.js} +341 -282
- package/dist/data-access.d.ts +50 -0
- package/{data-access.mjs → dist/data-access.js} +238 -243
- package/dist/default-deny.d.ts +15 -0
- package/{default-deny.mjs → dist/default-deny.js} +103 -88
- package/dist/e2e-flow.d.ts +25 -0
- package/{e2e-flow.mjs → dist/e2e-flow.js} +113 -112
- package/dist/edge-hardening.d.ts +10 -0
- package/dist/edge-hardening.js +173 -0
- package/dist/error-handling.d.ts +21 -0
- package/{error-handling.mjs → dist/error-handling.js} +289 -239
- package/dist/event-bus.d.ts +14 -0
- package/{event-bus.mjs → dist/event-bus.js} +146 -129
- package/dist/feature-thin.d.ts +12 -0
- package/{feature-thin.mjs → dist/feature-thin.js} +208 -191
- package/dist/function-budget.d.ts +7 -0
- package/{function-budget.mjs → dist/function-budget.js} +24 -27
- package/dist/health-ready.d.ts +10 -0
- package/dist/health-ready.js +703 -0
- package/dist/idempotency.d.ts +10 -0
- package/{idempotency.mjs → dist/idempotency.js} +296 -226
- package/dist/index.d.ts +54 -0
- package/{index.mjs → dist/index.js} +91 -109
- package/dist/infra-owner.d.ts +18 -0
- package/{infra-owner.mjs → dist/infra-owner.js} +58 -51
- package/dist/injection.d.ts +30 -0
- package/{injection.mjs → dist/injection.js} +397 -344
- package/dist/input-bounds.d.ts +15 -0
- package/{input-bounds.mjs → dist/input-bounds.js} +143 -132
- package/dist/jobs.d.ts +17 -0
- package/{jobs.mjs → dist/jobs.js} +116 -99
- package/dist/jwt-alg.d.ts +6 -0
- package/dist/jwt-alg.js +49 -0
- package/dist/lib/app-roles.d.ts +25 -0
- package/{lib/app-roles.mjs → dist/lib/app-roles.js} +15 -17
- package/dist/lib/ast.d.ts +40 -0
- package/dist/lib/ast.js +100 -0
- package/dist/lib/client-idempotency.d.ts +3 -0
- package/{lib/client-idempotency.mjs → dist/lib/client-idempotency.js} +316 -268
- package/dist/lib/config.d.ts +36 -0
- package/{lib/config.mjs → dist/lib/config.js} +24 -27
- package/dist/lib/db-writes.d.ts +29 -0
- package/{lib/db-writes.mjs → dist/lib/db-writes.js} +27 -27
- package/dist/lib/declared.d.ts +77 -0
- package/{lib/declared.mjs → dist/lib/declared.js} +83 -78
- package/dist/lib/doors.d.ts +50 -0
- package/{lib/doors.mjs → dist/lib/doors.js} +45 -50
- package/dist/lib/edition.d.ts +25 -0
- package/{lib/edition.mjs → dist/lib/edition.js} +15 -20
- package/dist/lib/entity-writes.d.ts +7 -0
- package/{lib/entity-writes.mjs → dist/lib/entity-writes.js} +31 -22
- package/dist/lib/hfs.d.ts +34 -0
- package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
- package/dist/lib/import-source.d.ts +63 -0
- package/dist/lib/import-source.js +134 -0
- package/dist/lib/path.d.ts +8 -0
- package/{lib/path.mjs → dist/lib/path.js} +4 -7
- package/dist/lib/persistence.d.ts +115 -0
- package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
- package/dist/lib/ports.d.ts +70 -0
- package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
- package/dist/lib/rule.d.ts +31 -0
- package/dist/lib/rule.js +2 -0
- package/dist/lib/runtime-root.d.ts +4 -0
- package/dist/lib/runtime-root.js +10 -0
- package/dist/lib/schema-values.d.ts +13 -0
- package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
- package/dist/lib/specifier.d.ts +12 -0
- package/dist/lib/specifier.js +29 -0
- package/dist/lib/subject-values.d.ts +4 -0
- package/dist/lib/subject-values.js +61 -0
- package/dist/lib/transactions.d.ts +18 -0
- package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
- package/dist/lib/transport-slots.d.ts +17 -0
- package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
- package/dist/lib/types.d.ts +96 -0
- package/dist/lib/types.js +150 -0
- package/dist/lib/unit-spec.d.ts +48 -0
- package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
- package/dist/lib/webhook-ack.d.ts +4 -0
- package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
- package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
- package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
- package/dist/lib/webhook-handoff-intake.d.ts +4 -0
- package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
- package/dist/lib/webhook-handoff.d.ts +15 -0
- package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
- package/dist/lib/webhook-verifiers.d.ts +20 -0
- package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
- package/dist/lib/why.d.ts +9 -0
- package/{lib/why.mjs → dist/lib/why.js} +6 -6
- package/dist/log-safety.d.ts +20 -0
- package/dist/log-safety.js +308 -0
- package/dist/module-layering.d.ts +42 -0
- package/dist/module-layering.js +257 -0
- package/dist/module-shape.d.ts +47 -0
- package/{module-shape.mjs → dist/module-shape.js} +278 -236
- package/dist/naming.d.ts +49 -0
- package/dist/naming.js +246 -0
- package/dist/observability.d.ts +25 -0
- package/dist/observability.js +245 -0
- package/dist/operations.d.ts +23 -0
- package/{operations.mjs → dist/operations.js} +410 -332
- package/dist/project-graph.d.ts +9 -0
- package/{project-graph.mjs → dist/project-graph.js} +8 -13
- package/dist/projections.d.ts +11 -0
- package/{projections.mjs → dist/projections.js} +60 -57
- package/dist/query-safety.d.ts +21 -0
- package/{query-safety.mjs → dist/query-safety.js} +92 -108
- package/dist/realtime.d.ts +15 -0
- package/{realtime.mjs → dist/realtime.js} +108 -106
- package/dist/resilience.d.ts +15 -0
- package/dist/resilience.js +319 -0
- package/dist/schema-authority.d.ts +15 -0
- package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
- package/dist/service-deps.d.ts +17 -0
- package/{service-deps.mjs → dist/service-deps.js} +133 -130
- package/dist/service-isolation.d.ts +8 -0
- package/dist/service-isolation.js +76 -0
- package/dist/size-budget.d.ts +9 -0
- package/{size-budget.mjs → dist/size-budget.js} +27 -27
- package/dist/sonar-parity.d.ts +5 -0
- package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
- package/dist/spec-no-skip.d.ts +9 -0
- package/dist/spec-no-skip.js +81 -0
- package/dist/spec-quality.d.ts +10 -0
- package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
- package/dist/suppression.d.ts +26 -0
- package/{suppression.mjs → dist/suppression.js} +30 -45
- package/dist/temporal.d.ts +9 -0
- package/{temporal.mjs → dist/temporal.js} +75 -65
- package/dist/test-world.d.ts +28 -0
- package/{test-world.mjs → dist/test-world.js} +102 -83
- package/dist/testing.d.ts +51 -0
- package/dist/testing.js +368 -0
- package/dist/third-party-owner.d.ts +8 -0
- package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
- package/dist/transport.d.ts +24 -0
- package/{transport.mjs → dist/transport.js} +279 -240
- package/dist/type-safety.d.ts +25 -0
- package/dist/type-safety.js +297 -0
- package/dist/unit-spec.d.ts +30 -0
- package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
- package/dist/uploads.d.ts +9 -0
- package/{uploads.mjs → dist/uploads.js} +62 -54
- package/dist/user-copy.d.ts +9 -0
- package/{user-copy.mjs → dist/user-copy.js} +76 -67
- package/dist/webhooks.d.ts +16 -0
- package/{webhooks.mjs → dist/webhooks.js} +243 -231
- package/package.json +17 -8
- package/runtime/knowledge/hfs/canon-pins.yaml +22 -14
- package/runtime/knowledge/hfs/rules.yaml +23 -0
- package/runtime/scripts/lib/package-at.mjs +5 -5
- package/async-discipline.mjs +0 -83
- package/comments.mjs +0 -416
- package/edge-hardening.mjs +0 -139
- package/health-ready.mjs +0 -539
- package/jwt-alg.mjs +0 -45
- package/lib/ast.mjs +0 -88
- package/lib/import-source.mjs +0 -104
- package/lib/specifier.mjs +0 -27
- package/lib/subject-values.mjs +0 -55
- package/lib/types.mjs +0 -133
- package/log-safety.mjs +0 -303
- package/module-layering.mjs +0 -270
- package/naming.mjs +0 -251
- package/observability.mjs +0 -241
- package/resilience.mjs +0 -304
- package/service-isolation.mjs +0 -75
- package/spec-no-skip.mjs +0 -85
- package/testing.mjs +0 -384
- package/type-safety.mjs +0 -323
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
+
/** A body or argument carries a declared type, never `unknown`, `any` or GraphQLJSON. */
|
|
3
|
+
export declare const noUntypedBody: RuleModule;
|
|
4
|
+
/** An open door states why it is open, from the closed `PublicReason` list of `domain/identity`. */
|
|
5
|
+
export declare const publicNeedsReason: RuleModule;
|
|
6
|
+
/** The identity enum and each public door use exactly the canon's four reasons. */
|
|
7
|
+
export declare const publicReasonClosed: RuleModule;
|
|
8
|
+
/** The rules this law contributes to the plugin. */
|
|
9
|
+
export declare const rules: {
|
|
10
|
+
"no-untyped-body": RuleModule;
|
|
11
|
+
"public-needs-reason": RuleModule;
|
|
12
|
+
"public-reason-closed": RuleModule;
|
|
13
|
+
};
|
|
14
|
+
/** Every rule starts at error: public doors and typed inputs hold the default-deny boundary. */
|
|
15
|
+
export declare const recommended: Recommended;
|
|
@@ -15,69 +15,77 @@
|
|
|
15
15
|
* The `APP_GUARD` registration and the app-level guard live in the composition check, not here: a rule reading
|
|
16
16
|
* one file cannot see which module the app registered.
|
|
17
17
|
*/
|
|
18
|
-
import { isTransportSlot } from "./lib/transport-slots.
|
|
19
|
-
import { decoratorName, keyName } from "./lib/ast.
|
|
20
|
-
import { isOwnedBy, isOwnedEnumMember, isOwnedType, partsOf, typeOf } from "./lib/declared.
|
|
21
|
-
import { hfsOf } from "./lib/hfs.
|
|
22
|
-
import { isDeclarationFile, normalizePath } from "./lib/path.
|
|
23
|
-
import { typed } from "./lib/types.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
18
|
+
import { isTransportSlot } from "./lib/transport-slots.js";
|
|
19
|
+
import { decoratorName, keyName } from "./lib/ast.js";
|
|
20
|
+
import { isOwnedBy, isOwnedEnumMember, isOwnedType, partsOf, typeOf } from "./lib/declared.js";
|
|
21
|
+
import { hfsOf } from "./lib/hfs.js";
|
|
22
|
+
import { isDeclarationFile, normalizePath } from "./lib/path.js";
|
|
23
|
+
import { typed } from "./lib/types.js";
|
|
24
|
+
import ts from "typescript";
|
|
25
|
+
import { isNode } from "./lib/rule.js";
|
|
26
|
+
const BODY_DECORATORS = new Set(["Body", "Args"]);
|
|
27
|
+
const PUBLIC_REASONS = new Set(["Health", "AuthHandshake", "SignedWebhook", "CatalogRead"]);
|
|
28
|
+
const REASON_WRAPPERS = new Set(["TSAsExpression", "TSTypeAssertion", "TSNonNullExpression", "TSSatisfiesExpression"]);
|
|
29
|
+
const isReasonWrapper = (node) => REASON_WRAPPERS.has(node.type);
|
|
29
30
|
/** The reason expression supplied to a public decorator, or null when it supplies none. */
|
|
30
31
|
const publicReasonOf = (node) => {
|
|
31
|
-
const expression = node.expression
|
|
32
|
-
const argument = expression.type === "CallExpression" ? expression.arguments[0] : undefined
|
|
33
|
-
if (argument?.type !== "ObjectExpression")
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const expression = node.expression;
|
|
33
|
+
const argument = expression.type === "CallExpression" ? expression.arguments[0] : undefined;
|
|
34
|
+
if (argument?.type !== "ObjectExpression")
|
|
35
|
+
return null;
|
|
36
|
+
const property = argument.properties.find((item) => item.type === "Property" && !item.computed && keyName(item.key) === "reason");
|
|
37
|
+
return property ? property.value : null;
|
|
38
|
+
};
|
|
38
39
|
/** A static member name; a computed identifier is an expression rather than the member's name. */
|
|
39
40
|
const staticMemberName = (node) => {
|
|
40
|
-
if (node.computed && node.property.type !== "Literal")
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (node.computed && node.property.type !== "Literal")
|
|
42
|
+
return null;
|
|
43
|
+
return keyName(node.property);
|
|
44
|
+
};
|
|
44
45
|
/** All declared names of the enum, including TypeScript's merged declarations. */
|
|
45
46
|
const publicReasonNames = (context, node) => {
|
|
46
|
-
const { checker, toTs } = typed(context)
|
|
47
|
-
const declaration = toTs(node)
|
|
48
|
-
const symbol = checker.getSymbolAtLocation(declaration.name)
|
|
49
|
-
const members = (symbol?.declarations ?? []).flatMap((part) => part.members
|
|
50
|
-
return new Set(members.map((member) => member.name.text))
|
|
51
|
-
}
|
|
52
|
-
|
|
47
|
+
const { checker, toTs } = typed(context);
|
|
48
|
+
const declaration = toTs(node);
|
|
49
|
+
const symbol = checker.getSymbolAtLocation(declaration.name);
|
|
50
|
+
const members = (symbol?.declarations ?? []).flatMap((part) => (ts.isEnumDeclaration(part) ? part.members : []));
|
|
51
|
+
return new Set(members.map((member) => ("text" in member.name ? member.name.text : undefined)));
|
|
52
|
+
};
|
|
53
53
|
/** Reject added enum members even when the expression is an alias or a union of reasons. */
|
|
54
54
|
const hasAddedPublicReason = (context, reason) => {
|
|
55
|
-
let value = reason
|
|
56
|
-
while (
|
|
55
|
+
let value = reason;
|
|
56
|
+
while (isReasonWrapper(value))
|
|
57
|
+
value = value.expression;
|
|
57
58
|
// A stale or not-yet-declared member has an error type, but its enum receiver still has an owner.
|
|
58
59
|
if (value.type === "MemberExpression" && isOwnedType(context, value.object, "PublicReason", "domain", "identity")) {
|
|
59
|
-
const name = staticMemberName(value)
|
|
60
|
-
if (name !== null && !PUBLIC_REASONS.has(name))
|
|
60
|
+
const name = staticMemberName(value);
|
|
61
|
+
if (name !== null && !PUBLIC_REASONS.has(name))
|
|
62
|
+
return true;
|
|
61
63
|
}
|
|
62
64
|
if (isOwnedEnumMember(context, reason, "PublicReason", "domain", "identity")) {
|
|
63
|
-
return partsOf(typeOf(context, reason)).some((part) =>
|
|
65
|
+
return partsOf(typeOf(context, reason)).some((part) => {
|
|
66
|
+
const name = part.getSymbol()?.name;
|
|
67
|
+
return name === undefined || !PUBLIC_REASONS.has(name);
|
|
68
|
+
});
|
|
64
69
|
}
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
68
72
|
const isUntyped = (annotation) => {
|
|
69
|
-
if (!annotation)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
73
|
+
if (!annotation)
|
|
74
|
+
return true;
|
|
75
|
+
const type = annotation.typeAnnotation;
|
|
76
|
+
if (!type)
|
|
77
|
+
return true;
|
|
78
|
+
if (["TSUnknownKeyword", "TSAnyKeyword", "TSObjectKeyword"].includes(type.type))
|
|
79
|
+
return true;
|
|
80
|
+
if (type.type === "TSTypeLiteral" && type.members.length === 0)
|
|
81
|
+
return true;
|
|
74
82
|
if (type.type === "TSTypeReference" && type.typeName.type === "Identifier" && type.typeName.name === "Record") {
|
|
75
|
-
const
|
|
76
|
-
|
|
83
|
+
const legacy = Reflect.get(type, "typeParameters");
|
|
84
|
+
const value = type.typeArguments?.params?.[1] ?? (isNode(legacy) && legacy.type === "TSTypeParameterInstantiation" ? legacy : undefined)?.params?.[1];
|
|
85
|
+
return value?.type === "TSUnknownKeyword" || value?.type === "TSAnyKeyword";
|
|
77
86
|
}
|
|
78
|
-
return false
|
|
79
|
-
}
|
|
80
|
-
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
81
89
|
/** A body or argument carries a declared type, never `unknown`, `any` or GraphQLJSON. */
|
|
82
90
|
export const noUntypedBody = {
|
|
83
91
|
meta: {
|
|
@@ -91,38 +99,41 @@ export const noUntypedBody = {
|
|
|
91
99
|
},
|
|
92
100
|
},
|
|
93
101
|
create(context) {
|
|
94
|
-
const filename = normalizePath(context.filename || context.getFilename())
|
|
95
|
-
if (isDeclarationFile(filename))
|
|
96
|
-
|
|
97
|
-
const
|
|
102
|
+
const filename = normalizePath(context.filename || context.getFilename());
|
|
103
|
+
if (isDeclarationFile(filename))
|
|
104
|
+
return {};
|
|
105
|
+
const slot = hfsOf(context).slotOf(filename) ?? "";
|
|
106
|
+
const inTransport = isTransportSlot(slot) || slot.startsWith("be.feature.transport.");
|
|
98
107
|
return {
|
|
99
108
|
Identifier(node) {
|
|
100
109
|
if (node.name === "GraphQLJSON" && !/^Import.*Specifier$/.test(node.parent?.type ?? "")) {
|
|
101
|
-
context.report({ node, messageId: "json" })
|
|
110
|
+
context.report({ node, messageId: "json" });
|
|
102
111
|
}
|
|
103
112
|
},
|
|
104
113
|
SwitchStatement(node) {
|
|
105
|
-
const discriminant = node.discriminant
|
|
114
|
+
const discriminant = node.discriminant;
|
|
106
115
|
if (inTransport && discriminant.type === "MemberExpression" && keyName(discriminant.property) === "operation") {
|
|
107
|
-
context.report({ node, messageId: "operationSwitch" })
|
|
116
|
+
context.report({ node, messageId: "operationSwitch" });
|
|
108
117
|
}
|
|
109
118
|
},
|
|
110
119
|
Decorator(node) {
|
|
111
|
-
const name = decoratorName(node)
|
|
112
|
-
if (!BODY_DECORATORS.has(name))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
120
|
+
const name = decoratorName(node);
|
|
121
|
+
if (name === null || !BODY_DECORATORS.has(name))
|
|
122
|
+
return;
|
|
123
|
+
const parameter = node.parent;
|
|
124
|
+
if (!parameter)
|
|
125
|
+
return;
|
|
126
|
+
const bound = parameter.type === "TSParameterProperty" ? parameter.parameter : parameter;
|
|
127
|
+
if (bound.type !== "Identifier" && bound.type !== "ObjectPattern" && bound.type !== "AssignmentPattern")
|
|
128
|
+
return;
|
|
129
|
+
const annotated = bound.type === "AssignmentPattern" ? bound.left : bound;
|
|
118
130
|
if (isUntyped(annotated.typeAnnotation)) {
|
|
119
|
-
context.report({ node, messageId: "untyped", data: { decorator: name } })
|
|
131
|
+
context.report({ node, messageId: "untyped", data: { decorator: name } });
|
|
120
132
|
}
|
|
121
133
|
},
|
|
122
|
-
}
|
|
134
|
+
};
|
|
123
135
|
},
|
|
124
|
-
}
|
|
125
|
-
|
|
136
|
+
};
|
|
126
137
|
/** An open door states why it is open, from the closed `PublicReason` list of `domain/identity`. */
|
|
127
138
|
export const publicNeedsReason = {
|
|
128
139
|
meta: {
|
|
@@ -134,18 +145,20 @@ export const publicNeedsReason = {
|
|
|
134
145
|
},
|
|
135
146
|
},
|
|
136
147
|
create(context) {
|
|
137
|
-
const filename = normalizePath(context.filename || context.getFilename())
|
|
138
|
-
if (isDeclarationFile(filename))
|
|
148
|
+
const filename = normalizePath(context.filename || context.getFilename());
|
|
149
|
+
if (isDeclarationFile(filename))
|
|
150
|
+
return {};
|
|
139
151
|
return {
|
|
140
152
|
Decorator(node) {
|
|
141
|
-
if (decoratorName(node) !== "Public")
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
if (decoratorName(node) !== "Public")
|
|
154
|
+
return;
|
|
155
|
+
const reason = publicReasonOf(node);
|
|
156
|
+
if (reason === null || !isOwnedEnumMember(context, reason, "PublicReason", "domain", "identity"))
|
|
157
|
+
context.report({ node, messageId: "reason" });
|
|
144
158
|
},
|
|
145
|
-
}
|
|
159
|
+
};
|
|
146
160
|
},
|
|
147
|
-
}
|
|
148
|
-
|
|
161
|
+
};
|
|
149
162
|
/** The identity enum and each public door use exactly the canon's four reasons. */
|
|
150
163
|
export const publicReasonClosed = {
|
|
151
164
|
meta: {
|
|
@@ -157,36 +170,38 @@ export const publicReasonClosed = {
|
|
|
157
170
|
},
|
|
158
171
|
},
|
|
159
172
|
create(context) {
|
|
160
|
-
const filename = normalizePath(context.filename || context.getFilename())
|
|
161
|
-
if (isDeclarationFile(filename))
|
|
162
|
-
|
|
173
|
+
const filename = normalizePath(context.filename || context.getFilename());
|
|
174
|
+
if (isDeclarationFile(filename))
|
|
175
|
+
return {};
|
|
176
|
+
const inIdentity = isOwnedBy(hfsOf(context), filename, "domain", "identity");
|
|
163
177
|
return {
|
|
164
178
|
TSEnumDeclaration(node) {
|
|
165
|
-
if (!inIdentity || node.id.name !== "PublicReason")
|
|
166
|
-
|
|
179
|
+
if (!inIdentity || node.id.name !== "PublicReason")
|
|
180
|
+
return;
|
|
181
|
+
const names = publicReasonNames(context, node);
|
|
167
182
|
if (names.size !== PUBLIC_REASONS.size || [...PUBLIC_REASONS].some((name) => !names.has(name))) {
|
|
168
|
-
context.report({ node, messageId: "closed" })
|
|
183
|
+
context.report({ node, messageId: "closed" });
|
|
169
184
|
}
|
|
170
185
|
},
|
|
171
186
|
Decorator(node) {
|
|
172
|
-
if (decoratorName(node) !== "Public")
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
if (decoratorName(node) !== "Public")
|
|
188
|
+
return;
|
|
189
|
+
const reason = publicReasonOf(node);
|
|
190
|
+
if (reason !== null && hasAddedPublicReason(context, reason))
|
|
191
|
+
context.report({ node, messageId: "closed" });
|
|
175
192
|
},
|
|
176
|
-
}
|
|
193
|
+
};
|
|
177
194
|
},
|
|
178
|
-
}
|
|
179
|
-
|
|
195
|
+
};
|
|
180
196
|
/** The rules this law contributes to the plugin. */
|
|
181
197
|
export const rules = {
|
|
182
198
|
"no-untyped-body": noUntypedBody,
|
|
183
199
|
"public-needs-reason": publicNeedsReason,
|
|
184
200
|
"public-reason-closed": publicReasonClosed,
|
|
185
|
-
}
|
|
186
|
-
|
|
201
|
+
};
|
|
187
202
|
/** Every rule starts at error: public doors and typed inputs hold the default-deny boundary. */
|
|
188
203
|
export const recommended = {
|
|
189
204
|
"starci-be/no-untyped-body": "error",
|
|
190
205
|
"starci-be/public-needs-reason": "error",
|
|
191
206
|
"starci-be/public-reason-closed": "error",
|
|
192
|
-
}
|
|
207
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
+
/** E2E enters through production transport and never invokes an internal actor directly. */
|
|
3
|
+
export declare const e2eUsesProductionTransport: RuleModule;
|
|
4
|
+
/** A flow polls until the state settles; it never waits for a duration. */
|
|
5
|
+
export declare const noSleepInFlow: RuleModule;
|
|
6
|
+
/**
|
|
7
|
+
* A step asserts one outcome. A branch means the test is prepared for either, which is no assertion.
|
|
8
|
+
*
|
|
9
|
+
* The probe handed to `world.waitFor(label, probe)` is not a step: it is a polling predicate ("answer the row once it is
|
|
10
|
+
* there, else nothing"), and a test whose probe never becomes ready FAILS at the deadline, so no path passes by omission.
|
|
11
|
+
* A probe is recognised by the type of the receiver (`waitFor` on a value whose type is declared in the test world,
|
|
12
|
+
* slot `be.tests.world`), never by the name of a variable; a `waitFor` of any other type, and every branch outside the
|
|
13
|
+
* probe, is still a branch in a step.
|
|
14
|
+
*/
|
|
15
|
+
export declare const noBranchInFlowStep: RuleModule;
|
|
16
|
+
/** A flow boots through the shared setup; it does not build its own copy of the app. */
|
|
17
|
+
export declare const noWiringInFlowSpec: RuleModule;
|
|
18
|
+
export declare const rules: {
|
|
19
|
+
"e2e-uses-production-transport": RuleModule;
|
|
20
|
+
"no-sleep-in-flow": RuleModule;
|
|
21
|
+
"no-branch-in-flow-step": RuleModule;
|
|
22
|
+
"no-wiring-in-flow-spec": RuleModule;
|
|
23
|
+
};
|
|
24
|
+
/** Every rule of this law ships at `error`. */
|
|
25
|
+
export declare const recommended: Recommended;
|