[Glitch] Run eslint --fix

I don't like it changing files this way, but it's basically what
c49213f0ea and a few others did.
This commit is contained in:
Claire
2023-02-03 20:52:07 +01:00
parent ed7cb79723
commit 155424e52f
233 changed files with 1262 additions and 1248 deletions

View File

@ -32,7 +32,7 @@ class ActionBar extends React.PureComponent {
handleLogout = () => {
this.props.onLogout();
}
};
render () {
const { intl } = this.props;

View File

@ -22,9 +22,9 @@ import { length } from 'stringz';
const messages = defineMessages({
placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' },
missingDescriptionMessage: { id: 'confirmations.missing_media_description.message',
defaultMessage: 'At least one media attachment is lacking a description. Consider describing all media attachments for the visually impaired before sending your toot.' },
defaultMessage: 'At least one media attachment is lacking a description. Consider describing all media attachments for the visually impaired before sending your toot.' },
missingDescriptionConfirm: { id: 'confirmations.missing_media_description.confirm',
defaultMessage: 'Send anyway' },
defaultMessage: 'Send anyway' },
spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' },
});
@ -83,22 +83,22 @@ class ComposeForm extends ImmutablePureComponent {
handleChange = (e) => {
this.props.onChange(e.target.value);
}
};
getFulltextForCharacterCounting = () => {
return [
this.props.spoiler? this.props.spoilerText: '',
countableText(this.props.text),
this.props.advancedOptions && this.props.advancedOptions.get('do_not_federate') ? ' 👁️' : ''
this.props.advancedOptions && this.props.advancedOptions.get('do_not_federate') ? ' 👁️' : '',
].join('');
}
};
canSubmit = () => {
const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props;
const fulltext = this.getFulltextForCharacterCounting();
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (!fulltext.trim().length && !anyMedia));
}
};
handleSubmit = (overriddenVisibility = null) => {
const {
@ -129,7 +129,7 @@ class ComposeForm extends ImmutablePureComponent {
}
onSubmit(this.context.router ? this.context.router.history : null);
}
}
};
// Changes the text value of the spoiler.
handleChangeSpoiler = ({ target: { value } }) => {
@ -137,7 +137,7 @@ class ComposeForm extends ImmutablePureComponent {
if (onChangeSpoilerText) {
onChangeSpoilerText(value);
}
}
};
setRef = c => {
this.composeForm = c;
@ -150,7 +150,7 @@ class ComposeForm extends ImmutablePureComponent {
if (onPickEmoji) {
onPickEmoji(selectionStart, data);
}
}
};
// Handles the secondary submit button.
handleSecondarySubmit = () => {
@ -158,16 +158,16 @@ class ComposeForm extends ImmutablePureComponent {
sideArm,
} = this.props;
this.handleSubmit(sideArm === 'none' ? null : sideArm);
}
};
// Selects a suggestion from the autofill.
onSuggestionSelected = (tokenStart, token, value) => {
this.props.onSuggestionSelected(tokenStart, token, value, ['text']);
}
};
onSpoilerSuggestionSelected = (tokenStart, token, value) => {
this.props.onSuggestionSelected(tokenStart, token, value, ['spoiler_text']);
}
};
handleKeyDown = (e) => {
if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
@ -177,21 +177,21 @@ class ComposeForm extends ImmutablePureComponent {
if (e.keyCode == 13 && e.altKey) {
this.handleSecondarySubmit();
}
}
};
// Sets a reference to the textarea.
setAutosuggestTextarea = (textareaComponent) => {
if (textareaComponent) {
this.textarea = textareaComponent.textarea;
}
}
};
// Sets a reference to the CW field.
handleRefSpoilerText = (spoilerComponent) => {
if (spoilerComponent) {
this.spoilerText = spoilerComponent.input;
}
}
};
handleFocus = () => {
if (this.composeForm && !this.props.singleColumn) {
@ -200,7 +200,7 @@ class ComposeForm extends ImmutablePureComponent {
this.composeForm.scrollIntoView();
}
}
}
};
componentDidMount () {
this._updateFocusAndSelection({ });
@ -217,7 +217,7 @@ class ComposeForm extends ImmutablePureComponent {
// - Replying to more than one user, selects any usernames past
// the first; this provides a convenient shortcut to drop
// everyone else from the conversation.
_updateFocusAndSelection = (prevProps) => {
_updateFocusAndSelection = (prevProps) => {
const {
textarea,
spoilerText,
@ -271,7 +271,7 @@ class ComposeForm extends ImmutablePureComponent {
}
}
}
}
};
render () {

View File

@ -64,7 +64,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
}
this.setState({ open: !this.state.open, openedViaKeyboard: type !== 'click' });
}
}
};
handleKeyDown = (e) => {
switch (e.key) {
@ -72,13 +72,13 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
this.handleClose();
break;
}
}
};
handleMouseDown = () => {
if (!this.state.open) {
this.activeElement = document.activeElement;
}
}
};
handleButtonKeyDown = (e) => {
switch(e.key) {
@ -87,7 +87,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
this.handleMouseDown();
break;
}
}
};
handleKeyPress = (e) => {
switch(e.key) {
@ -98,14 +98,14 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
e.preventDefault();
break;
}
}
};
handleClose = () => {
if (this.state.open && this.activeElement) {
this.activeElement.focus({ preventScroll: true });
}
this.setState({ open: false });
}
};
handleItemClick = (e) => {
const {
@ -151,22 +151,22 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
...rest,
active: value && name === value,
name,
})
}),
),
};
}
};
setTargetRef = c => {
this.target = c;
}
};
findTarget = () => {
return this.target;
}
};
handleOverlayEnter = (state) => {
this.setState({ placement: state.placement });
}
};
// Rendering.
render () {

View File

@ -44,12 +44,12 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
};
// Stores our node in `this.node`.
setRef = (node) => {
this.node = node;
}
};
// On mounting, we add our listeners.
componentDidMount () {
@ -84,7 +84,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
onClose();
}
onChange(name);
}
};
// Handle changes differently whether the dropdown is a list of options or actions
handleChange = (name) => {
@ -93,7 +93,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
} else {
this.setState({ value: name });
}
}
};
handleKeyDown = (e) => {
const index = Number(e.currentTarget.getAttribute('data-index'));
@ -135,11 +135,11 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
e.preventDefault();
e.stopPropagation();
}
}
};
setFocusRef = c => {
this.focusedItem = c;
}
};
renderItem = (item, i) => {
const { name, icon, meta, text } = item;
@ -177,7 +177,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
{contents}
</div>
);
}
};
// Rendering.
render () {

View File

@ -58,7 +58,7 @@ class ModifierPickerMenu extends React.PureComponent {
handleClick = e => {
this.props.onSelect(e.currentTarget.getAttribute('data-index') * 1);
}
};
componentWillReceiveProps (nextProps) {
if (nextProps.active) {
@ -76,7 +76,7 @@ class ModifierPickerMenu extends React.PureComponent {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
};
attachListeners () {
document.addEventListener('click', this.handleDocumentClick, false);
@ -90,7 +90,7 @@ class ModifierPickerMenu extends React.PureComponent {
setRef = c => {
this.node = c;
}
};
render () {
const { active } = this.props;
@ -125,12 +125,12 @@ class ModifierPicker extends React.PureComponent {
} else {
this.props.onOpen();
}
}
};
handleSelect = modifier => {
this.props.onChange(modifier);
this.props.onClose();
}
};
render () {
const { active, modifier } = this.props;
@ -175,7 +175,7 @@ class EmojiPickerMenu extends React.PureComponent {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
};
componentDidMount () {
document.addEventListener('click', this.handleDocumentClick, false);
@ -199,7 +199,7 @@ class EmojiPickerMenu extends React.PureComponent {
setRef = c => {
this.node = c;
}
};
getI18n = () => {
const { intl } = this.props;
@ -220,7 +220,7 @@ class EmojiPickerMenu extends React.PureComponent {
custom: intl.formatMessage(messages.custom),
},
};
}
};
handleClick = (emoji, event) => {
if (!emoji.native) {
@ -230,19 +230,19 @@ class EmojiPickerMenu extends React.PureComponent {
this.props.onClose();
}
this.props.onPick(emoji);
}
};
handleModifierOpen = () => {
this.setState({ modifierOpen: true });
}
};
handleModifierClose = () => {
this.setState({ modifierOpen: false });
}
};
handleModifierChange = modifier => {
this.props.onSkinTone(modifier);
}
};
render () {
const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
@ -327,7 +327,7 @@ class EmojiPickerDropdown extends React.PureComponent {
setRef = (c) => {
this.dropdown = c;
}
};
onShowDropdown = () => {
this.setState({ active: true });
@ -344,11 +344,11 @@ class EmojiPickerDropdown extends React.PureComponent {
this.setState({ loading: false, active: false });
});
}
}
};
onHideDropdown = () => {
this.setState({ active: false });
}
};
onToggle = (e) => {
if (!this.state.loading && (!e.key || e.key === 'Enter')) {
@ -358,21 +358,21 @@ class EmojiPickerDropdown extends React.PureComponent {
this.onShowDropdown(e);
}
}
}
};
handleKeyDown = e => {
if (e.key === 'Escape') {
this.onHideDropdown();
}
}
};
setTargetRef = c => {
this.target = c;
}
};
findTarget = () => {
return this.target;
}
};
render () {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, button } = this.props;

