Fix more JS linting issues (#2212)

* Fix uses of intl.formatMessages without default messages

* Ignore lint issue for ColumnLink button
This commit is contained in:
Claire 2023-05-08 15:16:55 +02:00 committed by GitHub
parent 16c5354b8c
commit 5d18840ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -24,6 +24,10 @@ const messages = defineMessages({
id: 'compose_form.publish_loud', id: 'compose_form.publish_loud',
}, },
saveChanges: { id: 'compose_form.save_changes', defaultMessage: 'Save changes' }, saveChanges: { id: 'compose_form.save_changes', defaultMessage: 'Save changes' },
public: { id: 'privacy.public.short', defaultMessage: 'Public' },
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
direct: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
}); });
class Publisher extends ImmutablePureComponent { class Publisher extends ImmutablePureComponent {
@ -68,6 +72,13 @@ class Publisher extends ImmutablePureComponent {
publishText = privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish); publishText = privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
} }
const privacyNames = {
public: messages.public,
unlisted: messages.unlisted,
private: messages.private,
direct: messages.direct,
};
return ( return (
<div className={computedClass}> <div className={computedClass}>
{sideArm && !isEditing && sideArm !== 'none' ? ( {sideArm && !isEditing && sideArm !== 'none' ? (
@ -78,7 +89,7 @@ class Publisher extends ImmutablePureComponent {
onClick={onSecondarySubmit} onClick={onSecondarySubmit}
style={{ padding: null }} style={{ padding: null }}
text={<Icon id={privacyIcons[sideArm]} />} text={<Icon id={privacyIcons[sideArm]} />}
title={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${sideArm}.short` })}`} title={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage(privacyNames[sideArm])}`}
/> />
</div> </div>
) : null} ) : null}
@ -86,7 +97,7 @@ class Publisher extends ImmutablePureComponent {
<Button <Button
className='primary' className='primary'
text={publishText} text={publishText}
title={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${privacy}.short` })}`} title={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage(privacyNames[privacy])}`}
onClick={this.handleSubmit} onClick={this.handleSubmit}
disabled={disabled} disabled={disabled}
/> />

View File

@ -29,6 +29,10 @@ const messages = defineMessages({
rewrite_mentions_username: { id: 'settings.rewrite_mentions_username', defaultMessage: 'Rewrite with username' }, rewrite_mentions_username: { id: 'settings.rewrite_mentions_username', defaultMessage: 'Rewrite with username' },
pop_in_left: { id: 'settings.pop_in_left', defaultMessage: 'Left' }, pop_in_left: { id: 'settings.pop_in_left', defaultMessage: 'Left' },
pop_in_right: { id: 'settings.pop_in_right', defaultMessage: 'Right' }, pop_in_right: { id: 'settings.pop_in_right', defaultMessage: 'Right' },
public: { id: 'privacy.public.short', defaultMessage: 'Public' },
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
direct: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
}); });
class LocalSettingsPage extends React.PureComponent { class LocalSettingsPage extends React.PureComponent {
@ -241,10 +245,10 @@ class LocalSettingsPage extends React.PureComponent {
id='mastodon-settings--side_arm' id='mastodon-settings--side_arm'
options={[ options={[
{ value: 'none', message: intl.formatMessage(messages.side_arm_none) }, { value: 'none', message: intl.formatMessage(messages.side_arm_none) },
{ value: 'direct', message: intl.formatMessage({ id: 'privacy.direct.short' }) }, { value: 'direct', message: intl.formatMessage(messages.direct) },
{ value: 'private', message: intl.formatMessage({ id: 'privacy.private.short' }) }, { value: 'private', message: intl.formatMessage(messages.private) },
{ value: 'unlisted', message: intl.formatMessage({ id: 'privacy.unlisted.short' }) }, { value: 'unlisted', message: intl.formatMessage(messages.unlisted) },
{ value: 'public', message: intl.formatMessage({ id: 'privacy.public.short' }) }, { value: 'public', message: intl.formatMessage(messages.public) },
]} ]}
onChange={onChange} onChange={onChange}
> >

View File

@ -32,6 +32,7 @@ const ColumnLink = ({ icon, text, to, onClick, href, method, badge, transparent,
return onClick(e); return onClick(e);
}; };
return ( return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid -- intentional to have the same look and feel as other menu items
<a href='#' onClick={onClick && handleOnClick} className={className} title={text} {...other} tabIndex={0}> <a href='#' onClick={onClick && handleOnClick} className={className} title={text} {...other} tabIndex={0}>
{iconElement} {iconElement}
<span>{text}</span> <span>{text}</span>