From fd11c9c6663bcb9c8204dc9a392a417bdf3c46cc Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 7 Oct 2020 01:48:54 -0700 Subject: [PATCH] eslint: Fix unicorn/prefer-includes. https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-includes.md Signed-off-by: Anders Kaseorg --- frontend_tests/zjsunit/namespace.js | 9 +++++---- static/js/muting_ui.js | 2 +- static/js/pill_typeahead.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.js index baa61022cc..a113f18087 100644 --- a/frontend_tests/zjsunit/namespace.js +++ b/frontend_tests/zjsunit/namespace.js @@ -1,5 +1,7 @@ "use strict"; +const path = require("path"); + const _ = require("lodash"); const requires = []; @@ -50,11 +52,10 @@ exports.clear_zulip_refs = function () { correctly, but it will fail if we run it standalone. */ + const staticPath = path.resolve(__dirname, "../../static") + path.sep; _.each(require.cache, (_, fn) => { - if (fn.indexOf("static/") >= 0) { - if (fn.indexOf("static/templates") < 0) { - delete require.cache[fn]; - } + if (fn.startsWith(staticPath) && !fn.startsWith(staticPath + "templates" + path.sep)) { + delete require.cache[fn]; } }); }; diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 2be325b321..d79362f3a0 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -85,7 +85,7 @@ exports.set_up_muted_topics_ui = function () { filter: { element: $search_input, predicate(item, value) { - return item.topic.toLocaleLowerCase().indexOf(value) >= 0; + return item.topic.toLocaleLowerCase().includes(value); }, onupdate() { ui.reset_scrollbar(muted_topics_table.closest(".progressive-table-wrapper")); diff --git a/static/js/pill_typeahead.js b/static/js/pill_typeahead.js index 3d5a23814a..40f17a242b 100644 --- a/static/js/pill_typeahead.js +++ b/static/js/pill_typeahead.js @@ -34,7 +34,7 @@ exports.set_up = function (input, pills, opts) { if (include_streams(query)) { query = query.trim().slice(1); - return item.name.toLowerCase().indexOf(query) !== -1; + return item.name.toLowerCase().includes(query); } if (!settings_data.show_email()) {