From 774e1189d26fffd914107a4236f6287043c988f8 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Mon, 9 Oct 2023 13:38:29 +0200 Subject: [PATCH] Change `eslint` config to autofix missing comma and indentation in JS files (#26711) --- .eslintrc.js | 3 ++- app/javascript/mastodon/actions/alerts.js | 2 +- .../mastodon/actions/importer/normalizer.js | 6 +++--- app/javascript/mastodon/components/column.jsx | 2 +- app/javascript/mastodon/components/poll.jsx | 2 +- app/javascript/mastodon/components/status.jsx | 2 +- .../compose/components/navigation_bar.jsx | 2 +- .../features/compose/components/search.jsx | 16 ++++++++-------- .../mastodon/features/explore/results.jsx | 6 +++--- .../mastodon/features/firehose/index.jsx | 2 +- .../features/interaction_modal/index.jsx | 8 ++++---- .../mastodon/features/reblogs/index.jsx | 2 +- .../mastodon/features/report/comment.jsx | 2 +- .../status/components/detailed_status.jsx | 2 +- .../mastodon/features/ui/components/header.jsx | 4 ++-- .../features/ui/components/modal_root.jsx | 2 +- .../features/ui/components/sign_in_banner.jsx | 2 +- app/javascript/packs/application.js | 2 +- streaming/index.js | 10 +++++----- 19 files changed, 39 insertions(+), 38 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d5f0ae1ac..3bac9ed69 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,6 @@ module.exports = { 'plugin:import/recommended', 'plugin:promise/recommended', 'plugin:jsdoc/recommended', - 'plugin:prettier/recommended', ], env: { @@ -63,7 +62,9 @@ module.exports = { 'consistent-return': 'error', 'dot-notation': 'error', eqeqeq: ['error', 'always', { 'null': 'ignore' }], + 'indent': ['error', 2], 'jsx-quotes': ['error', 'prefer-single'], + 'semi': ['error', 'always'], 'no-case-declarations': 'off', 'no-catch-shadow': 'error', 'no-console': [ diff --git a/app/javascript/mastodon/actions/alerts.js b/app/javascript/mastodon/actions/alerts.js index 051a9675b..42834146b 100644 --- a/app/javascript/mastodon/actions/alerts.js +++ b/app/javascript/mastodon/actions/alerts.js @@ -56,4 +56,4 @@ export const showAlertForError = (error, skipNotFound = false) => { title: messages.unexpectedTitle, message: messages.unexpectedMessage, }); -} +}; diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js index e6b361c0c..a72142a86 100644 --- a/app/javascript/mastodon/actions/importer/normalizer.js +++ b/app/javascript/mastodon/actions/importer/normalizer.js @@ -104,7 +104,7 @@ export function normalizeStatus(status, normalOldStatus) { normalStatus.media_attachments.forEach(item => { const oldItem = list.find(i => i.get('id') === item.id); if (oldItem && oldItem.get('description') === item.description) { - item.translation = oldItem.get('translation') + item.translation = oldItem.get('translation'); } }); } @@ -137,13 +137,13 @@ export function normalizePoll(poll, normalOldPoll) { ...option, voted: poll.own_votes && poll.own_votes.includes(index), titleHtml: emojify(escapeTextContentForBrowser(option.title), emojiMap), - } + }; if (normalOldPoll && normalOldPoll.getIn(['options', index, 'title']) === option.title) { normalOption.translation = normalOldPoll.getIn(['options', index, 'translation']); } - return normalOption + return normalOption; }); return normalPoll; diff --git a/app/javascript/mastodon/components/column.jsx b/app/javascript/mastodon/components/column.jsx index cf9df3ba2..abc87a57e 100644 --- a/app/javascript/mastodon/components/column.jsx +++ b/app/javascript/mastodon/components/column.jsx @@ -22,7 +22,7 @@ export default class Column extends PureComponent { scrollable = document.scrollingElement; } else { scrollable = this.node.querySelector('.scrollable'); - } + } if (!scrollable) { return; diff --git a/app/javascript/mastodon/components/poll.jsx b/app/javascript/mastodon/components/poll.jsx index 4304f9acd..2d992d73a 100644 --- a/app/javascript/mastodon/components/poll.jsx +++ b/app/javascript/mastodon/components/poll.jsx @@ -132,7 +132,7 @@ class Poll extends ImmutablePureComponent { handleReveal = () => { this.setState({ revealed: true }); - } + }; renderOption (option, optionIndex, showResults) { const { poll, lang, disabled, intl } = this.props; diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 4a5ad54a1..49d00ca7c 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -199,7 +199,7 @@ class Status extends ImmutablePureComponent { } else if (attachments.getIn([0, 'type']) === 'audio') { return '16 / 9'; } else { - return (attachments.size === 1 && attachments.getIn([0, 'meta', 'small', 'aspect'])) ? attachments.getIn([0, 'meta', 'small', 'aspect']) : '3 / 2' + return (attachments.size === 1 && attachments.getIn([0, 'meta', 'small', 'aspect'])) ? attachments.getIn([0, 'meta', 'small', 'aspect']) : '3 / 2'; } } diff --git a/app/javascript/mastodon/features/compose/components/navigation_bar.jsx b/app/javascript/mastodon/features/compose/components/navigation_bar.jsx index 5af38da43..e842ab1f8 100644 --- a/app/javascript/mastodon/features/compose/components/navigation_bar.jsx +++ b/app/javascript/mastodon/features/compose/components/navigation_bar.jsx @@ -20,7 +20,7 @@ export default class NavigationBar extends ImmutablePureComponent { }; render () { - const username = this.props.account.get('acct') + const username = this.props.account.get('acct'); return (
diff --git a/app/javascript/mastodon/features/compose/components/search.jsx b/app/javascript/mastodon/features/compose/components/search.jsx index 7e1d8b760..dfbfa98f5 100644 --- a/app/javascript/mastodon/features/compose/components/search.jsx +++ b/app/javascript/mastodon/features/compose/components/search.jsx @@ -57,14 +57,14 @@ class Search extends PureComponent { }; defaultOptions = [ - { label: <>has: , action: e => { e.preventDefault(); this._insertText('has:') } }, - { label: <>is: , action: e => { e.preventDefault(); this._insertText('is:') } }, - { label: <>language: , action: e => { e.preventDefault(); this._insertText('language:') } }, - { label: <>from: , action: e => { e.preventDefault(); this._insertText('from:') } }, - { label: <>before: , action: e => { e.preventDefault(); this._insertText('before:') } }, - { label: <>during: , action: e => { e.preventDefault(); this._insertText('during:') } }, - { label: <>after: , action: e => { e.preventDefault(); this._insertText('after:') } }, - { label: <>in: , action: e => { e.preventDefault(); this._insertText('in:') } } + { label: <>has: , action: e => { e.preventDefault(); this._insertText('has:'); } }, + { label: <>is: , action: e => { e.preventDefault(); this._insertText('is:'); } }, + { label: <>language: , action: e => { e.preventDefault(); this._insertText('language:'); } }, + { label: <>from: , action: e => { e.preventDefault(); this._insertText('from:'); } }, + { label: <>before: , action: e => { e.preventDefault(); this._insertText('before:'); } }, + { label: <>during: , action: e => { e.preventDefault(); this._insertText('during:'); } }, + { label: <>after: , action: e => { e.preventDefault(); this._insertText('after:'); } }, + { label: <>in: , action: e => { e.preventDefault(); this._insertText('in:'); } } ]; setRef = c => { diff --git a/app/javascript/mastodon/features/explore/results.jsx b/app/javascript/mastodon/features/explore/results.jsx index 4c23d6422..a3c6adee9 100644 --- a/app/javascript/mastodon/features/explore/results.jsx +++ b/app/javascript/mastodon/features/explore/results.jsx @@ -80,7 +80,7 @@ class Results extends PureComponent { } return null; - }; + } handleSelectAll = () => { const { submittedType, dispatch } = this.props; @@ -116,7 +116,7 @@ class Results extends PureComponent { } this.setState({ type: 'hashtags' }); - } + }; handleSelectStatuses = () => { const { submittedType, dispatch } = this.props; @@ -128,7 +128,7 @@ class Results extends PureComponent { } this.setState({ type: 'statuses' }); - } + }; handleLoadMoreAccounts = () => this._loadMore('accounts'); handleLoadMoreStatuses = () => this._loadMore('statuses'); diff --git a/app/javascript/mastodon/features/firehose/index.jsx b/app/javascript/mastodon/features/firehose/index.jsx index efde58a5c..849ee38f5 100644 --- a/app/javascript/mastodon/features/firehose/index.jsx +++ b/app/javascript/mastodon/features/firehose/index.jsx @@ -199,7 +199,7 @@ const Firehose = ({ feedType, multiColumn }) => { ); -} +}; Firehose.propTypes = { multiColumn: PropTypes.bool, diff --git a/app/javascript/mastodon/features/interaction_modal/index.jsx b/app/javascript/mastodon/features/interaction_modal/index.jsx index 2a9fa0e33..69bbd8cd8 100644 --- a/app/javascript/mastodon/features/interaction_modal/index.jsx +++ b/app/javascript/mastodon/features/interaction_modal/index.jsx @@ -27,9 +27,9 @@ const mapStateToProps = (state, { accountId }) => ({ const mapDispatchToProps = (dispatch) => ({ onSignupClick() { dispatch(closeModal({ - modalType: undefined, - ignoreFocus: false, - })); + modalType: undefined, + ignoreFocus: false, + })); dispatch(openModal({ modalType: 'CLOSED_REGISTRATIONS' })); }, }); @@ -187,7 +187,7 @@ class LoginForm extends React.PureComponent { setIFrameRef = (iframe) => { this.iframeRef = iframe; - } + }; handleFocus = () => { this.setState({ expanded: true }); diff --git a/app/javascript/mastodon/features/reblogs/index.jsx b/app/javascript/mastodon/features/reblogs/index.jsx index 0c4e6dbb9..9de905790 100644 --- a/app/javascript/mastodon/features/reblogs/index.jsx +++ b/app/javascript/mastodon/features/reblogs/index.jsx @@ -45,7 +45,7 @@ class Reblogs extends ImmutablePureComponent { if (!this.props.accountIds) { this.props.dispatch(fetchReblogs(this.props.params.statusId)); } - }; + } handleRefresh = () => { this.props.dispatch(fetchReblogs(this.props.params.statusId)); diff --git a/app/javascript/mastodon/features/report/comment.jsx b/app/javascript/mastodon/features/report/comment.jsx index 98ac4caa0..ca9ea9d26 100644 --- a/app/javascript/mastodon/features/report/comment.jsx +++ b/app/javascript/mastodon/features/report/comment.jsx @@ -104,7 +104,7 @@ const Comment = ({ comment, domain, statusIds, isRemote, isSubmitting, selectedD
); -} +}; Comment.propTypes = { comment: PropTypes.string.isRequired, diff --git a/app/javascript/mastodon/features/status/components/detailed_status.jsx b/app/javascript/mastodon/features/status/components/detailed_status.jsx index 3927aba2f..e590ddb82 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.jsx +++ b/app/javascript/mastodon/features/status/components/detailed_status.jsx @@ -132,7 +132,7 @@ class DetailedStatus extends ImmutablePureComponent { } else if (attachments.getIn([0, 'type']) === 'audio') { return '16 / 9'; } else { - return (attachments.size === 1 && attachments.getIn([0, 'meta', 'small', 'aspect'])) ? attachments.getIn([0, 'meta', 'small', 'aspect']) : '3 / 2' + return (attachments.size === 1 && attachments.getIn([0, 'meta', 'small', 'aspect'])) ? attachments.getIn([0, 'meta', 'small', 'aspect']) : '3 / 2'; } } diff --git a/app/javascript/mastodon/features/ui/components/header.jsx b/app/javascript/mastodon/features/ui/components/header.jsx index 68484b59a..8c6cd600e 100644 --- a/app/javascript/mastodon/features/ui/components/header.jsx +++ b/app/javascript/mastodon/features/ui/components/header.jsx @@ -76,8 +76,8 @@ class Header extends PureComponent { if (sso_redirect) { content = ( - - ) + + ); } else { let signupButton; diff --git a/app/javascript/mastodon/features/ui/components/modal_root.jsx b/app/javascript/mastodon/features/ui/components/modal_root.jsx index f6de5dad3..46f0dc706 100644 --- a/app/javascript/mastodon/features/ui/components/modal_root.jsx +++ b/app/javascript/mastodon/features/ui/components/modal_root.jsx @@ -117,7 +117,7 @@ export default class ModalRoot extends PureComponent { {(SpecificComponent) => { const ref = typeof SpecificComponent !== 'function' ? this.setModalRef : undefined; - return + return ; }} diff --git a/app/javascript/mastodon/features/ui/components/sign_in_banner.jsx b/app/javascript/mastodon/features/ui/components/sign_in_banner.jsx index d5f0c00dc..4216f3da3 100644 --- a/app/javascript/mastodon/features/ui/components/sign_in_banner.jsx +++ b/app/javascript/mastodon/features/ui/components/sign_in_banner.jsx @@ -25,7 +25,7 @@ const SignInBanner = () => {

- ) + ); } if (registrationsOpen) { diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index f26321c41..d13388b47 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -1,5 +1,5 @@ import './public-path'; -import main from "mastodon/main" +import main from "mastodon/main"; import { start } from '../mastodon/common'; import { loadLocale } from '../mastodon/locales'; diff --git a/streaming/index.js b/streaming/index.js index 3565ed278..b3765531c 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -256,7 +256,7 @@ const startServer = async () => { CHANNEL_NAMES.forEach(( channel ) => { connectedChannels.set({ type: 'websocket', channel }, 0); connectedChannels.set({ type: 'eventsource', channel }, 0); - }) + }); // Prime the counters so that we don't loose metrics between restarts. // Unfortunately counters don't support the set() API, so instead I'm using @@ -1296,7 +1296,7 @@ const startServer = async () => { log.verbose(request.requestId, 'Subscription error:', err.toString()); socket.send(JSON.stringify({ error: err.toString() })); }); - } + }; const removeSubscription = (subscriptions, channelIds, request) => { @@ -1316,7 +1316,7 @@ const startServer = async () => { subscription.stopHeartbeat(); delete subscriptions[channelIds.join(';')]; - } + }; /** * @param {WebSocketSession} session @@ -1336,7 +1336,7 @@ const startServer = async () => { socket.send(JSON.stringify({ error: "Error unsubscribing from channel" })); } }); - } + }; /** * @param {WebSocketSession} session @@ -1414,7 +1414,7 @@ const startServer = async () => { const subscriptions = Object.keys(session.subscriptions); subscriptions.forEach(channelIds => { - removeSubscription(session.subscriptions, channelIds.split(';'), req) + removeSubscription(session.subscriptions, channelIds.split(';'), req); }); // Decrement the metrics for connected clients: