Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix unicorn/prefer-array-find.

Anders Kaseorg2694f5caede6
diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js
index b02711793ba..ad895263d02 100644
--- a/frontend_tests/node_tests/people.js
+++ b/frontend_tests/node_tests/people.js
@@ -878,7 +878,7 @@ run_test("updates", () => {
const all_people = get_all_persons();
assert.equal(all_people.length, 2);
- person = all_people.filter((p) => p.email === new_email)[0];
+ person = all_people.find((p) => p.email === new_email);
assert.equal(person.full_name, "Foo Barson");
// Test shim where we can still retrieve user info using the
diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js
index fc7627001e7..14b044a9189 100644
--- a/frontend_tests/node_tests/reactions.js
+++ b/frontend_tests/node_tests/reactions.js
@@ -454,7 +454,7 @@ run_test("add_and_remove_reaction", () => {
const result = reactions.get_message_reactions(message);
assert(reaction_element.hasClass("reacted"));
- const realm_emoji_data = result.filter((v) => v.emoji_name === "realm_emoji")[0];
+ const realm_emoji_data = result.find((v) => v.emoji_name === "realm_emoji");
assert.equal(realm_emoji_data.count, 2);
assert.equal(realm_emoji_data.is_realm_emoji, true);
diff --git a/static/js/reminder.js b/static/js/reminder.js
index d3b7bcf7166..5655ac990e4 100644
--- a/static/js/reminder.js
+++ b/static/js/reminder.js
@@ -50,9 +50,9 @@ exports.schedule_message = function (request) {
const command_line = raw_message[0];
const message = raw_message.slice(1).join("\n");
- const deferred_message_type = deferred_message_types.filter(
+ const deferred_message_type = deferred_message_types.find(
(props) => command_line.match(props.test) !== null,
- )[0];
+ );
const command = command_line.match(deferred_message_type.test)[0];
const deliver_at = command_line.slice(command.length + 1);