fix(ci): report client warnings without linting twice

Use the completed ESLint results to locate warnings in changed files. Rechecking alternate source versions still exhausted the runner, even in sequence.

Reset transient sheet state without a second render from an effect.
This commit is contained in:
Maurice
2026-12-04 09:59:06 +01:00
parent 814e4f047e
commit b06fa93c4a
5 changed files with 48 additions and 99 deletions
@@ -1,13 +1,12 @@
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { afterEach, describe, expect, it } from 'vitest';
import {
areaCounts,
changedWarnings,
check,
inlineConfigsOf,
lintClient,
newWarningsOf,
tally,
} from '../../../scripts/lib/eslint-warnings.mjs';
import { RatchetError } from '../../../scripts/lib/ratchet.mjs';
@@ -192,32 +191,15 @@ describe('lint:warnings', () => {
expect(byKey['b.js'].inlineConfigs).toEqual([]);
});
it('names the file and line behind a grown count, measured against the base, and nothing without one', async () => {
const root = mkdtempSync(join(tmpdir(), 'lint-new-'));
try {
mkdirSync(join(root, 'src'));
writeFileSync(join(root, 'src/new.ts'), 'two');
writeFileSync(join(root, 'src/old.ts'), 'one');
// new.ts held none of the rule on the base, old.ts already held its one
const git = (_root: string, args: string[]) =>
args[0] === 'diff' ? 'src/new.ts\nsrc/old.ts\n' : args[1]?.endsWith('old.ts') ? 'one' : 'none';
const counts: Record<string, number> = { two: 2, one: 1, none: 0 };
const lintText = async (text: string) => [
{
messages: Array.from({ length: counts[text] ?? 0 }, (_, i) => ({
ruleId: 'no-empty',
severity: 1,
message: `w${i}`,
line: i + 1,
})),
},
];
const keys = ['src/new.ts', 'src/old.ts', 'src/untouched.ts'];
const lines = await newWarningsOf({ root, rule: 'no-empty', area: 'src', keys, lintText, ref: 'base', git });
expect(lines).toEqual(['src/new.ts:1 w0', 'src/new.ts:2 w1']);
expect(await newWarningsOf({ root, rule: 'no-empty', area: 'src', keys, lintText, git: () => null })).toBeNull();
} finally {
rmSync(root, { recursive: true, force: true });
}
it('locates the selected rule in changed files using the completed lint pass', () => {
const root = join('/r');
const warning = { ...warn('no-empty', 'Empty block'), line: 5 };
const results = [
result(root, 'src/changed.ts', [warning, warn('no-console')]),
result(root, 'src/unchanged.ts', [warning]),
result(root, 'src/changed.test.ts', [warning]),
];
const changed = new Set(['src/changed.ts', 'src/changed.test.ts']);
expect(changedWarnings(results, root, changed, 'src', 'no-empty')).toEqual(['src/changed.ts:5 Empty block']);
});
});