Make valid-i18n-keys rule strict and fix most exceptions
This commit is contained in:
parent
18a6da310f
commit
11cfcb4e32
36 changed files with 796 additions and 687 deletions
|
@ -71,24 +71,29 @@ export class Intl extends React.Component<Props> {
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public override render() {
|
||||
const { components, id, i18n, renderText = defaultRenderText } = this.props;
|
||||
const {
|
||||
components,
|
||||
id,
|
||||
// Indirection for linter/migration tooling
|
||||
i18n: localizer,
|
||||
renderText = defaultRenderText,
|
||||
} = this.props;
|
||||
|
||||
if (!id) {
|
||||
log.error('Error: Intl id prop not provided');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!i18n.isLegacyFormat(id)) {
|
||||
if (!localizer.isLegacyFormat(id)) {
|
||||
strictAssert(
|
||||
!Array.isArray(components),
|
||||
`components cannot be an array for ICU message ${id}`
|
||||
);
|
||||
const intl = i18n.getIntl();
|
||||
const intl = localizer.getIntl();
|
||||
return intl.formatMessage({ id }, components);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line local-rules/valid-i18n-keys
|
||||
const text = i18n(id);
|
||||
const text = localizer(id);
|
||||
const results: Array<
|
||||
string | JSX.Element | Array<string | JSX.Element> | null
|
||||
> = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue