From cb092f23337a8af4e465c5315ca2ecf91edb19a1 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 4 Nov 2026 19:32:34 -0800 Subject: [PATCH] Fix the Probes page failing to load; add a JS syntax check An apostrophe in "aren't" ended a single-quoted string in views/probes.js, so the module failed to parse ("missing ) after argument list") and the Probes page couldn't load. Use the typographic apostrophe like the rest of the UI copy. scripts/check-js.sh parses every frontend module as an ES module (node in a container if the host has none). Plain node --check on a .js file accepted the broken file. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 1 + app/static/js/views/probes.js | 2 +- scripts/check-js.sh | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 scripts/check-js.sh diff --git a/CLAUDE.md b/CLAUDE.md index 887b413..1ac43d3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -89,6 +89,7 @@ tests/ pytest: hub API, health maths, fake AdGuard, probe checks - no `"${arr[@]}"` on possibly-empty arrays under `set -u` - don't `source <(...)` - check with `docker run --rm -v "$PWD":/src:ro bash:3.2 bash -n /src/install.sh` +- **After any frontend change, run `bash scripts/check-js.sh`.** It parses every module as an ES module, the way browsers load them. Plain `node --check file.js` missed a broken string once, and the Probes page failed to load. In UI copy, write apostrophes as ’ so a `'` can't end a single-quoted string. - **No build step.** Plain ES modules and CSS. Vendor any library into `app/static/vendor/` with its version noted. - **Frontend style.** Follow the house style: toolbar → content → status bar per screen, house classes/tokens, sentence-case copy. Put user and API strings into the DOM with `textContent` only (`el()` does this). Never `replaceChildren(null)`; use `fill()` from `common.js`. - **Startup work goes in `lifespan`, never at import.** `update` imports `app.main` as a pre-flight check. diff --git a/app/static/js/views/probes.js b/app/static/js/views/probes.js index be399b1..f8c09da 100644 --- a/app/static/js/views/probes.js +++ b/app/static/js/views/probes.js @@ -90,7 +90,7 @@ function list(root, ctx) { function showInstall(p) { const cmd = installCommand(info, p.token); const dlg = modal(`Install “${p.name}”`, el('div', { style: 'display:grid;gap:12px' }, - el('p', { style: 'margin:0' }, 'Run this on the machine that will be the probe. It starts on boot and keeps running. On a Proxmox node it creates a small LXC container for the probe. On macOS and inside LXC containers it installs as a system service. On other Linux hosts it uses Docker. On Linux it needs root: if you aren't root, put sudo env before HUB_URL. If the git repo is private, the installer asks for a read-only token.'), + el('p', { style: 'margin:0' }, 'Run this on the machine that will be the probe. It starts on boot and keeps running. On a Proxmox node it creates a small LXC container for the probe. On macOS and inside LXC containers it installs as a system service. On other Linux hosts it uses Docker. On Linux it needs root: if you aren’t root, put sudo env before HUB_URL. If the git repo is private, the installer asks for a read-only token.'), commandBlock(cmd), el('p.small.muted', { style: 'margin:0' }, `The probe reports to ${info.hub_url || location.origin}. If that address isn't reachable from the probe, change HUB_URL in the command. The command is also on the probe's page.`), ), { wide: true, footer: [el('a.btn', { href: `/probes/${p.id}`, onclick: () => dlg.close() }, 'Open probe'), el('button.btn.primary', { type: 'button', onclick: () => dlg.close() }, 'Done')] }); diff --git a/scripts/check-js.sh b/scripts/check-js.sh new file mode 100755 index 0000000..3ff8a17 --- /dev/null +++ b/scripts/check-js.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Syntax-check every frontend module as an ES module, the way browsers load them. +# (A plain `node --check file.js` can miss errors: it may not parse the file as a module.) +# Runs node in a container when the host has none. Exit 1 on the first broken file. +set -euo pipefail +cd "$(dirname "$0")/.." +check() { + local tmp f fail=0 + tmp=$(mktemp -d) + for f in $(find app/static/js -name '*.js' | sort); do + cp "$f" "$tmp/check.mjs" + if ! node --check "$tmp/check.mjs" 2>"$tmp/err"; then echo "SYNTAX ERROR in $f:"; sed -n '1,6p' "$tmp/err"; fail=1; fi + done + rm -rf "$tmp" + [ "$fail" = 0 ] && echo "js: all modules parse" + return "$fail" +} +if command -v node >/dev/null 2>&1; then check +else docker run --rm -v "$PWD":/src:ro -w /src node:22-slim bash scripts/check-js.sh; fi