View File

@ -47,6 +47,7 @@ const messages = defineMessages({
export default @injectIntl
class Header extends ImmutablePureComponent {
static propTypes = {
columns: ImmutablePropTypes.list,
unreadNotifications: PropTypes.number,
@ -63,7 +64,7 @@ class Header extends ImmutablePureComponent {
this.props.onLogout();
return false;
}
};
render () {
const { intl, columns, unreadNotifications, showNotificationsBadge, onSettingsClick } = this.props;
@ -71,8 +72,8 @@ class Header extends ImmutablePureComponent {
// Only renders the component if the column isn't being shown.
const renderForColumn = conditionalRender.bind(null,
columnId => !columns || !columns.some(
column => column.get('id') === columnId
)
column => column.get('id') === columnId,
),
);
// The result.
@ -125,10 +126,11 @@ class Header extends ImmutablePureComponent {
<a
aria-label={intl.formatMessage(messages.logout)}
onClick={this.handleLogoutClick}
href={ signOutLink }
href={signOutLink}
title={intl.formatMessage(messages.logout)}
><Icon id='sign-out' /></a>
</nav>
);
};
}
}

View File

@ -40,7 +40,7 @@ class LanguageDropdownMenu extends React.PureComponent {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
};
componentDidMount () {
document.addEventListener('click', this.handleDocumentClick, false);
@ -63,15 +63,15 @@ class LanguageDropdownMenu extends React.PureComponent {
setRef = c => {
this.node = c;
}
};
setListRef = c => {
this.listNode = c;
}
};
handleSearchChange = ({ target }) => {
this.setState({ searchValue: target.value });
}
};
search () {
const { languages, value, frequentlyUsedLanguages } = this.props;
@ -122,7 +122,7 @@ class LanguageDropdownMenu extends React.PureComponent {
this.props.onClose();
this.props.onChange(value);
}
};
handleKeyDown = e => {
const { onClose } = this.props;
@ -163,7 +163,7 @@ class LanguageDropdownMenu extends React.PureComponent {
e.preventDefault();
e.stopPropagation();
}
}
};
handleSearchKeyDown = e => {
const { onChange, onClose } = this.props;
@ -199,11 +199,11 @@ class LanguageDropdownMenu extends React.PureComponent {
break;
}
}
};
handleClear = () => {
this.setState({ searchValue: '' });
}
};
renderItem = lang => {
const { value } = this.props;
@ -213,7 +213,7 @@ class LanguageDropdownMenu extends React.PureComponent {
<span className='language-dropdown__dropdown__results__item__native-name'>{lang[2]}</span> <span className='language-dropdown__dropdown__results__item__common-name'>({lang[1]})</span>
</div>
);
}
};
render () {
const { intl } = this.props;
@ -259,7 +259,7 @@ class LanguageDropdown extends React.PureComponent {
}
this.setState({ open: !this.state.open });
}
};
handleClose = () => {
const { value, onClose } = this.props;
@ -270,24 +270,24 @@ class LanguageDropdown extends React.PureComponent {
this.setState({ open: false });
onClose(value);
}
};
handleChange = value => {
const { onChange } = this.props;
onChange(value);
}
};
setTargetRef = c => {
this.target = c;
}
};
findTarget = () => {
return this.target;
}
};
handleOverlayEnter = (state) => {
this.setState({ placement: state.placement });
}
};
render () {
const { value, intl, frequentlyUsedLanguages } = this.props;

View File

@ -144,7 +144,7 @@ class ComposerOptions extends ImmutablePureComponent {
if (files.length && onUpload) {
onUpload(files);
}
}
};
// Handles attachment clicks.
handleClickAttach = (name) => {
@ -164,12 +164,12 @@ class ComposerOptions extends ImmutablePureComponent {
}
return;
}
}
};
// Handles a ref to the file input.
handleRefFileElement = (fileElement) => {
this.fileElement = fileElement;
}
};
renderToggleItemContents = (item) => {
const { onChangeAdvancedOption } = this.props;

View File

@ -49,15 +49,15 @@ class Option extends React.PureComponent {
onSuggestionsClearRequested = () => {
this.props.onClearSuggestions();
}
};
onSuggestionsFetchRequested = (token) => {
this.props.onFetchSuggestions(token);
}
};
onSuggestionSelected = (tokenStart, token, value) => {
this.props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', this.props.index]);
}
};
render () {
const { isPollMultiple, title, lang, index, autoFocus, intl } = this.props;

View File

@ -94,5 +94,6 @@ class Publisher extends ImmutablePureComponent {
</div>
</div>
);
};
}
}

