From 61a0c58dee383bf79a3b6ff6c08f82a34710d8dd Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 1 Oct 2024 12:26:30 -0400 Subject: [PATCH] [Glitch] Enable ESLlint no-case-declarations Port f91f077985eccf9933346052ce4ee532215099c6 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/streaming.js | 3 ++- .../flavours/glitch/components/status_content.jsx | 3 ++- app/javascript/flavours/glitch/reducers/compose.js | 6 ++++-- app/javascript/flavours/glitch/reducers/notifications.js | 3 ++- app/javascript/flavours/glitch/reducers/search.js | 3 ++- app/javascript/flavours/glitch/utils/resize_image.js | 6 ++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/streaming.js b/app/javascript/flavours/glitch/actions/streaming.js index 7948984fba..fa7af7055e 100644 --- a/app/javascript/flavours/glitch/actions/streaming.js +++ b/app/javascript/flavours/glitch/actions/streaming.js @@ -106,12 +106,13 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti dispatch(processNewNotificationForGroups(notificationJSON)); break; } - case 'notifications_merged': + case 'notifications_merged': { const state = getState(); if (state.notifications.top || !state.notifications.mounted) dispatch(expandNotifications({ forceLoad: true, maxId: undefined })); dispatch(refreshStaleNotificationGroups()); break; + } case 'conversation': // @ts-expect-error dispatch(updateConversations(JSON.parse(data.payload))); diff --git a/app/javascript/flavours/glitch/components/status_content.jsx b/app/javascript/flavours/glitch/components/status_content.jsx index d6dfd9f490..a15a4df25a 100644 --- a/app/javascript/flavours/glitch/components/status_content.jsx +++ b/app/javascript/flavours/glitch/components/status_content.jsx @@ -41,7 +41,7 @@ const isLinkMisleading = (link) => { case Node.TEXT_NODE: linkTextParts.push(node.textContent); break; - case Node.ELEMENT_NODE: + case Node.ELEMENT_NODE: { if (node.classList.contains('invisible')) return; const children = node.childNodes; for (let i = 0; i < children.length; i++) { @@ -49,6 +49,7 @@ const isLinkMisleading = (link) => { } break; } + } }; walk(link); diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 211402ab2a..836ad10862 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -512,7 +512,7 @@ export default function compose(state = initialState, action) { return item; })); - case INIT_MEDIA_EDIT_MODAL: + case INIT_MEDIA_EDIT_MODAL: { const media = state.get('media_attachments').find(item => item.get('id') === action.id); return state.set('media_modal', ImmutableMap({ id: action.id, @@ -521,6 +521,7 @@ export default function compose(state = initialState, action) { focusY: media.getIn(['meta', 'focus', 'y'], 0), dirty: false, })); + } case COMPOSE_CHANGE_MEDIA_DESCRIPTION: return state.setIn(['media_modal', 'description'], action.description).setIn(['media_modal', 'dirty'], true); case COMPOSE_CHANGE_MEDIA_FOCUS: @@ -575,7 +576,7 @@ export default function compose(state = initialState, action) { })); case COMPOSE_DOODLE_SET: return state.mergeIn(['doodle'], action.options); - case REDRAFT: + case REDRAFT: { const do_not_federate = !!action.status.get('local_only'); let text = action.raw_text || unescapeHTML(expandMentions(action.status)); if (do_not_federate) text = text.replace(/ ?👁\ufe0f?\u200b?$/, ''); @@ -616,6 +617,7 @@ export default function compose(state = initialState, action) { })); } }); + } case COMPOSE_SET_STATUS: return state.withMutations(map => { map.set('id', action.status.get('id')); diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index b9773a0da6..8453dd7038 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -369,9 +369,10 @@ export default function notifications(state = initialState, action) { } return markAllForDelete(st, action.yes); - case NOTIFICATIONS_MARK_AS_READ: + case NOTIFICATIONS_MARK_AS_READ: { const lastNotification = state.get('items').find(item => item !== null); return lastNotification ? recountUnread(state, lastNotification.get('id')) : state; + } default: return state; diff --git a/app/javascript/flavours/glitch/reducers/search.js b/app/javascript/flavours/glitch/reducers/search.js index 7828d49eee..7de1c65c07 100644 --- a/app/javascript/flavours/glitch/reducers/search.js +++ b/app/javascript/flavours/glitch/reducers/search.js @@ -72,9 +72,10 @@ export default function search(state = initialState, action) { }); case SEARCH_EXPAND_REQUEST: return state.set('type', action.searchType).set('isLoading', true); - case SEARCH_EXPAND_SUCCESS: + case SEARCH_EXPAND_SUCCESS: { const results = action.searchType === 'hashtags' ? ImmutableOrderedSet(fromJS(action.results.hashtags)) : action.results[action.searchType].map(item => item.id); return state.updateIn(['results', action.searchType], list => list.union(results)).set('isLoading', false); + } case SEARCH_HISTORY_UPDATE: return state.set('recent', ImmutableOrderedSet(fromJS(action.recent))); default: diff --git a/app/javascript/flavours/glitch/utils/resize_image.js b/app/javascript/flavours/glitch/utils/resize_image.js index e3d4e6a354..c579fe5a2c 100644 --- a/app/javascript/flavours/glitch/utils/resize_image.js +++ b/app/javascript/flavours/glitch/utils/resize_image.js @@ -17,7 +17,7 @@ const dropOrientationIfNeeded = (orientation) => new Promise(resolve => { case false: resolve(orientation); break; - default: + default: { // black 2x1 JPEG, with the following meta information set: // - EXIF Orientation: 6 (Rotated 90° CCW) const testImageURL = @@ -39,6 +39,7 @@ const dropOrientationIfNeeded = (orientation) => new Promise(resolve => { }; img.src = testImageURL; } + } }); // Some browsers don't allow reading from a canvas and instead return all-white @@ -52,7 +53,7 @@ const checkCanvasReliability = () => new Promise((resolve, reject) => { case false: resolve(); break; - default: + default: { // 2×2 GIF with white, red, green and blue pixels const testImageURL = 'data:image/gif;base64,R0lGODdhAgACAKEDAAAA//8AAAD/AP///ywAAAAAAgACAAACA1wEBQA7'; @@ -78,6 +79,7 @@ const checkCanvasReliability = () => new Promise((resolve, reject) => { }; img.src = testImageURL; } + } }); const getImageUrl = inputFile => new Promise((resolve, reject) => {