test(gates): hold the lint and lane configs to a committed snapshot
The register test detected narrowings by modelling config shapes, and each review round found one more shape it did not model (a basePath global ignore, a rule src never declares, a widened glob filed under a narrow row, a substring check on a CI line, knip.json beside knip.jsonc). It now compares instead: gates.snapshot.json holds ESLint's effective config for every code file and the lines that run each lane, and any difference fails until it is regenerated. The register is read off the snapshot's configs, which surfaced the ui/ and lib/ test scopes the sampling never reached. The complexity ratchet also names a wrapped function by its binding (const onSave = useCallback(() => ...)), not as "useCallback callback".
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
boundNamesIn,
|
||||
complexityOffenders,
|
||||
lineCounts,
|
||||
MAX_COMPLEXITY,
|
||||
@@ -134,3 +135,15 @@ describe("function complexity", async () => {
|
||||
expect(Object.keys(COMPLEX).filter((fn) => !(fn in actual))).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("function names (the ratchet's keys)", () => {
|
||||
it("names an unnamed function by what it is bound to, through a wrapping call", () => {
|
||||
const code = [
|
||||
"const onSave = useCallback(() => 1);",
|
||||
"useEffect(() => {});",
|
||||
"const o = { k: function () {} };",
|
||||
"const v = useMemo(() => g(() => 2));",
|
||||
].join(" ");
|
||||
expect(boundNamesIn(code)).toEqual(["onSave", "useEffect callback", "k", "v", "g callback"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user