Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix unicorn/prefer-direct-iteration.

Anders Kaseorg8e7f942d6132
diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.ts
index dc1ec819d83..904962a7f63 100644
--- a/web/src/attachments_ui.ts
+++ b/web/src/attachments_ui.ts
@@ -268,7 +268,7 @@ export function suggest_delete_detached_attachments(attachments_list: ServerAtta
function do_delete_attachments(): void {
dialog_widget.show_dialog_spinner();
- for (const [id, attachment] of attachments_map.entries()) {
+ for (const [id, attachment] of attachments_map) {
void channel.del({
url: "/json/attachments/" + attachment.id,
success() {
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index 95a8cfccf3b..6f207415ecd 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -273,10 +273,7 @@ function save_data_to_ls(): void {
ls.set(ls_filter_key, [...filters]);
ls.set(
ls_per_channel_filters_key,
- [...per_channel_filters.entries()].map(([channel_id, filter_set]) => [
- channel_id,
- [...filter_set],
- ]),
+ [...per_channel_filters].map(([channel_id, filter_set]) => [channel_id, [...filter_set]]),
);
ls.set(ls_collapsed_containers_key, [...collapsed_containers]);
}
@@ -2204,7 +2201,7 @@ export function update_internal(): void {
}
}
- for (const [folder_id, folder_info] of folders_info.entries()) {
+ for (const [folder_id, folder_info] of folders_info) {
const folder_dict = channel_folders_dict.get(folder_id);
const name = get_folder_name_from_id(folder_id);
const is_collapsed = collapsed_containers.has(get_channel_folder_header_id(folder_id));
diff --git a/web/src/message_list_data_cache.ts b/web/src/message_list_data_cache.ts
index f46fffe6635..a7eb3ef9526 100644
--- a/web/src/message_list_data_cache.ts
+++ b/web/src/message_list_data_cache.ts
@@ -29,7 +29,7 @@ function move_to_end(key: number, cached_data: MessageListData): void {
}
export function get(filter: Filter): MessageListData | undefined {
- for (const [key, cached_data] of cache.entries()) {
+ for (const [key, cached_data] of cache) {
if (cached_data.filter.equals(filter)) {
move_to_end(key, cached_data);
return cached_data;
@@ -39,7 +39,7 @@ export function get(filter: Filter): MessageListData | undefined {
}
export function add(message_list_data: MessageListData): void {
- for (const [key, cached_data] of cache.entries()) {
+ for (const [key, cached_data] of cache) {
if (cached_data.filter.equals(message_list_data.filter)) {
// We could chose to maintain in the cache the
// message_list_data passed in, or the one already in the
@@ -56,7 +56,7 @@ export function add(message_list_data: MessageListData): void {
if (cache.size >= CACHE_STORAGE_LIMIT) {
// Remove the oldest item from the cache.
- for (const [key, cached_data] of cache.entries()) {
+ for (const [key, cached_data] of cache) {
// We never want to remove the recent_view_messages_data from the cache.
if (
cached_data.filter.equals(
@@ -96,7 +96,7 @@ export function get_superset_datasets(filter: Filter): MessageListData[] {
}
export function remove(filter: Filter): void {
- for (const [key, cached_data] of cache.entries()) {
+ for (const [key, cached_data] of cache) {
if (cached_data.filter.equals(filter)) {
cache.delete(key);
return;
diff --git a/web/src/narrow_banner.ts b/web/src/narrow_banner.ts
index b032bb234dc..190727cb897 100644
--- a/web/src/narrow_banner.ts
+++ b/web/src/narrow_banner.ts
@@ -560,7 +560,7 @@ export function pick_empty_narrow_banner(
};
}
const valid_people_in_dms: people.User[] = [];
- for (const user of people_in_dms.values()) {
+ for (const user of people_in_dms) {
if (user === undefined) {
return {
// We don't pinpoint which user is invalid,
diff --git a/web/src/portico/hello.ts b/web/src/portico/hello.ts
index 6646e4656d5..00cbfc44532 100644
--- a/web/src/portico/hello.ts
+++ b/web/src/portico/hello.ts
@@ -47,9 +47,7 @@ function update_client_logo(): void {
const current_logo_class = client_logo_elt.className;
current_client_logo_class_names.delete(current_logo_class);
- const next_logo_class = get_random_item_from_array([
- ...future_client_logo_class_names.values(),
- ]);
+ const next_logo_class = get_random_item_from_array([...future_client_logo_class_names]);
future_client_logo_class_names.delete(next_logo_class);
client_logo_elt.className = next_logo_class;
current_client_logo_class_names.add(next_logo_class);
diff --git a/web/src/presence.ts b/web/src/presence.ts
index f5101fb0ae8..c832d48b854 100644
--- a/web/src/presence.ts
+++ b/web/src/presence.ts
@@ -84,7 +84,7 @@ export function get_user_ids(): number[] {
}
export function get_active_or_idle_user_ids(): number[] {
- return [...presence_info.entries()]
+ return [...presence_info]
.filter((entry) => entry[1].status !== "offline")
.map((entry) => entry[0]);
}
diff --git a/web/src/reactions.ts b/web/src/reactions.ts
index 3803bbdfe8b..c3bb5422b01 100644
--- a/web/src/reactions.ts
+++ b/web/src/reactions.ts
@@ -726,7 +726,7 @@ export let update_vote_text_on_message = (message: Message): void => {
update_clean_reactions(message);
const reaction_counts_and_user_ids = get_reaction_counts_and_user_ids(message);
const should_display_reactors = check_should_display_reactors(reaction_counts_and_user_ids);
- for (const [reaction, clean_reaction] of message.clean_reactions.entries()) {
+ for (const [reaction, clean_reaction] of message.clean_reactions) {
const reaction_elem = find_reaction(message.id, clean_reaction.local_id);
const vote_text = get_vote_text(clean_reaction.user_ids, should_display_reactors);
const message_clean_reaction = message.clean_reactions.get(reaction);
diff --git a/web/src/recent_senders.ts b/web/src/recent_senders.ts
index de3539af309..00f031f5955 100644
--- a/web/src/recent_senders.ts
+++ b/web/src/recent_senders.ts
@@ -241,7 +241,7 @@ export function get_topic_recent_senders(stream_id: number, topic: string): numb
return list2.max_id() - list1.max_id();
}
- const sorted_senders = [...sender_dict.entries()];
+ const sorted_senders = [...sender_dict];
sorted_senders.sort(by_max_message_id);
return Array.from(sorted_senders, (item) => item[0]);
}
diff --git a/web/src/recent_view_data.ts b/web/src/recent_view_data.ts
index b9e969c75c8..a2c37b61051 100644
--- a/web/src/recent_view_data.ts
+++ b/web/src/recent_view_data.ts
@@ -55,9 +55,7 @@ export function process_message(msg: Message): boolean {
function get_sorted_conversations(): Map<string | undefined, ConversationData> {
// Sort all recent conversations by last message time.
- return new Map(
- [...conversations.entries()].toSorted((a, b) => b[1].last_msg_id - a[1].last_msg_id),
- );
+ return new Map([...conversations].toSorted((a, b) => b[1].last_msg_id - a[1].last_msg_id));
}
export function get_conversations(): Map<string | undefined, ConversationData> {
diff --git a/web/src/settings_exports.ts b/web/src/settings_exports.ts
index 4ea12828f7e..e8388293017 100644
--- a/web/src/settings_exports.ts
+++ b/web/src/settings_exports.ts
@@ -194,7 +194,7 @@ const filter_by_consent_options: Option[] = [
function get_export_consents_having_consent_value(consent: boolean): ExportConsent[] {
const export_consent_list: ExportConsent[] = [];
- for (const [user_id, user_consent_info] of export_consents.entries()) {
+ for (const [user_id, user_consent_info] of export_consents) {
const consented = user_consent_info.consented;
const email_address_visibility = user_consent_info.email_address_visibility;
if (consent === user_consent_info.consented) {
@@ -212,7 +212,7 @@ function get_export_consents_having_email_visibility_value(
email_address_visibility_code: number,
): ExportConsent[] {
const export_consent_list: ExportConsent[] = [];
- for (const [user_id, user_consent_info] of export_consents.entries()) {
+ for (const [user_id, user_consent_info] of export_consents) {
const consented = user_consent_info.consented;
const email_address_visibility = user_consent_info.email_address_visibility;
if (email_address_visibility_code === email_address_visibility) {
diff --git a/web/src/stream_list.ts b/web/src/stream_list.ts
index cc62bc696c7..4f9d773e3b1 100644
--- a/web/src/stream_list.ts
+++ b/web/src/stream_list.ts
@@ -1008,7 +1008,7 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
hidden_muted: 0,
};
- for (const [stream_id, stream_count_info] of counts.stream_count.entries()) {
+ for (const [stream_id, stream_count_info] of counts.stream_count) {
const sub = sub_store.get(stream_id);
assert(sub);
if (sub.pin_to_top) {
diff --git a/web/src/stream_topic_history.ts b/web/src/stream_topic_history.ts
index 92adce2f27c..ffa178ad7b3 100644
--- a/web/src/stream_topic_history.ts
+++ b/web/src/stream_topic_history.ts
@@ -238,7 +238,7 @@ export class PerStreamHistory {
// This data source is locally echoed messages, which should
// are treated as newer than all delivered messages.
const local_echo_topics = [
- ...echo_state.get_waiting_for_ack_local_ids_by_topic(this.stream_id).entries(),
+ ...echo_state.get_waiting_for_ack_local_ids_by_topic(this.stream_id),
].map(([topic, local_id]) => ({pretty_name: topic, message_id: local_id}));
const local_echo_set = new Set<string>(
local_echo_topics.map((message_topic) => message_topic.pretty_name.toLowerCase()),
diff --git a/web/src/typing_data.ts b/web/src/typing_data.ts
index ea4dd5b626a..cc2e03e675f 100644
--- a/web/src/typing_data.ts
+++ b/web/src/typing_data.ts
@@ -66,7 +66,7 @@ export function get_topic_typists(stream_id: number, topic: string): number[] {
}
export function clear_typing_data(): void {
- for (const [, timer] of inbound_timer_dict.entries()) {
+ for (const [, timer] of inbound_timer_dict) {
clearTimeout(timer);
}
inbound_timer_dict.clear();
diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjs
index 7707927feb0..95602217303 100644
--- a/web/tests/composebox_typeahead.test.cjs
+++ b/web/tests/composebox_typeahead.test.cjs
@@ -366,12 +366,12 @@ const light_command = {
const light_command_item = slash_item(light_command);
const name_to_codepoint = {};
-for (const [key, val] of emojis_by_name.entries()) {
+for (const [key, val] of emojis_by_name) {
name_to_codepoint[key] = val.emoji_code;
}
const codepoint_to_name = {};
-for (const [key, val] of emojis_by_name.entries()) {
+for (const [key, val] of emojis_by_name) {
codepoint_to_name[val.emoji_code] = key;
}
@@ -389,7 +389,7 @@ emoji.initialize({
});
emoji.active_realm_emojis.clear();
emoji.emojis_by_name.clear();
-for (const [key, val] of emojis_by_name.entries()) {
+for (const [key, val] of emojis_by_name) {
emoji.emojis_by_name.set(key, val);
}
typeahead.set_frequently_used_emojis(
diff --git a/web/tests/markdown_parse.test.cjs b/web/tests/markdown_parse.test.cjs
index 3d85310e0ac..65b162138a0 100644
--- a/web/tests/markdown_parse.test.cjs
+++ b/web/tests/markdown_parse.test.cjs
@@ -23,7 +23,7 @@ function get_actual_name_from_user_id(user_id) {
}
function get_user_id_from_name(name) {
- for (const [user_id, _name] of user_map.entries()) {
+ for (const [user_id, _name] of user_map) {
if (name === _name) {
return user_id;
}
@@ -98,7 +98,7 @@ function get_emoji_codepoint(emoji_name) {
}
function get_emoji_name(codepoint) {
- for (const [emoji_name, _codepoint] of emoji_map.entries()) {
+ for (const [emoji_name, _codepoint] of emoji_map) {
if (codepoint === _codepoint) {
return emoji_name;
}