Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix no-implicit-coercion.
Anders Kaseorg5c8117a426b7
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 20e0f14c904..cc7e6101d39 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -54,6 +54,7 @@"no-else-return": "error","no-eq-null": "error","no-eval": "error",+ "no-implicit-coercion": "error","no-implied-eval": "error","no-inner-declarations": "off","no-iterator": "error",diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.jsindex 8a2e65b69e9..fd86d4f06ba 100644--- a/frontend_tests/node_tests/drafts.js+++ b/frontend_tests/node_tests/drafts.js@@ -145,7 +145,7 @@ run_test("snapshot_message", () => {return draft.type;};global.compose_state.composing = function () {- return !!draft.type;+ return Boolean(draft.type);};global.compose_state.message_content = function () {return draft.content;diff --git a/static/js/compose_state.js b/static/js/compose_state.jsindex 50867a1c4ee..3483efae473 100644--- a/static/js/compose_state.js+++ b/static/js/compose_state.js@@ -13,7 +13,7 @@ exports.get_message_type = function () {exports.composing = function () {// This is very similar to get_message_type(), but it returns// a boolean.- return !!message_type;+ return Boolean(message_type);};exports.focus_in_empty_compose = function () {diff --git a/static/js/lightbox.js b/static/js/lightbox.jsindex 9a70862b10b..d00954fbf28 100644--- a/static/js/lightbox.js+++ b/static/js/lightbox.js@@ -201,9 +201,9 @@ exports.parse_image_data = function (image) {// if wrapped in the .youtube-video class, it will be length = 1, and therefore// cast to true.- const is_youtube_video = !!$image.closest(".youtube-video").length;- const is_vimeo_video = !!$image.closest(".vimeo-video").length;- const is_embed_video = !!$image.closest(".embed-video").length;+ const is_youtube_video = Boolean($image.closest(".youtube-video").length);+ const is_vimeo_video = Boolean($image.closest(".vimeo-video").length);+ const is_embed_video = Boolean($image.closest(".embed-video").length);// check if image is descendent of #preview_contentconst is_compose_preview_image = $image.closest("#preview_content").length === 1;diff --git a/static/js/notifications.js b/static/js/notifications.jsindex 55e177c2bbb..ab3b7a0d86e 100644--- a/static/js/notifications.js+++ b/static/js/notifications.js@@ -163,7 +163,7 @@ exports.redraw_title = function () {// Make sure we're working with a number, as a defensive programming// measure. And we don't have images above 99, so display those as// 'infinite'.- n = +new_message_count;+ n = Number(new_message_count);if (n > 99) {n = "infinite";}diff --git a/static/js/overlays.js b/static/js/overlays.jsindex 933fce07176..b4d951f7a08 100644--- a/static/js/overlays.js+++ b/static/js/overlays.js@@ -11,7 +11,7 @@ function reset_state() {}exports.is_active = function () {- return !!open_overlay_name;+ return Boolean(open_overlay_name);};exports.is_modal_open = function () {diff --git a/static/js/recent_topics.js b/static/js/recent_topics.jsindex 591c933be63..4512aa3a6be 100644--- a/static/js/recent_topics.js+++ b/static/js/recent_topics.js@@ -175,7 +175,7 @@ function format_topic(topic_data) {// We only supply the data to the topic rows and let jquery// display / hide them according to filters instead of// doing complete re-render.- const topic_muted = !!muting.is_topic_muted(stream_id, topic);+ const topic_muted = Boolean(muting.is_topic_muted(stream_id, topic));const stream_muted = stream_data.is_muted(stream_id);const muted = topic_muted || stream_muted;const unread_count = unread.unread_topic_counter.get(stream_id, topic);@@ -266,7 +266,7 @@ exports.filters_should_hide_topic = function (topic_data) {}if (!filters.has("include_muted")) {- const topic_muted = !!muting.is_topic_muted(msg.stream_id, msg.topic);+ const topic_muted = Boolean(muting.is_topic_muted(msg.stream_id, msg.topic));const stream_muted = stream_data.is_muted(msg.stream_id);if (topic_muted || stream_muted) {return true;diff --git a/static/js/settings_org.js b/static/js/settings_org.jsindex c15a5f115b2..bb515a33952 100644--- a/static/js/settings_org.js+++ b/static/js/settings_org.js@@ -733,7 +733,7 @@ exports.build_page = function () {$("#id_realm_message_content_edit_limit_minutes"),);// Disable editing if the parsed time limit is 0 seconds- data.allow_message_editing = !!data.message_content_edit_limit_seconds;+ data.allow_message_editing = Boolean(data.message_content_edit_limit_seconds);} else {data.allow_message_editing = true;data.message_content_edit_limit_seconds = settings_config.msg_edit_limit_dropdown_values.get(@@ -748,7 +748,7 @@ exports.build_page = function () {$("#id_realm_message_content_delete_limit_minutes"),);// Disable deleting if the parsed time limit is 0 seconds- data.allow_message_deleting = !!data.message_content_delete_limit_seconds;+ data.allow_message_deleting = Boolean(data.message_content_delete_limit_seconds);} else {data.allow_message_deleting = true;data.message_content_delete_limit_seconds = settings_config.msg_delete_limit_dropdown_values.get(