From 7ddff4aec41560871d67a22c1c1701a7a08da369 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Mon, 7 Sep 2026 00:09:31 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=F0=9F=94=A7=EF=BC=9Ar?= =?UTF-8?q?efuse=20to=20pass=20a=20check=20that=20read=20no=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A tool handed no files does not fail. `prettier --check` with an empty argument list prints `No parser and no file path given` and exits 0. So a task whose glob stops matching -- a directory renamed, an extension changed, an exclusion widened past what it meant -- goes green for ever, having read nothing. Twenty-two of the twenty-four tasks that discover their own files were open to this. The two that were not, `verify.unit` and `verify.htmlValidForVNU`, each guard themselves and say why in a comment: a pattern matching nothing "would report success having run no tests". That reasoning was right and was never applied anywhere else, so it is a shared helper now. A project that genuinely has none of a kind should delete the task rather than leave it matching nothing. Deleting it is how a repository says so out loud, and this is what makes staying quiet impossible. Ported from OpenINF/.github#905, where it was found by claiming the opposite in a commit message and then checking. Signed-off-by: Derek Lewis Assisted-by: Claude-Code:claude-opus-5 --- build/tasks/format/format-dockerfile.mts | 6 +++-- build/tasks/format/format-js.mts | 6 +++-- build/tasks/format/format-json.mts | 14 +++++++---- build/tasks/format/format-liquid.mts | 6 +++-- build/tasks/format/format-md.mts | 12 +++++---- build/tasks/format/format-scss.mts | 12 +++++---- build/tasks/format/format-svg.mts | 6 +++-- build/tasks/format/format-toml.mts | 6 +++-- build/tasks/format/format-ts.mts | 6 +++-- build/tasks/format/format-yaml.mts | 6 +++-- build/tasks/verify/verify-dockerfile.mts | 6 +++-- build/tasks/verify/verify-filenames.mts | 6 ++++- build/tasks/verify/verify-js.mts | 6 +++-- build/tasks/verify/verify-json.mts | 14 +++++++---- build/tasks/verify/verify-liquid.mts | 6 +++-- build/tasks/verify/verify-md.mts | 14 ++++++----- build/tasks/verify/verify-scss.mts | 9 +++---- build/tasks/verify/verify-spelling.mts | 9 +++++-- build/tasks/verify/verify-svg.mts | 12 +++++---- build/tasks/verify/verify-toml.mts | 6 +++-- build/tasks/verify/verify-ts.mts | 6 +++-- build/tasks/verify/verify-yaml.mts | 6 +++-- build/utils.mts | 31 ++++++++++++++++++++++++ 23 files changed, 146 insertions(+), 65 deletions(-) diff --git a/build/tasks/format/format-dockerfile.mts b/build/tasks/format/format-dockerfile.mts index 13af0e929..0e34a0944 100644 --- a/build/tasks/format/format-dockerfile.mts +++ b/build/tasks/format/format-dockerfile.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-dockerfile */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const dockerfileFiles = await glob([ '.devcontainer/**/Dockerfile', @@ -14,7 +14,9 @@ const dockerfileFiles = await glob([ ]); let exitCode = 0; -const scripts = [`dprint fmt ${quote(dockerfileFiles)}`]; +const scripts = matched(dockerfileFiles, '.devcontainer/**/Dockerfile') + ? [`dprint fmt ${quote(dockerfileFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-js.mts b/build/tasks/format/format-js.mts index 5a0a44886..671ca6684 100644 --- a/build/tasks/format/format-js.mts +++ b/build/tasks/format/format-js.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-js */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const jsFiles = await glob([ '**/*.js', @@ -16,7 +16,9 @@ const jsFiles = await glob([ ]); let exitCode = 0; -const scripts = [`biome check --write ${quote(jsFiles)}`]; +const scripts = matched(jsFiles, '**/*.js, **/*.mjs') + ? [`biome check --write ${quote(jsFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-json.mts b/build/tasks/format/format-json.mts index b043d5128..f7b9d0407 100644 --- a/build/tasks/format/format-json.mts +++ b/build/tasks/format/format-json.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-json */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const EXCLUDED = ['!_site/', '!node_modules/']; @@ -17,10 +17,14 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]); const json5Files = await glob(['**/*.json5', ...EXCLUDED]); let exitCode = 0; -const scripts = [ - `biome check --write ${quote(jsonFiles)}`, - ...(json5Files.length > 0 ? [`prettier --write ${quote(json5Files)}`] : []), -]; +const scripts = matched(jsonFiles, '**/*.json, **/*.jsonc') + ? [ + `biome check --write ${quote(jsonFiles)}`, + ...(json5Files.length > 0 + ? [`prettier --write ${quote(json5Files)}`] + : []), + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-liquid.mts b/build/tasks/format/format-liquid.mts index 6a405b647..e6a971f62 100644 --- a/build/tasks/format/format-liquid.mts +++ b/build/tasks/format/format-liquid.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-liquid */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const LiquidFiles = await glob([ '**/*.html', @@ -15,7 +15,9 @@ const LiquidFiles = await glob([ ]); let exitCode = 0; -const scripts = [`prettier --write ${quote(LiquidFiles)}`]; +const scripts = matched(LiquidFiles, '**/*.html, **/*.liquid') + ? [`prettier --write ${quote(LiquidFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-md.mts b/build/tasks/format/format-md.mts index bc5bb21fb..80f0951d2 100644 --- a/build/tasks/format/format-md.mts +++ b/build/tasks/format/format-md.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-md */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const markdownFiles = await glob([ '**/*.md', @@ -23,10 +23,12 @@ const markdownFiles = await glob([ ]); let exitCode = 0; -const scripts = [ - `prettier --write ${quote(markdownFiles)}`, - `markdownlint-cli2 --fix ${quote(markdownFiles)}`, -]; +const scripts = matched(markdownFiles, '**/*.md') + ? [ + `prettier --write ${quote(markdownFiles)}`, + `markdownlint-cli2 --fix ${quote(markdownFiles)}`, + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-scss.mts b/build/tasks/format/format-scss.mts index d2e1ef011..06de357db 100644 --- a/build/tasks/format/format-scss.mts +++ b/build/tasks/format/format-scss.mts @@ -5,15 +5,17 @@ * @module {type ES6Module} build/tasks/format/format-scss */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const scssFiles = await glob(['**/*.scss', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [ - `prettier --write ${quote(scssFiles)}`, - `stylelint --fix ${quote(scssFiles)}`, -]; +const scripts = matched(scssFiles, '**/*.scss') + ? [ + `prettier --write ${quote(scssFiles)}`, + `stylelint --fix ${quote(scssFiles)}`, + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-svg.mts b/build/tasks/format/format-svg.mts index bde614b6d..a52cfecee 100644 --- a/build/tasks/format/format-svg.mts +++ b/build/tasks/format/format-svg.mts @@ -5,12 +5,14 @@ * @module {type ES6Module} build/tasks/format/format-svg */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const svgFiles = await glob(['**/*.svg', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [`prettier --write ${quote(svgFiles)}`]; +const scripts = matched(svgFiles, '**/*.svg') + ? [`prettier --write ${quote(svgFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-toml.mts b/build/tasks/format/format-toml.mts index 90bbba11b..8f8f5dfaa 100644 --- a/build/tasks/format/format-toml.mts +++ b/build/tasks/format/format-toml.mts @@ -5,12 +5,14 @@ * @module {type ES6Module} build/tasks/format/format-toml */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const tomlFiles = await glob(['**/*.toml', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [`dprint fmt ${quote(tomlFiles)}`]; +const scripts = matched(tomlFiles, '**/*.toml') + ? [`dprint fmt ${quote(tomlFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-ts.mts b/build/tasks/format/format-ts.mts index 4acd1f74b..fa75fadb7 100644 --- a/build/tasks/format/format-ts.mts +++ b/build/tasks/format/format-ts.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-ts */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const tsFiles = await glob([ '**/*.ts', @@ -15,7 +15,9 @@ const tsFiles = await glob([ ]); let exitCode = 0; -const scripts = [`biome check --write ${quote(tsFiles)}`]; +const scripts = matched(tsFiles, '**/*.ts, **/*.mts') + ? [`biome check --write ${quote(tsFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/format/format-yaml.mts b/build/tasks/format/format-yaml.mts index 088e8b301..ca20dee19 100644 --- a/build/tasks/format/format-yaml.mts +++ b/build/tasks/format/format-yaml.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/format/format-yaml */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const yamlFiles = await glob([ '**/*.yml', @@ -15,7 +15,9 @@ const yamlFiles = await glob([ ]); let exitCode = 0; -const scripts = [`prettier --write ${quote(yamlFiles)}`]; +const scripts = matched(yamlFiles, '**/*.yml, **/*.yaml') + ? [`prettier --write ${quote(yamlFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-dockerfile.mts b/build/tasks/verify/verify-dockerfile.mts index d5e689b36..0f3baf160 100644 --- a/build/tasks/verify/verify-dockerfile.mts +++ b/build/tasks/verify/verify-dockerfile.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-dockerfile */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const dockerfileFiles = await glob([ '.devcontainer/**/Dockerfile', @@ -14,7 +14,9 @@ const dockerfileFiles = await glob([ ]); let exitCode = 0; -const scripts = [`dprint check ${quote(dockerfileFiles)}`]; +const scripts = matched(dockerfileFiles, '.devcontainer/**/Dockerfile') + ? [`dprint check ${quote(dockerfileFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-filenames.mts b/build/tasks/verify/verify-filenames.mts index 8630e35e7..b69dc0211 100644 --- a/build/tasks/verify/verify-filenames.mts +++ b/build/tasks/verify/verify-filenames.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-filenames */ -import { glob } from '@openinf/portal/build/utils'; +import { glob, matched } from '@openinf/portal/build/utils'; /** * Lowercase words joined by hyphens. A leading underscore is Eleventy's and @@ -33,6 +33,10 @@ const EXEMPT = new Set([ const files = await glob(['**/*', '!_site/', '!node_modules/']); +// This one hands nothing to a tool, but `glob` finding nothing would still +// leave it looping zero times and reporting success. +if (!matched(files, '**/*')) process.exit(1); + // A directory is only ever seen here as part of some file's path, and the // same directory is part of many, so each is judged once. const checked = new Set(); diff --git a/build/tasks/verify/verify-js.mts b/build/tasks/verify/verify-js.mts index 3ec594207..ae05ce59e 100644 --- a/build/tasks/verify/verify-js.mts +++ b/build/tasks/verify/verify-js.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-js */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const jsFiles = await glob([ '**/*.js', @@ -16,7 +16,9 @@ const jsFiles = await glob([ ]); let exitCode = 0; -const scripts = [`biome check ${quote(jsFiles)}`]; +const scripts = matched(jsFiles, '**/*.js, **/*.mjs') + ? [`biome check ${quote(jsFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-json.mts b/build/tasks/verify/verify-json.mts index dffb0f415..2d575fb79 100644 --- a/build/tasks/verify/verify-json.mts +++ b/build/tasks/verify/verify-json.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-json */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const EXCLUDED = ['!_site/', '!node_modules/']; @@ -17,10 +17,14 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]); const json5Files = await glob(['**/*.json5', ...EXCLUDED]); let exitCode = 0; -const scripts = [ - `biome check ${quote(jsonFiles)}`, - ...(json5Files.length > 0 ? [`prettier --check ${quote(json5Files)}`] : []), -]; +const scripts = matched(jsonFiles, '**/*.json, **/*.jsonc') + ? [ + `biome check ${quote(jsonFiles)}`, + ...(json5Files.length > 0 + ? [`prettier --check ${quote(json5Files)}`] + : []), + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-liquid.mts b/build/tasks/verify/verify-liquid.mts index cc67eeb23..3f79a2523 100644 --- a/build/tasks/verify/verify-liquid.mts +++ b/build/tasks/verify/verify-liquid.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-liquid */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const liquidFiles = await glob([ '**/*.html', @@ -15,7 +15,9 @@ const liquidFiles = await glob([ ]); let exitCode = 0; -const scripts = [`prettier --check ${quote(liquidFiles)}`]; +const scripts = matched(liquidFiles, '**/*.html, **/*.liquid') + ? [`prettier --check ${quote(liquidFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-md.mts b/build/tasks/verify/verify-md.mts index 5dd673a15..362e3ac72 100644 --- a/build/tasks/verify/verify-md.mts +++ b/build/tasks/verify/verify-md.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-md */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const markdownFiles = await glob([ '**/*.md', @@ -23,11 +23,13 @@ const markdownFiles = await glob([ ]); let exitCode = 0; -const scripts = [ - `prettier --check ${quote(markdownFiles)}`, - `markdownlint-cli2 ${quote(markdownFiles)}`, - `remark -f --silently-ignore ${quote(markdownFiles)}`, -]; +const scripts = matched(markdownFiles, '**/*.md') + ? [ + `prettier --check ${quote(markdownFiles)}`, + `markdownlint-cli2 ${quote(markdownFiles)}`, + `remark -f --silently-ignore ${quote(markdownFiles)}`, + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-scss.mts b/build/tasks/verify/verify-scss.mts index afabbf023..ce3a36e16 100644 --- a/build/tasks/verify/verify-scss.mts +++ b/build/tasks/verify/verify-scss.mts @@ -5,15 +5,14 @@ * @module {type ES6Module} build/tasks/verify/verify-scss */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const scssFiles = await glob(['**/*.scss', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [ - `prettier --check ${quote(scssFiles)}`, - `stylelint ${quote(scssFiles)}`, -]; +const scripts = matched(scssFiles, '**/*.scss') + ? [`prettier --check ${quote(scssFiles)}`, `stylelint ${quote(scssFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-spelling.mts b/build/tasks/verify/verify-spelling.mts index 7ef3ddbd9..1d510d0ef 100644 --- a/build/tasks/verify/verify-spelling.mts +++ b/build/tasks/verify/verify-spelling.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-spelling */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; // Comments and template prose are read as often as the documentation is, and // cspell's `en` dictionary is the American one, so this is also what holds the @@ -30,4 +30,9 @@ const files = await glob([ '!collections/_pages/vision.md', ]); -process.exitCode = await exec(`cspell lint ${quote(files)}`); +process.exitCode = matched( + files, + '**/*.{md,html,liquid,scss,mts,mjs,json,yml,yaml,sh}' +) + ? await exec(`cspell lint ${quote(files)}`) + : 1; diff --git a/build/tasks/verify/verify-svg.mts b/build/tasks/verify/verify-svg.mts index e89c31763..cf66c690b 100644 --- a/build/tasks/verify/verify-svg.mts +++ b/build/tasks/verify/verify-svg.mts @@ -5,16 +5,18 @@ * @module {type ES6Module} build/tasks/verify/verify-svg */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; import vnu from 'vnu-jar'; const svgFiles = await glob(['**/*.svg', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [ - `prettier --check ${quote(svgFiles)}`, - `java -jar ${quote(vnu)} --svg ${quote(svgFiles)}`, -]; +const scripts = matched(svgFiles, '**/*.svg') + ? [ + `prettier --check ${quote(svgFiles)}`, + `java -jar ${quote(vnu)} --svg ${quote(svgFiles)}`, + ] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-toml.mts b/build/tasks/verify/verify-toml.mts index 051625019..c8db8d471 100644 --- a/build/tasks/verify/verify-toml.mts +++ b/build/tasks/verify/verify-toml.mts @@ -5,12 +5,14 @@ * @module {type ES6Module} build/tasks/verify/verify-toml */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const tomlFiles = await glob(['**/*.toml', '!_site/', '!node_modules/']); let exitCode = 0; -const scripts = [`dprint check ${quote(tomlFiles)}`]; +const scripts = matched(tomlFiles, '**/*.toml') + ? [`dprint check ${quote(tomlFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-ts.mts b/build/tasks/verify/verify-ts.mts index 81d83e6b7..038356f86 100644 --- a/build/tasks/verify/verify-ts.mts +++ b/build/tasks/verify/verify-ts.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-ts */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const tsFiles = await glob([ '**/*.ts', @@ -18,7 +18,9 @@ let exitCode = 0; // tsc reads its file list from tsconfig.json rather than taking one, and // `erasableSyntaxOnly` there is what stops syntax node refuses to strip from // reaching a task script. -const scripts = [`biome check ${quote(tsFiles)}`, 'tsc --noEmit']; +const scripts = matched(tsFiles, '**/*.ts, **/*.mts') + ? [`biome check ${quote(tsFiles)}`, 'tsc --noEmit'] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-yaml.mts b/build/tasks/verify/verify-yaml.mts index 83662e5ce..2f766fa57 100644 --- a/build/tasks/verify/verify-yaml.mts +++ b/build/tasks/verify/verify-yaml.mts @@ -5,7 +5,7 @@ * @module {type ES6Module} build/tasks/verify/verify-yaml */ -import { exec, glob, quote } from '@openinf/portal/build/utils'; +import { exec, glob, matched, quote } from '@openinf/portal/build/utils'; const yamlFiles = await glob([ '**/*.yml', @@ -15,7 +15,9 @@ const yamlFiles = await glob([ ]); let exitCode = 0; -const scripts = [`prettier --check ${quote(yamlFiles)}`]; +const scripts = matched(yamlFiles, '**/*.yml, **/*.yaml') + ? [`prettier --check ${quote(yamlFiles)}`] + : []; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/utils.mts b/build/utils.mts index c8eb16233..043b89421 100644 --- a/build/utils.mts +++ b/build/utils.mts @@ -51,6 +51,37 @@ export const quote = (paths: string | string[]) => }) .join(' '); +/** + * Says whether a task has anything to work on, and objects when it has not. + * + * A tool handed no files does not fail. `prettier --check` with an empty + * argument list prints `No parser and no file path given` and exits 0; + * `node --test` given a pattern matching nothing exits 0 having run no tests. + * Either way the task reports success over nothing, which is the one answer a + * check must never give -- a glob that stopped matching, because a directory + * was renamed or an extension changed, would go green for ever. + * + * `verify.unit` has guarded itself this way from the start. This is the same + * guard, said once. + * + * A project that genuinely has none of a kind should delete the task rather + * than leave it matching nothing. Deleting it is how a repository says so out + * loud, and this is what makes staying quiet impossible. + * @param {string[]} files What the glob found. + * @param {string} what The patterns it looked for, named in the complaint. + * @returns {boolean} Whether there is anything to check. + */ +export function matched(files: string[], what: string) { + if (files.length > 0) return true; + + console.error( + `Nothing matched ${what}. A check that read no files has not passed; if this project has none, delete the task rather than let it report success over an empty list.` + ); + process.exitCode = 1; + + return false; +} + /** * Expands a trailing-slash directory pattern (e.g. `_site/`) to cover * everything beneath it. On its own, a trailing slash matches just the one From 6b3ab096f557b7b7d9f897987fc020a78c8db7ee Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Mon, 7 Sep 2026 03:56:45 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=F0=9F=94=A7=EF=BC=9Ag?= =?UTF-8?q?uard=20each=20list,=20not=20the=20pair?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review catch on the JSON tasks, and the same shape in verify.ts. `verify.json` and `format.json` read two lists and ran one guard over both. With `matched(jsonFiles, ...)` deciding whether either tool ran, a checkout where no plain JSON matched skipped JSON5 as well -- and skipped it by way of the guard added to stop exactly that kind of silence. Each list guards its own command now. The fix is not to widen the guard to cover both lists, which was the other way suggested. That makes a project with no plain JSON pass quietly, which is the outcome this whole change exists to refuse. Under the split, JSON5 is still checked when no JSON matched and the task still fails for the JSON that did not: both facts are reported, and neither hides the other. `verify.ts` had it too, in the other direction: `tsc --noEmit` was gated on a glob it does not read. tsc takes its file list from tsconfig.json, whose input set is wider than `**/*.ts, **/*.mts`, so gating it there would let a checkout of nothing this glob names go unchecked. Only Biome is handed the list; tsc runs either way. This is what OpenINF/.github landed in af2e821, whose message calls out the same trap; this branch had the pre-fix shape. Checked by simulating an empty JSON list: `.renovaterc.json5` is still handed to prettier, and the task still exits 1 for the JSON that matched nothing. Signed-off-by: Derek Lewis Assisted-by: Claude-Code:claude-opus-5 --- build/tasks/format/format-json.mts | 18 ++++++++++-------- build/tasks/verify/verify-json.mts | 18 ++++++++++-------- build/tasks/verify/verify-ts.mts | 12 +++++++++--- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/build/tasks/format/format-json.mts b/build/tasks/format/format-json.mts index f7b9d0407..c0d17632c 100644 --- a/build/tasks/format/format-json.mts +++ b/build/tasks/format/format-json.mts @@ -17,14 +17,16 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]); const json5Files = await glob(['**/*.json5', ...EXCLUDED]); let exitCode = 0; -const scripts = matched(jsonFiles, '**/*.json, **/*.jsonc') - ? [ - `biome check --write ${quote(jsonFiles)}`, - ...(json5Files.length > 0 - ? [`prettier --write ${quote(json5Files)}`] - : []), - ] - : []; +// Two lists, two tools, and a guard each: JSON5 going unformatted because no +// plain JSON matched would be the silence this guard exists to prevent. +const scripts = [ + ...(matched(jsonFiles, '**/*.json, **/*.jsonc') + ? [`biome check --write ${quote(jsonFiles)}`] + : []), + ...(matched(json5Files, '**/*.json5') + ? [`prettier --write ${quote(json5Files)}`] + : []), +]; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-json.mts b/build/tasks/verify/verify-json.mts index 2d575fb79..1c679c215 100644 --- a/build/tasks/verify/verify-json.mts +++ b/build/tasks/verify/verify-json.mts @@ -17,14 +17,16 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]); const json5Files = await glob(['**/*.json5', ...EXCLUDED]); let exitCode = 0; -const scripts = matched(jsonFiles, '**/*.json, **/*.jsonc') - ? [ - `biome check ${quote(jsonFiles)}`, - ...(json5Files.length > 0 - ? [`prettier --check ${quote(json5Files)}`] - : []), - ] - : []; +// Two lists, two tools, and a guard each: JSON5 going unchecked because no +// plain JSON matched would be the silence this guard exists to prevent. +const scripts = [ + ...(matched(jsonFiles, '**/*.json, **/*.jsonc') + ? [`biome check ${quote(jsonFiles)}`] + : []), + ...(matched(json5Files, '**/*.json5') + ? [`prettier --check ${quote(json5Files)}`] + : []), +]; for (const element of scripts) { exitCode = await exec(element); diff --git a/build/tasks/verify/verify-ts.mts b/build/tasks/verify/verify-ts.mts index 038356f86..5102410fc 100644 --- a/build/tasks/verify/verify-ts.mts +++ b/build/tasks/verify/verify-ts.mts @@ -18,9 +18,15 @@ let exitCode = 0; // tsc reads its file list from tsconfig.json rather than taking one, and // `erasableSyntaxOnly` there is what stops syntax node refuses to strip from // reaching a task script. -const scripts = matched(tsFiles, '**/*.ts, **/*.mts') - ? [`biome check ${quote(tsFiles)}`, 'tsc --noEmit'] - : []; +// Only Biome is handed the list. tsc reads its own from tsconfig.json, whose +// input set is wider than this glob, so gating it on this list would let a +// checkout of nothing this glob names go unchecked. +const scripts = [ + ...(matched(tsFiles, '**/*.ts, **/*.mts') + ? [`biome check ${quote(tsFiles)}`] + : []), + 'tsc --noEmit', +]; for (const element of scripts) { exitCode = await exec(element);