Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-useless-else.
Anders Kaseorg070820a826da
diff --git a/web/src/add_subscribers_pill.ts b/web/src/add_subscribers_pill.tsindex 4f9923cf98f..b31cd10ae1d 100644--- a/web/src/add_subscribers_pill.ts+++ b/web/src/add_subscribers_pill.ts@@ -85,7 +85,8 @@ export function get_display_value_from_item(item: CombinedPill): string {if (item.type === "user_group") {const group = user_groups.get_user_group_from_id(item.group_id);return user_groups.get_display_group_name(group.name);- } else if (item.type === "stream") {+ }+ if (item.type === "stream") {return stream_pill.get_display_value_from_item(item);}assert(item.type === "user");@@ -95,7 +96,8 @@ export function get_display_value_from_item(item: CombinedPill): string {export function generate_pill_html(item: CombinedPill): string {if (item.type === "user_group") {return user_group_pill.generate_pill_html(item);- } else if (item.type === "user") {+ }+ if (item.type === "user") {return user_pill.generate_pill_html(item);}assert(item.type === "stream");diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.tsindex 87627152b16..dc1ec819d83 100644--- a/web/src/attachments_ui.ts+++ b/web/src/attachments_ui.ts@@ -144,7 +144,8 @@ function sort_mentioned_in(a: Attachment, b: Attachment): number {if (a_id > b_id) {return 1;- } else if (a_id === b_id) {+ }+ if (a_id === b_id) {return 0;}diff --git a/web/src/buddy_list.ts b/web/src/buddy_list.tsindex 5c6d86dbbcc..b804309ae10 100644--- a/web/src/buddy_list.ts+++ b/web/src/buddy_list.ts@@ -49,7 +49,8 @@ function get_total_human_subscriber_count(): number {if (current_sub) {return peer_data.get_subscriber_count(current_sub.stream_id, false);- } else if (pm_ids_set.size > 0) {+ }+ if (pm_ids_set.size > 0) {// The current user is only in the provided recipients list// for direct message conversations with oneself.const all_recipient_user_ids_set = pm_ids_set.union(new Set([current_user.user_id]));diff --git a/web/src/click_handlers.ts b/web/src/click_handlers.tsindex d54136be435..5a3494e5fad 100644--- a/web/src/click_handlers.ts+++ b/web/src/click_handlers.ts@@ -1107,7 +1107,8 @@ export function initialize(): void {// into compose and modify it.$("textarea#compose-textarea").trigger("focus");return;- } else if (+ }+ if (!window.getSelection()?.toString() &&// Clicking any input or text area should not close// the compose box; this means using the sidebardiff --git a/web/src/compose_state.ts b/web/src/compose_state.tsindex 9b3a28e7bb8..982b272a04e 100644--- a/web/src/compose_state.ts+++ b/web/src/compose_state.ts@@ -117,7 +117,8 @@ function get_or_set(}if (no_trim) {return oldval;- } else if (keep_leading_spaces) {+ }+ if (keep_leading_spaces) {return oldval.trimEnd().replace(/^(\r?\n)+/, "");}return oldval.trim();diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.tsindex 55c11853b60..2a106c830a8 100644--- a/web/src/compose_ui.ts+++ b/web/src/compose_ui.ts@@ -204,7 +204,8 @@ function get_focus_area(opts: ComposeTriggeredOptions): string {!stream_data.can_use_empty_topic(opts.stream_id)) {return "input#stream_message_recipient_topic";- } else if (+ }+ if ((opts.message_type === "stream" && opts.stream_id !== undefined) ||(opts.message_type === "private" && opts.private_message_recipient_ids.length > 0)) {@@ -448,7 +449,8 @@ export function compute_placeholder_text(opts: ComposePlaceholderOptions): strin{defaultMessage: "Message #{channel_name} > {topic_name}"},{channel_name: stream_name, topic_name: topic_display_name},);- } else if (stream_name) {+ }+ if (stream_name) {return $t({defaultMessage: "Message #{channel_name}"}, {channel_name: stream_name});}} else if (opts.direct_message_user_ids.length > 0) {@@ -1063,7 +1065,8 @@ export let format_text = (range.end - syntax_start.length,);return false;- } else if (is_inner_text_formatted(syntax_start, syntax_end)) {+ }+ if (is_inner_text_formatted(syntax_start, syntax_end)) {// Remove syntax inside the selection, if present.text =text.slice(0, range.start) +@@ -1404,7 +1407,8 @@ export let format_text = (range.end - italic_syntax.length,);break;- } else if (+ }+ if (selected_text.length > italic_syntax.length * 2 &&// If the selected text contains italic syntaxselected_text.startsWith(italic_syntax) &&diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.tsindex 2c6d90b6236..7f765859332 100644--- a/web/src/compose_validate.ts+++ b/web/src/compose_validate.ts@@ -1226,7 +1226,8 @@ export let validate = (scheduling_message: boolean, show_banner = true): boolean}is_validating_compose_box = false;return false;- } else if ($("textarea#compose-textarea").hasClass("invalid")) {+ }+ if ($("textarea#compose-textarea").hasClass("invalid")) {// Hide the invalid indicator now that it's non-empty.$("textarea#compose-textarea").toggleClass("invalid", false);}diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.tsindex 5dbcd8f6352..3654eb4dc15 100644--- a/web/src/composebox_typeahead.ts+++ b/web/src/composebox_typeahead.ts@@ -482,7 +482,8 @@ export function tokenize_compose_str(s: string): string {// Code block must start on a new lineif (i === 2) {return s;- } else if (i > 2 && s[i - 3] === "\n") {+ }+ if (i > 2 && s[i - 3] === "\n") {return s.slice(i - 2);}break;@@ -497,7 +498,8 @@ export function tokenize_compose_str(s: string): string {case "_":if (i === 0) {return s;- } else if (/[\s"'(/<[{]/.test(s[i - 1]!)) {+ }+ if (/[\s"'(/<[{]/.test(s[i - 1]!)) {return s.slice(i);}break;@@ -1737,7 +1739,8 @@ export function initialize_compose_typeahead($element: JQuery<HTMLTextAreaElemenitem.language === realm.realm_default_code_block_language) {return `<em>${$t({defaultMessage: "(default)"})}</em>`;- } else if (item.language === "text") {+ }+ if (item.language === "text") {return `<em>${$t({defaultMessage: "(no highlighting)"})}</em>`;}}@@ -1883,7 +1886,8 @@ export function initialize({): string | false {if (typeof item !== "string" && item.type === "user") {return `<em>${$t({defaultMessage: "DM"})}</em>`;- } else if (!matching_items.includes(item)) {+ }+ if (!matching_items.includes(item)) {return `<em>${$t({defaultMessage: "New"})}</em>`;}return false;diff --git a/web/src/copy_messages.ts b/web/src/copy_messages.tsindex bcd5f4a2a4f..051cb5bda98 100644--- a/web/src/copy_messages.ts+++ b/web/src/copy_messages.ts@@ -39,7 +39,8 @@ function find_boundary_tr(}if (j === 10) {return undefined;- } else if (j !== 0) {+ }+ if (j !== 0) {// If we updated tr, then we are not dealing with a selection// that is entirely within one td, and we can skip the same td// check (In fact, we need to because it won't work correctlydiff --git a/web/src/drafts.ts b/web/src/drafts.tsindex af0691f5274..becdf8d92c8 100644--- a/web/src/drafts.ts+++ b/web/src/drafts.ts@@ -525,7 +525,8 @@ export function current_recipient_data(): {topic: compose_state.topic(),private_recipient_ids: undefined,};- } else if (compose_state.get_message_type() === "private") {+ }+ if (compose_state.get_message_type() === "private") {return {stream_name: undefined,topic: undefined,diff --git a/web/src/emoji_picker.ts b/web/src/emoji_picker.tsindex 2fb28b77b5c..f4ecb879f8b 100644--- a/web/src/emoji_picker.ts+++ b/web/src/emoji_picker.ts@@ -242,7 +242,8 @@ function get_total_sections(): number {function get_max_index(section: number): number | undefined {if (search_is_active) {return search_results.length;- } else if (section >= 0 && section < get_total_sections()) {+ }+ if (section >= 0 && section < get_total_sections()) {return complete_emoji_catalog[section]!.emojis.length;}return undefined;@@ -664,7 +665,8 @@ export function navigate(event_name: string, e?: JQuery.KeyDownEvent): boolean {return true;}return false;- } else if (+ }+ if ((current_section === 0 && current_index < 6 && event_name === "up_arrow") ||(current_section === 0 && current_index === 0 && event_name === "left_arrow")) {diff --git a/web/src/folder_dropdown_widget.ts b/web/src/folder_dropdown_widget.tsindex 8e01a9d6911..da8e4004217 100644--- a/web/src/folder_dropdown_widget.ts+++ b/web/src/folder_dropdown_widget.ts@@ -80,7 +80,8 @@ export function get_tooltip_text_for_folder_filter(folder_filter_value: number):const folder_filters = FOLDER_FILTERS;if (folder_filter_value === folder_filters.ANY_FOLDER_DROPDOWN_OPTION) {return $t({defaultMessage: "Filter by folder"});- } else if (folder_filter_value === folder_filters.UNCATEGORIZED_DROPDOWN_OPTION) {+ }+ if (folder_filter_value === folder_filters.UNCATEGORIZED_DROPDOWN_OPTION) {return $t({defaultMessage: "Viewing uncategorized channels"});}const folder = channel_folders.get_channel_folder_by_id(folder_filter_value);diff --git a/web/src/gif_picker_ui.ts b/web/src/gif_picker_ui.tsindex 72f1a32b41e..7adc8d8e088 100644--- a/web/src/gif_picker_ui.ts+++ b/web/src/gif_picker_ui.ts@@ -380,7 +380,8 @@ function get_gif_network(): GifNetwork {// In terms of preference, Tenor > KLIPY > GIPHY.if (gif_state.is_tenor_enabled()) {return new tenor_network.TenorNetwork();- } else if (gif_state.is_klipy_enabled()) {+ }+ if (gif_state.is_klipy_enabled()) {return new klipy_network.KlipyNetwork();}return new giphy_network.GiphyNetwork();diff --git a/web/src/hotkey.ts b/web/src/hotkey.tsindex 5a17dc036fc..eef94c1d017 100644--- a/web/src/hotkey.ts+++ b/web/src/hotkey.ts@@ -1117,10 +1117,12 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {if (overlays.lightbox_open()) {lightbox.prev();return true;- } else if (overlays.streams_open()) {+ }+ if (overlays.streams_open()) {stream_settings_ui.toggle_view(event_name);return true;- } else if (compose_state.focus_in_formatting_buttons()) {+ }+ if (compose_state.focus_in_formatting_buttons()) {// Allow left arrow to scroll the formatting buttons backwardreturn false;}@@ -1133,7 +1135,8 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {if (overlays.lightbox_open()) {lightbox.next();return true;- } else if (overlays.streams_open()) {+ }+ if (overlays.streams_open()) {stream_settings_ui.toggle_view(event_name);return true;}@@ -1412,7 +1415,8 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {if (narrow_state.narrowed_by_topic_reply()) {// narrow to stream if user is in topic viewreturn do_narrow_action(message_view.narrow_by_recipient);- } else if (narrow_state.narrowed_by_pm_reply()) {+ }+ if (narrow_state.narrowed_by_pm_reply()) {// do nothing if user is in DM viewreturn false;}diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.tsindex 364ab54b698..95a8cfccf3b 100644--- a/web/src/inbox_ui.ts+++ b/web/src/inbox_ui.ts@@ -662,7 +662,8 @@ function rerender_stream_inbox_header_if_needed(function get_channel_folder_header_id(folder_id: number): string {if (folder_id === OTHER_CHANNELS_FOLDER_ID) {return OTHER_CHANNEL_HEADER_ID;- } else if (folder_id === PINNED_CHANNEL_FOLDER_ID) {+ }+ if (folder_id === PINNED_CHANNEL_FOLDER_ID) {return PINNED_CHANNEL_HEADER_ID;}return CHANNEL_FOLDER_HEADER_ID_PREFIX + folder_id;diff --git a/web/src/left_sidebar_navigation_area.ts b/web/src/left_sidebar_navigation_area.tsindex 9ae9d52937b..fd39d4d0087 100644--- a/web/src/left_sidebar_navigation_area.ts+++ b/web/src/left_sidebar_navigation_area.ts@@ -126,7 +126,8 @@ export function handle_narrow_activated(filter: Filter): void {if (filter_name === "starred") {select_top_left_corner_item(".top_left_starred_messages");return;- } else if (filter_name === "mentioned") {+ }+ if (filter_name === "mentioned") {select_top_left_corner_item(".top_left_mentions");return;}diff --git a/web/src/lightbox.ts b/web/src/lightbox.tsindex 79c800fc215..72c97890ef1 100644--- a/web/src/lightbox.ts+++ b/web/src/lightbox.ts@@ -438,11 +438,10 @@ export function show_from_selected_message(): void {$prev_traverse = true;$message = $message_selected;break;- } else {- $message = rows.last_message_in_group($prev_message_group);- $media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());- continue;}+ $message = rows.last_message_in_group($prev_message_group);+ $media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());+ continue;}$message = $message.prev();$media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());@@ -454,11 +453,10 @@ export function show_from_selected_message(): void {const $next_message_group = $message.parent().nextAll(".recipient_row").first();if ($next_message_group.length === 0) {break;- } else {- $message = rows.first_message_in_group($next_message_group);- $media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());- continue;}+ $message = rows.first_message_in_group($next_message_group);+ $media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());+ continue;}$message = $message.next();$media = $message.find<HTMLMediaElement | HTMLImageElement>(media_classes());diff --git a/web/src/list_widget.ts b/web/src/list_widget.tsindex ad5ba83bd6f..458aa2dff1f 100644--- a/web/src/list_widget.ts+++ b/web/src/list_widget.ts@@ -152,7 +152,8 @@ export function alphabetic_sort<Prop extends string>(if (str1 === str2) {return 0;- } else if (str1 > str2) {+ }+ if (str1 > str2) {return 1;}@@ -169,7 +170,8 @@ export function numeric_sort<Prop extends string>(if (a_prop > b_prop) {return 1;- } else if (a_prop === b_prop) {+ }+ if (a_prop === b_prop) {return 0;}diff --git a/web/src/message_edit.ts b/web/src/message_edit.tsindex 6a02437ab0d..fe54ed43e9e 100644--- a/web/src/message_edit.ts+++ b/web/src/message_edit.ts@@ -561,7 +561,8 @@ function timer_text(seconds_left: number): string {const seconds = seconds_left % 60;if (minutes >= 1) {return $t({defaultMessage: "{minutes} min to edit"}, {minutes: minutes.toString()});- } else if (seconds_left >= 10) {+ }+ if (seconds_left >= 10) {return $t({defaultMessage: "{seconds} sec to edit"},{seconds: (seconds - (seconds % 5)).toString()},@@ -864,7 +865,8 @@ function get_resolve_topic_time_limit_error_string(},{N: time_limit},);- } else if (time_limit_unit === "hour") {+ }+ if (time_limit_unit === "hour") {return $t({defaultMessage:@@ -890,7 +892,8 @@ function get_resolve_topic_time_limit_error_string(},{N: time_limit},);- } else if (time_limit_unit === "hour") {+ }+ if (time_limit_unit === "hour") {return $t({defaultMessage:@@ -1456,7 +1459,8 @@ export async function save_message_row_edit($row: JQuery): Promise<void> {$container,);return;- } else if (code === "EXPECTATION_MISMATCH") {+ }+ if (code === "EXPECTATION_MISMATCH") {const message = $t({defaultMessage:"Error editing message: Message was edited by another client.",diff --git a/web/src/message_list_view.ts b/web/src/message_list_view.tsindex 46fbb064994..fe8f6936463 100644--- a/web/src/message_list_view.ts+++ b/web/src/message_list_view.ts@@ -2265,7 +2265,8 @@ export class MessageListView {navbar_bottom + header_props.height + margin_between_recipient_rows;if (header_props.top < partially_hidden_header_position) {return -1;- } else if (header_props.top > sticky_or_about_to_be_sticky_header_position) {+ }+ if (header_props.top > sticky_or_about_to_be_sticky_header_position) {return 1;}/* Headers between `partially_hidden_header_position` and `sticky_or_about_to_be_sticky_header_position`@@ -2290,7 +2291,8 @@ export class MessageListView {if (diff === 0) {$sticky_header = $(header);break;- } else if (diff === 1) {+ }+ if (diff === 1) {end = mid - 1;} else {start = mid + 1;diff --git a/web/src/navbar_menus.ts b/web/src/navbar_menus.tsindex 3e1e2be88b0..a2e1830491a 100644--- a/web/src/navbar_menus.ts+++ b/web/src/navbar_menus.ts@@ -73,7 +73,8 @@ function get_target_navbar_menu(if (event_name === "left_arrow" && index !== -1) {return [...$navbar_menus].slice(0, index).findLast((menu) => menu.getClientRects().length)?.id;- } else if (event_name === "right_arrow" && index !== -1) {+ }+ if (event_name === "right_arrow" && index !== -1) {return [...$navbar_menus].slice(index + 1).find((menu) => menu.getClientRects().length)?.id;}return undefined;diff --git a/web/src/password_quality.ts b/web/src/password_quality.tsindex 75a087fbe91..dc78bee4fa9 100644--- a/web/src/password_quality.ts+++ b/web/src/password_quality.ts@@ -64,7 +64,8 @@ export function password_warning(password: string, $password_field: JQuery): str{defaultMessage: "Password should be at least {length} characters long."},{length: min_length},);- } else if (password.length > max_length) {+ }+ if (password.length > max_length) {return $t({defaultMessage: "Maximum password length: {max} characters.",diff --git a/web/src/peer_data.ts b/web/src/peer_data.tsindex e5f15293a95..ca5a46d500d 100644--- a/web/src/peer_data.ts+++ b/web/src/peer_data.ts@@ -583,7 +583,7 @@ export async function fetch_subscriptions_for_user(user_id: number): Promise<voibreak;}// Failed request, so try again (unless we've reached the retry limit)- else if (result === null) {+ if (result === null) {num_attempts += 1;const retry_delay_secs = get_retry_backoff_seconds(undefined, num_attempts);await new Promise((resolve) => setTimeout(resolve, retry_delay_secs * 1000));diff --git a/web/src/people.ts b/web/src/people.tsindex 4e53135ad47..4e96cf13a9a 100644--- a/web/src/people.ts+++ b/web/src/people.ts@@ -1121,7 +1121,8 @@ export function get_people_for_dm(opts: {}): User[] {if (opts.exclude_non_message_people) {return opts.active_users_only ? get_active_message_people() : get_message_people();- } else if (opts.exclude_non_welcome_bots) {+ }+ if (opts.exclude_non_welcome_bots) {return get_realm_users_and_welcome_bot();}return get_realm_users_and_system_bots();diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.tsindex 7ceac9c872f..11eea8ba120 100644--- a/web/src/recent_view_ui.ts+++ b/web/src/recent_view_ui.ts@@ -1420,7 +1420,8 @@ function sort_comparator(a: string, b: string): number {// compares strings in lowercase and returns -1, 0, 1if (a.toLowerCase() > b.toLowerCase()) {return 1;- } else if (a.toLowerCase() === b.toLowerCase()) {+ }+ if (a.toLowerCase() === b.toLowerCase()) {return 0;}return -1;@@ -1580,7 +1581,8 @@ function topic_offset_to_visible_area($topic_row: JQuery): string | undefined {if (topic_props.top < thead_bottom) {return "above";// Topic is below the visible scroll region.- } else if (topic_props.bottom > compose_top) {+ }+ if (topic_props.bottom > compose_top) {return "below";}diff --git a/web/src/scroll_util.ts b/web/src/scroll_util.tsindex fd5f3a75aa2..5a5c3f4e9f6 100644--- a/web/src/scroll_util.ts+++ b/web/src/scroll_util.ts@@ -25,7 +25,8 @@ export function get_scroll_element($element: JQueryOrZJQuery): JQuery {const sb = SimpleBar.instances.get(element);if (sb) {return $(sb.getScrollElement()!);- } else if (element.hasAttribute("data-simplebar")) {+ }+ if (element.hasAttribute("data-simplebar")) {// The SimpleBar mutation observer hasn’t processed this element yet.// Create the SimpleBar early in case we need to add event listeners.return $(new SimpleBar(element, {tabIndex: -1}).getScrollElement()!);diff --git a/web/src/search_pill.ts b/web/src/search_pill.tsindex 0587db94e00..7784cfe9677 100644--- a/web/src/search_pill.ts+++ b/web/src/search_pill.ts@@ -339,7 +339,8 @@ export function generate_pills_html(suggestion: Suggestion, text_query: string):pills: pill_render_data,description_html,});- } else if (render_data.type === "search_user" && is_sent_by_me_pill(render_data)) {+ }+ if (render_data.type === "search_user" && is_sent_by_me_pill(render_data)) {const description_html = render_data.negated? $t({defaultMessage: "Exclude messages you sent"}): $t({defaultMessage: "Messages you sent"});diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.tsindex cf40a6c0060..93c616c0174 100644--- a/web/src/search_suggestion.ts+++ b/web/src/search_suggestion.ts@@ -657,7 +657,8 @@ function get_topic_suggestions(excluded_channel_ids.has(subscribed_channel_id.toString())) {continue;- } else if (!show_topics_from_other_channels) {+ }+ if (!show_topics_from_other_channels) {continue;}diff --git a/web/src/server_events.js b/web/src/server_events.jsindex 7bb76ae7a6a..eeca58227b6 100644--- a/web/src/server_events.js+++ b/web/src/server_events.js@@ -222,7 +222,8 @@ function get_events({dont_block = false} = {}) {if (error_type === "abort") {// Don't restart if we explicitly abortedreturn;- } else if (error_type === "timeout") {+ }+ if (error_type === "timeout") {// Retry indefinitely on timeout.get_events_failures = 0;popup_banners.close_connection_error_popup_banner("server_events");diff --git a/web/src/settings_account.ts b/web/src/settings_account.tsindex 80f1a8027c5..176d0581184 100644--- a/web/src/settings_account.ts+++ b/web/src/settings_account.ts@@ -616,7 +616,8 @@ export function set_up(): void {"Sorry for the trouble!",);return;- } else if (!password_quality(new_pw, undefined, $new_pw_field)) {+ }+ if (!password_quality(new_pw, undefined, $new_pw_field)) {settings_change_error($t_html({defaultMessage: "New password is too weak!"}));return;}diff --git a/web/src/settings_components.ts b/web/src/settings_components.tsindex 493df3e3260..2bfc496fcd7 100644--- a/web/src/settings_components.ts+++ b/web/src/settings_components.ts@@ -487,7 +487,8 @@ export function read_field_data_from_form(// Only the following field types support associated field data.if (field_type_id === field_types.DROPDOWN.id) {return read_custom_profile_field_choices_from_form($profile_field_form, old_field_data);- } else if (field_type_id === field_types.EXTERNAL_ACCOUNT.id) {+ }+ if (field_type_id === field_types.EXTERNAL_ACCOUNT.id) {const parsed_old_field_data = old_field_data? external_account_field_schema.parse(old_field_data): undefined;@@ -787,7 +788,8 @@ export function set_input_element_value(assert(typeof value === "boolean");$input_elem.prop("checked", value);return;- } else if (input_type === "string" || input_type === "number") {+ }+ if (input_type === "string" || input_type === "number") {assert(typeof value !== "boolean");$input_elem.val(value);return;diff --git a/web/src/settings_exports.ts b/web/src/settings_exports.tsindex c50b90c6776..4ea12828f7e 100644--- a/web/src/settings_exports.ts+++ b/web/src/settings_exports.ts@@ -84,7 +84,8 @@ function sort_user(a: RealmExport, b: RealmExport): number {const b_name = people.get_full_name(b.acting_user_id).toLowerCase();if (a_name > b_name) {return 1;- } else if (a_name === b_name) {+ }+ if (a_name === b_name) {return 0;}return -1;@@ -166,7 +167,8 @@ function sort_user_by_name(a: ExportConsent, b: ExportConsent): number {const b_name = people.get_full_name(b.user_id).toLowerCase();if (a_name > b_name) {return 1;- } else if (a_name === b_name) {+ }+ if (a_name === b_name) {return 0;}return -1;diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.tsindex 7ad7ccd0f1d..91c68d04a23 100644--- a/web/src/stream_edit.ts+++ b/web/src/stream_edit.ts@@ -652,7 +652,8 @@ function show_stream_email_address_modal(address: string, sub: StreamSubscriptiofunction update_option_label(sender: User | CurrentUser | Bot): string {if (sender.user_id === people.EMAIL_GATEWAY_BOT.user_id) {return "Email Gateway bot";- } else if (sender.user_id === current_user.user_id) {+ }+ if (sender.user_id === current_user.user_id) {return $t({defaultMessage: "You"});}return sender.full_name;diff --git a/web/src/stream_list.ts b/web/src/stream_list.tsindex 181434f059f..cc62bc696c7 100644--- a/web/src/stream_list.ts+++ b/web/src/stream_list.ts@@ -355,7 +355,8 @@ export function rewire_stream_list_section_container_html(function get_section_channel_plus_icon_url(section: StreamListSection): string | undefined {if (section.folder_id !== null) {return `#channels/folders/${section.folder_id}/new`;- } else if (section.id === "normal-streams") {+ }+ if (section.id === "normal-streams") {return "#channels/new";}return undefined;diff --git a/web/src/stream_popover.ts b/web/src/stream_popover.tsindex 02e23d992cb..d905a93bd0e 100644--- a/web/src/stream_popover.ts+++ b/web/src/stream_popover.ts@@ -314,7 +314,8 @@ async function get_message_placement_in_conversation(message_lists.current.data.first()?.id === current_message_id) {return "first";- } else if (+ }+ if (message_lists.current.data.fetch_status.has_found_newest() &&message_lists.current.data.last()?.id === current_message_id) {diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.tsindex 4bdc8387a36..91d6ac6eb6d 100644--- a/web/src/stream_settings_ui.ts+++ b/web/src/stream_settings_ui.ts@@ -1250,13 +1250,15 @@ export function switch_rows(event: string): boolean {if (hash_parser.is_create_new_stream_narrow()) {// Prevent switching stream rows when creating a new streamreturn false;- } else if (+ }+ if (hash_parser.is_subscribers_section_opened_for_stream() &&$add_subscriber_pill_input.is(":focus")) {// Prevent switching stream rows when adding a subscriberreturn false;- } else if (!active_data.id || active_data.$row.hasClass("notdisplayed")) {+ }+ if (!active_data.id || active_data.$row.hasClass("notdisplayed")) {$switch_row = $("div.stream-row:not(.notdisplayed)").first();if ($("#search_stream_name").is(":focus")) {$("#search_stream_name").trigger("blur");diff --git a/web/src/thumbnail.ts b/web/src/thumbnail.tsindex 3a064eec83b..3296613be97 100644--- a/web/src/thumbnail.ts+++ b/web/src/thumbnail.ts@@ -29,7 +29,8 @@ export function initialize(): void {const sorted_formats = realm.server_thumbnail_formats.toSorted((a, b) => {if (a.max_width !== b.max_width) {return Math.abs(a.max_width - 840) < Math.abs(b.max_width - 840) ? -1 : 1;- } else if (a.format !== b.format) {+ }+ if (a.format !== b.format) {let a_index = format_preferences.indexOf(a.format);if (a_index === -1) {a_index = format_preferences.length;diff --git a/web/src/timerender.ts b/web/src/timerender.tsindex 19f43664302..54170b71ec4 100644--- a/web/src/timerender.ts+++ b/web/src/timerender.ts@@ -275,11 +275,8 @@ export function relative_time_string_from_date(date: Date, use_minutes_short_forif (days_old < 90) {return $t({defaultMessage: "{days_old} days ago"}, {days_old});- } else if (- days_old > 90 &&- days_old < 365 &&- date.getFullYear() === current_date.getFullYear()- ) {+ }+ if (days_old > 90 && days_old < 365 && date.getFullYear() === current_date.getFullYear()) {// Online more than 90 days ago, in the same yearreturn get_localized_date_or_time_for_format(date, "dayofyear");}@@ -317,7 +314,8 @@ export function last_seen_status_from_date(last_active_date: Date): string {if (days_old < 90) {return $t({defaultMessage: "Active {days_old} days ago"}, {days_old});- } else if (+ }+ if (days_old > 90 &&days_old < 365 &&last_active_date.getFullYear() === current_date.getFullYear()@@ -500,13 +498,17 @@ export function format_time_modern(time: number | Date, today = new Date()): strif (time > today) {/* For timestamps in the future, we always show the year*/return get_localized_date_or_time_for_format(time, "dayofyear_year");- } else if (hours < 24) {+ }+ if (hours < 24) {return stringify_time(time);- } else if (days_old === 1) {+ }+ if (days_old === 1) {return $t({defaultMessage: "Yesterday"});- } else if (days_old < 7) {+ }+ if (days_old < 7) {return get_localized_date_or_time_for_format(time, "weekday");- } else if (days_old <= 180) {+ }+ if (days_old <= 180) {return get_localized_date_or_time_for_format(time, "dayofyear");}diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.tsindex 58ef806a176..9117210c06c 100644--- a/web/src/tippyjs.ts+++ b/web/src/tippyjs.ts@@ -611,13 +611,16 @@ export function initialize(): void {if ($(instance.reference).closest("span").hasClass("deactivate-user-tooltip")) {instance.setContent($t({defaultMessage: "Deactivate user"}));return undefined;- } else if ($(instance.reference).closest("span").hasClass("reactivate-user-tooltip")) {+ }+ if ($(instance.reference).closest("span").hasClass("reactivate-user-tooltip")) {instance.setContent($t({defaultMessage: "Reactivate user"}));return undefined;- } else if ($(instance.reference).closest("span").hasClass("deactivate-bot-tooltip")) {+ }+ if ($(instance.reference).closest("span").hasClass("deactivate-bot-tooltip")) {instance.setContent($t({defaultMessage: "Deactivate bot"}));return undefined;- } else if ($(instance.reference).closest("span").hasClass("reactivate-bot-tooltip")) {+ }+ if ($(instance.reference).closest("span").hasClass("reactivate-bot-tooltip")) {instance.setContent($t({defaultMessage: "Reactivate bot"}));return undefined;}diff --git a/web/src/topic_generator.ts b/web/src/topic_generator.tsindex 68363ceee50..521a4489db5 100644--- a/web/src/topic_generator.ts+++ b/web/src/topic_generator.ts@@ -158,7 +158,8 @@ export function get_next_topic(/* istanbul ignore next */return topics.filter((topic) => !user_topics.is_topic_muted(stream_id, topic));- } else if (stream_data.is_muted(stream_id)) {+ }+ if (stream_data.is_muted(stream_id)) {return topics.filter((topic) =>user_topics.is_topic_unmuted_or_followed(stream_id, topic),);diff --git a/web/src/typeahead_helper.ts b/web/src/typeahead_helper.tsindex 2a146a4b81d..99214005866 100644--- a/web/src/typeahead_helper.ts+++ b/web/src/typeahead_helper.ts@@ -302,7 +302,8 @@ export function compare_users_for_dms(user_a: User, user_b: User, query = ""): nif (a_message_id !== undefined && b_message_id !== undefined) {if (a_message_id > b_message_id) {return -1;- } else if (a_message_id < b_message_id) {+ }+ if (a_message_id < b_message_id) {return 1;}} else if (a_message_id !== undefined) {@@ -472,9 +473,11 @@ function compare_language_by_popularity(lang_a: string, lang_b: string): number// languages seem sensible.if (!lang_a_data && !lang_b_data) {return 0; // Neither have popularity, so they tie.- } else if (!lang_a_data) {+ }+ if (!lang_a_data) {return 1; // lang_a doesn't have popularity, so sort a after b.- } else if (!lang_b_data) {+ }+ if (!lang_b_data) {return -1; // lang_b doesn't have popularity, so sort a before b.}@@ -1016,7 +1019,8 @@ function slash_command_comparator(): number {if (slash_command_a.name < slash_command_b.name) {return -1;- } else if (slash_command_a.name > slash_command_b.name) {+ }+ if (slash_command_a.name > slash_command_b.name) {return 1;}/* istanbul ignore next */diff --git a/web/src/typing_status.ts b/web/src/typing_status.tsindex 4c3232dd840..2d1ecd6f6d8 100644--- a/web/src/typing_status.ts+++ b/web/src/typing_status.ts@@ -56,7 +56,8 @@ function same_recipient(a: Recipient | null, b: Recipient | null): boolean {if (a.message_type === "direct" && b.message_type === "direct") {// direct message recipientsreturn _.isEqual(a.ids, b.ids);- } else if (a.message_type === "stream" && b.message_type === "stream") {+ }+ if (a.message_type === "stream" && b.message_type === "stream") {// stream recipientsreturn same_stream_and_topic(a, b);}diff --git a/web/src/unread_ops.ts b/web/src/unread_ops.tsindex 953843cd3d2..5bdc699c439 100644--- a/web/src/unread_ops.ts+++ b/web/src/unread_ops.ts@@ -423,7 +423,8 @@ export function mark_as_unread_from_here(message_id: number): void {do_mark_unread(undefined);}return;- } else if (prefer_local_ids) {+ }+ if (prefer_local_ids) {// Since we have the anchor message ID and the newest// messages, we know exactly which messages to mark as unread.if (locally_available_matching_message_ids.length < MIN_MARK_AS_UNREAD_COUNT_KNOWN) {diff --git a/web/src/user_status_ui.ts b/web/src/user_status_ui.tsindex 20e15052d07..c43f372bddc 100644--- a/web/src/user_status_ui.ts+++ b/web/src/user_status_ui.ts@@ -119,7 +119,8 @@ function emoji_status_fields_changed(): boolean {if (old_emoji_info === undefined && Object.keys(selected_emoji_info).length === 0) {return false;- } else if (+ }+ if (old_emoji_info !== undefined &&old_emoji_info.emoji_name === selected_emoji_info.emoji_name &&old_emoji_info.reaction_type === selected_emoji_info.reaction_type &&diff --git a/web/src/util.ts b/web/src/util.tsindex 94d7d12b87f..7e19fc18f8b 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -88,7 +88,8 @@ export const same_recipient = function util_same_recipient(a?: Recipient, b?: Rereturn false;}return a.to_user_ids === b.to_user_ids;- } else if (a.type === "stream" && b.type === "stream") {+ }+ if (a.type === "stream" && b.type === "stream") {return same_stream_and_topic(a, b);}@@ -523,7 +524,8 @@ export function the<T>(items: T[] | JQuery<T>): T {export function compare_a_b<T>(a: T, b: T): number {if (a > b) {return 1;- } else if (a === b) {+ }+ if (a === b) {return 0;}return -1;diff --git a/web/tests/lib/markdown_assert.cjs b/web/tests/lib/markdown_assert.cjsindex 17127d019af..3e4a7a66756 100644--- a/web/tests/lib/markdown_assert.cjs+++ b/web/tests/lib/markdown_assert.cjs@@ -87,7 +87,8 @@ class MarkdownComparer {const name_b = b.name;if (name_a < name_b) {return -1;- } else if (name_a > name_b) {+ }+ if (name_a > name_b) {return 1;}/* istanbul ignore next */diff --git a/web/tests/lib/namespace.cjs b/web/tests/lib/namespace.cjsindex c31504d4808..29e7bcbb9a1 100644--- a/web/tests/lib/namespace.cjs+++ b/web/tests/lib/namespace.cjs@@ -30,10 +30,12 @@ function load(request, parent, isMain) {if (module_mocks.has(filename)) {used_module_mocks.add(filename);return module_mocks.get(filename);- } else if (filename.endsWith(".hbs") && filename.startsWith(template_path + path.sep)) {+ }+ if (filename.endsWith(".hbs") && filename.startsWith(template_path + path.sep)) {const actual_render = actual_load(request, parent, isMain);return template_stub({filename, actual_render});- } else if (filename === jquery_path) {+ }+ if (filename === jquery_path) {return {$: jquery_function ?? $};}diff --git a/web/tests/people.test.cjs b/web/tests/people.test.cjsindex bc7b796cf19..11f86982cbc 100644--- a/web/tests/people.test.cjs+++ b/web/tests/people.test.cjs@@ -1937,7 +1937,8 @@ run_test("fetch_users corner case", async ({override, override_rewire}) => {msg: "",});return;- } else if (data.user_ids === "[1,2]") {+ }+ if (data.user_ids === "[1,2]") {if (!sent_success_response_for_third_user) {error({responseJSON: {msg: "Network error"}});return;diff --git a/web/tests/pill_typeahead.test.cjs b/web/tests/pill_typeahead.test.cjsindex 4ba45fe6cc8..0ca448a8a89 100644--- a/web/tests/pill_typeahead.test.cjs+++ b/web/tests/pill_typeahead.test.cjs@@ -45,7 +45,8 @@ function override_typeahead_helper({mock_template, override_rewire}) {mock_template("typeahead_list_item.hbs", false, (args) => {if (args.stream) {return "<rendered-stream-stub>";- } else if (args.is_user_group) {+ }+ if (args.is_user_group) {return "<rendered-group-stub>";}assert.ok(args.is_person);diff --git a/web/tests/recent_view.test.cjs b/web/tests/recent_view.test.cjsindex bfb7dad9018..e53fccb7c22 100644--- a/web/tests/recent_view.test.cjs+++ b/web/tests/recent_view.test.cjs@@ -132,9 +132,11 @@ mock_esm("../src/user_topics", {get_topic_visibility_policy(stream_id, topic) {if (stream_id === stream1 && topic === topic7) {return all_visibility_policies.MUTED;- } else if (stream_id === stream6 && topic === topic11) {+ }+ if (stream_id === stream6 && topic === topic11) {return all_visibility_policies.UNMUTED;- } else if (stream_id === stream6 && topic === topic12) {+ }+ if (stream_id === stream6 && topic === topic12) {return all_visibility_policies.FOLLOWED;}return all_visibility_policies.INHERIT;