Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-array-for-each.
Anders Kaseorg552f4e3d224f
diff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.jsindex 3bd1435315f..7074030b65b 100644--- a/frontend_tests/node_tests/common.js+++ b/frontend_tests/node_tests/common.js@@ -101,25 +101,25 @@ run_test("adjust_mac_shortcuts", () => {return false;};key_no = 1;- keys_to_test_non_mac.forEach((value, key) => {+ for (const [key, value] of keys_to_test_non_mac) {keys_elem_list.push(get_key_stub_html(key, value, "hotkey_non_mac_" + key_no));key_no += 1;- });+ }common.adjust_mac_shortcuts(".markdown_content");- keys_elem_list.forEach((key_elem) => {+ for (const key_elem of keys_elem_list) {assert(key_elem.text(), key_elem.expected_key());- });+ }keys_elem_list = [];key_no = 1;common.has_mac_keyboard = function () {return true;};- keys_to_test_mac.forEach((value, key) => {+ for (const [key, value] of keys_to_test_mac) {keys_elem_list.push(get_key_stub_html(key, value, "hotkey_" + key_no));key_no += 1;- });+ }$(".markdown_content").each = (f) => {for (const key_elem of keys_elem_list) {@@ -127,9 +127,9 @@ run_test("adjust_mac_shortcuts", () => {}};common.adjust_mac_shortcuts(".markdown_content");- keys_elem_list.forEach((key_elem) => {+ for (const key_elem of keys_elem_list) {assert.equal(key_elem.text(), key_elem.expected_key());- });+ }const markdown_hotkey_1 = get_key_stub_html("Ctrl + Backspace",diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.jsindex 7b23251cb4d..ad9c087da62 100644--- a/frontend_tests/node_tests/composebox_typeahead.js+++ b/frontend_tests/node_tests/composebox_typeahead.js@@ -1338,13 +1338,13 @@ run_test("begins_typeahead", () => {assert_typeahead_equals("```test", "ing", false);assert_typeahead_equals("~~~test", "ing", false);const terminal_symbols = ",.;?!()[]> \"'\n\t";- terminal_symbols.split().forEach((symbol) => {+ for (const symbol of terminal_symbols.split()) {assert_stream_list("#test", symbol);assert_typeahead_equals("@test", symbol, all_mentions);assert_typeahead_equals(":test", symbol, emoji_list);assert_typeahead_equals("```test", symbol, lang_list);assert_typeahead_equals("~~~test", symbol, lang_list);- });+ }});run_test("tokenizing", () => {diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.jsindex aabbae962b9..5a230b2e42e 100644--- a/frontend_tests/node_tests/filter.js+++ b/frontend_tests/node_tests/filter.js@@ -1481,9 +1481,9 @@ run_test("navbar_helpers", () => {},];- test_cases.forEach((test_case) => {+ for (const test_case of test_cases) {test_helpers(test_case);- });+ }// TODO: these may be removed, based on design decisionsconst sender_me = [{operator: "sender", operand: "me"}];@@ -1504,9 +1504,9 @@ run_test("navbar_helpers", () => {},];- redirect_edge_cases.forEach((test_case) => {+ for (const test_case of redirect_edge_cases) {test_redirect_url_with_search(test_case);- });+ }// TODO: test every single one of the "ALL" redirects from the navbar behaviour tablediff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.jsindex b5d5b5fa36d..d6660777963 100644--- a/frontend_tests/node_tests/markdown.js+++ b/frontend_tests/node_tests/markdown.js@@ -235,22 +235,22 @@ run_test("markdown_detection", () => {"YouTube URL https://www.youtube.com/watch?v=HHZ8iqswiCw&feature=youtu.be&a",];- no_markup.forEach((content) => {+ for (const content of no_markup) {assert.equal(markdown.contains_backend_only_syntax(content), false);- });+ }- markup.forEach((content) => {+ for (const content of markup) {assert.equal(markdown.contains_backend_only_syntax(content), true);- });+ }});run_test("marked_shared", () => {const tests = markdown_test_cases.regular_tests;- tests.forEach((test) => {+ for (const test of tests) {// Ignore tests if specifiedif (test.ignore === true) {- return;+ continue;}const message = {raw_content: test.input};@@ -266,7 +266,7 @@ run_test("marked_shared", () => {} else {markdown_assert.equal(test.expected_output, output, error_message);}- });+ }});run_test("message_flags", () => {@@ -531,7 +531,7 @@ run_test("marked", () => {},];- test_cases.forEach((test_case) => {+ for (const test_case of test_cases) {// Disable emoji conversion by default.page_params.translate_emoticons = test_case.translate_emoticons || false;@@ -542,7 +542,7 @@ run_test("marked", () => {markdown.apply_markdown(message);const output = message.content;assert.equal(output, expected);- });+ }});run_test("topic_links", () => {@@ -671,9 +671,9 @@ run_test("backend_only_realm_filters", () => {"Here is the PR-#123.","Function abc() was introduced in (PR)#123.",];- backend_only_realm_filters.forEach((content) => {+ for (const content of backend_only_realm_filters) {assert.equal(markdown.contains_backend_only_syntax(content), true);- });+ }});run_test("python_to_js_filter", () => {diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.jsindex 54b7714cae4..ec1a8c43632 100644--- a/frontend_tests/node_tests/message_store.js+++ b/frontend_tests/node_tests/message_store.js@@ -170,14 +170,14 @@ run_test("message_booleans_parity", () => {const update_message = {topic: "update_booleans"};message_store.set_message_booleans(set_message);message_store.update_booleans(update_message, flags);- Object.keys(expected_message).forEach((key) => {+ for (const key of Object.keys(expected_message)) {assert.equal(set_message[key],expected_message[key],`'${key}' != ${expected_message[key]}`,);assert.equal(update_message[key], expected_message[key]);- });+ }assert.equal(set_message.topic, "set_message_booleans");assert.equal(update_message.topic, "update_booleans");};diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.jsindex e5acec1efab..183acb9ae6c 100644--- a/frontend_tests/node_tests/rendered_markdown.js+++ b/frontend_tests/node_tests/rendered_markdown.js@@ -59,9 +59,9 @@ stream_data.add_sub(stream);const $array = (array) => {const each = (func) => {- array.forEach((e) => {+ for (const e of array) {func.call(e);- });+ }};return {each};};diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.jsindex 0c545800dee..8f7f36e13e4 100644--- a/frontend_tests/node_tests/settings_org.js+++ b/frontend_tests/node_tests/settings_org.js@@ -1018,10 +1018,10 @@ run_test("misc", () => {".dropdown_list_reset_button:enabled",$.create("<disable button>"),);- widget_settings.forEach((name) => {+ for (const name of widget_settings) {const elem = $.create(`#${name}_widget #${name}_name`);elem.closest = () => dropdown_list_parent;- });+ }// We do not define any settings we need in page_params yet, but we don't need to for this test.blueslip.expect(diff --git a/frontend_tests/node_tests/spoilers.js b/frontend_tests/node_tests/spoilers.jsindex 5876677239c..4632f329fc9 100644--- a/frontend_tests/node_tests/spoilers.js+++ b/frontend_tests/node_tests/spoilers.js@@ -12,9 +12,9 @@ zrequire("spoilers");// This function is taken from rendered_markdown.js and slightly modified.const $array = (array) => {const each = (func) => {- array.forEach((elem, index) => {+ for (const [index, elem] of array.entries()) {func.call(this, index, elem);- });+ }};return {each};};diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.jsindex 42efea3b56a..e9a1f4188e6 100644--- a/frontend_tests/node_tests/typeahead_helper.js+++ b/frontend_tests/node_tests/typeahead_helper.js@@ -115,7 +115,9 @@ run_test("sort_streams", () => {];process_test_streams();- test_streams.forEach(stream_data.update_calculated_fields);+ for (const sub of test_streams) {+ stream_data.update_calculated_fields(sub);+ }test_streams = th.sort_streams(test_streams, "wr");assert.deepEqual(test_streams[0].name, "Docs"); // Description matchassert.deepEqual(test_streams[1].name, "Denmark"); // Popular streamdiff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.jsindex ab1022e3cdb..12dcdb1f05d 100644--- a/frontend_tests/zjsunit/index.js+++ b/frontend_tests/zjsunit/index.js@@ -75,7 +75,7 @@ function run_one_module(file) {test.set_verbose(files.length === 1);try {- files.forEach((file) => {+ for (const file of files) {namespace.set_global("window", window);namespace.set_global("to_$", () => window);namespace.set_global("location", {@@ -98,7 +98,7 @@ try {namespace.restore();Handlebars.HandlebarsEnvironment.call(Handlebars);- });+ }} catch (error) {if (error.stack) {console.info(short_tb(error.stack));diff --git a/frontend_tests/zjsunit/markdown_assert.js b/frontend_tests/zjsunit/markdown_assert.jsindex 49566cbd7f4..445daa225e8 100644--- a/frontend_tests/zjsunit/markdown_assert.js+++ b/frontend_tests/zjsunit/markdown_assert.js@@ -76,9 +76,9 @@ class MarkdownComparer {}// If put in above forEach loop, causes issues (possible nodes.attribute invalidation?)- attributeList.forEach((attr) => {+ for (const attr of attributeList) {node.removeAttribute(attr.name);- });+ }attributeList.sort((a, b) => {const name_a = a.name;@@ -92,9 +92,9 @@ class MarkdownComparer {});// Put them back in, in order- attributeList.forEach((attribute) => {+ for (const attribute of attributeList) {node.setAttribute(attribute.name, attribute.value);- });+ }if (node.hasChildNodes()) {for (const childNode of node.children) {diff --git a/frontend_tests/zjsunit/mdiff.js b/frontend_tests/zjsunit/mdiff.jsindex 464fe0ee6b7..2c6996558ef 100644--- a/frontend_tests/zjsunit/mdiff.js+++ b/frontend_tests/zjsunit/mdiff.js@@ -25,7 +25,7 @@ function apply_color(input_string, changes) {["insert", (string) => "\u001B[32m" + string + "\u001B[0m"],["replace", (string) => "\u001B[33m" + string + "\u001B[0m"],]);- changes.forEach((change) => {+ for (const change of changes) {if (formatter.has(change.tag)) {processed_string += input_string.slice(previous_index, change.beginning_index);processed_string += formatter.get(change.tag)(@@ -33,7 +33,7 @@ function apply_color(input_string, changes) {);previous_index = change.ending_index;}- });+ }processed_string += input_string.slice(previous_index);return processed_string;@@ -102,7 +102,7 @@ function diff_strings(string_0, string_1) {ndiff_output = difflib.ndiff(string_0.split("\n"), string_1.split("\n"));- ndiff_output.forEach((line) => {+ for (const line of ndiff_output) {if (line.startsWith("+")) {output_lines.push(line);} else if (line.startsWith("-")) {@@ -116,7 +116,7 @@ function diff_strings(string_0, string_1) {} else {output_lines.push(line);}- });+ }const emphasize_codes = (string) =>"\u001B[34m" + string.slice(0, 1) + "\u001B[0m" + string.slice(1);diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.jsindex 10cafc89fe9..77a69512e87 100644--- a/frontend_tests/zjsunit/namespace.js+++ b/frontend_tests/zjsunit/namespace.js@@ -61,9 +61,9 @@ exports.clear_zulip_refs = function () {};exports.restore = function () {- requires.forEach((fn) => {+ for (const fn of requires) {delete require.cache[require.resolve(fn)];- });+ }Object.assign(global, old_globals);old_globals = {};for (const name of new_globals) {diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.jsindex 3ece134d585..cf4ce0e8bce 100644--- a/frontend_tests/zjsunit/zjquery.js+++ b/frontend_tests/zjsunit/zjquery.js@@ -300,9 +300,9 @@ exports.make_new_elem = function (selector, opts) {},removeClass(class_names) {class_names = class_names.split(" ");- class_names.forEach((class_name) => {+ for (const class_name of class_names) {classes.delete(class_name);- });+ }return self;},remove() {diff --git a/static/js/billing/helpers.js b/static/js/billing/helpers.jsindex 2435844620b..06e63a873cc 100644--- a/static/js/billing/helpers.js+++ b/static/js/billing/helpers.js@@ -32,13 +32,13 @@ exports.create_ajax_request = function (data.stripe_token = JSON.stringify(stripe_token.id);}- form.serializeArray().forEach((item) => {+ for (const item of form.serializeArray()) {if (numeric_inputs.includes(item.name)) {data[item.name] = item.value;} else {data[item.name] = JSON.stringify(item.value);}- });+ }$.post({url,diff --git a/static/js/color_data.js b/static/js/color_data.jsindex e62eff04414..a0fa34125d4 100644--- a/static/js/color_data.js+++ b/static/js/color_data.js@@ -55,7 +55,9 @@ exports.claim_color = function (color) {exports.claim_colors = function (subs) {const colors = new Set(subs.map((sub) => sub.color));- colors.forEach(exports.claim_color);+ for (const color of colors) {+ exports.claim_color(color);+ }};exports.pick_color = function () {diff --git a/static/js/components.js b/static/js/components.jsindex 7e44b974638..07058d92bcb 100644--- a/static/js/components.js+++ b/static/js/components.js@@ -20,7 +20,7 @@ exports.toggle = function (opts) {// classes need to be added for correct alignment or other purposes_component.addClass(opts.html_class);}- opts.values.forEach((value, i) => {+ for (const [i, value] of opts.values.entries()) {// create a tab with a tab-id so they don't have to be referenced// by text value which can be inconsistent.const tab = $(@@ -43,7 +43,7 @@ exports.toggle = function (opts) {tab.addClass("middle");}_component.append(tab);- });+ }return _component;})(opts);diff --git a/static/js/debug.js b/static/js/debug.jsindex 94b7b8bcc18..a32bc432316 100644--- a/static/js/debug.js+++ b/static/js/debug.js@@ -23,7 +23,7 @@ export function check_duplicate_ids() {const collisions = [];let total_collisions = 0;- Array.prototype.slice.call(document.querySelectorAll("*")).forEach((o) => {+ for (const o of Array.prototype.slice.call(document.querySelectorAll("*"))) {if (o.id && ids.has(o.id)) {const el = collisions.find((c) => c.id === o.id);@@ -53,7 +53,7 @@ export function check_duplicate_ids() {} else if (o.id) {ids.add(o.id);}- });+ }return {collisions,diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.jsindex decc522b4ad..215a7916614 100644--- a/static/js/emoji_picker.js+++ b/static/js/emoji_picker.js@@ -546,11 +546,11 @@ exports.emoji_select_tab = function (elt) {const scrollheight = elt.prop("scrollHeight");const elt_height = elt.height();let currently_selected = "";- section_head_offsets.forEach((o) => {+ for (const o of section_head_offsets) {if (scrolltop + elt_height / 2 >= o.position_y) {currently_selected = o.section;}- });+ }// Handles the corner case of the last category being// smaller than half of the emoji picker height.if (elt_height + scrolltop === scrollheight) {diff --git a/static/js/hotspots.js b/static/js/hotspots.jsindex a926e69836e..92c5901d956 100644--- a/static/js/hotspots.js+++ b/static/js/hotspots.js@@ -235,7 +235,7 @@ function insert_hotspot_into_DOM(hotspot) {}// reposition on any event that might update the UI- ["resize", "scroll", "onkeydown", "click"].forEach((event_name) => {+ for (const event_name of ["resize", "scroll", "onkeydown", "click"]) {window.addEventListener(event_name,_.debounce(() => {@@ -245,7 +245,7 @@ function insert_hotspot_into_DOM(hotspot) {}, 10),true,);- });+ }}, hotspot.delay * 1000);}@@ -278,10 +278,10 @@ function close_read_hotspots(new_hotspots) {exports.load_new = function (new_hotspots) {close_read_hotspots(new_hotspots);- new_hotspots.forEach((hotspot) => {+ for (const hotspot of new_hotspots) {hotspot.location = HOTSPOT_LOCATIONS.get(hotspot.name);- });- new_hotspots.forEach(insert_hotspot_into_DOM);+ insert_hotspot_into_DOM(hotspot);+ }};exports.initialize = function () {diff --git a/static/js/input_pill.js b/static/js/input_pill.jsindex a62fae7aef9..0743503a680 100644--- a/static/js/input_pill.js+++ b/static/js/input_pill.js@@ -198,15 +198,12 @@ exports.create = function (opts) {// this is an array to push all the errored values to, so it's drafts// of pills for the user to fix.- const drafts = [];-- pills.forEach((pill) => {- // if this returns `false`, it erroed and we should push it to- // the draft pills.- if (funcs.appendPill(pill) === false) {- drafts.push(pill);- }- });+ const drafts = pills.filter(+ (pill) =>+ // if this returns `false`, it erroed and we should push it to+ // the draft pills.+ funcs.appendPill(pill) === false,+ );store.$input.text(drafts.join(", "));// when using the `text` insertion feature with jQuery the caret isdiff --git a/static/js/invite.js b/static/js/invite.jsindex 9c453aeedf0..7c1f92001ba 100644--- a/static/js/invite.js+++ b/static/js/invite.js@@ -76,14 +76,14 @@ function submit_invitation_form() {const invitee_emails_errored = [];const error_list = [];let is_invitee_deactivated = false;- arr.errors.forEach((value) => {+ for (const value of arr.errors) {const [email, error_message, deactivated] = value;error_list.push(`${email}: ${error_message}`);if (deactivated) {is_invitee_deactivated = true;}invitee_emails_errored.push(email);- });+ }const error_response = render_invitation_failed_error({error_message: arr.msg,diff --git a/static/js/lightbox.js b/static/js/lightbox.jsindex d00954fbf28..2070eb51d75 100644--- a/static/js/lightbox.js+++ b/static/js/lightbox.js@@ -12,7 +12,7 @@ function render_lightbox_list_images(preview_source) {const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));const $image_list = $("#lightbox_overlay .image-list").html("");- images.forEach((img) => {+ for (const img of images) {const src = img.getAttribute("src");const className = preview_source === src ? "image selected" : "image";@@ -28,7 +28,7 @@ function render_lightbox_list_images(preview_source) {// that navigating within the list only needs the `src`// attribute used to construct the node object above.exports.parse_image_data(img);- }, "");+ }}}diff --git a/static/js/localstorage.js b/static/js/localstorage.jsindex 51969646615..d2c52123f83 100644--- a/static/js/localstorage.js+++ b/static/js/localstorage.js@@ -68,9 +68,9 @@ const ls = {const key_regex = new RegExp(this.formGetter(version, regex));const keys = Object.keys(localStorage).filter((key) => key_regex.test(key));- keys.forEach((key) => {+ for (const key of keys) {localStorage.removeItem(key);- });+ }},// migrate from an older version of a data src to a newer one with adiff --git a/static/js/message_fetch.js b/static/js/message_fetch.jsindex bc1951a0e4b..6e493259119 100644--- a/static/js/message_fetch.js+++ b/static/js/message_fetch.js@@ -34,8 +34,10 @@ function process_result(data, opts) {narrow.show_empty_narrow_message();}- messages.forEach(message_store.set_message_booleans);- messages = messages.map(message_store.add_message_metadata);+ messages = messages.map((message) => {+ message_store.set_message_booleans(message);+ return message_store.add_message_metadata(message);+ });// In case any of the newly fetched messages are new, add them to// our unread data structures. It's important that this run evendiff --git a/static/js/message_list_data.js b/static/js/message_list_data.jsindex 5315db28a28..9c7a86a8002 100644--- a/static/js/message_list_data.js+++ b/static/js/message_list_data.js@@ -430,7 +430,7 @@ class MessageListData {}_add_to_hash(messages) {- messages.forEach((elem) => {+ for (const elem of messages) {const id = Number.parseFloat(elem.id);if (Number.isNaN(id)) {throw new TypeError("Bad message id");@@ -440,10 +440,10 @@ class MessageListData {}if (this._hash.has(id)) {blueslip.error("Duplicate message added to MessageListData");- return;+ continue;}this._hash.set(id, elem);- });+ }}_is_localonly_id(id) {diff --git a/static/js/message_store.js b/static/js/message_store.jsindex 09126785865..452cd075cc2 100644--- a/static/js/message_store.js+++ b/static/js/message_store.js@@ -43,7 +43,9 @@ exports.get = function get(message_id) {};exports.each = function (f) {- stored_messages.forEach(f);+ for (const [id, message] of stored_messages) {+ f(message, id);+ }};exports.get_pm_emails = function (message) {diff --git a/static/js/popovers.js b/static/js/popovers.jsindex 07b5b1a700c..b1858fc70e7 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -897,10 +897,10 @@ exports.register_click_handlers = function () {const url_prefix = playground_info[0].url_prefix;view_in_playground_button.attr("href", url_prefix + encodeURIComponent(extracted_code));} else {- playground_info.forEach(($playground) => {+ for (const $playground of playground_info) {$playground.playground_url =$playground.url_prefix + encodeURIComponent(extracted_code);- });+ }exports.toggle_playground_link_popover(this, playground_info);}});@@ -1309,11 +1309,11 @@ exports.hide_all_except_sidebars = function () {exports.hide_playground_links_popover();// look through all the popovers that have been added and removed.- list_of_popovers.forEach(($o) => {+ for (const $o of list_of_popovers) {if (!document.body.contains($o.$element[0]) && $o.$tip) {$o.$tip.remove();}- });+ }list_of_popovers = [];};diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.jsindex ad91048fa8b..ca84e7bd6d2 100644--- a/static/js/portico/integrations.js+++ b/static/js/portico/integrations.js@@ -11,27 +11,23 @@ const INTEGRATIONS = new Map();const CATEGORIES = new Map();function load_data() {- $(".integration-lozenge")- .toArray()- .forEach((integration) => {- const name = $(integration).data("name");- const display_name = $(integration).find(".integration-name").text().trim();-- if (display_name && name) {- INTEGRATIONS.set(name, display_name);- }- });+ for (const integration of $(".integration-lozenge")) {+ const name = $(integration).data("name");+ const display_name = $(integration).find(".integration-name").text().trim();- $(".integration-category")- .toArray()- .forEach((category) => {- const name = $(category).data("category");- const display_name = $(category).text().trim();+ if (display_name && name) {+ INTEGRATIONS.set(name, display_name);+ }+ }- if (display_name && name) {- CATEGORIES.set(name, display_name);- }- });+ for (const category of $(".integration-category")) {+ const name = $(category).data("category");+ const display_name = $(category).text().trim();++ if (display_name && name) {+ CATEGORIES.set(name, display_name);+ }+ }}const INITIAL_STATE = {@@ -43,27 +39,25 @@ const INITIAL_STATE = {let state = {...INITIAL_STATE};function adjust_font_sizing() {- $(".integration-lozenge")- .toArray()- .forEach((integration) => {- const $integration_name = $(integration).find(".integration-name");- const $integration_category = $(integration).find(".integration-category");+ for (const integration of $(".integration-lozenge")) {+ const $integration_name = $(integration).find(".integration-name");+ const $integration_category = $(integration).find(".integration-category");- // if the text has wrapped to two lines, decrease font-size+ // if the text has wrapped to two lines, decrease font-size+ if ($integration_name.height() > 30) {+ $integration_name.css("font-size", "1em");if ($integration_name.height() > 30) {- $integration_name.css("font-size", "1em");- if ($integration_name.height() > 30) {- $integration_name.css("font-size", ".95em");- }+ $integration_name.css("font-size", ".95em");}+ }+ if ($integration_category.height() > 30) {+ $integration_category.css("font-size", ".8em");if ($integration_category.height() > 30) {- $integration_category.css("font-size", ".8em");- if ($integration_category.height() > 30) {- $integration_category.css("font-size", ".75em");- }+ $integration_category.css("font-size", ".75em");}- });+ }+ }}function update_path() {@@ -105,8 +99,7 @@ function update_categories() {const update_integrations = _.debounce(() => {const max_scrollY = window.scrollY;- const integrations = $(".integration-lozenges").children().toArray();- integrations.forEach((integration) => {+ for (const integration of $(".integration-lozenges").children()) {const $integration = $(integration).find(".integration-lozenge");const $integration_category = $integration.find(".integration-category");@@ -133,7 +126,7 @@ const update_integrations = _.debounce(() => {}document.body.scrollTop = Math.min(window.scrollY, max_scrollY);- });+ }adjust_font_sizing();}, 50);@@ -151,7 +144,7 @@ function hide_catalog_show_integration() {function show_integration(doc) {$("#integration-instructions-group .name").text(INTEGRATIONS.get(state.integration));$("#integration-instructions-group .categories .integration-category").remove();- categories.forEach((category) => {+ for (const category of categories) {let link;for (const [name, display_name] of CATEGORIES) {if (display_name === category) {@@ -163,7 +156,7 @@ function hide_catalog_show_integration() {.append('<h3 class="integration-category"></h3>');category_el.find(".integration-category").attr("data-category", link).text(category);$("#integration-instructions-group .categories").append(category_el);- });+ }$("#integration-instructions-group").css({opacity: 0,display: "flex",@@ -305,9 +298,8 @@ function toggle_categories_dropdown() {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 (const integration_element of integrations) {+ for (const integration_element of $(".integration-lozenges").children()) {const integration = $(integration_element).find(".integration-lozenge");if ($(integration).css("display") !== "none") {diff --git a/static/js/portico/integrations_dev_panel.js b/static/js/portico/integrations_dev_panel.jsindex ef56a5d702d..410ec02161c 100644--- a/static/js/portico/integrations_dev_panel.js+++ b/static/js/portico/integrations_dev_panel.js@@ -38,7 +38,7 @@ const clear_handlers = {function clear_elements(elements) {// Supports strings (a selector to clear) or calling a function// (for more complex logic).- elements.forEach((element_name) => {+ for (const element_name of elements) {const handler = clear_handlers[element_name];if (typeof handler === "string") {const element_object = $(handler)[0];@@ -47,7 +47,7 @@ function clear_elements(elements) {} else {handler();}- });+ }return;}@@ -102,7 +102,7 @@ function set_results(response) {const responses = response.responses;let data = "Results:\n\n";- responses.forEach((response) => {+ for (const response of responses) {if (response.fixture_name !== undefined) {data += "Fixture: " + response.fixture_name;data += "\nStatus Code: " + response.status_code;@@ -110,7 +110,7 @@ function set_results(response) {data += "Status Code: " + response.status_code;}data += "\nResponse: " + response.message + "\n\n";- });+ }$("#idp-results")[0].value = data;}@@ -142,12 +142,12 @@ function load_fixture_options(integration_name) {const fixtures_options_dropdown = $("#fixture_name")[0];const fixtures_names = Object.keys(loaded_fixtures.get(integration_name)).sort();- fixtures_names.forEach((fixture_name) => {+ for (const fixture_name of fixtures_names) {const new_dropdown_option = document.createElement("option");new_dropdown_option.value = fixture_name;new_dropdown_option.innerHTML = fixture_name;fixtures_options_dropdown.add(new_dropdown_option);- });+ }load_fixture_body(fixtures_names[0]);return;diff --git a/static/js/portico/landing-page.js b/static/js/portico/landing-page.jsindex 10dada3e22f..bd0eef25fb7 100644--- a/static/js/portico/landing-page.js+++ b/static/js/portico/landing-page.js@@ -79,11 +79,11 @@ const apps_events = function () {let result;const parts = path_parts();- Object.keys(info).forEach((version) => {+ for (const version of Object.keys(info)) {if (parts.includes(version)) {result = version;}- });+ }result = result || detect_user_os();return result;diff --git a/static/js/portico/team.js b/static/js/portico/team.jsindex 8a798a2511e..e142cb0607c 100644--- a/static/js/portico/team.js+++ b/static/js/portico/team.js@@ -20,9 +20,9 @@ const loaded_repos = [];function calculate_total_commits(contributor) {let commits = 0;- Object.keys(repo_name_to_tab_name).forEach((repo_name) => {+ for (const repo_name of Object.keys(repo_name_to_tab_name)) {commits += contributor[repo_name] || 0;- });+ }return commits;}diff --git a/static/js/server_events.js b/static/js/server_events.jsindex 73b59a6435f..9e8fc347d9d 100644--- a/static/js/server_events.js+++ b/static/js/server_events.js@@ -102,7 +102,9 @@ function get_events_success(events) {try {messages = echo.process_from_server(messages);if (messages.length > 0) {- messages.forEach(message_store.set_message_booleans);+ for (const message of messages) {+ message_store.set_message_booleans(message);+ }const sent_by_this_client = messages.some((msg) =>sent_messages.messages.has(msg.local_id),diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.jsindex 8d64e57359e..909824c7d98 100644--- a/static/js/server_events_dispatch.js+++ b/static/js/server_events_dispatch.js@@ -345,42 +345,42 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {}}} else if (event.op === "peer_add") {- event.stream_ids.forEach((stream_id) => {+ for (const stream_id of event.stream_ids) {const sub = stream_data.get_sub_by_id(stream_id);if (!sub) {blueslip.warn("Cannot find stream for peer_add: " + stream_id);- return;+ continue;}- event.user_ids.forEach((user_id) => {+ for (const user_id of event.user_ids) {if (!peer_data.add_subscriber(stream_id, user_id)) {blueslip.warn("Cannot process peer_add event");- return;+ continue;}- });+ }subs.update_subscribers_ui(sub);- });+ }compose_fade.update_faded_users();} else if (event.op === "peer_remove") {- event.stream_ids.forEach((stream_id) => {+ for (const stream_id of event.stream_ids) {const sub = stream_data.get_sub_by_id(stream_id);if (!sub) {blueslip.warn("Cannot find stream for peer_remove: " + stream_id);- return;+ continue;}- event.user_ids.forEach((user_id) => {+ for (const user_id of event.user_ids) {if (!peer_data.remove_subscriber(sub.stream_id, user_id)) {blueslip.warn("Cannot process peer_remove event.");- return;+ continue;}- });+ }subs.update_subscribers_ui(sub);- });+ }compose_fade.update_faded_users();} else if (event.op === "remove") {for (const rec of event.subscriptions) {diff --git a/static/js/settings_account.js b/static/js/settings_account.jsindex ec2e064e6ee..17c8a937913 100644--- a/static/js/settings_account.js+++ b/static/js/settings_account.js@@ -146,7 +146,7 @@ exports.append_custom_profile_fields = function (element_id, user_id) {[all_field_types.URL.id, "url"],]);- all_custom_fields.forEach((field) => {+ for (const field of all_custom_fields) {let field_value = people.get_custom_profile_data(user_id, field.id);const is_choice_field = field.type === all_field_types.CHOICE.id;const field_choices = [];@@ -178,7 +178,7 @@ exports.append_custom_profile_fields = function (element_id, user_id) {field_choices,});$(element_id).append(html);- });+ }};exports.initialize_custom_date_type_fields = function (element_id) {@@ -219,7 +219,7 @@ exports.initialize_custom_user_type_fields = function (return user_pills;}- page_params.custom_profile_fields.forEach((field) => {+ for (const field of page_params.custom_profile_fields) {let field_value_raw = people.get_custom_profile_data(user_id, field.id);if (field_value_raw) {@@ -249,10 +249,10 @@ exports.initialize_custom_user_type_fields = function (if (field_value_raw) {const field_value = JSON.parse(field_value_raw);if (field_value) {- field_value.forEach((pill_user_id) => {+ for (const pill_user_id of field_value) {const user = people.get_by_user_id(pill_user_id);user_pill.append_user(user, pills);- });+ }}}@@ -270,7 +270,7 @@ exports.initialize_custom_user_type_fields = function (}user_pills.set(field.id, pills);}- });+ }return user_pills;};diff --git a/static/js/settings_org.js b/static/js/settings_org.jsindex 877d946912d..d91a95452d6 100644--- a/static/js/settings_org.js+++ b/static/js/settings_org.js@@ -644,7 +644,9 @@ exports.build_page = function () {// Populate authentication methods tableexports.populate_auth_methods(page_params.realm_authentication_methods);- simple_dropdown_properties.forEach(set_property_dropdown_value);+ for (const property_name of simple_dropdown_properties) {+ set_property_dropdown_value(property_name);+ }set_realm_waiting_period_dropdown();set_video_chat_provider_dropdown();@@ -684,7 +686,9 @@ exports.build_page = function () {(e) => {e.preventDefault();e.stopPropagation();- get_subsection_property_elements(e.target).forEach(discard_property_element_changes);+ for (const elem of get_subsection_property_elements(e.target)) {+ discard_property_element_changes(elem);+ }const save_btn_controls = $(e.target).closest(".save-button-controls");exports.change_save_button_state(save_btn_controls, "discarded");},diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.jsindex 4d7f19ae1c0..69dedf5493c 100644--- a/static/js/settings_user_groups.js+++ b/static/js/settings_user_groups.js@@ -65,10 +65,10 @@ exports.populate_user_groups = function () {}const userg = $('div.user-group[id="' + data.id + '"]');- data.members.forEach((user_id) => {+ for (const user_id of data.members) {const user = people.get_by_user_id(user_id);user_pill.append_user(user, pills);- });+ }function update_membership(group_id) {if (exports.can_edit(group_id)) {diff --git a/static/js/stats/stats.js b/static/js/stats/stats.jsindex 6fba87703fa..0b67ce02bb1 100644--- a/static/js/stats/stats.js+++ b/static/js/stats/stats.js@@ -183,9 +183,9 @@ function populate_messages_sent_over_time(data) {document.querySelector("#hover_date").textContent =data.points[0].data.text[data.points[0].pointNumber];const values = [null, null, null];- data.points.forEach((trace) => {+ for (const trace of data.points) {values[trace.curveNumber] = trace.y;- });+ }const hover_text_ids = ["#hover_me", "#hover_human", "#hover_bot"];const hover_value_ids = ["#hover_me_value", "#hover_human_value", "#hover_bot_value"];for (const [i, value] of values.entries()) {@@ -391,14 +391,14 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) {}const labels = labels_.slice();const values = [];- labels.forEach((label) => {+ for (const label of labels) {if (data.has(label)) {values.push(data.get(label));data.delete(label);} else {values.push(0);}- });+ }if (data.size !== 0) {labels[labels.length - 1] = "Other";for (const sum of data.values()) {@@ -443,9 +443,9 @@ function populate_messages_sent_by_client(data) {}label_values.sort((a, b) => b.value - a.value);const labels = [];- label_values.forEach((item) => {+ for (const item of label_values) {labels.push(item.label);- });+ }function make_plot_data(time_series_data, num_steps) {const plot_data = compute_summary_chart_data(time_series_data, num_steps, labels);@@ -732,9 +732,9 @@ function populate_number_of_users(data) {document.querySelector("#users_hover_date").textContent =data.points[0].data.text[data.points[0].pointNumber];const values = [null, null, null];- data.points.forEach((trace) => {+ for (const trace of data.points) {values[trace.curveNumber] = trace.y;- });+ }const hover_value_ids = ["#users_hover_1day_value","#users_hover_15day_value",@@ -865,9 +865,9 @@ function populate_messages_read_over_time(data) {document.querySelector("#read_hover_date").textContent =data.points[0].data.text[data.points[0].pointNumber];const values = [null, null];- data.points.forEach((trace) => {+ for (const trace of data.points) {values[trace.curveNumber] = trace.y;- });+ }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 (const [i, value] of values.entries()) {diff --git a/static/js/stream_data.js b/static/js/stream_data.jsindex d6680d23ed4..312d7c802bf 100644--- a/static/js/stream_data.js+++ b/static/js/stream_data.js@@ -602,9 +602,9 @@ exports.all_topics_in_cache = function (sub) {exports.set_realm_default_streams = function (realm_default_streams) {default_stream_ids.clear();- realm_default_streams.forEach((stream) => {+ for (const stream of realm_default_streams) {default_stream_ids.add(stream.stream_id);- });+ }};exports.get_default_stream_ids = function () {@@ -903,12 +903,12 @@ exports.initialize = function (params) {color_data.claim_colors(subscriptions);function populate_subscriptions(subs, subscribed, previously_subscribed) {- subs.forEach((sub) => {+ for (const sub of subs) {sub.subscribed = subscribed;sub.previously_subscribed = previously_subscribed;exports.create_sub_from_server_data(sub);- });+ }}exports.set_realm_default_streams(realm_default_streams);diff --git a/static/js/stream_list.js b/static/js/stream_list.jsindex 30860410592..72e8658e434 100644--- a/static/js/stream_list.js+++ b/static/js/stream_list.js@@ -114,7 +114,9 @@ exports.build_stream_list = function (force_rerender) {topic_list.clear();parent.empty();- stream_groups.pinned_streams.forEach(add_sidebar_li);+ for (const stream_id of stream_groups.pinned_streams) {+ add_sidebar_li(stream_id);+ }const any_pinned_streams = stream_groups.pinned_streams.length > 0;const any_normal_streams = stream_groups.normal_streams.length > 0;@@ -124,13 +126,17 @@ exports.build_stream_list = function (force_rerender) {elems.push('<hr class="stream-split">');}- stream_groups.normal_streams.forEach(add_sidebar_li);+ for (const stream_id of stream_groups.normal_streams) {+ add_sidebar_li(stream_id);+ }if (any_dormant_streams && any_normal_streams) {elems.push('<hr class="stream-split">');}- stream_groups.dormant_streams.forEach(add_sidebar_li);+ for (const stream_id of stream_groups.dormant_streams) {+ add_sidebar_li(stream_id);+ }parent.append(elems);};diff --git a/static/js/upload.js b/static/js/upload.jsindex c0a4ae5a451..219e95c3b67 100644--- a/static/js/upload.js+++ b/static/js/upload.js@@ -136,13 +136,13 @@ exports.upload_files = function (uppy, config, files) {.show();exports.get_item("send_status_message", config).html($("<p>").text(i18n.t("Uploading…")));exports.get_item("send_status_close_button", config).one("click", () => {- uppy.getFiles().forEach((file) => {+ for (const file of uppy.getFiles()) {compose_ui.replace_syntax(exports.get_translated_status(file),"",exports.get_item("textarea", config),);- });+ }compose_ui.autosize_textarea(exports.get_item("textarea", config));uppy.cancelAll();exports.get_item("textarea", config).trigger("focus");@@ -261,7 +261,7 @@ exports.setup_upload = function (config) {uppy.on("complete", () => {let uploads_in_progress = false;- uppy.getFiles().forEach((file) => {+ for (const file of uppy.getFiles()) {if (file.progress.uploadComplete) {// The uploaded files should be removed since uppy don't allow files in the store// to be re-uploaded again.@@ -272,7 +272,7 @@ exports.setup_upload = function (config) {// still be in progress.uploads_in_progress = true;}- });+ }const has_errors = exports.get_item("send_status", config).hasClass("alert-error");if (!uploads_in_progress && !has_errors) {