View File

@ -33,7 +33,7 @@ class ReplyIndicator extends ImmutablePureComponent {
if (onCancel) {
onCancel();
}
}
};
// Rendering.
render () {

View File

@ -71,14 +71,14 @@ class Search extends React.PureComponent {
setRef = c => {
this.searchForm = c;
}
};
handleChange = (e) => {
const { onChange } = this.props;
if (onChange) {
onChange(e.target.value);
}
}
};
handleClear = (e) => {
const {
@ -90,11 +90,11 @@ class Search extends React.PureComponent {
if (onClear && (submitted || value && value.length)) {
onClear();
}
}
};
handleBlur = () => {
this.setState({ expanded: false });
}
};
handleFocus = () => {
this.setState({ expanded: true });
@ -106,7 +106,7 @@ class Search extends React.PureComponent {
this.searchForm.scrollIntoView();
}
}
}
};
handleKeyUp = (e) => {
const { onSubmit } = this.props;
@ -121,11 +121,11 @@ class Search extends React.PureComponent {
case 'Escape':
focusRoot();
}
}
};
findTarget = () => {
return this.searchForm;
}
};
render () {
const { intl, value, submitted } = this.props;

View File

@ -103,7 +103,7 @@ class SearchResults extends ImmutablePureComponent {
<section className='search-results__section'>
<h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
{results.get('statuses').map(statusId => <StatusContainer id={statusId} key={statusId}/>)}
{results.get('statuses').map(statusId => <StatusContainer id={statusId} key={statusId} />)}
{results.get('statuses').size >= 5 && <LoadMore visible onClick={this.handleLoadMoreStatuses} />}
</section>
@ -136,5 +136,6 @@ class SearchResults extends ImmutablePureComponent {
{hashtags}
</div>
);
};
}
}

