Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-for-loop.
Anders Kaseorgde791b82b6e5
diff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.jsindex f9d7a0918cf..f2dfa1343f8 100644--- a/frontend_tests/node_tests/common.js+++ b/frontend_tests/node_tests/common.js@@ -116,8 +116,8 @@ run_test("adjust_mac_shortcuts", () => {});$(".markdown_content").each = (f) => {- for (let key_id = 0; key_id < keys_elem_list.length; key_id += 1) {- f.call(keys_elem_list[key_id]);+ for (const key_elem of keys_elem_list) {+ f.call(key_elem);}};common.adjust_mac_shortcuts(".markdown_content");diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.jsindex c834e57df24..ff8db1f0208 100644--- a/frontend_tests/puppeteer_lib/common.js+++ b/frontend_tests/puppeteer_lib/common.js@@ -309,8 +309,8 @@ class CommonUtils {} else if (type === "private") {await page.keyboard.press("KeyX");const recipients = params.recipient.split(", ");- for (let i = 0; i < recipients.length; i += 1) {- await this.pm_recipient.set(page, recipients[i]);+ for (const recipient of recipients) {+ await this.pm_recipient.set(page, recipient);}delete params.recipient;} else {@@ -353,8 +353,7 @@ class CommonUtils {}async send_multiple_messages(page, msgs) {- for (let msg_index = 0; msg_index < msgs.length; msg_index += 1) {- const msg = msgs[msg_index];+ for (const msg of msgs) {await this.send_message(page, msg.stream !== undefined ? "stream" : "private", msg);}}diff --git a/static/js/floating_recipient_bar.js b/static/js/floating_recipient_bar.jsindex 2dd387a6449..a045a993176 100644--- a/static/js/floating_recipient_bar.js+++ b/static/js/floating_recipient_bar.js@@ -20,7 +20,7 @@ exports.first_visible_message = function (bar) {const frb_top = frb_bottom - 25;let result;- for (let i = 0; i < messages.length; i += 1) {+ for (const message_element of messages) {// The details of this comparison function are sensitive, since we're// balancing between three possible bugs://@@ -47,7 +47,7 @@ exports.first_visible_message = function (bar) {// message_viewport.scrollTop() to set precise scrolling// positions determines the value for date_bar_height_offset.- let message = $(messages[i]);+ let message = $(message_element);const message_bottom = top_offset(message) + message.safeOuterHeight();const date_bar_height_offset = 10;diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.jsindex 4ec47535e73..f87b2337857 100644--- a/static/js/portico/integrations.js+++ b/static/js/portico/integrations.js@@ -328,8 +328,8 @@ function integration_events() {$('#integration-search input[type="text"]').on("keypress", (e) => {const integrations = $(".integration-lozenges").children().toArray();if (e.which === 13 && e.target.value !== "") {- for (let i = 0; i < integrations.length; i += 1) {- const integration = $(integrations[i]).find(".integration-lozenge");+ for (const integration_element of integrations) {+ const integration = $(integration_element).find(".integration-lozenge");if ($(integration).css("display") !== "none") {$(integration).closest("a")[0].click();diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.jsindex 2518be4fae5..d1c1a1bbc71 100644--- a/static/js/settings_profile_fields.js+++ b/static/js/settings_profile_fields.js@@ -215,15 +215,7 @@ function get_profile_field_info(id) {}function get_profile_field(id) {- const all_custom_fields = page_params.custom_profile_fields;- let field;- for (let i = 0; i < all_custom_fields.length; i += 1) {- if (all_custom_fields[i].id === id) {- field = all_custom_fields[i];- break;- }- }- return field;+ return page_params.custom_profile_fields.find((field) => field.id === id);}exports.parse_field_choices_from_field_data = function (field_data) {diff --git a/static/js/stats/stats.js b/static/js/stats/stats.jsindex 553fee7f57e..6371f324c02 100644--- a/static/js/stats/stats.js+++ b/static/js/stats/stats.js@@ -188,11 +188,11 @@ function populate_messages_sent_over_time(data) {});const hover_text_ids = ["#hover_me", "#hover_human", "#hover_bot"];const hover_value_ids = ["#hover_me_value", "#hover_human_value", "#hover_bot_value"];- for (let i = 0; i < values.length; i += 1) {- if (values[i] !== null) {+ for (const [i, value] of values.entries()) {+ if (value !== null) {document.querySelector(hover_text_ids[i]).style.display = "inline";document.querySelector(hover_value_ids[i]).style.display = "inline";- document.querySelector(hover_value_ids[i]).textContent = values[i];+ document.querySelector(hover_value_ids[i]).textContent = value;} else {document.querySelector(hover_text_ids[i]).style.display = "none";document.querySelector(hover_value_ids[i]).style.display = "none";@@ -737,10 +737,10 @@ function populate_number_of_users(data) {"#users_hover_15day_value","#users_hover_all_time_value",];- for (let i = 0; i < values.length; i += 1) {- if (values[i] !== null) {+ for (const [i, value] of values.entries()) {+ if (value !== null) {document.querySelector(hover_value_ids[i]).style.display = "inline";- document.querySelector(hover_value_ids[i]).textContent = values[i];+ document.querySelector(hover_value_ids[i]).textContent = value;} else {document.querySelector(hover_value_ids[i]).style.display = "none";}@@ -867,11 +867,11 @@ function populate_messages_read_over_time(data) {});const read_hover_text_ids = ["#read_hover_me", "#read_hover_everyone"];const read_hover_value_ids = ["#read_hover_me_value", "#read_hover_everyone_value"];- for (let i = 0; i < values.length; i += 1) {- if (values[i] !== null) {+ for (const [i, value] of values.entries()) {+ if (value !== null) {document.querySelector(read_hover_text_ids[i]).style.display = "inline";document.querySelector(read_hover_value_ids[i]).style.display = "inline";- document.querySelector(read_hover_value_ids[i]).textContent = values[i];+ document.querySelector(read_hover_value_ids[i]).textContent = value;} else {document.querySelector(read_hover_text_ids[i]).style.display = "none";document.querySelector(read_hover_value_ids[i]).style.display = "none";