From f91f077985eccf9933346052ce4ee532215099c6 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 1 Oct 2024 12:26:30 -0400 Subject: [PATCH] Enable ESLlint no-case-declarations (#30768) --- .eslintrc.js | 1 - app/javascript/mastodon/actions/streaming.js | 3 ++- app/javascript/mastodon/reducers/compose.js | 3 ++- app/javascript/mastodon/reducers/notifications.js | 3 ++- app/javascript/mastodon/reducers/search.js | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b6e4253e61..93ff1d7b59 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -64,7 +64,6 @@ module.exports = defineConfig({ 'indent': ['error', 2], 'jsx-quotes': ['error', 'prefer-single'], 'semi': ['error', 'always'], - 'no-case-declarations': 'off', 'no-catch-shadow': 'error', 'no-console': [ 'warn', diff --git a/app/javascript/mastodon/actions/streaming.js b/app/javascript/mastodon/actions/streaming.js index b6fc31fae8..30e643363a 100644 --- a/app/javascript/mastodon/actions/streaming.js +++ b/app/javascript/mastodon/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/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 9f66c09631..e77f2ac6e6 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -407,7 +407,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, @@ -416,6 +416,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: diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js index 622f5e8e88..c99a619b52 100644 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@ -298,9 +298,10 @@ export default function notifications(state = initialState, action) { return action.payload.timeline === 'home' ? state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) : state; - 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; + } case NOTIFICATIONS_SET_BROWSER_SUPPORT: return state.set('browserSupport', action.value); case NOTIFICATIONS_SET_BROWSER_PERMISSION: diff --git a/app/javascript/mastodon/reducers/search.js b/app/javascript/mastodon/reducers/search.js index 7828d49eee..7de1c65c07 100644 --- a/app/javascript/mastodon/reducers/search.js +++ b/app/javascript/mastodon/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: