[PR #5178] [CLOSED] chore: add i18n string literal ESLint rule to frontend #5338

Closed
opened 2026-06-05 15:21:01 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5178
Author: @angelplusultra
Created: 3/9/2026
Status: Closed

Base: masterHead: i18n-eslint


📝 Commits (3)

  • 617fbb1 add i18n eslint plugin
  • 552aad2 fix dyamic key lint errors
  • 1a0e838 Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into i18n-eslint

📊 Changes

6 files changed (+44 additions, -20 deletions)

View changed files

📝 frontend/eslint.config.js (+4 -1)
📝 frontend/package.json (+1 -0)
📝 frontend/src/components/CommunityHub/PublishEntityModal/SystemPrompts/index.jsx (+1 -1)
📝 frontend/src/components/KeyboardShortcutsHelp/index.jsx (+5 -5)
📝 frontend/src/utils/keyboardShortcuts.js (+21 -13)
📝 frontend/yarn.lock (+12 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5178 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 3/9/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `i18n-eslint` --- ### 📝 Commits (3) - [`617fbb1`](https://github.com/Mintplex-Labs/anything-llm/commit/617fbb156be5229fc0bbeda9097862cbe0fed607) add i18n eslint plugin - [`552aad2`](https://github.com/Mintplex-Labs/anything-llm/commit/552aad275b6f1523b0f886038c519cac21b914d2) fix dyamic key lint errors - [`1a0e838`](https://github.com/Mintplex-Labs/anything-llm/commit/1a0e838e51935e6e940765ec3fd59c6f2669820d) Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into i18n-eslint ### 📊 Changes **6 files changed** (+44 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `frontend/eslint.config.js` (+4 -1) 📝 `frontend/package.json` (+1 -0) 📝 `frontend/src/components/CommunityHub/PublishEntityModal/SystemPrompts/index.jsx` (+1 -1) 📝 `frontend/src/components/KeyboardShortcutsHelp/index.jsx` (+5 -5) 📝 `frontend/src/utils/keyboardShortcuts.js` (+21 -13) 📝 `frontend/yarn.lock` (+12 -0) </details> ### 📄 Description ### Pull Request Type - [ ] ✨ feat (New feature) - [ ] 🐛 fix (Bug fix) - [ ] ♻️ refactor (Code refactoring without changing behavior) - [ ] 💄 style (UI style changes) - [x] 🔨 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 - [x] I ran `yarn lint` from the root of the repo & committed changes - [ ] Relevant documentation has been updated (if applicable) - [x] I have tested my code functionality - [ ] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:01 -04:00
yindo closed this issue 2026-06-05 15:21:01 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5338