Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/prefer-smaller-scope.
Anders Kaseorg9124c0819831
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.tsindex 97e41c95fe8..c63f4cee703 100644--- a/web/src/composebox_typeahead.ts+++ b/web/src/composebox_typeahead.ts@@ -724,7 +724,6 @@ export function get_person_suggestion_for_topic_typeahead(query: string): UserPilet filtered_persons;let participants_people;- let dm_people;if (current_narrow_participant_ids) {// Check DM permissions for the user suggestion only, since we@@ -745,7 +744,7 @@ export function get_person_suggestion_for_topic_typeahead(query: string): UserPi}if (!(filtered_persons && filtered_persons?.length >= 3)) {- dm_people = util.try_parse_as_truthy(+ const dm_people = util.try_parse_as_truthy(pm_conversations.get_partners().filter(diff --git a/web/src/copy_messages.ts b/web/src/copy_messages.tsindex 051cb5bda98..3eb91678653 100644--- a/web/src/copy_messages.ts+++ b/web/src/copy_messages.ts@@ -604,26 +604,20 @@ export function analyze_selection(selection: Selection): {// full content.let i;- let range;const ranges = [];- let $startc;- let $endc;- let $initial_end_tr;let start_id;let end_id;- let start_data;- let end_data;// skip_same_td_check is true whenever we know for a fact that the// selection covers multiple messages (and thus we should no// longer consider letting the browser handle the copy event).let skip_same_td_check = false;for (i = 0; i < selection.rangeCount; i += 1) {- range = selection.getRangeAt(i);+ const range = selection.getRangeAt(i);ranges.push(range);- $startc = $(range.startContainer);- start_data = find_boundary_tr(+ const $startc = $(range.startContainer);+ const start_data = find_boundary_tr($startc.parents(".selectable_row, .message_header").not(".overlay-message-header")@@ -638,9 +632,9 @@ export function analyze_selection(selection: Selection): {// touched by the selection.start_id ??= start_data[0];- $endc = $(range.endContainer);- $initial_end_tr = get_end_tr_from_endc($endc);- end_data = find_boundary_tr($initial_end_tr, ($row) => $row.prev());+ const $endc = $(range.endContainer);+ const $initial_end_tr = get_end_tr_from_endc($endc);+ const end_data = find_boundary_tr($initial_end_tr, ($row) => $row.prev());if (end_data === undefined) {// Skip any selection sections that don't intersect a message.diff --git a/web/src/message_list_view.ts b/web/src/message_list_view.tsindex fe8f6936463..7a451f7c728 100644--- a/web/src/message_list_view.ts+++ b/web/src/message_list_view.ts@@ -1390,8 +1390,6 @@ export class MessageListView {const new_dom_elements = [];let $rendered_groups;let $dom_messages;- let $last_message_row;- let $last_group_row;for (const message_container of message_containers) {this.set_edited_notice_locations(message_container);@@ -1444,8 +1442,8 @@ export class MessageListView {// Insert new messages in to the last message groupif (message_actions.append_messages.length > 0) {- $last_message_row = this.$list.find(".message_row").last().expectOne();- $last_group_row = rows.get_message_recipient_row($last_message_row);+ const $last_message_row = this.$list.find(".message_row").last().expectOne();+ const $last_group_row = rows.get_message_recipient_row($last_message_row);$dom_messages = $(message_actions.append_messages.map((message_container) => this._get_message_template(message_container))diff --git a/web/src/message_notifications.ts b/web/src/message_notifications.tsindex 3810d990230..48f64ee2ebd 100644--- a/web/src/message_notifications.ts+++ b/web/src/message_notifications.ts@@ -113,8 +113,6 @@ function get_notification_title(): string {let title_prefix = message.sender_full_name;let title_suffix = "";- let other_recipients;- let other_recipients_translated;if (msg_count > 1) {title_prefix = $t(@@ -126,9 +124,9 @@ function get_notification_title(switch (message.type) {case "private":if (message.display_recipient.length > 2) {- other_recipients = remove_sender_from_list_of_recipients(message);+ const other_recipients = remove_sender_from_list_of_recipients(message);// Same as compose_ui.compute_placeholder_text.- other_recipients_translated = util.format_array_as_list(+ const other_recipients_translated = util.format_array_as_list(other_recipients.split(", "),"long","conjunction",diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.tsindex 164666549cd..b7891d17b27 100644--- a/web/src/narrow_state.ts+++ b/web/src/narrow_state.ts@@ -258,9 +258,6 @@ export let _possible_unread_message_ids = (message_list_filter: Filter): number[// If we do return a result, it will be a subset of unread// message ids but possibly a superset of unread message ids// that match our filter.- let filter_stream_id: number | undefined;- let topic_name: string | undefined;- let filter_pm_string: string | undefined;// For the `with` operator, we can only correctly compute the// correct channel/topic for lookup unreads in if we either@@ -280,8 +277,8 @@ export let _possible_unread_message_ids = (message_list_filter: Filter): number[message_list_filter.can_bucket_by("channel", "topic", "with") ||message_list_filter.can_bucket_by("channel", "topic")) {- filter_stream_id = stream_id(message_list_filter, true);- topic_name = topic(message_list_filter);+ const filter_stream_id = stream_id(message_list_filter, true);+ const topic_name = topic(message_list_filter);if (filter_stream_id === undefined || topic_name === undefined) {return [];}@@ -289,7 +286,7 @@ export let _possible_unread_message_ids = (message_list_filter: Filter): number[}if (message_list_filter.can_bucket_by("channel")) {- filter_stream_id = stream_id(message_list_filter, true);+ const filter_stream_id = stream_id(message_list_filter, true);if (filter_stream_id === undefined) {return [];}@@ -300,7 +297,7 @@ export let _possible_unread_message_ids = (message_list_filter: Filter): number[message_list_filter.can_bucket_by("dm", "with") ||message_list_filter.can_bucket_by("dm")) {- filter_pm_string = pm_ids_string(message_list_filter);+ const filter_pm_string = pm_ids_string(message_list_filter);if (filter_pm_string === undefined) {return [];}diff --git a/web/src/util.ts b/web/src/util.tsindex 7e19fc18f8b..77b807fd20b 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -31,11 +31,9 @@ export function lower_bound<T1, T2>(const last = array.length;let len = last - first;- let middle;- let step;while (len > 0) {- step = Math.floor(len / 2);- middle = first + step;+ const step = Math.floor(len / 2);+ const middle = first + step;if (less(array[middle]!, value, middle)) {first = middle;first += 1;