mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(ci): repair mobile tests and lint diagnostics
Restore the saved-list filter import and test the actual sheet backdrop. Remove unsafe fixture assertions and apply formatting reported by CI. Reuse the current lint results and compare base files in sequence so warning diagnostics can finish without exhausting the heap.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"@typescript-eslint/no-explicit-any": 113,
|
||||
"trek/no-swallowed-catch": 124,
|
||||
"max-params": 31,
|
||||
"trek/store-without-selector": 65,
|
||||
"trek/store-without-selector": 64,
|
||||
"react-hooks/refs": 380,
|
||||
"react-hooks/set-state-in-effect": 188,
|
||||
"@typescript-eslint/no-floating-promises": 156,
|
||||
|
||||
@@ -172,48 +172,49 @@ function ofRule(results, rule, area) {
|
||||
* this names the file that tipped it. Null when `ref` is not at hand (a clone
|
||||
* without it), and the report then keeps to the files holding the most.
|
||||
*/
|
||||
export async function newWarningsOf({ root, rule, area, keys, lintText, ref = baseRef(), git = gitIn }) {
|
||||
export async function newWarningsOf({ root, rule, area, keys, lintText, current = null, ref = baseRef(), git = gitIn }) {
|
||||
const changed = git(root, ['diff', '--name-only', '--relative', ref, '--', '.']);
|
||||
if (changed === null) return null;
|
||||
const differs = new Set(changed.split('\n').filter(Boolean));
|
||||
const found = await Promise.all(
|
||||
keys
|
||||
.filter((key) => differs.has(key))
|
||||
.map(async (key) => {
|
||||
const path = join(root, key);
|
||||
// A typed rule can trip over a text that is not the file on disk (the
|
||||
// base version); then the file's own warnings are told, marked so.
|
||||
const lint = async (text) => {
|
||||
try {
|
||||
return { messages: ofRule(await lintText(text, path), rule, area) };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const now = await lint(readText(path));
|
||||
if (!now) return [];
|
||||
const before = git(root, ['show', `${ref}:./${key}`]);
|
||||
const was = before === null ? { messages: [] } : await lint(before);
|
||||
if (was && now.messages.length <= was.messages.length) return [];
|
||||
const note = was ? '' : ' (the base version could not be linted)';
|
||||
return now.messages.map((m) => `${key}:${m.line ?? 0} ${m.message}${note}`);
|
||||
})
|
||||
);
|
||||
return found.flat();
|
||||
const found = [];
|
||||
// Run typed linting for base versions in sequence. Linting many alternate
|
||||
// versions in parallel can exhaust the CI runner's heap.
|
||||
for (const key of keys.filter((key) => differs.has(key))) {
|
||||
const path = join(root, key);
|
||||
const lint = async (text) => {
|
||||
try {
|
||||
return ofRule(await lintText(text, path), rule, area);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const now = current ? ofRule([current.get(key)], rule, area) : await lint(readText(path));
|
||||
if (!now?.length) continue;
|
||||
const before = git(root, ['show', `${ref}:./${key}`]);
|
||||
const was = before === null ? [] : await lint(before);
|
||||
if (was && now.length <= was.length) continue;
|
||||
const note = was ? '' : ' (the base version could not be linted)';
|
||||
for (const message of now) found.push(`${key}:${message.line ?? 0} ${message.message}${note}`);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Prints, under the grown counts, the files and lines behind each one (see newWarningsOf). */
|
||||
async function reportNew(grown, { root, files, lintText, error }) {
|
||||
async function reportNew(grown, { root, files, lintText, error, results }) {
|
||||
if (!grown.length || !lintText) return;
|
||||
const found = await Promise.all(
|
||||
grown.map(({ area, rule }) => newWarningsOf({ root, rule, area, keys: Object.keys(files[area][rule]), lintText }))
|
||||
);
|
||||
grown.forEach(({ area, rule }, i) => {
|
||||
const lines = found[i];
|
||||
if (!lines?.length) return;
|
||||
const current = new Map(results.map((result) => [toKey(root, result.filePath), result]));
|
||||
const previous = new Map();
|
||||
const lintOnce = (text, path) => {
|
||||
if (!previous.has(path)) previous.set(path, lintText(text, path));
|
||||
return previous.get(path);
|
||||
};
|
||||
for (const { area, rule } of grown) {
|
||||
const keys = Object.keys(files[area][rule]);
|
||||
const lines = await newWarningsOf({ root, rule, area, keys, lintText: lintOnce, current });
|
||||
if (!lines?.length) continue;
|
||||
error(`New ${rule} warning(s) in ${area}, against ${baseRef()}:`);
|
||||
for (const line of lines) error(` ${line}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Lints one file's text with the client's own config, for newWarningsOf. */
|
||||
@@ -238,7 +239,8 @@ export async function check({
|
||||
error = console.error,
|
||||
}) {
|
||||
let baseline = readBaseline(baselinePath, areaCounts);
|
||||
const { counts, files, errors } = tally(await lint(root), root);
|
||||
const results = await lint(root);
|
||||
const { counts, files, errors } = tally(results, root);
|
||||
|
||||
if (update) {
|
||||
baseline = Object.fromEntries(AREAS.map((area) => [area, lowerCounts(baseline[area], counts[area])]));
|
||||
@@ -268,7 +270,7 @@ export async function check({
|
||||
});
|
||||
stale += fallen.length;
|
||||
}
|
||||
await reportNew(grown, { root, files, lintText: lintText && lintText(root), error });
|
||||
await reportNew(grown, { root, files, lintText: lintText && lintText(root), error, results });
|
||||
if (grown.length) {
|
||||
error(
|
||||
'Fix the new warning rather than silencing it: an eslint-disable comment is counted under "suppressed". ' +
|
||||
|
||||
Reference in New Issue
Block a user