feat(core-eslint): add no-undeclared-rate-limit conformance rule

Adds the `no-undeclared-rate-limit` ESLint rule (warn severity) that
enforces rate-limit drift at lint time:

- Warns when rateLimit.consume("X", _) is called inside a use-case but
  "X" is absent from manifest.useCases[name].rateLimit
- Warns when a declared rateLimit budget has no matching consume call
  in the use-case body (unusedDeclaration)
- Is a no-op outside use-case files

Extends _manifest-ast.js to extract the rateLimit[] field from both
parseManifestUseCases and parseManifestFully. Updates _manifest-ast
tests to include the new field in expected shapes. Registers the rule
at warn severity in plugin.js and base.js. Adds RuleTester fixtures
for all four cases (declared+matching, undeclared, unused, non-use-case).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 08:43:30 +00:00
parent a478a8e6ea
commit 18cef2f889
7 changed files with 226 additions and 4 deletions

View File

@@ -87,6 +87,7 @@ function extractUseCaseEntry(objExpr) {
publishes: [],
consumes: [],
analyticsEvents: [],
rateLimit: [],
};
for (const prop of objExpr.properties) {
if (prop.type !== "Property" || prop.key.type !== "Identifier") continue;
@@ -97,7 +98,8 @@ function extractUseCaseEntry(objExpr) {
(key === "audits" ||
key === "publishes" ||
key === "consumes" ||
key === "analyticsEvents") &&
key === "analyticsEvents" ||
key === "rateLimit") &&
prop.value.type === "ArrayExpression"
) {
entry[key] = extractStringLiterals(prop.value);
@@ -219,6 +221,7 @@ function extractUseCaseEntryFromObj(objExpr) {
publishes: [],
consumes: [],
analyticsEvents: [],
rateLimit: [],
};
for (const prop of objExpr.properties) {
if (prop.type !== "Property" || prop.key.type !== "Identifier") continue;
@@ -229,7 +232,8 @@ function extractUseCaseEntryFromObj(objExpr) {
(key === "audits" ||
key === "publishes" ||
key === "consumes" ||
key === "analyticsEvents") &&
key === "analyticsEvents" ||
key === "rateLimit") &&
prop.value.type === "ArrayExpression"
) {
entry[key] = extractStringLiterals(prop.value);