[frontend] Duplicated utility functions (esc, el) across 5+ files instead of shared imports #792

Closed
opened 2026-06-03 00:40:24 +02:00 by sleepy · 0 comments
Owner

Finding

Per AGENTS.md: "Writing new helpers without searching for existing ones first" is prohibited. Yet multiple files re-declare the same utility functions locally instead of importing the canonical version from ui.js:

esc() (HTML escape):

  • ui.js:738 — canonical export
  • settings.js:14 — redeclares as wrapper
  • admin.js:17 — redeclares as wrapper
  • usage.js:51 — redeclares independently (different implementation!)
  • skills.js:17 — redeclares as wrapper

el() (getElementById shorthand):

  • ui.js:564 — canonical export
  • settings.js:13 — redeclares locally
  • admin.js:16 — redeclares locally
  • search-chat.js:11 — redeclares locally

Impact

  • usage.js has a different esc() implementation — if it differs from ui.js.esc(), some code paths escape differently than others
  • Duplicated wrappers add maintenance burden and risk of divergence
  • Violates AGENTS.md rule against creating new helpers when existing ones exist

Recommendation

Replace all local esc() and el() declarations with import { esc, el } from './ui.js' or use the existing module references.

## Finding Per AGENTS.md: _"Writing new helpers without searching for existing ones first"_ is prohibited. Yet multiple files re-declare the same utility functions locally instead of importing the canonical version from `ui.js`: **`esc()` (HTML escape):** - `ui.js:738` — canonical export - `settings.js:14` — redeclares as wrapper - `admin.js:17` — redeclares as wrapper - `usage.js:51` — redeclares independently (different implementation!) - `skills.js:17` — redeclares as wrapper **`el()` (getElementById shorthand):** - `ui.js:564` — canonical export - `settings.js:13` — redeclares locally - `admin.js:16` — redeclares locally - `search-chat.js:11` — redeclares locally ## Impact - `usage.js` has a different `esc()` implementation — if it differs from `ui.js.esc()`, some code paths escape differently than others - Duplicated wrappers add maintenance burden and risk of divergence - Violates AGENTS.md rule against creating new helpers when existing ones exist ## Recommendation Replace all local `esc()` and `el()` declarations with `import { esc, el } from './ui.js'` or use the existing module references.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/odysseus#792
No description provided.