fix(limits): keep bracket-access reads in numeric-limit discovery

A quoted name after an identifier, call, or optional chain is a producer. Only declaration arrays and comments stay out of discovery.
This commit is contained in:
Cursor Agent authored and morluto committed 2026-11-11 19:39:06 +08:00
1 parent f2d55aba7b
commit 7fe465505f
2 files changed
+59 -2

No files matched your search

@@ -41,6 +41,17 @@ it("does not treat a registry declaration as a producer", () => {
).toBe(false);
});
it("keeps a bracket-access read as a producer", () => {
const name = "REA_NEW_MAX_BYTES";
const discovered = discoverNumericLimitUses([
{
path: "src/config/newLimit.ts",
source: `const selected = environment["${name}"] ?? environment?.[ "${name}" ];`,
},
]);
expect(discovered.get(name)).toBe("src/config/newLimit.ts");
});
it("does not treat a registration allowlist or a comment as a producer", () => {
const discovered = discoverNumericLimitUses([
{