Fix i18n lint rule with emoji->emojify component

This commit is contained in:
Jamie Kyle 2023-06-14 17:57:04 -07:00 committed by GitHub
parent 35e07832a6
commit 5e8c22bf28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 21 deletions

View file

@ -33,10 +33,10 @@ function filterLegacyMessages(
return icuMessages;
}
export function renderEmoji(parts: ReadonlyArray<unknown>): JSX.Element {
strictAssert(parts.length === 1, '<emoji> must contain only one child');
export function renderEmojify(parts: ReadonlyArray<unknown>): JSX.Element {
strictAssert(parts.length === 1, '<emojify> must contain only one child');
const text = parts[0];
strictAssert(typeof text === 'string', '<emoji> must contain only text');
strictAssert(typeof text === 'string', '<emojify> must contain only text');
return <Emojify text={text} />;
}
@ -50,7 +50,7 @@ export function createCachedIntl(
locale: locale.replace('_', '-'), // normalize supported locales to browser format
messages: icuMessages,
defaultRichTextElements: {
emoji: renderEmoji,
emojify: renderEmojify,
},
},
intlCache