@starci/eslint-canon-be 3.5.0 → 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 +15 -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 +17 -10
- 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,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.
|
|
7
|
-
import { importOf, moduleReferences } from "./lib/import-source.
|
|
8
|
-
import { resolveVariable } from "./lib/transactions.
|
|
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))
|
|
34
|
-
|
|
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))
|
|
43
|
-
|
|
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 === "*")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
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))
|
|
59
|
-
|
|
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")
|
|
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)
|
|
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))
|
|
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")
|
|
97
|
-
|
|
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")
|
|
100
|
-
|
|
101
|
-
|
|
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.
|
|
24
|
-
import { keyName, staticText } from "./lib/ast.
|
|
25
|
-
import { hfsOf } from "./lib/hfs.
|
|
26
|
-
import { ownerNameOf } from "./lib/ports.
|
|
27
|
-
import { typeOrigins, typed } from "./lib/types.
|
|
28
|
-
import { isDeclarationFile } from "./lib/path.
|
|
29
|
-
|
|
30
|
-
const
|
|
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)
|
|
37
|
-
|
|
38
|
-
if (/^[A-
|
|
39
|
-
|
|
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))
|
|
46
|
-
|
|
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))
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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))
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
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)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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))
|
|
95
|
-
|
|
96
|
-
|
|
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")
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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;
|