Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/prefer-set-has.
Anders Kaseorgb178fc6069f6
diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.jsindex 00621705e8c..695dc4eee1e 100644--- a/frontend_tests/node_tests/stream_data.js+++ b/frontend_tests/node_tests/stream_data.js@@ -923,10 +923,10 @@ run_test("initialize", () => {initialize();assert(!stream_data.is_filtering_inactives());- const stream_names = stream_data.get_streams_for_admin().map((elem) => elem.name);- assert(stream_names.includes("subscriptions"));- assert(stream_names.includes("unsubscribed"));- assert(stream_names.includes("never_subscribed"));+ const stream_names = new Set(stream_data.get_streams_for_admin().map((elem) => elem.name));+ assert(stream_names.has("subscriptions"));+ assert(stream_names.has("unsubscribed"));+ assert(stream_names.has("never_subscribed"));assert.equal(stream_data.get_notifications_stream(), "");// Simulate a private stream the user isn't subscribed todiff --git a/static/js/hotkey.js b/static/js/hotkey.jsindex 4bbd03b9484..50e500c02cc 100644--- a/static/js/hotkey.js+++ b/static/js/hotkey.js@@ -8,7 +8,7 @@ function do_narrow_action(action) {}// For message actions and user profile menu.-const menu_dropdown_hotkeys = ["down_arrow", "up_arrow", "vim_up", "vim_down", "enter"];+const menu_dropdown_hotkeys = new Set(["down_arrow", "up_arrow", "vim_up", "vim_down", "enter"]);// Note that multiple keys can map to the same event_name, which// we'll do in cases where they have the exact same semantics.@@ -573,7 +573,7 @@ exports.process_hotkey = function (e, hotkey) {}}- if (menu_dropdown_hotkeys.includes(event_name)) {+ if (menu_dropdown_hotkeys.has(event_name)) {if (popovers.actions_popped()) {popovers.actions_menu_handle_keyboard(event_name);return true;diff --git a/static/js/message_fetch.js b/static/js/message_fetch.jsindex c69536ea749..480cc0f048a 100644--- a/static/js/message_fetch.js+++ b/static/js/message_fetch.js@@ -130,8 +130,8 @@ function get_messages_success(data, opts) {// or convert the emails string to user IDs directly into the Filter code// because doing so breaks the app in various modules that expect emails string.function handle_operators_supporting_id_based_api(data) {- const operators_supporting_ids = ["pm-with"];- const operators_supporting_id = ["sender", "group-pm-with", "stream"];+ const operators_supporting_ids = new Set(["pm-with"]);+ const operators_supporting_id = new Set(["sender", "group-pm-with", "stream"]);if (data.narrow === undefined) {return data;@@ -139,11 +139,11 @@ function handle_operators_supporting_id_based_api(data) {data.narrow = JSON.parse(data.narrow);data.narrow = data.narrow.map((filter) => {- if (operators_supporting_ids.includes(filter.operator)) {+ if (operators_supporting_ids.has(filter.operator)) {filter.operand = people.emails_strings_to_user_ids_array(filter.operand);}- if (operators_supporting_id.includes(filter.operator)) {+ if (operators_supporting_id.has(filter.operator)) {if (filter.operator === "stream") {const stream_id = stream_data.get_stream_id(filter.operand);if (stream_id !== undefined) {diff --git a/static/js/portico/tabbed-instructions.js b/static/js/portico/tabbed-instructions.jsindex f33c50abfab..de6a003dc42 100644--- a/static/js/portico/tabbed-instructions.js+++ b/static/js/portico/tabbed-instructions.js@@ -19,7 +19,7 @@ export function detect_user_os() {export function activate_correct_tab($codeSection) {const user_os = detect_user_os();- const desktop_os = ["mac", "linux", "windows"];+ const desktop_os = new Set(["mac", "linux", "windows"]);const $li = $codeSection.find("ul.nav li");const $blocks = $codeSection.find(".blocks div");@@ -30,7 +30,7 @@ export function activate_correct_tab($codeSection) {$(this).addClass("active");}- if (desktop_os.includes(user_os) && language === "desktop-web") {+ if (desktop_os.has(user_os) && language === "desktop-web") {$(this).addClass("active");}});@@ -42,7 +42,7 @@ export function activate_correct_tab($codeSection) {$(this).addClass("active");}- if (desktop_os.includes(user_os) && language === "desktop-web") {+ if (desktop_os.has(user_os) && language === "desktop-web") {$(this).addClass("active");}});diff --git a/static/js/rtl.js b/static/js/rtl.jsindex 0da1a13a752..4ce56097242 100644--- a/static/js/rtl.js+++ b/static/js/rtl.js@@ -36,9 +36,9 @@ function convert_from_raw(digits, part_length, raw) {}/** Isolate initiator characters. */-const i_chars = [0x2066, 0x2067, 0x2068];+const i_chars = new Set([0x2066, 0x2067, 0x2068]);/** Pop directional isolate character. */-const pdi_chars = [0x2069];+const pdi_chars = new Set([0x2069]);/** The digits that are used for base conversions from base 92. */const digits ='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@[]^_`{|}~';@@ -86,10 +86,10 @@ const lr_ranges = convert_from_raw(* @returns {'I' | 'PDI' | 'R' | 'L' | 'Other'}*/function get_bidi_class(ch) {- if (i_chars.includes(ch)) {+ if (i_chars.has(ch)) {return "I"; // LRI, RLI, FSI}- if (pdi_chars.includes(ch)) {+ if (pdi_chars.has(ch)) {return "PDI";}let i = util.lower_bound(rl_ranges, ch);