Skip to content

ci(lint): declare getNodeFreshness as a readonly browser global - #62

Merged
dborup merged 1 commit into
masterfrom
codex/fix-eslint-getnodefreshness-global
Sep 17, 2026
Merged

dborup merged 1 commit into
masterfrom
codex/fix-eslint-getnodefreshness-global

Conversation

@dborup

@dborup dborup commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Problem

The "🧹 Frontend lint (eslint no-undef)" CI step (npx eslint public/*.js, eslint 8.57.1) fails on master e17377d8 with two errors:

public/live.js   3191:45  error  'getNodeFreshness' is not defined  no-undef
public/nodes.js   251:9   error  'getNodeFreshness' is not defined  no-undef
✖ 91 problems (2 errors, 89 warnings)

They were introduced with relay-aware node staleness (06cd0b73, 6edb1820, 2026-08-06) but stayed hidden because the CI job always stopped at an earlier step; the first run to reach lint was the CI integration draft #61.

Cause: missing lint declaration, not a runtime error

  • public/roles.js:528 assigns window.getNodeFreshness = function (…) directly in the file's top-level IIFE (not in a callback), so it exists as soon as roles.js has executed. Loading roles.js alone in a VM confirms it is a function immediately after load.
  • public/index.html loads roles.js synchronously first (line 177), before nodes.js (216) and live.js (224); none of them use defer/async/type="module", and index.html is the only page loading live.js/nodes.js.
  • Both call sites are additionally guarded: window.getNodeFreshness ? getNodeFreshness(…) : null.

ESLint only reports it because the bare call getNodeFreshness(…) refers to a browser global that is not listed in .eslintrc.json, unlike the neighbouring getNodeStatus / getHealthThresholds helpers.

Change

.eslintrc.json only (+1): add "getNodeFreshness": "readonly" to globals, alphabetically between getHealthThresholds and getNodeStatus, following the file's existing convention. No change to no-undef or any other rule, workflows, or runtime code.

Verification (local, eslint 8.57.1 — the version the CI step installed — in an isolated scratch directory, workflow command eslint public/*.js)

  • Baseline master: ✖ 91 problems (2 errors, 89 warnings) — identical to CI, including the two errors above.
  • This branch: exit 0, ✖ 89 problems (0 errors, 89 warnings); the 89 warning lines are identical to baseline (pre-existing no-unused-vars warnings, not addressed here).
  • Mutation in a scratch copy: renaming the live.js call to getNodeFreshnessTypo fails again with 'getNodeFreshnessTypo' is not defined (no-undef), so real undefined references are still caught.
  • .eslintrc.json parses as JSON; git diff --check clean.

Relation to other PRs

Independent of #56, #59 and #60. It is being added to the CI integration draft #61 ("CI integration only — do not merge") so the combined run can get past the lint step. GitHub CI for this PR on its own will still stop earlier (the Kpa-clawbot#1648 M4 scan is fixed by #56) and may hit the known flaky ingestor watchdog test.

🤖 Generated with Claude Code

roles.js defines window.getNodeFreshness at load time and index.html loads
it before nodes.js and live.js, which call it as a bare global. ESLint's
no-undef flagged both calls because the global was missing from
.eslintrc.json, failing the frontend lint step.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dborup
dborup merged commit 254e9cc into master Sep 17, 2026
5 of 6 checks passed
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.

1 participant