Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/prefer-logical-operator-over-ternary.
Anders Kaseorg95bdfcaa1b6a
diff --git a/web/debug-require-webpack-plugin.ts b/web/debug-require-webpack-plugin.tsindex 2ddd2cc70a2..2a24beaa641 100644--- a/web/debug-require-webpack-plugin.ts+++ b/web/debug-require-webpack-plugin.ts@@ -62,8 +62,8 @@ export default class DebugRequirePlugin implements webpack.WebpackPluginInstanceimport.meta.dirname,"./debug-require.cjs",{},- (err?: Error | null, result?: string | false) => {- resolve(err ? false : result!);+ (err, result) => {+ resolve(err === null && result!);},);});diff --git a/web/src/buddy_list.ts b/web/src/buddy_list.tsindex 1316e65c882..31b1e51d9be 100644--- a/web/src/buddy_list.ts+++ b/web/src/buddy_list.ts@@ -424,7 +424,7 @@ export class BuddyList extends BuddyListConf {// the user specified otherwise.this.set_section_collapse("#buddy-list-other-users-container",- this.render_data.hide_headers ? false : this.other_users_section.is_collapsed,+ !this.render_data.hide_headers && this.other_users_section.is_collapsed,);}diff --git a/web/src/compose_notifications.ts b/web/src/compose_notifications.tsindex 7161b320b51..6085d843722 100644--- a/web/src/compose_notifications.ts+++ b/web/src/compose_notifications.ts@@ -176,11 +176,8 @@ export function should_jump_to_sent_message_conversation(message: Message): boolreturn true;}- const current_filter = narrow_state.filter();- const is_conversation_view =- current_filter === undefined ? false : current_filter.is_conversation_view();const $row = message_lists.current.get_row(message.id);- if (is_conversation_view && $row.length > 0) {+ if (narrow_state.filter()?.is_conversation_view() && $row.length > 0) {// If our message is in the current conversation view, we do// not have a mix, so we are happy.return false;diff --git a/web/src/compose_send_menu_popover.ts b/web/src/compose_send_menu_popover.tsindex bf619822b64..8c6590dfab3 100644--- a/web/src/compose_send_menu_popover.ts+++ b/web/src/compose_send_menu_popover.ts@@ -57,7 +57,7 @@ export function open_schedule_message_menu(},onHide() {// onHide returning false prevents Tippy from closing the popover when flatpickr is open.- return flatpickr.is_open() ? false : undefined;+ return !flatpickr.is_open() && undefined;},onShow(instance) {// Only show send later options that are possible today.diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.tsindex c3fefb7fe30..850646ed4cb 100644--- a/web/src/compose_ui.ts+++ b/web/src/compose_ui.ts@@ -1299,9 +1299,8 @@ export let format_text = (text.slice(range.start - 1, range.start) === "[" &&text.slice(range.end, range.end + 2) === "](" &&text.includes(")", range.end + 2) &&- (text.includes("(", range.end + 2)- ? text.indexOf(")", range.end + 2) < text.indexOf("(", range.end + 2)- : true);+ (!text.includes("(", range.end + 2) ||+ text.indexOf(")", range.end + 2) < text.indexOf("(", range.end + 2));if (is_selection_description_of_link()) {let url = text.slice(range.end + 2, text.indexOf(")", range.end));diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.tsindex c4959f553ed..257602c5004 100644--- a/web/src/inbox_ui.ts+++ b/web/src/inbox_ui.ts@@ -493,9 +493,8 @@ function format_dm(const user_id = recipient_ids[0];const is_deactivated = !people.is_active_user_or_system_bot(user_id);is_bot = people.is_valid_bot_user(user_id);- user_circle_class = is_bot- ? false- : buddy_data.get_user_circle_class(recipient_ids[0], is_deactivated);+ user_circle_class =+ !is_bot && buddy_data.get_user_circle_class(recipient_ids[0], is_deactivated);}const has_unread_mention = unread.num_unread_mentions_for_user_ids_strings(user_ids_string) > 0;diff --git a/web/src/message_list.ts b/web/src/message_list.tsindex ecd98cde666..11355c5c1fc 100644--- a/web/src/message_list.ts+++ b/web/src/message_list.ts@@ -379,8 +379,6 @@ export class MessageList {* The user has "Automatically mark messages as read" optionturned on in their user settings.*/- const filter = this.data.filter;- const is_conversation_view = filter === undefined ? false : filter.is_conversation_view();return (this.data.can_mark_messages_read() &&!this.reading_prevented &&@@ -388,7 +386,7 @@ export class MessageList {web_mark_read_on_scroll_policy_values.never.code &&(user_settings.web_mark_read_on_scroll_policy !==web_mark_read_on_scroll_policy_values.conversation_only.code ||- is_conversation_view)+ this.data.filter.is_conversation_view()));}diff --git a/web/src/scheduled_messages_feed_ui.ts b/web/src/scheduled_messages_feed_ui.tsindex 1235cd74dbc..51434bdd033 100644--- a/web/src/scheduled_messages_feed_ui.ts+++ b/web/src/scheduled_messages_feed_ui.ts@@ -9,11 +9,9 @@ import * as util from "./util.ts";function get_scheduled_messages_matching_narrow(): ScheduledMessage[] {const scheduled_messages_list = scheduled_messages.get_all_scheduled_messages();- const filter = narrow_state.filter();- const is_conversation_view = filter === undefined ? false : filter.is_conversation_view();const current_view_type = narrow_state.narrowed_to_pms() ? "private" : "stream";- if (!is_conversation_view) {+ if (!narrow_state.filter()?.is_conversation_view()) {return [];}diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.tsindex 54af7d2c09e..8236ea87aa9 100644--- a/web/src/stream_edit.ts+++ b/web/src/stream_edit.ts@@ -312,9 +312,8 @@ export function stream_settings(sub: StreamSubscription): StreamSetting[] {return settings_labels.map(([setting, label]) => {const parsed_realm_setting = realm_labels_schema.safeParse(setting);- const realm_setting = parsed_realm_setting.success- ? check_realm_setting[parsed_realm_setting.data]- : false;+ const realm_setting =+ parsed_realm_setting.success && check_realm_setting[parsed_realm_setting.data];const notification_setting = notification_labels_schema.safeParse(setting);let is_checked;diff --git a/web/src/unread_ui.ts b/web/src/unread_ui.tsindex 5854a04e0a3..fd29fc7ec7d 100644--- a/web/src/unread_ui.ts+++ b/web/src/unread_ui.ts@@ -35,8 +35,6 @@ export function update_unread_banner(): void {return;}- const filter = narrow_state.filter();- const is_conversation_view = filter === undefined ? false : filter.is_conversation_view();toggle_dummy_banner(false);if (@@ -47,7 +45,7 @@ export function update_unread_banner(): void {} else if (user_settings.web_mark_read_on_scroll_policy ===web_mark_read_on_scroll_policy_values.conversation_only.code &&- !is_conversation_view+ !narrow_state.filter()?.is_conversation_view()) {set_mark_read_on_scroll_state_banner(render_mark_as_read_only_in_conversation_view());} else {diff --git a/web/tests/topic_list_data.test.cjs b/web/tests/topic_list_data.test.cjsindex 37fc303daa9..da387ee5395 100644--- a/web/tests/topic_list_data.test.cjs+++ b/web/tests/topic_list_data.test.cjs@@ -52,10 +52,8 @@ const general = make_stream({stream_data.add_sub_for_tests(general);-function get_list_info(zoom, search) {+function get_list_info(zoomed = false, search_term = "") {const stream_id = general.stream_id;- const zoomed = zoom === undefined ? false : zoom;- const search_term = search === undefined ? "" : search;return topic_list_data.get_list_info(stream_id, zoomed, (topics) =>topic_list_data.filter_topics_by_search_term(stream_id, topics, search_term),);