feat(core-eslint): add no-undeclared-consent-check rule (conformance gate 12)
Extends the conformance ESLint layer with the consent-check rule:
- `no-undeclared-consent-check` (warn): `consent.isGranted("X")` in a
use-case file must match a category declared in `manifest.requiresConsent`;
also warns when requiresConsent is declared but no isGranted call is found.
- `_manifest-ast.js`: adds `parseManifestFully` which extracts top-level
`name`, `requiredCores`, `requiresConsent`, and per-use-case maps from the
manifest AST; `requiresConsent` extraction tested in `_manifest-ast.test.js`.
- `_rule-context.js` / `_rule-schema.js`: shared helpers extracted from the
existing per-rule files so the new rule can resolve use-case name + feature
root without duplication.
- Existing rules (`no-undeclared-audit`, `no-undeclared-event-publish`,
`no-undeclared-analytics-event`) updated to use the shared helpers.
- `plugin.js` + `base.js` register the rule at warn severity.
- CLAUDE.md + conformance-quickref.md: rule count advanced from 11 → 12.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,7 @@ describe("parseManifestFully", () => {
|
||||
expect(parseManifestFully(fp)).toEqual({
|
||||
name: "auth",
|
||||
requiredCores: ["audit", "events"],
|
||||
requiresConsent: [],
|
||||
useCases: {
|
||||
signIn: {
|
||||
mutates: false,
|
||||
@@ -105,6 +106,23 @@ describe("parseManifestFully", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts requiresConsent categories from the manifest", () => {
|
||||
const fp = writeManifest(`export const consentManifest = defineFeature({
|
||||
name: "consent",
|
||||
requiredCores: [],
|
||||
requiresConsent: ["analytics", "marketing"],
|
||||
useCases: {},
|
||||
realtimeChannels: [],
|
||||
jobs: [],
|
||||
} as const);`);
|
||||
expect(parseManifestFully(fp)).toEqual({
|
||||
name: "consent",
|
||||
requiredCores: [],
|
||||
requiresConsent: ["analytics", "marketing"],
|
||||
useCases: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null when the manifest has no name", () => {
|
||||
const fp = writeManifest(`export const x = 1;`);
|
||||
expect(parseManifestFully(fp)).toBeNull();
|
||||
@@ -124,6 +142,7 @@ export const realManifest = defineFeature({
|
||||
expect(parseManifestFully(fp)).toEqual({
|
||||
name: "real",
|
||||
requiredCores: [],
|
||||
requiresConsent: [],
|
||||
useCases: {},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user