Skip to content

Fix CI: desktop import check skips regexes and compares whole names - #464

Merged
WARR-eV merged 3 commits into
mainfrom
fix-desktop-module-check
Nov 22, 2026
Merged

WARR-eV merged 3 commits into
mainfrom
fix-desktop-module-check

Conversation

@rudalabs

Copy link
Copy Markdown
Collaborator

The desktop UI job on main (c2a7f86) now gets past the syntax check and fails in scripts/check-desktop-modules.mjs – with uses that are none:

  • bom-lines.js, checkin-bom.js, report-inputs.js: uses $ of core.js – the $ is inside regex literals (/^\d+$/). code() blanked comments and strings but not regexes, although its comment said so.
  • bom-lines.js: uses el of dom.js – the final test looked for the name without a word boundary after it, so the start of else matched (dom.js exports el since recently).

Fix in the check, not in the modules: code() blanks regex literals (a /…/ where an expression starts; before strings, so a quote in a regex starts no string; line-preserving), and the use test requires the whole name. CHANGELOG entry.

Not run locally (no Node here) – the ui job runs it; if a later step of that job still fails, it is the first time those steps run on main since the syntax error.

🤖 Generated with Claude Code

rudalabs and others added 3 commits November 22, 2026 23:49
…p-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, "\\$&");
 }

-/** 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 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 <noreply@anthropic.com>
@WARR-eV
WARR-eV merged commit 0c43165 into main Nov 22, 2026
8 of 9 checks passed
@WARR-eV
WARR-eV deleted the fix-desktop-module-check branch November 22, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants