gui tests: a comment line doesn't say a plugin's words (#5332, #5327, #5426, #5482)

i18n-keys' "a plugin's words are its own" has been red on main since
73c98ebc2 and was filed four times with no owner. Each red was a Go
comment citing a word from the window: search_row_archive_test.go's
"(View routing, the …", trace.go's '"No session ID")' and
skills_shared_copy_test.go's "Use the library's sets …". A comment says
nothing to the window, so whole-line // comments in .go and .js are left
out of the scan. Words in code are still found.

Run on mote at this tree (on origin/main c9a1c557d):
- node --test i18n-keys.test.cjs: 4 pass, 0 fail (was 1 fail on
  e3f1efdaa, the same three words).
Broken by hand: a code line t("View routing") in app.js turns it red
("plugins/usage/i18n.js "View routing": internal/gui/assets/app.js says
it too").
This commit is contained in:
yetone
2026-11-09 20:14:03 +08:00
parent c9a1c557d0
commit 331f4a1393
+8 -1
View File
@@ -46,7 +46,14 @@ test("a plugin's words are its own", () => {
const p = path.join(d, e.name);
if (e.isDirectory()) {
if (!["node_modules", ".git", "site", "tests", "testdata", "docs"].includes(e.name)) walk(p);
} else if (/\.(go|js|html|css)$/.test(e.name) && e.name !== "i18n.js") texts.push([p, fs.readFileSync(p, "utf8")]);
} else if (/\.(go|js|html|css)$/.test(e.name) && e.name !== "i18n.js") {
let text = fs.readFileSync(p, "utf8");
// a comment line says nothing to the window: Go's "(View routing,
// the …" and "Use the library's sets …" cite a plugin's words
// (#5332, #5327, #5426, #5482)
if (/\.(go|js)$/.test(e.name)) text = text.split("\n").filter((l) => !/^\s*\/\//.test(l)).join("\n");
texts.push([p, text]);
}
}
};
walk(repo);