Files
OmniRoute/tests/unit/eslint-react-hooks-version-pinned.test.ts
Diego Rodrigues de Sa e Souza 93fdc16e72 chore(lint): adopt eslint-plugin-react-hooks 7.1.1 (#12428)
* chore(lint): adopt eslint-plugin-react-hooks 7.1.1

The #12146 migration (284 react-hooks compiler-rule violations resolved in 8
batches) completed on 2026-09-01, unblocking the 7.1.1 adoption the pin test
was holding back. Exact pin kept in both devDependencies and overrides; the
pin test moves to 7.1.1 (the dependabot-level ignore from #12329 stays — a
lint plugin coupled to the compiler rules always bumps via its own reviewed
PR, never riding a group).

* chore(lint): lockfile for the react-hooks 7.1.1 adoption

Generated with a bare 'npm install --package-lock-only' (naming the package
on the CLI rewrites the devDependency with a caret, which npm 11 then rejects
against the exact override). Validated on the .113 with a fresh npm ci +
cold NODE_OPTIONS=8G lint:json --max-warnings 0 → exit 0 (zero new
violations from the 7.1.1 rule set) and the re-pinned version test green.
2026-09-02 06:22:30 -03:00

42 lines
1.7 KiB
TypeScript

/**
* eslint-react-hooks-version-pinned.test.ts — keep lint policy deterministic.
*
* eslint-config-next accepts any eslint-plugin-react-hooks 7.x release. Minor
* releases can change React Compiler diagnostics, so resolving a newer plugin
* from unchanged source can produce hundreds of unrelated lint failures. Keep
* the direct declaration exact and aligned with the lockfile.
*/
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
import { fileURLToPath } from "node:url";
const ROOT = new URL("../../", import.meta.url);
const PLUGIN = "eslint-plugin-react-hooks";
const EXPECTED_VERSION = "7.1.1";
async function readJson(relative: string): Promise<Record<string, unknown>> {
return JSON.parse(await readFile(fileURLToPath(new URL(relative, ROOT)), "utf8"));
}
test("eslint-plugin-react-hooks is directly pinned to the locked version", async () => {
const pkg = await readJson("package.json");
const lock = await readJson("package-lock.json");
const declared = ((pkg.devDependencies ?? {}) as Record<string, string>)[PLUGIN];
const packages = (lock.packages ?? {}) as Record<string, { version?: string }>;
const locked = packages[`node_modules/${PLUGIN}`]?.version;
assert.ok(declared, `${PLUGIN} must be a direct devDependency`);
assert.equal(
declared,
EXPECTED_VERSION,
`${PLUGIN} must remain pinned to ${EXPECTED_VERSION} so a group bump can never ride past the compiler-rules migration review`
);
assert.ok(locked, `${PLUGIN} missing from package-lock.json`);
assert.equal(
declared,
locked,
`package.json declares ${PLUGIN}@${declared} but package-lock.json resolves ${locked}`
);
});