View File

@ -51,9 +51,10 @@ class TextareaIcons extends ImmutablePureComponent {
id={icon}
/>
</span>
) : null
) : null,
) : null}
</div>
);
}
}

View File

@ -23,12 +23,12 @@ export default class Upload extends ImmutablePureComponent {
handleUndoClick = e => {
e.stopPropagation();
this.props.onUndo(this.props.media.get('id'));
}
};
handleFocalPointClick = e => {
e.stopPropagation();
this.props.onOpenFocalPoint(this.props.media.get('id'));
}
};
render () {
const { media } = this.props;
@ -39,7 +39,7 @@ export default class Upload extends ImmutablePureComponent {
return (
<div className='compose-form__upload' tabIndex='0' role='button'>
<Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12, }) }}>
<Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}>
{({ scale }) => (
<div className='compose-form__upload-thumbnail' style={{ transform: `scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})`, backgroundPosition: `${x}% ${y}%` }}>
<div className='compose-form__upload__actions'>

View File

@ -6,6 +6,7 @@ import UploadContainer from '../containers/upload_container';
import SensitiveButtonContainer from '../containers/sensitive_button_container';
export default class UploadForm extends ImmutablePureComponent {
static propTypes = {
mediaIds: ImmutablePropTypes.list.isRequired,
};

View File

@ -22,11 +22,11 @@ import { privacyPreference } from 'flavours/glitch/utils/privacy_preference';
const messages = defineMessages({
missingDescriptionMessage: { id: 'confirmations.missing_media_description.message',
defaultMessage: 'At least one media attachment is lacking a description. Consider describing all media attachments for the visually impaired before sending your toot.' },
defaultMessage: 'At least one media attachment is lacking a description. Consider describing all media attachments for the visually impaired before sending your toot.' },
missingDescriptionConfirm: { id: 'confirmations.missing_media_description.confirm',
defaultMessage: 'Send anyway' },
defaultMessage: 'Send anyway' },
missingDescriptionEdit: { id: 'confirmations.missing_media_description.edit',
defaultMessage: 'Edit media' },
defaultMessage: 'Edit media' },
});
// State mapping.
@ -38,12 +38,12 @@ function mapStateToProps (state) {
const sideArmRestrictedPrivacy = replyPrivacy ? privacyPreference(replyPrivacy, sideArmBasePrivacy) : null;
let sideArmPrivacy = null;
switch (state.getIn(['local_settings', 'side_arm_reply_mode'])) {
case 'copy':
sideArmPrivacy = replyPrivacy;
break;
case 'restrict':
sideArmPrivacy = sideArmRestrictedPrivacy;
break;
case 'copy':
sideArmPrivacy = replyPrivacy;
break;
case 'restrict':
sideArmPrivacy = sideArmRestrictedPrivacy;
break;
}
sideArmPrivacy = sideArmPrivacy || sideArmBasePrivacy;
return {
@ -72,7 +72,7 @@ function mapStateToProps (state) {
isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
lang: state.getIn(['compose', 'language']),
};
};
}
// Dispatch mapping.
const mapDispatchToProps = (dispatch, { intl }) => ({
@ -124,7 +124,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onConfirm: () => {
if (overriddenVisibility) {
dispatch(changeComposeVisibility(overriddenVisibility));
};
}
dispatch(submitCompose(routerHistory));
},
secondary: intl.formatMessage(messages.missingDescriptionEdit),

View File

@ -23,7 +23,7 @@ function mapStateToProps (state) {
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
contentType: state.getIn(['compose', 'content_type']),
};
};
}
const mapDispatchToProps = (dispatch) => ({

View File

@ -8,7 +8,7 @@ import { profileLink, termsLink } from 'flavours/glitch/utils/backend_links';
const buildHashtagRE = () => {
try {
const HASHTAG_SEPARATORS = "_\\u00b7\\u200c";
const HASHTAG_SEPARATORS = '_\\u00b7\\u200c';
const ALPHA = '\\p{L}\\p{M}';
const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}';
return new RegExp(
@ -22,7 +22,7 @@ const buildHashtagRE = () => {
'[' + WORD + '_]*' +
'[' + ALPHA + ']' +
'[' + WORD + '_]*' +
'))', 'iu'
'))', 'iu',
);
} catch {
return /(?:^|[^\/\)\w])#(\w*[a-zA-Z·]\w*)/i;

View File

@ -43,6 +43,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
export default @connect(mapStateToProps, mapDispatchToProps)
@injectIntl
class Compose extends React.PureComponent {
static propTypes = {
multiColumn: PropTypes.bool,
showSearch: PropTypes.bool,

View File

@ -6,4 +6,4 @@ export function countableText(inputText) {
return inputText
.replace(urlRegex, urlPlaceholder)
.replace(/(^|[^\/\w])@(([a-z0-9_]+)@[a-z0-9\.\-]+[a-z0-9]+)/ig, '$1@$3');
};
}