fix(core-eslint): parse satisfies-shaped manifests; unify manifest parser
A manifest written as `{...} satisfies FeatureManifest` (or the combined
`as const satisfies` idiom) parsed to null, silently no-oping the
error-level conformance rules. unwrapAsConst now strips TSAsExpression
and TSSatisfiesExpression in a loop. The file also carried a verbatim
second copy of its own parser for parseManifestFully; both public entry
points now share one implementation. The template's field set (audits,
rateLimit, requiresConsent) is preserved.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,51 @@ describe("parseManifestFully", () => {
|
||||
expect(parseManifestFully(fp)).toBeNull();
|
||||
});
|
||||
|
||||
it("parses a `satisfies FeatureManifest` manifest (must not silently no-op the gates)", () => {
|
||||
const fp = writeManifest(`export const xManifest = defineFeature({
|
||||
name: "x",
|
||||
requiredCores: [],
|
||||
useCases: {
|
||||
doThing: { mutates: true, audits: ["x.done"], publishes: ["x.done"], consumes: [] },
|
||||
},
|
||||
realtimeChannels: [],
|
||||
jobs: [],
|
||||
} satisfies FeatureManifest);`);
|
||||
expect(parseManifestUseCases(fp)).toEqual({
|
||||
doThing: {
|
||||
mutates: true,
|
||||
audits: ["x.done"],
|
||||
publishes: ["x.done"],
|
||||
consumes: [],
|
||||
analyticsEvents: [],
|
||||
rateLimit: [],
|
||||
},
|
||||
});
|
||||
expect(parseManifestFully(fp)?.name).toBe("x");
|
||||
});
|
||||
|
||||
it("parses the combined `as const satisfies FeatureManifest` idiom", () => {
|
||||
const fp = writeManifest(`export const xManifest = defineFeature({
|
||||
name: "x",
|
||||
requiredCores: [],
|
||||
useCases: {
|
||||
doThing: { mutates: false, audits: [], publishes: [], consumes: [] },
|
||||
},
|
||||
realtimeChannels: [],
|
||||
jobs: [],
|
||||
} as const satisfies FeatureManifest);`);
|
||||
expect(parseManifestUseCases(fp)).toEqual({
|
||||
doThing: {
|
||||
mutates: false,
|
||||
audits: [],
|
||||
publishes: [],
|
||||
consumes: [],
|
||||
analyticsEvents: [],
|
||||
rateLimit: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("is not fooled by 'name:' inside a JSDoc comment (regex would false-match)", () => {
|
||||
const fp = writeManifest(`/**
|
||||
* Sample comment with name: "fake" embedded in it.
|
||||
|
||||
Reference in New Issue
Block a user