diff --git a/src/components/chat_list_item/chat_list_item.js b/src/components/chat_list_item/chat_list_item.js index c95895def..8bb2afd93 100644 --- a/src/components/chat_list_item/chat_list_item.js +++ b/src/components/chat_list_item/chat_list_item.js @@ -39,7 +39,7 @@ const ChatListItem = { messageForStatusContent() { const message = this.chat.lastMessage const messageEmojis = message ? message.emojis : [] - const isYou = message && message.account_id === this.currentUser.id + const isYou = message?.account_id === this.currentUser.id const content = message ? this.attachmentInfo || message.content : '' const messagePreview = isYou ? `${this.$t('chats.you')} ${content}` diff --git a/src/components/chat_message/chat_message.js b/src/components/chat_message/chat_message.js index 78be870b4..aabdec31f 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -111,7 +111,7 @@ const ChatMessage = { const user = this.$store.getters.findUser( this.message.in_reply_to_user_id, ) - return user && user.screen_name_ui + return user?.screen_name_ui } }, replyProfileLink() { diff --git a/src/components/chat_message/chat_message.vue b/src/components/chat_message/chat_message.vue index b772a9b20..394cce4b7 100644 --- a/src/components/chat_message/chat_message.vue +++ b/src/components/chat_message/chat_message.vue @@ -53,7 +53,7 @@ :user-screen-name="message.in_reply_to_screen_name" /> - + : { - if (data && data.statuses && data.statuses.length === 1) { + if (data?.statuses && data.statuses.length === 1) { this.$emit('update:id', data.statuses[0].id) } else { this.handleError(true) diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.vue b/src/components/settings_modal/admin_tabs/emoji_tab.vue index b118e0c52..c3bcd75b4 100644 --- a/src/components/settings_modal/admin_tabs/emoji_tab.vue +++ b/src/components/settings_modal/admin_tabs/emoji_tab.vue @@ -343,7 +343,7 @@ slot && slot.props && this.activeTab === slot.props.key, + (slot) => slot?.props && this.activeTab === slot.props.key, ) } else { return this.active diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js index 0fe9bc022..518345d9e 100644 --- a/src/components/settings_modal/tabs/appearance_tab.js +++ b/src/components/settings_modal/tabs/appearance_tab.js @@ -236,7 +236,7 @@ const AppearanceTab = { }, stylePalettes() { const ruleset = useInterfaceStore().styleDataUsed || [] - if (!ruleset && ruleset.length === 0) return + if (!ruleset?.length === 0) return const meta = ruleset.find((x) => x.component === '@meta') const result = ruleset .filter((x) => x.component.startsWith('@palette')) diff --git a/src/components/settings_modal/tabs/data_import_export_tab.js b/src/components/settings_modal/tabs/data_import_export_tab.js index 4554f4a1f..7fc6adefd 100644 --- a/src/components/settings_modal/tabs/data_import_export_tab.js +++ b/src/components/settings_modal/tabs/data_import_export_tab.js @@ -95,7 +95,7 @@ const DataImportExportTab = { return users .map((user) => { // check is it's a local user - if (user && user.is_local) { + if (user?.is_local) { // append the instance address return user.screen_name + '@' + location.hostname } diff --git a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js index c45d6ad76..61d3e42f7 100644 --- a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js +++ b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js @@ -81,7 +81,7 @@ const MutesAndBlocks = { return users .map((user) => { // check is it's a local user - if (user && user.is_local) { + if (user?.is_local) { // append the instance address return user.screen_name + '@' + location.hostname } diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index e0b7331c6..c810d93a0 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -220,7 +220,7 @@ slot && slot.props && this.activeTab === slot.props.key, + (slot) => slot?.props && this.activeTab === slot.props.key, ) } else { return this.active diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 8c5f4f251..17065a9ef 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -231,7 +231,7 @@ const Timeline = { tag: this.tag, }) .then(({ statuses }) => { - if (statuses && statuses.length === 0) { + if (statuses?.length === 0) { this.bottomedOut = true } }) diff --git a/src/components/unicode_domain_indicator/unicode_domain_indicator.vue b/src/components/unicode_domain_indicator/unicode_domain_indicator.vue index a979cc51d..08125694d 100644 --- a/src/components/unicode_domain_indicator/unicode_domain_indicator.vue +++ b/src/components/unicode_domain_indicator/unicode_domain_indicator.vue @@ -1,6 +1,6 @@ diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 7f8c68fd2..e6c6485f7 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -68,7 +68,7 @@ > diff --git a/src/services/errors/errors.js b/src/services/errors/errors.js index ccbae9b3e..5fbb8da11 100644 --- a/src/services/errors/errors.js +++ b/src/services/errors/errors.js @@ -14,7 +14,7 @@ export function StatusCodeError(statusCode, body, options, response) { this.name = 'StatusCodeError' this.statusCode = statusCode this.statusText = body.error || body.errors || body - this.details = JSON && JSON.stringify ? JSON.stringify(body) : body + this.details = JSON.stringify(body) this.errorData = body.error || body.errors this.message = this.statusCode + ' - ' + this.statusText this.error = body // legacy attribute diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index 201cd9ab4..65c177f98 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -231,7 +231,7 @@ export const SLOT_ORDERED = topoSort( Object.entries(SLOT_INHERITANCE) .sort( ([, aV], [, bV]) => - ((aV && aV.priority) || 0) - ((bV && bV.priority) || 0), + ((aV?.priority) || 0) - ((bV && bV.priority) || 0), ) .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}), ) @@ -408,7 +408,7 @@ export const getColors = (sourceColors, sourceOpacity) => delete outputColor.a } else { // Otherwise try to assign opacity - if (dependencyColor && dependencyColor.a === 0) { + if (dependencyColor?.a === 0) { // transparent dependency shall make dependents transparent too outputColor.a = 0 } else { diff --git a/src/services/user_profile_link_generator/user_profile_link_generator.js b/src/services/user_profile_link_generator/user_profile_link_generator.js index 8f4ab7e58..45cd0ea99 100644 --- a/src/services/user_profile_link_generator/user_profile_link_generator.js +++ b/src/services/user_profile_link_generator/user_profile_link_generator.js @@ -11,6 +11,6 @@ const generateProfileLink = (id, screenName, restrictedNicknames) => { } } -const isExternal = (screenName) => screenName && screenName.includes('@') +const isExternal = (screenName) => screenName?.includes('@') export default generateProfileLink diff --git a/src/stores/announcements.js b/src/stores/announcements.js index a5f3e4d8e..b09655755 100644 --- a/src/stores/announcements.js +++ b/src/stores/announcements.js @@ -74,7 +74,7 @@ export const useAnnouncementsStore = defineStore('announcements', { } catch (error) { // If and only if backend does not support announcements, it would return 404. // In this case, silently ignores it. - if (error && error.statusCode === 404) { + if (error?.statusCode === 404) { this.supportsAnnouncements = false } else { throw error diff --git a/src/stores/interface.js b/src/stores/interface.js index 654cc55fd..87ef65865 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -790,7 +790,7 @@ export const normalizeThemeData = (input) => { // New theme presets don't have 'theme' property, they use 'source' let out // shout, shout let it all out - if (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION) { + if (themeSource?.themeEngineVersion === CURRENT_VERSION) { // There are some themes in wild that have completely broken source out = { ...(themeData || {}), ...themeSource } } else { diff --git a/test/fixtures/setup_test.js b/test/fixtures/setup_test.js index 1a04b9549..b3804b102 100644 --- a/test/fixtures/setup_test.js +++ b/test/fixtures/setup_test.js @@ -132,7 +132,7 @@ export const waitForEvent = ( return vi.waitFor( () => { const e = wrapper.emitted(event) - if (e && e.length >= timesEmitted) { + if (e?.length >= timesEmitted) { return } throw new Error('event is not emitted')