Add ESLint rule to enforce Lingui msg usage (#9789)

* Add ESLint rule to enforce Lingui msg usage

Adds a custom ESLint rule 'lingui-msg-rule' that ensures the Lingui _()
function is called with msg`` template literals or plural/select macros,
preventing accidental misuse like _('string') which bypasses i18n.

https://claude.ai/code/session_01JMXXPUgAHiSBGmfGwUojKy

* Support msg({...}) descriptor form and add auto-fix

- Allow msg() function call form: _(msg({message: 'Hello'}))
- Add auto-fix for string literals: _('Bad') -> _(msg`Bad`)
- Add auto-fix for untagged templates: _(`Bad`) -> _(msg`Bad`)
- No auto-fix for variables/function calls (not safely fixable)

https://claude.ai/code/session_01JMXXPUgAHiSBGmfGwUojKy

* fix complex cases

* run autofix HELL YEAH

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-01-29 21:05:49 +02:00
committed by GitHub
parent 31553f0d40
commit 2cee96da8e
11 changed files with 331 additions and 23 deletions
@@ -312,13 +312,13 @@ export function Controls({
onPointerEnter={onPointerMoveEmptySpace}
onPointerMove={onPointerMoveEmptySpace}
onPointerLeave={onPointerLeaveEmptySpace}
accessibilityLabel={_(
accessibilityLabel={
!focused
? msg`Unmute video`
? _(msg`Unmute video`)
: playing
? msg`Pause video`
: msg`Play video`,
)}
? _(msg`Pause video`)
: _(msg`Play video`)
}
accessibilityHint=""
style={[
a.flex_1,
@@ -101,7 +101,7 @@ export function ProfileStarterPacks({
message={
emptyStateMessage ??
_(
'Starter packs let you share your favorite feeds and people with your friends.',
msg`Starter packs let you share your favorite feeds and people with your friends.`,
)
}
button={emptyStateButton}
+6 -4
View File
@@ -40,11 +40,13 @@ export function LeaveConvoPrompt({
<Prompt.Basic
control={control}
title={_(msg`Leave conversation`)}
description={_(
description={
hasMessages
? msg`Are you sure you want to leave this conversation? Your messages will be deleted for you, but not for the other participant.`
: msg`Are you sure you want to leave this conversation?`,
)}
? _(
msg`Are you sure you want to leave this conversation? Your messages will be deleted for you, but not for the other participant.`,
)
: _(msg`Are you sure you want to leave this conversation?`)
}
confirmButtonCta={_(msg`Leave`)}
confirmButtonColor="negative"
onConfirm={() => leaveConvo()}