Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-unreadable-for-of-expression.
Anders Kaseorg696e736ae3cb
diff --git a/web/debug-require-webpack-plugin.ts b/web/debug-require-webpack-plugin.tsindex 7a6588784c2..e71e9a269de 100644--- a/web/debug-require-webpack-plugin.ts+++ b/web/debug-require-webpack-plugin.ts@@ -91,7 +91,8 @@ export default class DebugRequirePlugin implements webpack.WebpackPluginInstanceif (m.resource === debugRequirePath) {hasDebugRequire = true;}- for (const name of resolved.get(m.resource) ?? []) {+ const names = resolved.get(m.resource) ?? [];+ for (const name of names) {ids.push([m.rawRequest.slice(0, m.rawRequest.lastIndexOf("!") + 1) +name,diff --git a/web/src/copy_messages.ts b/web/src/copy_messages.tsindex 3eb91678653..ee6c179f6cb 100644--- a/web/src/copy_messages.ts+++ b/web/src/copy_messages.ts@@ -392,7 +392,8 @@ function improve_time_selection_range(range: Range): void {// Chrome strips <time> and .timestamp-content-wrapper from the// paste HTML, so wrap the date text in a <span data-datetime> that// the paste handler can read.- for (const time of new Set([start_time, end_time])) {+ const times = new Set([start_time, end_time]);+ for (const time of times) {if (!time) {continue;}diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.tsindex ea5d2c98862..335b43cc094 100644--- a/web/src/inbox_ui.ts+++ b/web/src/inbox_ui.ts@@ -458,9 +458,9 @@ function load_data_from_ls(): void {z.optional(z.array(z.string())).parse(ls.get(ls_collapsed_containers_key)),);const saved_per_channel_filters = z- .optional(z.array(z.tuple([z.number(), z.array(z.string())])))+ ._default(z.array(z.tuple([z.number(), z.array(z.string())])), []).parse(ls.get(ls_per_channel_filters_key));- for (const [channel_id, filter_set] of saved_per_channel_filters ?? []) {+ for (const [channel_id, filter_set] of saved_per_channel_filters) {const valid_filter_set = new Set(filter_set.filter((filter) => valid_filters.has(filter)));if (valid_filter_set.size > 0) {per_channel_filters.set(channel_id, valid_filter_set);diff --git a/web/src/message_events.ts b/web/src/message_events.tsindex 6d8d960f826..cb2353b05b6 100644--- a/web/src/message_events.ts+++ b/web/src/message_events.ts@@ -207,9 +207,10 @@ export let update_views_filtered_on_message_property = (success(data) {const messages_to_add: Message[] = [];const messages_to_remove = new Set(message_ids);- for (const raw_message of z+ const {messages: raw_messages} = z.object({messages: z.array(raw_message_schema)})- .parse(data).messages) {+ .parse(data);+ for (const raw_message of raw_messages) {messages_to_remove.delete(raw_message.id);const message = message_store.get(raw_message.id);messages_to_add.push(diff --git a/web/src/settings_components.ts b/web/src/settings_components.tsindex a73cd77a97a..6a4efb7ea76 100644--- a/web/src/settings_components.ts+++ b/web/src/settings_components.ts@@ -412,9 +412,8 @@ function read_custom_profile_field_choices_from_form(const old_option_value_map = new Map<string, string>();if (old_field_data !== undefined) {- for (const [value, choice] of Object.entries(- custom_profile_field_choices_schema.parse(old_field_data),- )) {+ const choices = custom_profile_field_choices_schema.parse(old_field_data);+ for (const [value, choice] of Object.entries(choices)) {assert(typeof choice !== "string");old_option_value_map.set(choice.text, value);}diff --git a/web/tests/buddy_data.test.cjs b/web/tests/buddy_data.test.cjsindex fc850071f38..bb357a90091 100644--- a/web/tests/buddy_data.test.cjs+++ b/web/tests/buddy_data.test.cjs@@ -340,7 +340,8 @@ test("bulk_data_hacks", ({override_rewire}) => {// sanity checkassert.equal(mark.user_id, 1005);- for (const i of _.range(mark.user_id + 1, 2000)) {+ const start_id = mark.user_id + 1;+ for (const i of _.range(start_id, 2000)) {const person = {user_id: i,full_name: `Human ${i}`,diff --git a/web/tests/lib/zblueslip.cjs b/web/tests/lib/zblueslip.cjsindex d7f0980753d..55f1dae3ae8 100644--- a/web/tests/lib/zblueslip.cjs+++ b/web/tests/lib/zblueslip.cjs@@ -43,9 +43,11 @@ function make_zblueslip() {const check_seen_messages = () => {for (const name of names) {- for (const obj of lib.test_logs[name]) {+ const logs = lib.test_logs[name];+ const data = lib.test_data[name];+ for (const obj of logs) {const message = obj.message;- const i = lib.test_data[name].findIndex((x) => x.message === message);+ const i = data.findIndex((x) => x.message === message);if (i === -1) {// Only throw this for message types we want to explicitly track.// For example, we do not want to throw here for debug messages.@@ -54,10 +56,10 @@ function make_zblueslip() {}continue;}- lib.test_data[name][i].count += 1;+ data[i].count += 1;}- for (const obj of lib.test_data[name]) {+ for (const obj of data) {const message = obj.message;assert.equal(obj.count,diff --git a/web/tests/lib/zjquery_element.cjs b/web/tests/lib/zjquery_element.cjsindex aa81fa54a1f..fedf2de7b07 100644--- a/web/tests/lib/zjquery_element.cjs+++ b/web/tests/lib/zjquery_element.cjs@@ -344,9 +344,8 @@ exports.FakeJQuery = class extends RejectMissing {}for (const element of this) {- for (const [key, value] of Object.entries(- typeof property === "string" ? {[property]: args[0]} : property,- )) {+ const properties = typeof property === "string" ? {[property]: args[0]} : property;+ for (const [key, value] of Object.entries(properties)) {element.style.setProperty(decamel(key),typeof value === "number" &&