Curated, product-agnostic snapshot of the post-story-04 tree: demo content deleted, auth-only reference feature, web-next shell, all gates green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor library traces, and product naming are curated out; generic template repairs (coverage provider devDeps, root test:coverage script, live lint fixes, root-only release-please) are kept. See TEMPLATE.md for provenance, curation list, and usage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
import { parseManifestUseCases } from "./_manifest-ast.js";
|
|
import { manifestPathForFeature } from "./_manifest-source.js";
|
|
import { repoRootSchema } from "./_rule-schema.js";
|
|
import { resolveRuleContext } from "./_rule-context.js";
|
|
|
|
/** @type {import("eslint").Rule.RuleModule} */
|
|
export default {
|
|
meta: {
|
|
type: "problem",
|
|
docs: {
|
|
description:
|
|
'auditLog.record({ type: "X" }) inside a use-case factory must declare X in manifest.useCases[name].audits.',
|
|
},
|
|
schema: repoRootSchema,
|
|
messages: {
|
|
undeclared:
|
|
'{{useCase}} calls auditLog.record with type "{{event}}" but {{event}} is not declared in manifest.useCases.{{useCase}}.audits. Add it to the manifest or remove the call.',
|
|
},
|
|
},
|
|
create(context) {
|
|
const rc = resolveRuleContext(context);
|
|
if (!rc) return {};
|
|
const { useCaseName, featureRoot } = rc;
|
|
const manifest = parseManifestUseCases(manifestPathForFeature(featureRoot));
|
|
if (!manifest || !manifest[useCaseName]) return {};
|
|
const declared = new Set(manifest[useCaseName].audits);
|
|
return {
|
|
CallExpression(node) {
|
|
if (
|
|
node.callee.type === "MemberExpression" &&
|
|
node.callee.object.type === "Identifier" &&
|
|
node.callee.object.name === "auditLog" &&
|
|
node.callee.property.type === "Identifier" &&
|
|
node.callee.property.name === "record" &&
|
|
node.arguments.length > 0 &&
|
|
node.arguments[0].type === "ObjectExpression"
|
|
) {
|
|
const typeProp = node.arguments[0].properties.find(
|
|
(p) =>
|
|
p.type === "Property" &&
|
|
p.key.type === "Identifier" &&
|
|
p.key.name === "type",
|
|
);
|
|
if (
|
|
typeProp &&
|
|
typeProp.value.type === "Literal" &&
|
|
typeof typeProp.value.value === "string"
|
|
) {
|
|
const event = typeProp.value.value;
|
|
if (!declared.has(event)) {
|
|
context.report({
|
|
node,
|
|
messageId: "undeclared",
|
|
data: { event, useCase: useCaseName },
|
|
});
|
|
}
|
|
}
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|