Project

General

Profile

Actions

Feature #39515

open

Add ESLint rule for i18n string wrapping in JSX

Added by Lucy Fu about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Add a custom ESLint rule to automatically flag unwrapped string literals in JSX that should be wrapped with translation functions.

Motivation

Currently part of PR review standard R6 (all strings extracted for translation) is checked manually for JavaScript/JSX code. The Ruby portion can't be linted (ERB templates), but JSX string literals can be caught by ESLint.

This will:
  • Catch i18n violations at lint time in CI
  • Provide immediate feedback to contributors
  • Free up reviewers to focus on logic and architecture
  • Ensure consistent i18n coverage across the codebase

Implementation

Add a new rule in script/lint/@theforeman/eslint-plugin-rules/ that:
  • Detects string literals in JSX elements
  • Flags them if not wrapped in translation functions (e.g., __(), _(), etc.)
  • Follows the existing pattern of require-ouiaid.js

Example

Bad:

<Button>Click me</Button>
<Alert title="Error">Something went wrong</Alert>

Good:

<Button>{__('Click me')}</Button>
<Alert title={__('Error')}>{__('Something went wrong')}</Alert>

Related Issues

Part of PR review automation effort. See AI Review Skill Analysis for background.

Acceptance Criteria

  • ESLint rule implemented in script/lint/@theforeman/eslint-plugin-rules/
  • Rule registered in index.js
  • Rule enabled in .eslintrc
  • Tests added for the rule

No data to display

Actions

Also available in: Atom PDF