Skip to content

chore: add i18n string literal ESLint rule to frontend#5178

Closed
angelplusultra wants to merge 3 commits intomasterfrom
i18n-eslint
Closed

chore: add i18n string literal ESLint rule to frontend#5178
angelplusultra wants to merge 3 commits intomasterfrom
i18n-eslint

Conversation

@angelplusultra
Copy link
Contributor

Pull Request Type

  • ✨ feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

resolves #

Description

Adds eslint-plugin-i18next-no-undefined-translation-keys to the frontend ESLint config with the translation-key-string-literal rule set to error. This enforces that all t() calls use plain string literals — no template literals or dynamic expressions — making translation keys statically analyzable and easier to search for across the codebase.

Fixed existing violations:

  • SystemPrompts/index.jsx — changed a template literal t(`community_hub...`) to a regular string literal t("community_hub...").
  • keyboardShortcuts.js — refactored the static SHORTCUTS object into a getShortcuts(t) function so translation keys are resolved via string literal t() calls rather than dynamic lookups like t(`keyboard-shortcuts.shortcuts.${shortcut.translationKey}`).
  • Updated KeyboardShortcutsHelp/index.jsx to use the new getShortcuts(t) API.

Visuals (if applicable)

N/A

Additional Information

This rule only enforces that t() arguments are string literals. It does not validate that translation keys actually exist in locale files.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

@angelplusultra angelplusultra marked this pull request as ready for review March 9, 2026 17:25
Copy link
Collaborator

@shatfield4 shatfield4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timothycarambat
Copy link
Member

timothycarambat commented Mar 9, 2026

How is this intended to function?

 <h2 className="text-xl font-semibold text-white">
            {t("keyboard-shortcuts.title")}
            {t("keyboard-shortcuts.this-key-does-not-work")}
          </h2>

Frontend eslint shows no errors?

Edit: Nvm I see this only checks that the input in t is a string literal. I dont see how this helps us a ton - the input of the t is already that via type hint. This does not help us a ton in preventing adding keys with DNE in the translations dictionaries

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.

3 participants