Files
openclaw/test/scripts/strict-ratchet-sync.test.ts
Peter Steinberger e686693732 feat(tooling): adopt noUncheckedIndexedAccess via a strict-ratchet lane (phase 1) (#104577)
* feat(tooling): add noUncheckedIndexedAccess strict-ratchet lane

* fix(packages): make indexed access explicit across ratchet packages

Burns down all 65 noUncheckedIndexedAccess errors in the seven ratchet
packages with behavior-identical restructuring (iteration, charAt/slice,
regex-group guards, validated hextet tuple). net-policy invariant
violations now throw instead of failing open. Adds
@openclaw/normalization-core/expect (expectDefined/first/last) with
subpath export and tests. memory-host-sdk fixes kept but the package
stays out of the lane: it re-exports core src/** so the flag would apply
transitively to all of core.

* fix(lint): keep .oxlintrc.json strict-JSON parseable for extension lint wrappers
2026-07-11 10:26:12 -07:00

38 lines
1.5 KiB
TypeScript

import fs from "node:fs";
import JSON5 from "json5";
import { describe, expect, it } from "vitest";
import { STRICT_RATCHET_PACKAGE_DIRS, detectChangedLanes } from "../../scripts/changed-lanes.mjs";
import { createChangedCheckPlan } from "../../scripts/check-changed.mjs";
const config: unknown = JSON5.parse(fs.readFileSync("tsconfig.strict-ratchet.json", "utf8"));
if (
!config ||
typeof config !== "object" ||
!("include" in config) ||
!Array.isArray(config.include) ||
!config.include.every((entry) => typeof entry === "string")
) {
throw new Error("expected strict-ratchet tsconfig includes to be strings");
}
const includedPackageDirs = config.include
.filter((entry) => entry.startsWith("packages/") && entry.endsWith("/src/**/*"))
.map((entry) => entry.replace(/\/src\/\*\*\/\*$/u, ""));
describe("strict ratchet routing", () => {
it("keeps the changed-lane package list pinned to the tsconfig", () => {
expect(includedPackageDirs).toEqual(STRICT_RATCHET_PACKAGE_DIRS);
});
it.each(includedPackageDirs)("routes %s changes through the ratchet lane", (packageDir) => {
const result = detectChangedLanes([`${packageDir}/src/example.ts`]);
const plan = createChangedCheckPlan(result);
expect(result.lanes.strictRatchet).toBe(true);
expect(plan.commands.map((command) => command.args[0])).toContain("tsgo:strict-ratchet");
});
it("routes the ratchet tsconfig through its lane", () => {
expect(detectChangedLanes(["tsconfig.strict-ratchet.json"]).lanes.strictRatchet).toBe(true);
});
});