Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-immediate-mutation.
Anders Kaseorgd0f112dde69e
diff --git a/web/tests/buddy_data.test.cjs b/web/tests/buddy_data.test.cjsindex b1e14b343ff..32ce7dd6d1a 100644--- a/web/tests/buddy_data.test.cjs+++ b/web/tests/buddy_data.test.cjs@@ -364,11 +364,9 @@ test("bulk_data_hacks", ({override_rewire}) => {set_presence(user_id, "offline");}- let user_ids;-// Even though we have 1000 users, we only get the 400 active// users. This is a consequence of buddy_data.maybe_shrink_list.- user_ids = buddy_data.get_filtered_and_sorted_user_ids();+ let user_ids = buddy_data.get_filtered_and_sorted_user_ids();assert.equal(user_ids.length, 400);user_ids = buddy_data.get_filtered_and_sorted_user_ids("");diff --git a/web/tests/compose_paste.test.cjs b/web/tests/compose_paste.test.cjsindex d6f2ce3d35a..5f7f45a2680 100644--- a/web/tests/compose_paste.test.cjs+++ b/web/tests/compose_paste.test.cjs@@ -751,10 +751,8 @@ run_test("paste_handler_converter", () => {}const meta = '<meta http-equiv="content-type" content="text/html; charset=utf-8">';- let firefox_input;-// Non-silent user mention- firefox_input =+ let firefox_input =meta +'<p><span class="user-mention" data-user-id="10">' +'<span class="mention-content-wrapper">@King Hamlet</span></span></p>';@@ -859,10 +857,8 @@ run_test("paste_handler_converter", () => {'<span class="mention-content-wrapper">@Unknown</span></span></p>';assert.equal(compose_paste.paste_handler_converter(firefox_input), "@**|9999**");- let chrome_input;-// Non-silent user mention.- chrome_input = `<html><body><!--StartFragment--><span class="user-mention" data-user-id="10" style="padding: 0px 3px; border-radius: 3px; white-space: nowrap; font-size: 0.95em; color: rgba(255, 255, 255, 0.8); background-color: rgba(100, 100, 206, 0.25); cursor: pointer; font-family: "Source Sans 3 VF", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="mention-content-wrapper" style="font-size: 1.0526em;">@King Hamlet</span></span><span style="color: rgb(222, 222, 222); font-family: "Source Sans 3 VF", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(31, 40, 40); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">, how are you?</span><!--EndFragment--></body></html>`;+ let chrome_input = `<html><body><!--StartFragment--><span class="user-mention" data-user-id="10" style="padding: 0px 3px; border-radius: 3px; white-space: nowrap; font-size: 0.95em; color: rgba(255, 255, 255, 0.8); background-color: rgba(100, 100, 206, 0.25); cursor: pointer; font-family: "Source Sans 3 VF", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="mention-content-wrapper" style="font-size: 1.0526em;">@King Hamlet</span></span><span style="color: rgb(222, 222, 222); font-family: "Source Sans 3 VF", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(31, 40, 40); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">, how are you?</span><!--EndFragment--></body></html>`;assert.equal(compose_paste.paste_handler_converter(chrome_input),"@**King Hamlet|10**, how are you?",diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjsindex 98ebdf06fe8..eb873d149c8 100644--- a/web/tests/composebox_typeahead.test.cjs+++ b/web/tests/composebox_typeahead.test.cjs@@ -1780,8 +1780,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {return typeahead_helper.query_matches_person(query, person);}- let query;- query = "el"; // Matches both "othELlo" and "cordELia"+ let query = "el"; // Matches both "othELlo" and "cordELia"assert.equal(matcher(query, othello_item), true);assert.equal(matcher(query, cordelia_item), true);diff --git a/web/tests/dispatch.test.cjs b/web/tests/dispatch.test.cjsindex 9fe5567631d..67bfeb7b11f 100644--- a/web/tests/dispatch.test.cjs+++ b/web/tests/dispatch.test.cjs@@ -1665,9 +1665,7 @@ run_test("delete_message", ({override}) => {dispatch(event);- let args;-- args = message_events_stub.get_args("message_ids");+ let args = message_events_stub.get_args("message_ids");assert_same(args.message_ids, [1337]);args = unread_ops_stub.get_args("message_ids");diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjsindex d380642d286..c51dd4912f2 100644--- a/web/tests/filter.test.cjs+++ b/web/tests/filter.test.cjs@@ -1093,8 +1093,7 @@ test("canonicalization", () => {assert.equal(filter_util.canonicalize_operator("subject"), "topic");assert.equal(filter_util.canonicalize_operator("from"), "sender");- let term;- term = Filter.canonicalize_term({operator: "stream", operand: "Denmark"});+ let term = Filter.canonicalize_term({operator: "stream", operand: "Denmark"});assert.equal(term.operator, "channel");assert.equal(term.operand, "Denmark");@@ -1648,10 +1647,9 @@ test("negated_predicates", () => {});test("predicate_edge_cases", () => {- let predicate;// The code supports undefined as an operator to Filter, which results// in a predicate that accepts any message.- predicate = new Filter([]).predicate();+ let predicate = new Filter([]).predicate();assert.ok(predicate({}));// Upstream code should prevent Filter.predicate from being called with@@ -1852,9 +1850,8 @@ test("parse", () => {test("unparse", () => {let string;- let terms;- terms = [+ let terms = [{operator: "channel", operand: foo_stream_id.toString()},{operator: "topic", operand: "Bar", negated: true},{operator: "search", operand: "yo"},diff --git a/web/tests/message_view.test.cjs b/web/tests/message_view.test.cjsindex 2b9d5f35d9e..97e2cd6177a 100644--- a/web/tests/message_view.test.cjs+++ b/web/tests/message_view.test.cjs@@ -1247,10 +1247,9 @@ run_test("fast_track_current_msg_list_to_anchor date", ({override}) => {run_test("narrow_compute_title", () => {// Only tests cases where the narrow title is different from the filter title.- let filter;// Recent conversations & Inbox have `undefined` filter.- filter = undefined;+ let filter;recent_view_util.set_visible(true);inbox_util.set_visible(false);assert.equal(narrow_title.compute_narrow_title(filter), "translated: Recent conversations");diff --git a/web/tests/pill_typeahead.test.cjs b/web/tests/pill_typeahead.test.cjsindex 8b16152b9a3..bbd3764a281 100644--- a/web/tests/pill_typeahead.test.cjs+++ b/web/tests/pill_typeahead.test.cjs@@ -196,8 +196,7 @@ run_test("set_up_user", ({mock_template, override, override_rewire}) => {})();(function test_matcher() {- let result;- result = config.matcher(person_query)(me_item);+ let result = config.matcher(person_query)(me_item);assert.ok(result);result = config.matcher(person_query)(jill_item);assert.ok(!result);@@ -281,8 +280,7 @@ run_test("set_up_stream", ({mock_template, override, override_rewire}) => {})();(function test_matcher() {- let result;- result = config.matcher(stream_query)(denmark_item);+ let result = config.matcher(stream_query)(denmark_item);assert.ok(result);result = config.matcher(stream_query)(sweden_item);assert.ok(!result);@@ -372,8 +370,7 @@ run_test("set_up_user_group", ({mock_template, override, override_rewire}) => {})();(function test_matcher() {- let result;- result = config.matcher(group_query)(testers_item);+ let result = config.matcher(group_query)(testers_item);assert.ok(result);result = config.matcher(group_query)(admins_item);assert.ok(!result);@@ -781,9 +778,8 @@ run_test("set_up_group_setting_typeahead", ({mock_template, override, override_r})();(function test_matcher() {- let result;// group query, with correct item.- result = config.matcher(group_query)(testers_item);+ let result = config.matcher(group_query)(testers_item);assert.ok(result);// group query, with wrong item.result = config.matcher(group_query)(admins_item);diff --git a/web/tests/presence.test.cjs b/web/tests/presence.test.cjsindex 8ef7822a42d..afd27423dcc 100644--- a/web/tests/presence.test.cjs+++ b/web/tests/presence.test.cjs@@ -114,9 +114,8 @@ test("status_from_raw", () => {const status_from_raw = presence.status_from_raw;const now = 5000;- let raw;- raw = {+ let raw = {server_timestamp: now,active_timestamp: now - OFFLINE_THRESHOLD_SECS / 2,};@@ -332,9 +331,7 @@ test("last_active_date", () => {});test("update_info_from_event", () => {- let info;-- info = {+ let info = {active_timestamp: 500,idle_timestamp: 500,};diff --git a/web/tests/stream_list.test.cjs b/web/tests/stream_list.test.cjsindex 00f3805ccc3..40286ac8ed8 100644--- a/web/tests/stream_list.test.cjs+++ b/web/tests/stream_list.test.cjs@@ -395,9 +395,7 @@ test_ui("narrowing", ({override_rewire}) => {initialize_stream_data();assert.ok(!$("<devel-sidebar-row-stub>").hasClass("active-filter"));- let filter;-- filter = new Filter([{operator: "stream", operand: develSub.stream_id.toString()}]);+ let filter = new Filter([{operator: "stream", operand: develSub.stream_id.toString()}]);stream_list.handle_narrow_activated(filter);assert.ok($("<devel-sidebar-row-stub>").hasClass("active-filter"));