From 155c7a5f87fdb54ba989e628a595394cffde53d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20U=C5=9Bcinowicz?= Date: Sun, 22 Nov 2026 23:49:18 +0100 Subject: [PATCH 1/3] diff --git a/scripts/check-desktop-modules.mjs b/scripts/check-desktop-modules.mjs index ebd93d4..0c8b0ab 100755 --- a/scripts/check-desktop-modules.mjs +++ b/scripts/check-desktop-modules.mjs @@ -30,10 +30,20 @@ function escapeRegExp(text) { return text.replace(/[\\^$.*+?()[\]{}|\/-]/g, "\\$&"); } MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -/** Source without comments and string/regex contents (rough, line-preserving). */ +/** + * Source without comments and string/regex contents (rough, line-preserving). + * A regex literal is a `/…/` where an expression starts (after `(`, `,`, `=`, + * `:`, `[`, `!`, `&`, `|`, `?`, `{`, `}`, `;`, `return` or at the start of a + * line) – its `$`, `^` and words are no uses of names (`/^\d+$/` is no `$`). + * Regexes go before strings, so a quote inside a regex starts no string. + */ function code(text) { return text .replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")) + .replace( + /(^|[=(,:[!&|?{};]|\breturn)(\s*)\/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\n])*\]|[^/\\\n[])+\/[dgimsuyv]*/gm, + (m, pre, space) => pre + space + "/" + " ".repeat(Math.max(0, m.length - pre.length - space.length - 2)) + "/" + ) .replace(/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g, (m) => '""' + " ".repeat(Math.max(0, m.length - 2))) .replace(/\/\/[^\n]*/g, ""); } @@ -122,8 +132,9 @@ for (const [f, m] of Object.entries(mods)) { if (!o || o === f || m.imports.has(n) || local.has(n)) continue; // a shared module can only use shared names (a desktop name is a word in a regex or text) if (m.shared && !mods[o].shared) continue; - // an object key ({ name: … }) is not a use - if (new RegExp(`(^|[^.\\w$])${escapeRegExp(n)}(?!\\s*:)`, "m").test(m.body)) { + // the whole name (`el` is no use inside `else`); an object key + // ({ name: … }) is not a use + if (new RegExp(`(^|[^.\\w$])${escapeRegExp(n)}(?![\\w$])(?!\\s*:)`, "m").test(m.body)) { errors.push(`${f}: uses ${n} of ${o} without importing it`); } } --- scripts/check-desktop-modules.mjs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/check-desktop-modules.mjs b/scripts/check-desktop-modules.mjs index ebd93d41..0c8b0abb 100755 --- a/scripts/check-desktop-modules.mjs +++ b/scripts/check-desktop-modules.mjs @@ -30,10 +30,20 @@ function escapeRegExp(text) { return text.replace(/[\\^$.*+?()[\]{}|\/-]/g, "\\$&"); } -/** Source without comments and string/regex contents (rough, line-preserving). */ +/** + * Source without comments and string/regex contents (rough, line-preserving). + * A regex literal is a `/…/` where an expression starts (after `(`, `,`, `=`, + * `:`, `[`, `!`, `&`, `|`, `?`, `{`, `}`, `;`, `return` or at the start of a + * line) – its `$`, `^` and words are no uses of names (`/^\d+$/` is no `$`). + * Regexes go before strings, so a quote inside a regex starts no string. + */ function code(text) { return text .replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")) + .replace( + /(^|[=(,:[!&|?{};]|\breturn)(\s*)\/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\n])*\]|[^/\\\n[])+\/[dgimsuyv]*/gm, + (m, pre, space) => pre + space + "/" + " ".repeat(Math.max(0, m.length - pre.length - space.length - 2)) + "/" + ) .replace(/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g, (m) => '""' + " ".repeat(Math.max(0, m.length - 2))) .replace(/\/\/[^\n]*/g, ""); } @@ -122,8 +132,9 @@ for (const [f, m] of Object.entries(mods)) { if (!o || o === f || m.imports.has(n) || local.has(n)) continue; // a shared module can only use shared names (a desktop name is a word in a regex or text) if (m.shared && !mods[o].shared) continue; - // an object key ({ name: … }) is not a use - if (new RegExp(`(^|[^.\\w$])${escapeRegExp(n)}(?!\\s*:)`, "m").test(m.body)) { + // the whole name (`el` is no use inside `else`); an object key + // ({ name: … }) is not a use + if (new RegExp(`(^|[^.\\w$])${escapeRegExp(n)}(?![\\w$])(?!\\s*:)`, "m").test(m.body)) { errors.push(`${f}: uses ${n} of ${o} without importing it`); } } From f97a6fde14d0206e0977e7e3cee390c3a1665ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20U=C5=9Bcinowicz?= Date: Sun, 22 Nov 2026 23:49:26 +0100 Subject: [PATCH 2/3] Fix CI: desktop import check skips regexes and compares whole names scripts/check-desktop-modules.mjs failed the desktop UI job on main (c2a7f86) with false uses: the $ in regex literals like /^\d+$/ (bom-lines.js, checkin-bom.js, report-inputs.js) counted as a use of core.js's $, and the start of 'else' as a use of dom.js's new el. code() now blanks regex literals (before strings, line-preserving), and the final use test requires the whole name. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9655a4ad..78523ea7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ see the notices in the README. ### Fixed +- CI: the import check of the desktop modules (`scripts/check-desktop-modules.mjs`) + reported uses that are none – a `$` inside a regular expression (`/^\d+$/`) + as a use of `core.js`'s `$`, and the start of `else` as a use of + `shared/js/dom.js`'s `el` – and failed the *desktop UI* job. It now skips + regex contents and compares whole names. - Desktop: `desktop/ui/js/revision.js` started with three stray lines (a copy of its data block, left by a merge), so the file did not parse – the Revision tab could not load, and the *desktop UI* check failed on `main`. From d9061baaa37c8ecd9995c848a5b402c776a845cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20U=C5=9Bcinowicz?= Date: Sun, 22 Nov 2026 23:49:44 +0100 Subject: [PATCH 3/3] booger aids