eslint: Enable arrow-parens.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-01 16:39:34 -07:00 committed by Tim Abbott
parent d51afcf485
commit b0253c5a2e
96 changed files with 240 additions and 238 deletions

View File

@ -17,6 +17,7 @@
"rules": { "rules": {
"array-callback-return": "error", "array-callback-return": "error",
"array-bracket-spacing": "error", "array-bracket-spacing": "error",
"arrow-parens": "error",
"arrow-spacing": [ "error", { "before": true, "after": true } ], "arrow-spacing": [ "error", { "before": true, "after": true } ],
"block-scoped-var": "error", "block-scoped-var": "error",
"brace-style": [ "error", "1tbs", { "allowSingleLine": true } ], "brace-style": [ "error", "1tbs", { "allowSingleLine": true } ],

View File

@ -18,7 +18,7 @@ const _document = {
const _channel = {}; const _channel = {};
const _ui = { const _ui = {
get_content_element: element => element, get_content_element: (element) => element,
}; };
const _keydown_util = { const _keydown_util = {
@ -686,7 +686,7 @@ run_test('initialize', () => {
func(); func();
}, },
}); });
$(window).focus = func => func(); $(window).focus = (func) => func();
$(window).idle = () => {}; $(window).idle = () => {};
channel.post = function (payload) { channel.post = function (payload) {

View File

@ -137,7 +137,7 @@ run_test('test_basics', () => {
bot_data.add({...test_bot, user_id: 45, email: 'bot2@zulip.com', owner_id: me.user_id, is_active: true}); bot_data.add({...test_bot, user_id: 45, email: 'bot2@zulip.com', owner_id: me.user_id, is_active: true});
bot_data.add({...test_bot, user_id: 46, email: 'bot3@zulip.com', owner_id: fred.user_id, is_active: true}); bot_data.add({...test_bot, user_id: 46, email: 'bot3@zulip.com', owner_id: fred.user_id, is_active: true});
const editable_bots = bot_data.get_editable().map(bot => bot.email); const editable_bots = bot_data.get_editable().map((bot) => bot.email);
assert.deepEqual(['bot1@zulip.com', 'bot2@zulip.com'], editable_bots); assert.deepEqual(['bot1@zulip.com', 'bot2@zulip.com'], editable_bots);
}()); }());

View File

@ -114,7 +114,7 @@ const emojis_by_name = new Map(Object.entries({
heart: emoji_heart, heart: emoji_heart,
headphones: emoji_headphones, headphones: emoji_headphones,
})); }));
const emoji_list = Array.from(emojis_by_name.values(), emoji_dict => { const emoji_list = Array.from(emojis_by_name.values(), (emoji_dict) => {
if (emoji_dict.is_realm_emoji === true) { if (emoji_dict.is_realm_emoji === true) {
return { return {
emoji_name: emoji_dict.name, emoji_name: emoji_dict.name,
@ -518,7 +518,7 @@ run_test('content_typeahead_selected', () => {
}); });
function sorted_names_from(subs) { function sorted_names_from(subs) {
return subs.map(sub => sub.name).sort(); return subs.map((sub) => sub.name).sort();
} }
run_test('initialize', () => { run_test('initialize', () => {
@ -1320,7 +1320,7 @@ run_test('begins_typeahead', () => {
assert_typeahead_equals("```test", "ing", false); assert_typeahead_equals("```test", "ing", false);
assert_typeahead_equals("~~~test", "ing", false); assert_typeahead_equals("~~~test", "ing", false);
const terminal_symbols = ',.;?!()[] "\'\n\t'; const terminal_symbols = ',.;?!()[] "\'\n\t';
terminal_symbols.split().forEach(symbol => { terminal_symbols.split().forEach((symbol) => {
assert_stream_list("#test", symbol); assert_stream_list("#test", symbol);
assert_typeahead_equals("@test", symbol, all_mentions); assert_typeahead_equals("@test", symbol, all_mentions);
assert_typeahead_equals(":test", symbol, emoji_list); assert_typeahead_equals(":test", symbol, emoji_list);

View File

@ -8,7 +8,7 @@ const test_user = events.test_user;
set_global('$', global.make_zjquery()); set_global('$', global.make_zjquery());
global.patch_builtin('setTimeout', func => func()); global.patch_builtin('setTimeout', (func) => func());
// These dependencies are closer to the dispatcher, and they // These dependencies are closer to the dispatcher, and they
// apply to all tests. // apply to all tests.
@ -570,7 +570,7 @@ with_overrides(function (override) {
override('subs.add_sub_to_table', noop); override('subs.add_sub_to_table', noop);
dispatch(event); dispatch(event);
const args = stub.get_args('streams'); const args = stub.get_args('streams');
assert_same(args.streams.map(stream => stream.stream_id), [42, 99]); assert_same(args.streams.map((stream) => stream.stream_id), [42, 99]);
}); });
// stream delete // stream delete

View File

@ -24,7 +24,7 @@ run_test('basic_functions', () => {
let updated_value; let updated_value;
const opts = { const opts = {
widget_name: 'my_setting', widget_name: 'my_setting',
data: ['one', 'two', 'three'].map(x => ({name: x, value: x})), data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
value: 'one', value: 'one',
on_update: (val) => { updated_value = val; }, on_update: (val) => { updated_value = val; },
default_text: i18n.t("not set"), default_text: i18n.t("not set"),
@ -55,7 +55,7 @@ run_test('basic_functions', () => {
run_test('no_default_value', () => { run_test('no_default_value', () => {
const opts = { const opts = {
widget_name: 'my_setting', widget_name: 'my_setting',
data: ['one', 'two', 'three'].map(x => ({name: x, value: x})), data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
default_text: i18n.t("not set"), default_text: i18n.t("not set"),
render_text: (text) => `rendered: ${text}`, render_text: (text) => `rendered: ${text}`,
null_value: 'null-value', null_value: 'null-value',

View File

@ -35,7 +35,7 @@ people.add_active_user(steve);
people.initialize_current_user(me.user_id); people.initialize_current_user(me.user_id);
function assert_same_operators(result, terms) { function assert_same_operators(result, terms) {
terms = terms.map(term => { terms = terms.map((term) => {
// If negated flag is undefined, we explicitly // If negated flag is undefined, we explicitly
// set it to false. // set it to false.
let negated = term.negated; let negated = term.negated;
@ -571,7 +571,7 @@ run_test('canonicalizations', () => {
}); });
function get_predicate(operators) { function get_predicate(operators) {
operators = operators.map(op => ({ operators = operators.map((op) => ({
operator: op[0], operator: op[0],
operand: op[1], operand: op[1],
})); }));
@ -1558,7 +1558,7 @@ run_test('navbar_helpers', () => {
}, },
]; ];
test_cases.forEach(test_case => { test_cases.forEach((test_case) => {
test_helpers(test_case); test_helpers(test_case);
}); });
@ -1579,7 +1579,7 @@ run_test('navbar_helpers', () => {
}, },
]; ];
redirect_edge_cases.forEach(test_case => { redirect_edge_cases.forEach((test_case) => {
test_redirect_url_with_search(test_case); test_redirect_url_with_search(test_case);
}); });

View File

@ -107,7 +107,7 @@ function config_process_results(messages) {
messages_processed_for_bools.push(message); messages_processed_for_bools.push(message);
}; };
message_store.add_message_metadata = message => message; message_store.add_message_metadata = (message) => message;
message_util.do_unread_count_updates = function (arg) { message_util.do_unread_count_updates = function (arg) {
assert.deepEqual(arg, messages); assert.deepEqual(arg, messages);
@ -130,7 +130,7 @@ function config_process_results(messages) {
} }
function message_range(start, end) { function message_range(start, end) {
return _.range(start, end).map(idx => ({ return _.range(start, end).map((idx) => ({
id: idx, id: idx,
})); }));
} }

View File

@ -155,12 +155,12 @@ run_test('more muting', () => {
}); });
assert.deepEqual( assert.deepEqual(
mld._all_items.map(message => message.id), mld._all_items.map((message) => message.id),
[3, 4, 7, 8] [3, 4, 7, 8]
); );
assert.deepEqual( assert.deepEqual(
mld.all_messages().map(message => message.id), mld.all_messages().map((message) => message.id),
[4, 8] [4, 8]
); );
@ -177,12 +177,12 @@ run_test('more muting', () => {
const more_info = mld.add_messages(more_messages); const more_info = mld.add_messages(more_messages);
assert.deepEqual( assert.deepEqual(
mld._all_items.map(message => message.id), mld._all_items.map((message) => message.id),
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
); );
assert.deepEqual( assert.deepEqual(
mld.all_messages().map(message => message.id), mld.all_messages().map((message) => message.id),
[2, 4, 6, 8, 10] [2, 4, 6, 8, 10]
); );

View File

@ -169,7 +169,7 @@ run_test('merge_message_groups', () => {
} }
function extract_message_ids(lst) { function extract_message_ids(lst) {
return lst.map(item => item.msg.id); return lst.map((item) => item.msg.id);
} }
function assert_message_list_equal(list1, list2) { function assert_message_list_equal(list1, list2) {
@ -546,7 +546,7 @@ run_test('render_windows', () => {
let messages; let messages;
function reset_list(opts) { function reset_list(opts) {
messages = _.range(opts.count).map(i => ({ messages = _.range(opts.count).map((i) => ({
id: i, id: i,
})); }));
list.selected_idx = function () { return 0; }; list.selected_idx = function () { return 0; };

View File

@ -65,7 +65,7 @@ people.initialize_current_user(me.user_id);
function convert_recipients(people) { function convert_recipients(people) {
// Display_recipient uses `id` for user_ids. // Display_recipient uses `id` for user_ids.
return people.map(p => ({ return people.map((p) => ({
email: p.email, email: p.email,
id: p.user_id, id: p.user_id,
full_name: p.full_name, full_name: p.full_name,

View File

@ -17,7 +17,7 @@ set_global('resize', {
zrequire('narrow'); zrequire('narrow');
function set_filter(operators) { function set_filter(operators) {
operators = operators.map(op => ({ operators = operators.map((op) => ({
operator: op[0], operator: op[0],
operand: op[1], operand: op[1],
})); }));

View File

@ -68,7 +68,7 @@ function test_with(fixture) {
assert.deepEqual(id_info, fixture.expected_id_info); assert.deepEqual(id_info, fixture.expected_id_info);
const msgs = msg_data.all_messages(); const msgs = msg_data.all_messages();
const msg_ids = msgs.map(message => message.id); const msg_ids = msgs.map((message) => message.id);
assert.deepEqual(msg_ids, fixture.expected_msg_ids); assert.deepEqual(msg_ids, fixture.expected_msg_ids);
} }

View File

@ -7,7 +7,7 @@ zrequire('narrow_state');
set_global('page_params', {}); set_global('page_params', {});
function set_filter(operators) { function set_filter(operators) {
operators = operators.map(op => ({ operators = operators.map((op) => ({
operator: op[0], operator: op[0],
operand: op[1], operand: op[1],
})); }));

View File

@ -897,7 +897,7 @@ run_test('updates', () => {
const all_people = get_all_persons(); const all_people = get_all_persons();
assert.equal(all_people.length, 2); assert.equal(all_people.length, 2);
person = all_people.filter(p => p.email === new_email)[0]; person = all_people.filter((p) => p.email === new_email)[0];
assert.equal(person.full_name, 'Foo Barson'); assert.equal(person.full_name, 'Foo Barson');
// Test shim where we can still retrieve user info using the // Test shim where we can still retrieve user info using the

View File

@ -2,7 +2,7 @@ set_global('$', global.make_zjquery());
set_global('narrow_state', {}); set_global('narrow_state', {});
set_global('ui', { set_global('ui', {
get_content_element: element => element, get_content_element: (element) => element,
}); });
set_global('stream_popover', { set_global('stream_popover', {
hide_topic_popover: function () {}, hide_topic_popover: function () {},

View File

@ -420,7 +420,7 @@ run_test('add_and_remove_reaction', () => {
const result = reactions.get_message_reactions(message); const result = reactions.get_message_reactions(message);
assert(reaction_element.hasClass('reacted')); assert(reaction_element.hasClass('reacted'));
const realm_emoji_data = result.filter(v => v.emoji_name === 'realm_emoji')[0]; const realm_emoji_data = result.filter((v) => v.emoji_name === 'realm_emoji')[0];
assert.equal(realm_emoji_data.count, 2); assert.equal(realm_emoji_data.count, 2);
assert.equal(realm_emoji_data.is_realm_emoji, true); assert.equal(realm_emoji_data.is_realm_emoji, true);

View File

@ -5,7 +5,7 @@ const messages = [];
set_global('message_util', { set_global('message_util', {
get_messages_in_topic: (stream_id, topic) => { get_messages_in_topic: (stream_id, topic) => {
return messages.filter(x => { return messages.filter((x) => {
return x.stream_id === stream_id && return x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase(); x.topic.toLowerCase() === topic.toLowerCase();
}); });

View File

@ -52,7 +52,7 @@ stream_data.add_sub(stream);
const $array = (array) => { const $array = (array) => {
const each = (func) => { const each = (func) => {
array.forEach(e => { array.forEach((e) => {
func.call(e); func.call(e);
}); });
}; };

View File

@ -1,6 +1,6 @@
zrequire('scroll_util'); zrequire('scroll_util');
set_global('ui', { set_global('ui', {
get_scroll_element: element => element, get_scroll_element: (element) => element,
}); });
run_test('scroll_delta', () => { run_test('scroll_delta', () => {

View File

@ -27,7 +27,7 @@ set_global('search_pill_widget', {
search_pill.append_search_string = noop; search_pill.append_search_string = noop;
search_pill.get_search_string_for_current_filter = noop; search_pill.get_search_string_for_current_filter = noop;
global.patch_builtin('setTimeout', func => func()); global.patch_builtin('setTimeout', (func) => func());
run_test('clear_search_form', () => { run_test('clear_search_form', () => {
$('#search_query').val('noise'); $('#search_query').val('noise');

View File

@ -17,7 +17,7 @@ set_global('ui_util', {
set_global('narrow', {}); set_global('narrow', {});
set_global('Filter', {}); set_global('Filter', {});
global.patch_builtin('setTimeout', func => func()); global.patch_builtin('setTimeout', (func) => func());
run_test('update_button_visibility', () => { run_test('update_button_visibility', () => {
const search_query = $('#search_query'); const search_query = $('#search_query');

View File

@ -200,7 +200,7 @@ function test_submit_settings_form(submit_form) {
realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code, realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code,
}); });
global.patch_builtin('setTimeout', func => func()); global.patch_builtin('setTimeout', (func) => func());
const ev = { const ev = {
preventDefault: noop, preventDefault: noop,
stopPropagation: noop, stopPropagation: noop,
@ -1016,7 +1016,7 @@ run_test('misc', () => {
'realm_default_code_block_language']; 'realm_default_code_block_language'];
const dropdown_list_parent = $.create(`<list parent>`); const dropdown_list_parent = $.create(`<list parent>`);
dropdown_list_parent.set_find_results('.dropdown_list_reset_button:not([disabled])', $.create('<disable button>')); dropdown_list_parent.set_find_results('.dropdown_list_reset_button:not([disabled])', $.create('<disable button>'));
widget_settings.forEach(name => { widget_settings.forEach((name) => {
const elem = $.create(`#${name}_widget #${name}_name`); const elem = $.create(`#${name}_widget #${name}_name`);
elem.closest = () => { elem.closest = () => {
return dropdown_list_parent; return dropdown_list_parent;

View File

@ -210,7 +210,7 @@ run_test('populate_user_groups', () => {
(function test_source() { (function test_source() {
const result = config.source.call(fake_context, iago); const result = config.source.call(fake_context, iago);
const emails = result.map(user => user.email).sort(); const emails = result.map((user) => user.email).sort();
assert.deepEqual(emails, [alice.email, bob.email]); assert.deepEqual(emails, [alice.email, bob.email]);
}()); }());

View File

@ -35,7 +35,7 @@ people.add_active_user(me);
people.initialize_current_user(me.user_id); people.initialize_current_user(me.user_id);
function contains_sub(subs, sub) { function contains_sub(subs, sub) {
return subs.some(s => s.name === sub.name); return subs.some((s) => s.name === sub.name);
} }
run_test('basics', () => { run_test('basics', () => {
@ -921,7 +921,7 @@ run_test('initialize', () => {
initialize(); initialize();
assert(!stream_data.is_filtering_inactives()); assert(!stream_data.is_filtering_inactives());
const stream_names = stream_data.get_streams_for_admin().map(elem => elem.name); const stream_names = stream_data.get_streams_for_admin().map((elem) => elem.name);
assert(stream_names.includes('subscriptions')); assert(stream_names.includes('subscriptions'));
assert(stream_names.includes('unsubscribed')); assert(stream_names.includes('unsubscribed'));
assert(stream_names.includes('never_subscribed')); assert(stream_names.includes('never_subscribed'));

View File

@ -390,7 +390,7 @@ run_test('narrowing', () => {
scroll_util.scroll_element_into_container = noop; scroll_util.scroll_element_into_container = noop;
set_global('ui', { set_global('ui', {
get_scroll_element: element => element, get_scroll_element: (element) => element,
}); });
assert(!$('<devel sidebar row html>').hasClass('active-filter')); assert(!$('<devel sidebar row html>').hasClass('active-filter'));

View File

@ -1,8 +1,8 @@
global.stub_out_jquery(); global.stub_out_jquery();
set_global('ui', { set_global('ui', {
get_content_element: element => element, get_content_element: (element) => element,
get_scroll_element: element => element, get_scroll_element: (element) => element,
}); });
zrequire('stream_data'); zrequire('stream_data');
zrequire('search_util'); zrequire('search_util');

View File

@ -81,7 +81,7 @@ run_test('get_list_info unreads', () => {
// Going forward, we just stub get_recent_topic_names // Going forward, we just stub get_recent_topic_names
// for simpler test setup. // for simpler test setup.
stream_topic_history.get_recent_topic_names = () => { stream_topic_history.get_recent_topic_names = () => {
return _.range(15).map(i => 'topic ' + i); return _.range(15).map((i) => 'topic ' + i);
}; };
const unread_cnt = new Map(); const unread_cnt = new Map();
@ -108,7 +108,7 @@ run_test('get_list_info unreads', () => {
assert.equal(list_info.num_possible_topics, 15); assert.equal(list_info.num_possible_topics, 15);
assert.deepEqual( assert.deepEqual(
list_info.items.map(li => li.topic_name), list_info.items.map((li) => li.topic_name),
[ [
'topic 0', 'topic 0',
'topic 1', 'topic 1',
@ -128,7 +128,7 @@ run_test('get_list_info unreads', () => {
assert.equal(list_info.num_possible_topics, 15); assert.equal(list_info.num_possible_topics, 15);
assert.deepEqual( assert.deepEqual(
list_info.items.map(li => li.topic_name), list_info.items.map((li) => li.topic_name),
[ [
'topic 0', 'topic 0',
'topic 1', 'topic 1',
@ -155,7 +155,7 @@ run_test('get_list_info unreads', () => {
assert.equal(list_info.num_possible_topics, 15); assert.equal(list_info.num_possible_topics, 15);
assert.deepEqual( assert.deepEqual(
list_info.items.map(li => li.topic_name), list_info.items.map((li) => li.topic_name),
[ [
'topic 0', 'topic 0',
'topic 1', 'topic 1',

View File

@ -26,8 +26,8 @@ let next_id = 0;
function assertSameEmails(lst1, lst2) { function assertSameEmails(lst1, lst2) {
assert.deepEqual( assert.deepEqual(
lst1.map(r => r.email), lst1.map((r) => r.email),
lst2.map(r => r.email) lst2.map((r) => r.email)
); );
} }
@ -211,7 +211,7 @@ function get_typeahead_result(query, current_stream, current_topic) {
current_stream, current_stream,
current_topic current_topic
); );
return result.map(person => person.email); return result.map((person) => person.email);
} }
run_test('sort_recipients', () => { run_test('sort_recipients', () => {
@ -363,7 +363,7 @@ run_test('sort_recipients dup bots', () => {
const dup_objects = matches.concat([a_bot]); const dup_objects = matches.concat([a_bot]);
const recipients = th.sort_recipients(dup_objects, "b", "", ""); const recipients = th.sort_recipients(dup_objects, "b", "", "");
const recipients_email = recipients.map(person => person.email); const recipients_email = recipients.map((person) => person.email);
const expected = [ const expected = [
'b_bot@example.com', 'b_bot@example.com',
'b_user_3@zulip.net', 'b_user_3@zulip.net',
@ -400,7 +400,7 @@ run_test('sort_recipients subscribers', () => {
// b_user_2 is a subscriber and b_user_1 is not. // b_user_2 is a subscriber and b_user_1 is not.
const small_matches = [b_user_2, b_user_1]; const small_matches = [b_user_2, b_user_1];
const recipients = th.sort_recipients(small_matches, "b", "Dev", "Dev Topic"); const recipients = th.sort_recipients(small_matches, "b", "Dev", "Dev Topic");
const recipients_email = recipients.map(person => person.email); const recipients_email = recipients.map((person) => person.email);
const expected = [ const expected = [
'b_user_2@zulip.net', 'b_user_2@zulip.net',
'b_user_1@zulip.net', 'b_user_1@zulip.net',
@ -413,7 +413,7 @@ run_test('sort_recipients pm partners', () => {
// both are not subscribered to the stream Linux. // both are not subscribered to the stream Linux.
const small_matches = [b_user_3, b_user_2]; const small_matches = [b_user_3, b_user_2];
const recipients = th.sort_recipients(small_matches, "b", "Linux", "Linux Topic"); const recipients = th.sort_recipients(small_matches, "b", "Linux", "Linux Topic");
const recipients_email = recipients.map(person => person.email); const recipients_email = recipients.map((person) => person.email);
const expected = [ const expected = [
'b_user_3@zulip.net', 'b_user_3@zulip.net',
'b_user_2@zulip.net', 'b_user_2@zulip.net',
@ -432,7 +432,7 @@ run_test('sort broadcast mentions', () => {
''); '');
assert.deepEqual( assert.deepEqual(
results.map(r => r.email), results.map((r) => r.email),
['all', 'everyone', 'stream'] ['all', 'everyone', 'stream']
); );
@ -449,7 +449,7 @@ run_test('sort broadcast mentions', () => {
''); '');
assert.deepEqual( assert.deepEqual(
results2.map(r => r.email), results2.map((r) => r.email),
['all', ['all',
'everyone', 'everyone',
'stream', 'stream',
@ -709,7 +709,7 @@ run_test('sort_slash_commands', () => {
run_test('sort_recipientbox_typeahead', () => { run_test('sort_recipientbox_typeahead', () => {
let recipients = th.sort_recipientbox_typeahead("b, a", matches, ""); // search "a" let recipients = th.sort_recipientbox_typeahead("b, a", matches, ""); // search "a"
let recipients_email = recipients.map(person => person.email); let recipients_email = recipients.map((person) => person.email);
assert.deepEqual(recipients_email, [ assert.deepEqual(recipients_email, [
'a_user@zulip.org', // matches "a" 'a_user@zulip.org', // matches "a"
'a_bot@zulip.com', // matches "a" 'a_bot@zulip.com', // matches "a"
@ -721,7 +721,7 @@ run_test('sort_recipientbox_typeahead', () => {
]); ]);
recipients = th.sort_recipientbox_typeahead("b, a, b", matches, ""); // search "b" recipients = th.sort_recipientbox_typeahead("b, a, b", matches, ""); // search "b"
recipients_email = recipients.map(person => person.email); recipients_email = recipients.map((person) => person.email);
assert.deepEqual(recipients_email, [ assert.deepEqual(recipients_email, [
'b_bot@example.com', 'b_bot@example.com',
'b_user_3@zulip.net', 'b_user_3@zulip.net',

View File

@ -72,7 +72,7 @@ emoji.emojis_by_name = new Map();
util.is_mobile = () => false; util.is_mobile = () => false;
global.stub_templates(() => 'some-html'); global.stub_templates(() => 'some-html');
ui.get_scroll_element = element => element; ui.get_scroll_element = (element) => element;
zrequire('alert_words'); zrequire('alert_words');
zrequire('hash_util'); zrequire('hash_util');

View File

@ -119,7 +119,7 @@ function make_child(i, name) {
} }
function make_children(lst) { function make_children(lst) {
return lst.map(i => make_child(i, 'foo' + i)); return lst.map((i) => make_child(i, 'foo' + i));
} }
run_test('children', () => { run_test('children', () => {

View File

@ -105,7 +105,7 @@ class CommonUtils {
// is parsed but before DOMContentLoaded event is fired. // is parsed but before DOMContentLoaded event is fired.
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded' }), page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
page.$eval('#login_form', form => form.submit()), page.$eval('#login_form', (form) => form.submit()),
]); ]);
} }
@ -224,7 +224,7 @@ class CommonUtils {
// confirm if compose box is empty. // confirm if compose box is empty.
const compose_box_element = await page.$("#compose-textarea"); const compose_box_element = await page.$("#compose-textarea");
const compose_box_content = await page.evaluate(element => element.textContent, const compose_box_content = await page.evaluate((element) => element.textContent,
compose_box_element); compose_box_element);
assert.equal(compose_box_content, '', 'Compose box not empty after message sent'); assert.equal(compose_box_content, '', 'Compose box not empty after message sent');

View File

@ -14,7 +14,7 @@ async function realm_creation_tests(page) {
await page.type('#email', email); await page.type('#email', email);
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.$eval('#send_confirm', form => form.submit()), page.$eval('#send_confirm', (form) => form.submit()),
]); ]);
// Make sure onfirmation email is sent. // Make sure onfirmation email is sent.
@ -53,9 +53,9 @@ async function realm_creation_tests(page) {
}; };
// For some reason, page.click() does not work this for particular checkbox // For some reason, page.click() does not work this for particular checkbox
// so use page.$eval here to call the .click method in the browser. // so use page.$eval here to call the .click method in the browser.
await page.$eval('#realm_in_root_domain', el => el.click()); await page.$eval('#realm_in_root_domain', (el) => el.click());
await common.fill_form(page, '#registration', params); await common.fill_form(page, '#registration', params);
await page.$eval('#registration', form => form.submit()); await page.$eval('#registration', (form) => form.submit());
// Check if realm is created and user is logged in by checking if // Check if realm is created and user is logged in by checking if
// element of id `lightbox_overlay` exists. // element of id `lightbox_overlay` exists.

View File

@ -7,7 +7,7 @@ const templates_path = path.resolve(__dirname, "../../static/templates");
exports.make_handlebars = () => Handlebars.create(); exports.make_handlebars = () => Handlebars.create();
exports.stub_templates = stub => { exports.stub_templates = (stub) => {
window.template_stub = stub; window.template_stub = stub;
}; };

View File

@ -17,7 +17,7 @@ exports.t = function (str, context) {
*/ */
const keyword_regex = /__(- )?(\w)+__/g; const keyword_regex = /__(- )?(\w)+__/g;
const keys_in_str = str.match(keyword_regex) || []; const keys_in_str = str.match(keyword_regex) || [];
const substitutions = keys_in_str.map(key => { const substitutions = keys_in_str.map((key) => {
let prefix_length; let prefix_length;
if (key.startsWith("__- ")) { if (key.startsWith("__- ")) {
prefix_length = 4; prefix_length = 4;

View File

@ -79,7 +79,7 @@ global.read_fixture_data = (fn) => {
function short_tb(tb) { function short_tb(tb) {
const lines = tb.split('\n'); const lines = tb.split('\n');
const i = lines.findIndex(line => line.includes('run_test') || line.includes('run_one_module')); const i = lines.findIndex((line) => line.includes('run_test') || line.includes('run_one_module'));
if (i === -1) { if (i === -1) {
return tb; return tb;

View File

@ -41,7 +41,7 @@ exports.make_zblueslip = function () {
for (const name of names) { for (const name of names) {
for (const obj of lib.test_logs[name]) { for (const obj of lib.test_logs[name]) {
const message = obj.message; const message = obj.message;
const i = lib.test_data[name].findIndex(x => x.message === message); const i = lib.test_data[name].findIndex((x) => x.message === message);
if (i === -1) { if (i === -1) {
// Only throw this for message types we want to explicitly track. // Only throw this for message types we want to explicitly track.
// For example, we do not want to throw here for debug messages. // For example, we do not want to throw here for debug messages.
@ -99,7 +99,7 @@ exports.make_zblueslip = function () {
} }
} }
lib.test_logs[name].push({message, more_info, stack}); lib.test_logs[name].push({message, more_info, stack});
const matched_error_message = lib.test_data[name].find(x => x.message === message); const matched_error_message = lib.test_data[name].find((x) => x.message === message);
const exact_match_fail = !matched_error_message; const exact_match_fail = !matched_error_message;
if (exact_match_fail) { if (exact_match_fail) {
const error = Error(`Invalid ${name} message: "${message}".`); const error = Error(`Invalid ${name} message: "${message}".`);

View File

@ -523,9 +523,9 @@ exports.make_zjquery = function (opts) {
zjquery.state = function () { zjquery.state = function () {
// useful for debugging // useful for debugging
let res = Array.from(elems.values(), v => v.debug()); let res = Array.from(elems.values(), (v) => v.debug());
res = res.map(v => [v.selector, v.value, v.shown]); res = res.map((v) => [v.selector, v.value, v.shown]);
res.sort(); res.sort();

View File

@ -37,7 +37,7 @@ Logger.prototype = (function () {
pad(now.getUTCSeconds(), 2) + '.' + pad(now.getUTCSeconds(), 2) + '.' +
pad(now.getUTCMilliseconds(), 3) + ' UTC'; pad(now.getUTCMilliseconds(), 3) + ' UTC';
const str_args = args.map(x => typeof x === "object" ? JSON.stringify(x) : x); const str_args = args.map((x) => typeof x === "object" ? JSON.stringify(x) : x);
const log_entry = date_str + " " + name.toUpperCase() + const log_entry = date_str + " " + name.toUpperCase() +
': ' + str_args.join(""); ': ' + str_args.join("");

View File

@ -30,7 +30,7 @@ exports.all_user_ids = function () {
exports.add = function (bot) { exports.add = function (bot) {
const clean_bot = _.pick(bot, bot_fields); const clean_bot = _.pick(bot, bot_fields);
bots.set(bot.user_id, clean_bot); bots.set(bot.user_id, clean_bot);
const clean_services = bot.services.map(service => _.pick(service, services_fields)); const clean_services = bot.services.map((service) => _.pick(service, services_fields));
services.set(bot.user_id, clean_services); services.set(bot.user_id, clean_services);
send_change_event(); send_change_event();

View File

@ -116,12 +116,12 @@ function filter_user_ids(user_filter_text, user_ids) {
return user_ids; return user_ids;
} }
user_ids = user_ids.filter(user_id => !people.is_my_user_id(user_id)); user_ids = user_ids.filter((user_id) => !people.is_my_user_id(user_id));
let search_terms = user_filter_text.toLowerCase().split(/[|,]+/); let search_terms = user_filter_text.toLowerCase().split(/[|,]+/);
search_terms = search_terms.map(s => s.trim()); search_terms = search_terms.map((s) => s.trim());
const persons = user_ids.map(user_id => people.get_by_user_id(user_id)); const persons = user_ids.map((user_id) => people.get_by_user_id(user_id));
const user_id_dict = people.filter_people_by_search_terms(persons, search_terms); const user_id_dict = people.filter_people_by_search_terms(persons, search_terms);
return Array.from(user_id_dict.keys()); return Array.from(user_id_dict.keys());
@ -306,7 +306,7 @@ function get_user_id_list(user_filter_text) {
user_ids = presence.get_user_ids(); user_ids = presence.get_user_ids();
} }
user_ids = user_ids.filter(user_id => { user_ids = user_ids.filter((user_id) => {
const person = people.get_by_user_id(user_id); const person = people.get_by_user_id(user_id);
if (!person) { if (!person) {
@ -334,7 +334,7 @@ exports.get_items_for_users = function (user_ids) {
}; };
exports.huddle_fraction_present = function (huddle) { exports.huddle_fraction_present = function (huddle) {
const user_ids = huddle.split(',').map(s => parseInt(s, 10)); const user_ids = huddle.split(',').map((s) => parseInt(s, 10));
let num_present = 0; let num_present = 0;

View File

@ -33,7 +33,7 @@ exports.claim_color = function (color) {
}; };
exports.claim_colors = function (subs) { exports.claim_colors = function (subs) {
const colors = new Set(subs.map(sub => sub.color)); const colors = new Set(subs.map((sub) => sub.color));
colors.forEach(exports.claim_color); colors.forEach(exports.claim_color);
}; };

View File

@ -103,7 +103,7 @@ exports.toggle = function (opts) {
maybe_go_right: maybe_go_right, maybe_go_right: maybe_go_right,
disable_tab: function (name) { disable_tab: function (name) {
const value = opts.values.find(o => o.key === name); const value = opts.values.find((o) => o.key === name);
const idx = opts.values.indexOf(value); const idx = opts.values.indexOf(value);
meta.$ind_tab.eq(idx).addClass('disabled'); meta.$ind_tab.eq(idx).addClass('disabled');
@ -121,7 +121,7 @@ exports.toggle = function (opts) {
// go through the process of finding the correct tab for a given name, // go through the process of finding the correct tab for a given name,
// and when found, select that one and provide the proper callback. // and when found, select that one and provide the proper callback.
goto: function (name) { goto: function (name) {
const value = opts.values.find(o => o.label === name || o.key === name); const value = opts.values.find((o) => o.label === name || o.key === name);
const idx = opts.values.indexOf(value); const idx = opts.values.indexOf(value);

View File

@ -423,7 +423,7 @@ exports.get_invalid_recipient_emails = function () {
const private_recipients = util.extract_pm_recipients( const private_recipients = util.extract_pm_recipients(
compose_state.private_message_recipient()); compose_state.private_message_recipient());
const invalid_recipients = private_recipients.filter( const invalid_recipients = private_recipients.filter(
email => !people.is_valid_email_for_compose(email) (email) => !people.is_valid_email_for_compose(email)
); );
return invalid_recipients; return invalid_recipients;
@ -916,7 +916,7 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
const error_area = $("#compose_invite_users"); const error_area = $("#compose_invite_users");
const existing_invites_area = $('#compose_invite_users .compose_invite_user'); const existing_invites_area = $('#compose_invite_users .compose_invite_user');
const existing_invites = Array.from($(existing_invites_area), user_row => { const existing_invites = Array.from($(existing_invites_area), (user_row) => {
return parseInt($(user_row).data('user-id'), 10); return parseInt($(user_row).data('user-id'), 10);
}); });

View File

@ -92,7 +92,7 @@ exports.compute_placeholder_text = function (opts) {
// For Private Messages // For Private Messages
if (opts.private_message_recipient) { if (opts.private_message_recipient) {
const recipient_list = opts.private_message_recipient.split(","); const recipient_list = opts.private_message_recipient.split(",");
const recipient_names = recipient_list.map(recipient => { const recipient_names = recipient_list.map((recipient) => {
const user = people.get_by_email(recipient); const user = people.get_by_email(recipient);
return user.full_name; return user.full_name;
}).join(", "); }).join(", ");

View File

@ -381,7 +381,7 @@ function should_show_custom_query(query, items) {
if (!query) { if (!query) {
return false; return false;
} }
const matched = items.some(elem => elem.toLowerCase() === query.toLowerCase()); const matched = items.some((elem) => elem.toLowerCase() === query.toLowerCase());
return !matched; return !matched;
} }
@ -590,7 +590,7 @@ exports.get_sorted_filtered_items = function (query) {
exports.filter_and_sort_candidates = function (completing, candidates, token) { exports.filter_and_sort_candidates = function (completing, candidates, token) {
const matcher = exports.compose_content_matcher(completing, token); const matcher = exports.compose_content_matcher(completing, token);
const small_results = candidates.filter(item => matcher(item)); const small_results = candidates.filter((item) => matcher(item));
const sorted_results = exports.sort_results(completing, small_results, token); const sorted_results = exports.sort_results(completing, small_results, token);

View File

@ -245,7 +245,7 @@ exports.format_draft = function (draft) {
}; };
} else { } else {
const emails = util.extract_pm_recipients(draft.private_message_recipient); const emails = util.extract_pm_recipients(draft.private_message_recipient);
const recipients = emails.map(email => { const recipients = emails.map((email) => {
email = email.trim(); email = email.trim();
const person = people.get_by_email(email); const person = people.get_by_email(email);
if (person !== undefined) { if (person !== undefined) {

View File

@ -30,7 +30,7 @@ const DropdownListWidget = function (opts) {
} }
// Happy path // Happy path
const item = opts.data.find(x => x.value === value.toString()); const item = opts.data.find((x) => x.value === value.toString());
const text = opts.render_text(item.name); const text = opts.render_text(item.name);
elem.text(text); elem.text(text);
elem.removeClass('text-warning'); elem.removeClass('text-warning');

View File

@ -52,7 +52,7 @@ exports.build_display_recipient = function (message) {
const emails = util.extract_pm_recipients(message.private_message_recipient); const emails = util.extract_pm_recipients(message.private_message_recipient);
let sender_in_display_recipients = false; let sender_in_display_recipients = false;
const display_recipient = emails.map(email => { const display_recipient = emails.map((email) => {
email = email.trim(); email = email.trim();
const person = people.get_by_email(email); const person = people.get_by_email(email);
if (person === undefined) { if (person === undefined) {

View File

@ -103,7 +103,7 @@ function show_emoji_catalog() {
exports.generate_emoji_picker_data = function (realm_emojis) { exports.generate_emoji_picker_data = function (realm_emojis) {
const catalog = new Map(); const catalog = new Map();
catalog.set("Custom", Array.from(realm_emojis.keys(), realm_emoji_name => catalog.set("Custom", Array.from(realm_emojis.keys(), (realm_emoji_name) =>
emoji.emojis_by_name.get(realm_emoji_name) emoji.emojis_by_name.get(realm_emoji_name)
)); ));
@ -133,8 +133,8 @@ exports.generate_emoji_picker_data = function (realm_emojis) {
} }
catalog.set("Popular", popular); catalog.set("Popular", popular);
const categories = get_all_emoji_categories().filter(category => catalog.has(category.name)); const categories = get_all_emoji_categories().filter((category) => catalog.has(category.name));
exports.complete_emoji_catalog = categories.map(category => ({ exports.complete_emoji_catalog = categories.map((category) => ({
name: category.name, name: category.name,
icon: category.icon, icon: category.icon,
emojis: catalog.get(category.name), emojis: catalog.get(category.name),
@ -148,7 +148,7 @@ const generate_emoji_picker_content = function (id) {
emojis_used = reactions.get_emojis_used_by_user_for_message_id(id); emojis_used = reactions.get_emojis_used_by_user_for_message_id(id);
} }
for (const emoji_dict of emoji.emojis_by_name.values()) { for (const emoji_dict of emoji.emojis_by_name.values()) {
emoji_dict.has_reacted = emoji_dict.aliases.some(alias => emojis_used.includes(alias)); emoji_dict.has_reacted = emoji_dict.aliases.some((alias) => emojis_used.includes(alias));
} }
return render_emoji_popover_content({ return render_emoji_popover_content({
@ -212,7 +212,7 @@ function filter_emojis() {
for (const emoji_dict of emojis) { for (const emoji_dict of emojis) {
for (const alias of emoji_dict.aliases) { for (const alias of emoji_dict.aliases) {
const match = search_terms.every(search_term => alias.includes(search_term)); const match = search_terms.every((search_term) => alias.includes(search_term));
if (match) { if (match) {
search_results.push({ ...emoji_dict, name: alias }); search_results.push({ ...emoji_dict, name: alias });
break; // We only need the first matching alias per emoji. break; // We only need the first matching alias per emoji.

View File

@ -42,7 +42,7 @@ function wrap_quote(text) {
// beginning of each line // beginning of each line
for (const paragraph of paragraphs) { for (const paragraph of paragraphs) {
const lines = paragraph.split('\n'); const lines = paragraph.split('\n');
quoted_paragraphs.push(lines.filter(line => line !== '').map(line => '> ' + line).join('\n')); quoted_paragraphs.push(lines.filter((line) => line !== '').map((line) => '> ' + line).join('\n'));
} }
return quoted_paragraphs.join('\n\n'); return quoted_paragraphs.join('\n\n');

View File

@ -323,7 +323,7 @@ Filter.parse = function (str) {
might need to support multiple operators of the same type. might need to support multiple operators of the same type.
*/ */
Filter.unparse = function (operators) { Filter.unparse = function (operators) {
const parts = operators.map(elem => { const parts = operators.map((elem) => {
if (elem.operator === 'search') { if (elem.operator === 'search') {
// Search terms are the catch-all case. // Search terms are the catch-all case.
@ -357,7 +357,7 @@ Filter.prototype = {
public_operators: function () { public_operators: function () {
const safe_to_return = this._operators.filter( const safe_to_return = this._operators.filter(
// Filter out the embedded narrow (if any). // Filter out the embedded narrow (if any).
value => (value) =>
!( !(
page_params.narrow_stream !== undefined && page_params.narrow_stream !== undefined &&
value.operator === "stream" && value.operator === "stream" &&
@ -376,18 +376,18 @@ Filter.prototype = {
has_negated_operand: function (operator, operand) { has_negated_operand: function (operator, operand) {
return this._operators.some( return this._operators.some(
elem => elem.negated && (elem.operator === operator && elem.operand === operand) (elem) => elem.negated && (elem.operator === operator && elem.operand === operand)
); );
}, },
has_operand: function (operator, operand) { has_operand: function (operator, operand) {
return this._operators.some( return this._operators.some(
elem => !elem.negated && (elem.operator === operator && elem.operand === operand) (elem) => !elem.negated && (elem.operator === operator && elem.operand === operand)
); );
}, },
has_operator: function (operator) { has_operator: function (operator) {
return this._operators.some(elem => { return this._operators.some((elem) => {
if (elem.negated && !['search', 'has'].includes(elem.operator)) { if (elem.negated && !['search', 'has'].includes(elem.operator)) {
return false; return false;
} }
@ -591,7 +591,7 @@ Filter.prototype = {
return i18n.t('Private messages'); return i18n.t('Private messages');
case 'pm-with': { case 'pm-with': {
const emails = this.operands('pm-with')[0].split(','); const emails = this.operands('pm-with')[0].split(',');
const names = emails.map(email => { const names = emails.map((email) => {
if (!people.get_by_email(email)) { if (!people.get_by_email(email)) {
return email; return email;
} }
@ -673,15 +673,15 @@ Filter.prototype = {
return terms; return terms;
} }
return terms.filter(term => Filter.term_type(term) !== 'is-private'); return terms.filter((term) => Filter.term_type(term) !== 'is-private');
}, },
_canonicalize_operators: function (operators_mixed_case) { _canonicalize_operators: function (operators_mixed_case) {
return operators_mixed_case.map(tuple => Filter.canonicalize_term(tuple)); return operators_mixed_case.map((tuple) => Filter.canonicalize_term(tuple));
}, },
filter_with_new_params: function (params) { filter_with_new_params: function (params) {
const terms = this._operators.map(term => { const terms = this._operators.map((term) => {
const new_term = { ...term }; const new_term = { ...term };
if (new_term.operator === params.operator && !new_term.negated) { if (new_term.operator === params.operator && !new_term.negated) {
new_term.operand = params.operand; new_term.operand = params.operand;
@ -729,7 +729,7 @@ Filter.prototype = {
first_valid_id_from: function (msg_ids) { first_valid_id_from: function (msg_ids) {
const predicate = this.predicate(); const predicate = this.predicate();
const first_id = msg_ids.find(msg_id => { const first_id = msg_ids.find((msg_id) => {
const message = message_store.get(msg_id); const message = message_store.get(msg_id);
if (message === undefined) { if (message === undefined) {
@ -771,7 +771,7 @@ Filter.prototype = {
// build JavaScript code in a string and then eval() it. // build JavaScript code in a string and then eval() it.
return function (message) { return function (message) {
return operators.every(term => { return operators.every((term) => {
let ok = message_matches_search_term(message, term.operator, term.operand); let ok = message_matches_search_term(message, term.operator, term.operand);
if (term.negated) { if (term.negated) {
ok = !ok; ok = !ok;
@ -910,7 +910,7 @@ function describe_unescaped(operators) {
} }
} }
const more_parts = operators.map(elem => { const more_parts = operators.map((elem) => {
const operand = elem.operand; const operand = elem.operand;
const canonicalized_operator = Filter.canonicalize_operator(elem.operator); const canonicalized_operator = Filter.canonicalize_operator(elem.operator);
if (canonicalized_operator === 'is') { if (canonicalized_operator === 'is') {

View File

@ -237,7 +237,7 @@ exports.close_hotspot_icon = function (elem) {
function close_read_hotspots(new_hotspots) { function close_read_hotspots(new_hotspots) {
const unwanted_hotspots = _.difference( const unwanted_hotspots = _.difference(
Array.from(HOTSPOT_LOCATIONS.keys()), Array.from(HOTSPOT_LOCATIONS.keys()),
new_hotspots.map(hotspot => hotspot.name) new_hotspots.map((hotspot) => hotspot.name)
); );
for (const hotspot_name of unwanted_hotspots) { for (const hotspot_name of unwanted_hotspots) {

View File

@ -22,7 +22,7 @@ exports.set_up_toggler = function () {
const elem = exports.toggler.get(); const elem = exports.toggler.get();
elem.addClass('large allow-overflow'); elem.addClass('large allow-overflow');
const modals = opts.values.map(item => { const modals = opts.values.map((item) => {
const key = item.key; // e.g. message-formatting const key = item.key; // e.g. message-formatting
const modal = $('#' + key).find('.modal-body'); const modal = $('#' + key).find('.modal-body');
return modal; return modal;

View File

@ -219,11 +219,11 @@ exports.create = function (opts) {
}, },
getByID: function (id) { getByID: function (id) {
return store.pills.find(pill => pill.id === id); return store.pills.find((pill) => pill.id === id);
}, },
items: function () { items: function () {
return store.pills.map(pill => pill.item); return store.pills.map((pill) => pill.item);
}, },
createPillonPaste: function () { createPillonPaste: function () {

View File

@ -71,12 +71,12 @@ exports.contains_backend_only_syntax = function (content) {
// Try to guess whether or not a message contains syntax that only the // Try to guess whether or not a message contains syntax that only the
// backend markdown processor can correctly handle. // backend markdown processor can correctly handle.
// If it doesn't, we can immediately render it client-side for local echo. // If it doesn't, we can immediately render it client-side for local echo.
const markedup = backend_only_markdown_re.find(re => re.test(content)); const markedup = backend_only_markdown_re.find((re) => re.test(content));
// If a realm filter doesn't start with some specified characters // If a realm filter doesn't start with some specified characters
// then don't render it locally. It is workaround for the fact that // then don't render it locally. It is workaround for the fact that
// javascript regex doesn't support lookbehind. // javascript regex doesn't support lookbehind.
const false_filter_match = realm_filter_list.find(re => { const false_filter_match = realm_filter_list.find((re) => {
const pattern = /(?:[^\s'"\(,:<])/.source + re[0].source + /(?![\w])/.source; const pattern = /(?:[^\s'"\(,:<])/.source + re[0].source + /(?![\w])/.source;
const regex = new RegExp(pattern); const regex = new RegExp(pattern);
return regex.test(content); return regex.test(content);
@ -455,7 +455,7 @@ exports.initialize = function (realm_filters, helper_config) {
// No <code> around our code blocks instead a codehilite <div> and disable // No <code> around our code blocks instead a codehilite <div> and disable
// class-specific highlighting. // class-specific highlighting.
r.code = code => fenced_code.wrap_code(code) + '\n\n'; r.code = (code) => fenced_code.wrap_code(code) + '\n\n';
// Prohibit empty links for some reason. // Prohibit empty links for some reason.
const old_link = r.link; const old_link = r.link;

View File

@ -271,7 +271,7 @@ function edit_message(row, raw_content) {
const show_edit_stream = message.is_stream && page_params.is_admin; const show_edit_stream = message.is_stream && page_params.is_admin;
// current message's stream has been already been added and selected in handlebar // current message's stream has been already been added and selected in handlebar
const available_streams = show_edit_stream ? stream_data.subscribed_subs() const available_streams = show_edit_stream ? stream_data.subscribed_subs()
.filter(s => s.stream_id !== message.stream_id) : null; .filter((s) => s.stream_id !== message.stream_id) : null;
const form = $(render_message_edit_form({ const form = $(render_message_edit_form({
is_stream: message.type === 'stream', is_stream: message.type === 'stream',
@ -817,13 +817,13 @@ exports.delete_message = function (msg_id) {
success: function () { success: function () {
$('#delete_message_modal').modal("hide"); $('#delete_message_modal').modal("hide");
currently_deleting_messages = currently_deleting_messages.filter( currently_deleting_messages = currently_deleting_messages.filter(
id => id !== msg_id (id) => id !== msg_id
); );
hide_delete_btn_show_spinner(false); hide_delete_btn_show_spinner(false);
}, },
error: function (xhr) { error: function (xhr) {
currently_deleting_messages = currently_deleting_messages.filter( currently_deleting_messages = currently_deleting_messages.filter(
id => id !== msg_id (id) => id !== msg_id
); );
hide_delete_btn_show_spinner(false); hide_delete_btn_show_spinner(false);
ui_report.error(i18n.t("Error deleting message"), xhr, ui_report.error(i18n.t("Error deleting message"), xhr,

View File

@ -131,7 +131,7 @@ function handle_operators_supporting_id_based_api(data) {
} }
data.narrow = JSON.parse(data.narrow); data.narrow = JSON.parse(data.narrow);
data.narrow = data.narrow.map(filter => { data.narrow = data.narrow.map((filter) => {
if (operators_supporting_ids.includes(filter.operator)) { if (operators_supporting_ids.includes(filter.operator)) {
filter.operand = people.emails_strings_to_user_ids_array(filter.operand); filter.operand = people.emails_strings_to_user_ids_array(filter.operand);
} }

View File

@ -16,8 +16,8 @@ exports.send_read = (function () {
let start; let start;
function server_request() { function server_request() {
// Wait for server IDs before sending flags // Wait for server IDs before sending flags
const real_msgs = queue.filter(msg => !msg.locally_echoed); const real_msgs = queue.filter((msg) => !msg.locally_echoed);
const real_msg_ids = real_msgs.map(msg => msg.id); const real_msg_ids = real_msgs.map((msg) => msg.id);
if (real_msg_ids.length === 0) { if (real_msg_ids.length === 0) {
setTimeout(start, 100); setTimeout(start, 100);
@ -46,7 +46,7 @@ exports.send_read = (function () {
return; return;
} }
queue = queue.filter(message => !data.messages.includes(message.id)); queue = queue.filter((message) => !data.messages.includes(message.id));
if (queue.length > 0) { if (queue.length > 0) {
start(); start();

View File

@ -43,7 +43,7 @@ MessageListData.prototype = {
if (this._selected_id === -1) { if (this._selected_id === -1) {
return; return;
} }
const ids = this._items.map(message => message.id); const ids = this._items.map((message) => message.id);
const i = ids.indexOf(this._selected_id); const i = ids.indexOf(this._selected_id);
if (i === -1) { if (i === -1) {
@ -158,7 +158,7 @@ MessageListData.prototype = {
valid_non_duplicated_messages: function (messages) { valid_non_duplicated_messages: function (messages) {
const predicate = this._get_predicate(); const predicate = this._get_predicate();
const self = this; const self = this;
return messages.filter(msg => self.get(msg.id) === undefined && predicate(msg)); return messages.filter((msg) => self.get(msg.id) === undefined && predicate(msg));
}, },
filter_incoming: function (messages) { filter_incoming: function (messages) {
@ -168,7 +168,7 @@ MessageListData.prototype = {
unmuted_messages: function (messages) { unmuted_messages: function (messages) {
return messages.filter( return messages.filter(
message => (message) =>
!muting.is_topic_muted(message.stream_id, message.topic) || !muting.is_topic_muted(message.stream_id, message.topic) ||
message.mentioned message.mentioned
); );
@ -182,7 +182,7 @@ MessageListData.prototype = {
}, },
first_unread_message_id: function () { first_unread_message_id: function () {
const first_unread = this._items.find(message => unread.message_unread(message)); const first_unread = this._items.find((message) => unread.message_unread(message));
if (first_unread) { if (first_unread) {
return first_unread.id; return first_unread.id;
@ -231,7 +231,7 @@ MessageListData.prototype = {
// bottom_messages regardless // bottom_messages regardless
if (self.selected_id() === -1 && self.empty()) { if (self.selected_id() === -1 && self.empty()) {
const narrow_messages = self.filter_incoming(messages); const narrow_messages = self.filter_incoming(messages);
bottom_messages = narrow_messages.filter(msg => !self.get(msg.id)); bottom_messages = narrow_messages.filter((msg) => !self.get(msg.id));
} else { } else {
// Filter out duplicates that are already in self, and all messages // Filter out duplicates that are already in self, and all messages
// that fail our filter predicate // that fail our filter predicate
@ -342,10 +342,10 @@ MessageListData.prototype = {
msg_ids_to_remove.add(message.id); msg_ids_to_remove.add(message.id);
} }
this._items = this._items.filter(message => !msg_ids_to_remove.has(message.id)); this._items = this._items.filter((message) => !msg_ids_to_remove.has(message.id));
if (this.muting_enabled) { if (this.muting_enabled) {
this._all_items = this._all_items.filter( this._all_items = this._all_items.filter(
message => !msg_ids_to_remove.has(message.id) (message) => !msg_ids_to_remove.has(message.id)
); );
} }
}, },

View File

@ -562,7 +562,7 @@ MessageListView.prototype = {
// all messages lists. To prevent having both list views overwriting // all messages lists. To prevent having both list views overwriting
// each others data we will make a new message object to add data to // each others data we will make a new message object to add data to
// for rendering. // for rendering.
const message_containers = messages.map(message => { const message_containers = messages.map((message) => {
if (message.starred) { if (message.starred) {
message.starred_status = i18n.t("Unstar"); message.starred_status = i18n.t("Unstar");
} else { } else {
@ -671,7 +671,7 @@ MessageListView.prototype = {
if (message_actions.append_messages.length > 0) { if (message_actions.append_messages.length > 0) {
last_message_row = table.find('.message_row').last().expectOne(); last_message_row = table.find('.message_row').last().expectOne();
last_group_row = rows.get_message_recipient_row(last_message_row); last_group_row = rows.get_message_recipient_row(last_message_row);
dom_messages = $(message_actions.append_messages.map(message_container => self._get_message_template(message_container)).join('')).filter('.message_row'); dom_messages = $(message_actions.append_messages.map((message_container) => self._get_message_template(message_container)).join('')).filter('.message_row');
self._post_process(dom_messages); self._post_process(dom_messages);
last_group_row.append(dom_messages); last_group_row.append(dom_messages);
@ -1026,7 +1026,7 @@ MessageListView.prototype = {
// Since we don't have a way to get a message group from // Since we don't have a way to get a message group from
// the containing message container, we just do a search // the containing message container, we just do a search
// to find it. // to find it.
message_group => message_group.message_group_id === message_group_id (message_group) => message_group.message_group_id === message_group_id
); );
}, },
@ -1097,10 +1097,10 @@ MessageListView.prototype = {
const self = this; const self = this;
// Convert messages to list messages // Convert messages to list messages
let message_containers = messages.map(message => self.message_containers.get(message.id)); let message_containers = messages.map((message) => self.message_containers.get(message.id));
// We may not have the message_container if the stream or topic was muted // We may not have the message_container if the stream or topic was muted
message_containers = message_containers.filter( message_containers = message_containers.filter(
message_container => message_container !== undefined (message_container) => message_container !== undefined
); );
const message_groups = []; const message_groups = [];

View File

@ -49,7 +49,7 @@ exports.get_messages_in_topic = function (stream_id, topic) {
// all the messages. Please only use it in case of // all the messages. Please only use it in case of
// very rare events like topic edits. Its primary // very rare events like topic edits. Its primary
// use case is the new experimental Recent Topics UI. // use case is the new experimental Recent Topics UI.
return message_list.all.all_messages().filter(x => { return message_list.all.all_messages().filter((x) => {
return x.type === 'stream' && return x.type === 'stream' &&
x.stream_id === stream_id && x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase(); x.topic.toLowerCase() === topic.toLowerCase();

View File

@ -151,7 +151,7 @@ exports.activate = function (raw_operators, opts) {
message_scroll.hide_top_of_narrow_notices(); message_scroll.hide_top_of_narrow_notices();
message_scroll.hide_indicators(); message_scroll.hide_indicators();
blueslip.debug("Narrowed", {operators: operators.map(e => e.operator), blueslip.debug("Narrowed", {operators: operators.map((e) => e.operator),
trigger: opts ? opts.trigger : undefined, trigger: opts ? opts.trigger : undefined,
previous_id: current_msg_list.selected_id()}); previous_id: current_msg_list.selected_id()});
@ -725,7 +725,7 @@ exports.to_compose_target = function () {
if (compose_state.get_message_type() === 'private') { if (compose_state.get_message_type() === 'private') {
const recipient_string = compose_state.private_message_recipient(); const recipient_string = compose_state.private_message_recipient();
const emails = util.extract_pm_recipients(recipient_string); const emails = util.extract_pm_recipients(recipient_string);
const invalid = emails.filter(email => !people.is_valid_email_for_compose(email)); const invalid = emails.filter((email) => !people.is_valid_email_for_compose(email));
// If there are no recipients or any recipient is // If there are no recipients or any recipient is
// invalid, narrow to all PMs. // invalid, narrow to all PMs.
if (emails.length === 0 || invalid.length > 0) { if (emails.length === 0 || invalid.length > 0) {

View File

@ -41,7 +41,7 @@ exports.init = function () {
exports.init(); exports.init();
function split_to_ints(lst) { function split_to_ints(lst) {
return lst.split(',').map(s => parseInt(s, 10)); return lst.split(',').map((s) => parseInt(s, 10));
} }
@ -151,7 +151,7 @@ exports.huddle_string = function (message) {
return; return;
} }
let user_ids = message.display_recipient.map(recip => recip.id); let user_ids = message.display_recipient.map((recip) => recip.id);
function is_huddle_recip(user_id) { function is_huddle_recip(user_id) {
return user_id && return user_id &&
@ -173,7 +173,7 @@ exports.huddle_string = function (message) {
exports.user_ids_string_to_emails_string = function (user_ids_string) { exports.user_ids_string_to_emails_string = function (user_ids_string) {
const user_ids = split_to_ints(user_ids_string); const user_ids = split_to_ints(user_ids_string);
let emails = user_ids.map(user_id => { let emails = user_ids.map((user_id) => {
const person = people_by_user_id_dict.get(user_id); const person = people_by_user_id_dict.get(user_id);
return person && person.email; return person && person.email;
}); });
@ -183,7 +183,7 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
return; return;
} }
emails = emails.map(email => email.toLowerCase()); emails = emails.map((email) => email.toLowerCase());
emails.sort(); emails.sort();
@ -192,7 +192,7 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
exports.user_ids_string_to_ids_array = function (user_ids_string) { exports.user_ids_string_to_ids_array = function (user_ids_string) {
const user_ids = user_ids_string.split(','); const user_ids = user_ids_string.split(',');
const ids = user_ids.map(id => Number(id)); const ids = user_ids.map((id) => Number(id));
return ids; return ids;
}; };
@ -212,7 +212,7 @@ exports.reply_to_to_user_ids_string = function (emails_string) {
// invalid data. // invalid data.
const emails = emails_string.split(','); const emails = emails_string.split(',');
let user_ids = emails.map(email => { let user_ids = emails.map((email) => {
const person = exports.get_by_email(email); const person = exports.get_by_email(email);
return person && person.user_id; return person && person.user_id;
}); });
@ -261,7 +261,7 @@ exports.emails_strings_to_user_ids_string = function (emails_string) {
}; };
exports.email_list_to_user_ids_string = function (emails) { exports.email_list_to_user_ids_string = function (emails) {
let user_ids = emails.map(email => { let user_ids = emails.map((email) => {
const person = exports.get_by_email(email); const person = exports.get_by_email(email);
return person && person.user_id; return person && person.user_id;
}); });
@ -277,7 +277,7 @@ exports.email_list_to_user_ids_string = function (emails) {
}; };
exports.safe_full_names = function (user_ids) { exports.safe_full_names = function (user_ids) {
let names = user_ids.map(user_id => { let names = user_ids.map((user_id) => {
const person = people_by_user_id_dict.get(user_id); const person = people_by_user_id_dict.get(user_id);
return person && person.full_name; return person && person.full_name;
}); });
@ -295,7 +295,7 @@ exports.get_recipients = function (user_ids_string) {
// See message_store.get_pm_full_names() for a similar function. // See message_store.get_pm_full_names() for a similar function.
const user_ids = split_to_ints(user_ids_string); const user_ids = split_to_ints(user_ids_string);
const other_ids = user_ids.filter(user_id => !exports.is_my_user_id(user_id)); const other_ids = user_ids.filter((user_id) => !exports.is_my_user_id(user_id));
if (other_ids.length === 0) { if (other_ids.length === 0) {
// private message with oneself // private message with oneself
@ -323,7 +323,7 @@ exports.pm_reply_to = function (message) {
return; return;
} }
const emails = user_ids.map(user_id => { const emails = user_ids.map((user_id) => {
const person = people_by_user_id_dict.get(user_id); const person = people_by_user_id_dict.get(user_id);
if (!person) { if (!person) {
blueslip.error('Unknown user id in message: ' + user_id); blueslip.error('Unknown user id in message: ' + user_id);
@ -343,7 +343,7 @@ function sorted_other_user_ids(user_ids) {
// This excludes your own user id unless you're the only user // This excludes your own user id unless you're the only user
// (i.e. you sent a message to yourself). // (i.e. you sent a message to yourself).
const other_user_ids = user_ids.filter(user_id => !exports.is_my_user_id(user_id)); const other_user_ids = user_ids.filter((user_id) => !exports.is_my_user_id(user_id));
if (other_user_ids.length >= 1) { if (other_user_ids.length >= 1) {
user_ids = other_user_ids; user_ids = other_user_ids;
@ -389,7 +389,7 @@ exports.all_user_ids_in_pm = function (message) {
return; return;
} }
let user_ids = message.display_recipient.map(recip => recip.id); let user_ids = message.display_recipient.map((recip) => recip.id);
user_ids = sort_numerically(user_ids); user_ids = sort_numerically(user_ids);
return user_ids; return user_ids;
@ -405,7 +405,7 @@ exports.pm_with_user_ids = function (message) {
return; return;
} }
const user_ids = message.display_recipient.map(recip => recip.id); const user_ids = message.display_recipient.map((recip) => recip.id);
return sorted_other_user_ids(user_ids); return sorted_other_user_ids(user_ids);
}; };
@ -420,8 +420,8 @@ exports.group_pm_with_user_ids = function (message) {
return; return;
} }
const user_ids = message.display_recipient.map(recip => recip.id); const user_ids = message.display_recipient.map((recip) => recip.id);
const is_user_present = user_ids.some(user_id => exports.is_my_user_id(user_id)); const is_user_present = user_ids.some((user_id) => exports.is_my_user_id(user_id));
if (is_user_present) { if (is_user_present) {
user_ids.sort(); user_ids.sort();
if (user_ids.length > 2) { if (user_ids.length > 2) {
@ -483,19 +483,19 @@ exports.update_email_in_reply_to = function (reply_to, user_id, new_email) {
// and we don't warn on any errors. // and we don't warn on any errors.
let emails = reply_to.split(','); let emails = reply_to.split(',');
const persons = emails.map(email => people_dict.get(email.trim())); const persons = emails.map((email) => people_dict.get(email.trim()));
if (!persons.every(Boolean)) { if (!persons.every(Boolean)) {
return reply_to; return reply_to;
} }
const needs_patch = persons.some(person => person.user_id === user_id); const needs_patch = persons.some((person) => person.user_id === user_id);
if (!needs_patch) { if (!needs_patch) {
return reply_to; return reply_to;
} }
emails = persons.map(person => { emails = persons.map((person) => {
if (person.user_id === user_id) { if (person.user_id === user_id) {
return new_email; return new_email;
} }
@ -507,8 +507,8 @@ exports.update_email_in_reply_to = function (reply_to, user_id, new_email) {
exports.pm_with_operand_ids = function (operand) { exports.pm_with_operand_ids = function (operand) {
let emails = operand.split(','); let emails = operand.split(',');
emails = emails.map(email => email.trim()); emails = emails.map((email) => email.trim());
let persons = emails.map(email => people_dict.get(email)); let persons = emails.map((email) => people_dict.get(email));
// If your email is included in a PM group with other people, just ignore it // If your email is included in a PM group with other people, just ignore it
if (persons.length > 1) { if (persons.length > 1) {
@ -519,7 +519,7 @@ exports.pm_with_operand_ids = function (operand) {
return; return;
} }
let user_ids = persons.map(person => person.user_id); let user_ids = persons.map((person) => person.user_id);
user_ids = sort_numerically(user_ids); user_ids = sort_numerically(user_ids);
@ -579,7 +579,7 @@ exports.exclude_me_from_string = function (user_ids_string) {
return user_ids.join(','); return user_ids.join(',');
} }
user_ids = user_ids.filter(user_id => !exports.is_my_user_id(user_id)); user_ids = user_ids.filter((user_id) => !exports.is_my_user_id(user_id));
return user_ids.join(','); return user_ids.join(',');
}; };
@ -700,7 +700,7 @@ exports.is_valid_email_for_compose = function (email) {
exports.is_valid_bulk_emails_for_compose = function (emails) { exports.is_valid_bulk_emails_for_compose = function (emails) {
// Returns false if at least one of the emails is invalid. // Returns false if at least one of the emails is invalid.
return emails.every(email => { return emails.every((email) => {
if (!exports.is_valid_email_for_compose(email)) { if (!exports.is_valid_email_for_compose(email)) {
return false; return false;
} }
@ -851,7 +851,7 @@ exports.get_message_people = function () {
semantics semantics
*/ */
const message_people = message_store.user_ids().map( const message_people = message_store.user_ids().map(
user_id => people_by_user_id_dict.get(user_id) (user_id) => people_by_user_id_dict.get(user_id)
).filter(Boolean); ).filter(Boolean);
return message_people; return message_people;
@ -892,7 +892,7 @@ exports.build_termlet_matcher = function (termlet) {
} }
const names = full_name.toLowerCase().split(' '); const names = full_name.toLowerCase().split(' ');
return names.some(name => name.startsWith(termlet)); return names.some((name) => name.startsWith(termlet));
}; };
}; };
@ -909,7 +909,7 @@ exports.build_person_matcher = function (query) {
return true; return true;
} }
return termlet_matchers.every(matcher => matcher(user)); return termlet_matchers.every((matcher) => matcher(user));
}; };
}; };
@ -918,7 +918,7 @@ exports.filter_people_by_search_terms = function (users, search_terms) {
// Build our matchers outside the loop to avoid some // Build our matchers outside the loop to avoid some
// search overhead that is not user-specific. // search overhead that is not user-specific.
const matchers = search_terms.map(search_term => exports.build_person_matcher(search_term)); const matchers = search_terms.map((search_term) => exports.build_person_matcher(search_term));
// Loop through users and populate filtered_users only // Loop through users and populate filtered_users only
// if they include search_terms // if they include search_terms
@ -930,7 +930,7 @@ exports.filter_people_by_search_terms = function (users, search_terms) {
} }
// Return user emails that include search terms // Return user emails that include search terms
const match = matchers.some(matcher => matcher(user)); const match = matchers.some((matcher) => matcher(user));
if (match) { if (match) {
filtered_users.set(person.user_id, true); filtered_users.set(person.user_id, true);
@ -1198,7 +1198,7 @@ exports.filter_for_user_settings_search = function (persons, query) {
See #13554 for more context. See #13554 for more context.
*/ */
return persons.filter(person => exports.matches_user_settings_search(person, query)); return persons.filter((person) => exports.matches_user_settings_search(person, query));
}; };
exports.maybe_incr_recipient_count = function (message) { exports.maybe_incr_recipient_count = function (message) {

View File

@ -67,7 +67,7 @@ exports.recent = (function () {
self.get_strings = function () { self.get_strings = function () {
// returns array of structs with user_ids_string and // returns array of structs with user_ids_string and
// message_id // message_id
return recent_private_messages.map(conversation => conversation.user_ids_string); return recent_private_messages.map((conversation) => conversation.user_ids_string);
}; };
self.initialize = function (params) { self.initialize = function (params) {

View File

@ -162,7 +162,7 @@ exports.poll_data_holder = function (is_my_poll, question, options) {
// function to check whether option already exists // function to check whether option already exists
self.is_option_present = function (data, latest_option) { self.is_option_present = function (data, latest_option) {
return data.some(el => el.option === latest_option); return data.some((el) => el.option === latest_option);
}; };
// function to add all options added along with the /poll command // function to add all options added along with the /poll command

View File

@ -447,7 +447,7 @@ exports.toggle_actions_popover = function (element, id) {
const should_display_edit_history_option = const should_display_edit_history_option =
message.edit_history && message.edit_history &&
message.edit_history.some(entry => entry.prev_content !== undefined || message.edit_history.some((entry) => entry.prev_content !== undefined ||
util.get_edit_event_prev_topic(entry) !== undefined) && util.get_edit_event_prev_topic(entry) !== undefined) &&
page_params.realm_allow_edit_history; page_params.realm_allow_edit_history;

View File

@ -347,7 +347,7 @@ exports.remove_reaction = function (event) {
return; return;
} }
r.user_ids = r.user_ids.filter(id => id !== user_id); r.user_ids = r.user_ids.filter((id) => id !== user_id);
if (r.user_ids.length > 0) { if (r.user_ids.length > 0) {
exports.update_user_fields(r); exports.update_user_fields(r);
} else { } else {

View File

@ -224,7 +224,7 @@ exports.topic_in_search_results = function (keyword, stream, topic) {
keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const text = (stream + ' ' + topic).toLowerCase().replace(/\s+/g, ' '); const text = (stream + ' ' + topic).toLowerCase().replace(/\s+/g, ' ');
const search_words = keyword.toLowerCase().replace(/\s+/g, ' ').split(' '); const search_words = keyword.toLowerCase().replace(/\s+/g, ' ').split(' ');
return search_words.every(word => { return search_words.every((word) => {
if (text.search(word) !== -1) { if (text.search(word) !== -1) {
return true; return true;
} }

View File

@ -46,7 +46,7 @@ exports.schedule_message = function (request) {
const message = raw_message.slice(1).join('\n'); const message = raw_message.slice(1).join('\n');
const deferred_message_type = deferred_message_types.filter( const deferred_message_type = deferred_message_types.filter(
props => command_line.match(props.test) !== null (props) => command_line.match(props.test) !== null
)[0]; )[0];
const command = command_line.match(deferred_message_type.test)[0]; const command = command_line.match(deferred_message_type.test)[0];

View File

@ -33,7 +33,7 @@ exports.append_search_string = function (search_string, pill_widget) {
exports.get_search_string_for_current_filter = function (pill_widget) { exports.get_search_string_for_current_filter = function (pill_widget) {
const items = pill_widget.items(); const items = pill_widget.items();
const search_strings = items.map(item => item.display_value); const search_strings = items.map((item) => item.display_value);
return search_strings.join(' '); return search_strings.join(' ');
}; };

View File

@ -20,7 +20,7 @@ function make_person_highlighter(query) {
function match_criteria(operators, criteria) { function match_criteria(operators, criteria) {
const filter = new Filter(operators); const filter = new Filter(operators);
return criteria.some(cr => { return criteria.some((cr) => {
if (Object.prototype.hasOwnProperty.call(cr, 'operand')) { if (Object.prototype.hasOwnProperty.call(cr, 'operand')) {
return filter.has_operand(cr.operator, cr.operand); return filter.has_operand(cr.operator, cr.operand);
} }
@ -48,7 +48,7 @@ function format_as_suggestion(terms) {
} }
function compare_by_huddle(huddle) { function compare_by_huddle(huddle) {
huddle = huddle.slice(0, -1).map(person => { huddle = huddle.slice(0, -1).map((person) => {
person = people.get_by_email(person); person = people.get_by_email(person);
return person && person.user_id; return person && person.user_id;
}); });
@ -91,14 +91,14 @@ function get_stream_suggestions(last, operators) {
const query = last.operand; const query = last.operand;
let streams = stream_data.subscribed_streams(); let streams = stream_data.subscribed_streams();
streams = streams.filter(stream => stream_matches_query(stream, query)); streams = streams.filter((stream) => stream_matches_query(stream, query));
streams = typeahead_helper.sorter(query, streams); streams = typeahead_helper.sorter(query, streams);
const regex = typeahead_helper.build_highlight_regex(query); const regex = typeahead_helper.build_highlight_regex(query);
const hilite = typeahead_helper.highlight_with_escaping_and_regex; const hilite = typeahead_helper.highlight_with_escaping_and_regex;
const objs = streams.map(stream => { const objs = streams.map((stream) => {
const prefix = 'stream'; const prefix = 'stream';
const highlighted_stream = hilite(regex, stream); const highlighted_stream = hilite(regex, stream);
const verb = last.negated ? 'exclude ' : ''; const verb = last.negated ? 'exclude ' : '';
@ -159,7 +159,7 @@ function get_group_suggestions(last, operators) {
const highlight_person = make_person_highlighter(last_part); const highlight_person = make_person_highlighter(last_part);
const suggestions = persons.map(person => { const suggestions = persons.map((person) => {
const term = { const term = {
operator: 'pm-with', operator: 'pm-with',
operand: all_but_last_part + ',' + person.email, operand: all_but_last_part + ',' + person.email,
@ -239,7 +239,7 @@ function get_person_suggestions(people_getter, last, operators, autocomplete_ope
const highlight_person = make_person_highlighter(query); const highlight_person = make_person_highlighter(query);
const objs = persons.map(person => { const objs = persons.map((person) => {
const name = highlight_person(person); const name = highlight_person(person);
const description = prefix + ' ' + name; const description = prefix + ' ' + name;
const terms = [{ const terms = [{
@ -340,7 +340,7 @@ function get_topic_suggestions(last, operators) {
topics = topics.slice(0, 300); topics = topics.slice(0, 300);
if (guess !== '') { if (guess !== '') {
topics = topics.filter(topic => common.phrase_match(guess, topic)); topics = topics.filter((topic) => common.phrase_match(guess, topic));
} }
topics = topics.slice(0, 10); topics = topics.slice(0, 10);
@ -351,7 +351,7 @@ function get_topic_suggestions(last, operators) {
// care about case. // care about case.
topics.sort(); topics.sort();
return topics.map(topic => { return topics.map((topic) => {
const topic_term = {operator: 'topic', operand: topic, negated: negated}; const topic_term = {operator: 'topic', operand: topic, negated: negated};
const operators = suggest_operators.concat([topic_term]); const operators = suggest_operators.concat([topic_term]);
return format_as_suggestion(operators); return format_as_suggestion(operators);
@ -382,7 +382,7 @@ function get_special_filter_suggestions(last, operators, suggestions) {
// Negating suggestions on is_search_operand_negated is required for // Negating suggestions on is_search_operand_negated is required for
// suggesting negated operators. // suggesting negated operators.
if (last.negated || is_search_operand_negated) { if (last.negated || is_search_operand_negated) {
suggestions = suggestions.map(suggestion => ({ suggestions = suggestions.map((suggestion) => ({
search_string: '-' + suggestion.search_string, search_string: '-' + suggestion.search_string,
description: 'exclude ' + suggestion.description, description: 'exclude ' + suggestion.description,
invalid: suggestion.invalid, invalid: suggestion.invalid,
@ -390,7 +390,7 @@ function get_special_filter_suggestions(last, operators, suggestions) {
} }
const last_string = Filter.unparse([last]).toLowerCase(); const last_string = Filter.unparse([last]).toLowerCase();
suggestions = suggestions.filter(s => { suggestions = suggestions.filter((s) => {
if (match_criteria(operators, s.invalid)) { if (match_criteria(operators, s.invalid)) {
return false; return false;
} }
@ -565,9 +565,9 @@ function get_operator_suggestions(last) {
} }
let choices = ['stream', 'topic', 'pm-with', 'sender', 'near', 'from', 'group-pm-with']; let choices = ['stream', 'topic', 'pm-with', 'sender', 'near', 'from', 'group-pm-with'];
choices = choices.filter(choice => common.phrase_match(last_operand, choice)); choices = choices.filter((choice) => common.phrase_match(last_operand, choice));
return choices.map(choice => { return choices.map((choice) => {
const op = [{operator: choice, operand: '', negated: negated}]; const op = [{operator: choice, operand: '', negated: negated}];
return format_as_suggestion(op); return format_as_suggestion(op);
}); });
@ -743,7 +743,7 @@ exports.finalize_search_result = function (result) {
lookup_table.set(obj.search_string, obj); lookup_table.set(obj.search_string, obj);
} }
const strings = result.map(obj => obj.search_string); const strings = result.map((obj) => obj.search_string);
return { return {
strings: strings, strings: strings,
lookup_table: lookup_table, lookup_table: lookup_table,

View File

@ -17,7 +17,7 @@ exports.vanilla_match = function (opts) {
This is case insensitive. This is case insensitive.
*/ */
const val = opts.val.toLowerCase(); const val = opts.val.toLowerCase();
return opts.search_terms.some(term => val.includes(term)); return opts.search_terms.some((term) => val.includes(term));
}; };
window.search_util = exports; window.search_util = exports;

View File

@ -99,7 +99,7 @@ function get_events_success(events) {
if (messages.length > 0) { if (messages.length > 0) {
messages.forEach(message_store.set_message_booleans); messages.forEach(message_store.set_message_booleans);
const sent_by_this_client = messages.some(msg => const sent_by_this_client = messages.some((msg) =>
sent_messages.messages.has(msg.local_id) sent_messages.messages.has(msg.local_id)
); );
// If some message in this batch of events was sent by this // If some message in this batch of events was sent by this

View File

@ -64,7 +64,7 @@ function is_local_part(value, element) {
} }
exports.type_id_to_string = function (type_id) { exports.type_id_to_string = function (type_id) {
return page_params.bot_types.find(bot_type => bot_type.type_id === type_id).name; return page_params.bot_types.find((bot_type) => bot_type.type_id === type_id).name;
}; };
exports.render_bots = function () { exports.render_bots = function () {
@ -392,7 +392,7 @@ exports.set_up = function () {
const bot_id = parseInt(li.find('.bot_info').attr('data-user-id'), 10); const bot_id = parseInt(li.find('.bot_info').attr('data-user-id'), 10);
const bot = bot_data.get(bot_id); const bot = bot_data.get(bot_id);
const user_ids = people.get_active_human_ids(); const user_ids = people.get_active_human_ids();
const users_list = user_ids.map(user_id => ({ const users_list = user_ids.map((user_id) => ({
name: people.get_full_name(user_id), name: people.get_full_name(user_id),
value: user_id.toString(), value: user_id.toString(),
})); }));

View File

@ -192,7 +192,7 @@ exports.user_role_values = {
}; };
const user_role_array = Object.values(exports.user_role_values); const user_role_array = Object.values(exports.user_role_values);
exports.user_role_map = new Map(user_role_array.map(role => [role.code, role.description])); exports.user_role_map = new Map(user_role_array.map((role) => [role.code, role.description]));
// NOTIFICATIONS // NOTIFICATIONS

View File

@ -43,7 +43,7 @@ exports.maybe_disable_widgets = function () {
}; };
exports.get_sorted_options_list = function (option_values_object) { exports.get_sorted_options_list = function (option_values_object) {
const options_list = Object.keys(option_values_object).map(key => ({ const options_list = Object.keys(option_values_object).map((key) => ({
...option_values_object[key], ...option_values_object[key],
key: key, key: key,
})); }));
@ -264,7 +264,7 @@ exports.populate_realm_domains = function (realm_domains) {
} }
const domains_list = realm_domains.map( const domains_list = realm_domains.map(
realm_domain => realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain (realm_domain) => realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain
); );
let domains = domains_list.join(', '); let domains = domains_list.join(', ');
if (domains.length === 0) { if (domains.length === 0) {
@ -547,7 +547,7 @@ exports.signup_notifications_stream_widget = null;
exports.init_dropdown_widgets = () => { exports.init_dropdown_widgets = () => {
const streams = stream_data.get_streams_for_settings_page(); const streams = stream_data.get_streams_for_settings_page();
const notification_stream_options = { const notification_stream_options = {
data: streams.map(x => { data: streams.map((x) => {
const item = { const item = {
name: x.name, name: x.name,
value: x.stream_id.toString(), value: x.stream_id.toString(),
@ -575,7 +575,7 @@ exports.init_dropdown_widgets = () => {
notification_stream_options)); notification_stream_options));
exports.default_code_language_widget = dropdown_list_widget({ exports.default_code_language_widget = dropdown_list_widget({
widget_name: 'realm_default_code_block_language', widget_name: 'realm_default_code_block_language',
data: Object.keys(pygments_data.langs).map(x => { data: Object.keys(pygments_data.langs).map((x) => {
return { return {
name: x, name: x,
value: x, value: x,

View File

@ -198,7 +198,7 @@ exports.populate_user_groups = function () {
except_class); except_class);
if ($(event.relatedTarget).closest('#user-groups #' + data.id).length) { if ($(event.relatedTarget).closest('#user-groups #' + data.id).length) {
return blur_exceptions.some( return blur_exceptions.some(
class_name => $(event.relatedTarget).closest(class_name).length (class_name) => $(event.relatedTarget).closest(class_name).length
); );
} }
return false; return false;

View File

@ -458,7 +458,7 @@ function open_bot_form(person) {
const owner_id = bot_data.get(person.user_id).owner_id; const owner_id = bot_data.get(person.user_id).owner_id;
const user_ids = people.get_active_human_ids(); const user_ids = people.get_active_human_ids();
const users_list = user_ids.map(user_id => ({ const users_list = user_ids.map((user_id) => ({
name: people.get_full_name(user_id), name: people.get_full_name(user_id),
value: user_id.toString(), value: user_id.toString(),
})); }));

View File

@ -126,7 +126,7 @@ function update_announce_stream_state() {
} }
function get_principals() { function get_principals() {
return Array.from($("#stream_creation_form input:checkbox[name=user]:checked"), elem => { return Array.from($("#stream_creation_form input:checkbox[name=user]:checked"), (elem) => {
const label = $(elem).closest(".add-user-label"); const label = $(elem).closest(".add-user-label");
return parseInt(label.attr("data-user-id"), 10); return parseInt(label.attr("data-user-id"), 10);
}); });

View File

@ -167,7 +167,7 @@ exports.is_subscriber_subset = function (sub1, sub2) {
if (sub1.subscribers && sub2.subscribers) { if (sub1.subscribers && sub2.subscribers) {
const sub2_set = sub2.subscribers; const sub2_set = sub2.subscribers;
return Array.from(sub1.subscribers.keys()).every(key => sub2_set.has(key)); return Array.from(sub1.subscribers.keys()).every((key) => sub2_set.has(key));
} }
return false; return false;
@ -319,9 +319,10 @@ exports.delete_sub = function (stream_id) {
exports.get_non_default_stream_names = function () { exports.get_non_default_stream_names = function () {
let subs = Array.from(stream_info.values()); let subs = Array.from(stream_info.values());
subs = subs.filter( subs = subs.filter(
sub => !exports.is_default_stream_id(sub.stream_id) && (sub.subscribed || !sub.invite_only) (sub) =>
!exports.is_default_stream_id(sub.stream_id) && (sub.subscribed || !sub.invite_only)
); );
const names = subs.map(sub => sub.name); const names = subs.map((sub) => sub.name);
return names; return names;
}; };
@ -342,7 +343,7 @@ exports.get_updated_unsorted_subs = function () {
// We don't display unsubscribed streams to guest users. // We don't display unsubscribed streams to guest users.
if (page_params.is_guest) { if (page_params.is_guest) {
all_subs = all_subs.filter(sub => sub.subscribed); all_subs = all_subs.filter((sub) => sub.subscribed);
} }
return all_subs; return all_subs;
@ -361,7 +362,7 @@ exports.unsubscribed_subs = function () {
}; };
exports.subscribed_streams = function () { exports.subscribed_streams = function () {
return exports.subscribed_subs().map(sub => sub.name); return exports.subscribed_subs().map((sub) => sub.name);
}; };
exports.get_invite_stream_data = function () { exports.get_invite_stream_data = function () {
@ -393,7 +394,7 @@ exports.get_invite_stream_data = function () {
}; };
exports.get_colors = function () { exports.get_colors = function () {
return exports.subscribed_subs().map(sub => sub.color); return exports.subscribed_subs().map((sub) => sub.color);
}; };
exports.update_subscribers_count = function (sub) { exports.update_subscribers_count = function (sub) {
@ -510,12 +511,12 @@ exports.update_calculated_fields = function (sub) {
}; };
exports.all_subscribed_streams_are_in_home_view = function () { exports.all_subscribed_streams_are_in_home_view = function () {
return exports.subscribed_subs().every(sub => !sub.is_muted); return exports.subscribed_subs().every((sub) => !sub.is_muted);
}; };
exports.home_view_stream_names = function () { exports.home_view_stream_names = function () {
const home_view_subs = exports.subscribed_subs().filter(sub => !sub.is_muted); const home_view_subs = exports.subscribed_subs().filter((sub) => !sub.is_muted);
return home_view_subs.map(sub => sub.name); return home_view_subs.map((sub) => sub.name);
}; };
exports.canonicalized_name = function (stream_name) { exports.canonicalized_name = function (stream_name) {

View File

@ -273,7 +273,7 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
// likely will make it possible to move messages to/from private // likely will make it possible to move messages to/from private
// streams in the future. // streams in the future.
const available_streams = stream_data.subscribed_subs() const available_streams = stream_data.subscribed_subs()
.filter(s => s.stream_id !== current_stream_id); .filter((s) => s.stream_id !== current_stream_id);
const current_stream_name = stream_data.maybe_get_stream_name(current_stream_id); const current_stream_name = stream_data.maybe_get_stream_name(current_stream_id);
const args = { const args = {
available_streams, topic_name, current_stream_id, current_stream_name, available_streams, topic_name, current_stream_id, current_stream_name,

View File

@ -16,13 +16,13 @@ function filter_streams_by_search(streams, search_term) {
} }
let search_terms = search_term.toLowerCase().split(","); let search_terms = search_term.toLowerCase().split(",");
search_terms = search_terms.map(s => s.trim()); search_terms = search_terms.map((s) => s.trim());
const filtered_streams = streams.filter(stream => search_terms.some(search_term => { const filtered_streams = streams.filter((stream) => search_terms.some((search_term) => {
const lower_stream_name = stream.toLowerCase(); const lower_stream_name = stream.toLowerCase();
const cands = lower_stream_name.split(" "); const cands = lower_stream_name.split(" ");
cands.push(lower_stream_name); cands.push(lower_stream_name);
return cands.some(name => name.startsWith(search_term)); return cands.some((name) => name.startsWith(search_term));
})); }));
return filtered_streams; return filtered_streams;

View File

@ -184,7 +184,7 @@ exports.per_stream_history = function (stream_id) {
return b.message_id - a.message_id; return b.message_id - a.message_id;
}); });
const names = recents.map(obj => obj.pretty_name); const names = recents.map((obj) => obj.pretty_name);
return names; return names;
}; };

View File

@ -15,7 +15,7 @@ exports.get_message_events = function (message) {
return parseInt(m1.id, 10) - parseInt(m2.id, 10); return parseInt(m1.id, 10) - parseInt(m2.id, 10);
}); });
const events = message.submessages.map(obj => ({ const events = message.submessages.map((obj) => ({
sender_id: obj.sender_id, sender_id: obj.sender_id,
data: JSON.parse(obj.content), data: JSON.parse(obj.content),
})); }));
@ -90,7 +90,7 @@ exports.update_message = function (submsg) {
message.submessages = []; message.submessages = [];
} }
const existing = message.submessages.find(sm => sm.id === submsg.id); const existing = message.submessages.find((sm) => sm.id === submsg.id);
if (existing !== undefined) { if (existing !== undefined) {
blueslip.warn("Got submessage multiple times: " + submsg.id); blueslip.warn("Got submessage multiple times: " + submsg.id);

View File

@ -85,13 +85,13 @@ Handlebars.registerHelper('tr', function (context, options) {
// 1. `context` is very important. It can be `this` or an // 1. `context` is very important. It can be `this` or an
// object or key of the current context. // object or key of the current context.
// 2. Use `__` instead of `{{` and `}}` to declare expressions // 2. Use `__` instead of `{{` and `}}` to declare expressions
const result = i18n.t(options.fn(context).trim().split("\n").map(s => s.trim()).join(" "), context); const result = i18n.t(options.fn(context).trim().split("\n").map((s) => s.trim()).join(" "), context);
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);
}); });
Handlebars.registerHelper( Handlebars.registerHelper(
"rendered_markdown", "rendered_markdown",
content => new Handlebars.SafeString(util.clean_user_content_links(content)) (content) => new Handlebars.SafeString(util.clean_user_content_links(content))
); );
window.templates = exports; window.templates = exports;

View File

@ -193,7 +193,7 @@ exports.next_topic = function (streams, get_topics, has_unread_messages, curr_st
exports.get_next_topic = function (curr_stream, curr_topic) { exports.get_next_topic = function (curr_stream, curr_topic) {
let my_streams = stream_sort.get_streams(); let my_streams = stream_sort.get_streams();
my_streams = my_streams.filter(stream_name => { my_streams = my_streams.filter((stream_name) => {
if (!stream_data.is_stream_muted_by_name(stream_name)) { if (!stream_data.is_stream_muted_by_name(stream_name)) {
return true; return true;
} }
@ -208,7 +208,7 @@ exports.get_next_topic = function (curr_stream, curr_topic) {
function get_unmuted_topics(stream_name) { function get_unmuted_topics(stream_name) {
const stream_id = stream_data.get_stream_id(stream_name); const stream_id = stream_data.get_stream_id(stream_name);
let topics = stream_topic_history.get_recent_topic_names(stream_id); let topics = stream_topic_history.get_recent_topic_names(stream_id);
topics = topics.filter(topic => !muting.is_topic_muted(stream_id, topic)); topics = topics.filter((topic) => !muting.is_topic_muted(stream_id, topic));
return topics; return topics;
} }

View File

@ -8,7 +8,7 @@ const settings_data = require("./settings_data");
// For example, "a,,b, " => ["a", "b"] // For example, "a,,b, " => ["a", "b"]
exports.get_cleaned_pm_recipients = function (query_string) { exports.get_cleaned_pm_recipients = function (query_string) {
let recipients = util.extract_pm_recipients(query_string); let recipients = util.extract_pm_recipients(query_string);
recipients = recipients.filter(elem => elem.match(/\S/)); recipients = recipients.filter((elem) => elem.match(/\S/));
return recipients; return recipients;
}; };

View File

@ -32,7 +32,7 @@ exports.remove_typist = function (group, typist) {
return false; return false;
} }
current = current.filter(user_id => to_int(user_id) !== to_int(typist)); current = current.filter((user_id) => to_int(user_id) !== to_int(typist));
typist_dct.set(key, current); typist_dct.set(key, current);
return true; return true;

View File

@ -223,7 +223,7 @@ exports.initialize_kitchen_sink_stuff = function () {
render_end: event.msg_list.view._render_win_end, render_end: event.msg_list.view._render_win_end,
selected_id_from_idx: messages[event.msg_list.selected_idx()].id, selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
msg_list_sorted: _.isEqual( msg_list_sorted: _.isEqual(
messages.map(message => message.id), messages.map((message) => message.id),
_.chain(current_msg_list.all_messages()).pluck('id').clone().value().sort() _.chain(current_msg_list.all_messages()).pluck('id').clone().value().sort()
), ),
found_in_dom: row_from_dom.length, found_in_dom: row_from_dom.length,

View File

@ -273,9 +273,9 @@ exports.unread_topic_counter = (function () {
let topic_names = Array.from(per_stream_bucketer.keys()); let topic_names = Array.from(per_stream_bucketer.keys());
topic_names = topic_names.filter(topic_name => !topic_dict.has(topic_name)); topic_names = topic_names.filter((topic_name) => !topic_dict.has(topic_name));
const result = topic_names.map(topic_name => { const result = topic_names.map((topic_name) => {
const msgs = per_stream_bucketer.get_bucket(topic_name); const msgs = per_stream_bucketer.get_bucket(topic_name);
return { return {
@ -384,11 +384,11 @@ exports.message_unread = function (message) {
}; };
exports.get_unread_message_ids = function (message_ids) { exports.get_unread_message_ids = function (message_ids) {
return message_ids.filter(message_id => unread_messages.has(message_id)); return message_ids.filter((message_id) => unread_messages.has(message_id));
}; };
exports.get_unread_messages = function (messages) { exports.get_unread_messages = function (messages) {
return messages.filter(message => unread_messages.has(message.id)); return messages.filter((message) => unread_messages.has(message.id));
}; };
exports.update_unread_topics = function (msg, event) { exports.update_unread_topics = function (msg, event) {

View File

@ -221,7 +221,7 @@ exports.setup_upload = function (config) {
uppy.on('complete', () => { uppy.on('complete', () => {
let uploads_in_progress = false; let uploads_in_progress = false;
uppy.getFiles().forEach(file => { uppy.getFiles().forEach((file) => {
if (file.progress.uploadComplete) { if (file.progress.uploadComplete) {
// The uploaded files should be removed since uppy don't allow files in the store // The uploaded files should be removed since uppy don't allow files in the store
// to be re-uploaded again. // to be re-uploaded again.

View File

@ -8,7 +8,7 @@ exports.create_item_from_email = function (email, current_items) {
if (!user) { if (!user) {
if (page_params.realm_is_zephyr_mirror_realm) { if (page_params.realm_is_zephyr_mirror_realm) {
const existing_emails = current_items.map(item => item.email); const existing_emails = current_items.map((item) => item.email);
if (existing_emails.includes(email)) { if (existing_emails.includes(email)) {
return; return;
@ -27,7 +27,7 @@ exports.create_item_from_email = function (email, current_items) {
return; return;
} }
const existing_ids = current_items.map(item => item.user_id); const existing_ids = current_items.map((item) => item.user_id);
if (existing_ids.includes(user.user_id)) { if (existing_ids.includes(user.user_id)) {
return; return;
@ -67,7 +67,7 @@ exports.append_person = function (opts) {
exports.get_user_ids = function (pill_widget) { exports.get_user_ids = function (pill_widget) {
const items = pill_widget.items(); const items = pill_widget.items();
let user_ids = items.map(item => item.user_id); let user_ids = items.map((item) => item.user_id);
user_ids = user_ids.filter(Boolean); // be defensive about undefined users user_ids = user_ids.filter(Boolean); // be defensive about undefined users
return user_ids; return user_ids;
@ -81,7 +81,7 @@ exports.has_unconverted_data = function (pill_widget) {
} }
const items = pill_widget.items(); const items = pill_widget.items();
const has_unknown_items = items.some(item => item.user_id === undefined); const has_unknown_items = items.some((item) => item.user_id === undefined);
return has_unknown_items; return has_unknown_items;
}; };
@ -93,7 +93,7 @@ exports.typeahead_source = function (pill_widget) {
exports.filter_taken_users = function (items, pill_widget) { exports.filter_taken_users = function (items, pill_widget) {
const taken_user_ids = exports.get_user_ids(pill_widget); const taken_user_ids = exports.get_user_ids(pill_widget);
items = items.filter(item => !taken_user_ids.includes(item.user_id)); items = items.filter((item) => !taken_user_ids.includes(item.user_id));
return items; return items;
}; };

View File

@ -68,7 +68,7 @@ exports.is_pm_recipient = function (user_id, message) {
}; };
exports.extract_pm_recipients = function (recipients) { exports.extract_pm_recipients = function (recipients) {
return recipients.split(/\s*[,;]\s*/).filter(recipient => recipient.trim() !== ""); return recipients.split(/\s*[,;]\s*/).filter((recipient) => recipient.trim() !== "");
}; };
exports.same_recipient = function util_same_recipient(a, b) { exports.same_recipient = function util_same_recipient(a, b) {
@ -102,9 +102,9 @@ exports.normalize_recipients = function (recipients) {
// Converts a string listing emails of message recipients // Converts a string listing emails of message recipients
// into a canonical formatting: emails sorted ASCIIbetically // into a canonical formatting: emails sorted ASCIIbetically
// with exactly one comma and no spaces between each. // with exactly one comma and no spaces between each.
recipients = recipients.split(',').map(s => s.trim()); recipients = recipients.split(',').map((s) => s.trim());
recipients = recipients.map(s => s.toLowerCase()); recipients = recipients.map((s) => s.toLowerCase());
recipients = recipients.filter(s => s.length > 0); recipients = recipients.filter((s) => s.length > 0);
recipients.sort(); recipients.sort();
return recipients.join(','); return recipients.join(',');
}; };

View File

@ -37,7 +37,7 @@ exports.render_tag = (tag) => {
*/ */
const opts = tag.opts; const opts = tag.opts;
const tag_name = tag.tag_name; const tag_name = tag.tag_name;
const attr_str = opts.attrs.map(attr => ' ' + attr[0] + '="' + _.escape(attr[1]) + '"').join(''); const attr_str = opts.attrs.map((attr) => ' ' + attr[0] + '="' + _.escape(attr[1]) + '"').join('');
const start_tag = '<' + tag_name + attr_str + '>'; const start_tag = '<' + tag_name + attr_str + '>';
const end_tag = '</' + tag_name + '>'; const end_tag = '</' + tag_name + '>';
@ -47,7 +47,7 @@ exports.render_tag = (tag) => {
return; return;
} }
const innards = opts.keyed_nodes.map(node => node.render()).join('\n'); const innards = opts.keyed_nodes.map((node) => node.render()).join('\n');
return start_tag + '\n' + innards + '\n' + end_tag; return start_tag + '\n' + innards + '\n' + end_tag;
}; };

View File

@ -75,7 +75,7 @@ function query_matches_string(query, source_str, split_char) {
// account, there might be 2 attrs: their full name and their email. // account, there might be 2 attrs: their full name and their email.
// * split_char is the separator for this syntax (e.g. ' '). // * split_char is the separator for this syntax (e.g. ' ').
export function query_matches_source_attrs(query, source, match_attrs, split_char) { export function query_matches_source_attrs(query, source, match_attrs, split_char) {
return match_attrs.some(attr => { return match_attrs.some((attr) => {
const source_str = source[attr].toLowerCase(); const source_str = source[attr].toLowerCase();
return query_matches_string(query, source_str, split_char); return query_matches_string(query, source_str, split_char);
}); });
@ -151,7 +151,7 @@ export function sort_emojis(objs, query) {
function decent_match(name) { function decent_match(name) {
const pieces = name.toLowerCase().split('_'); const pieces = name.toLowerCase().split('_');
return pieces.some(piece => piece.startsWith(lowerQuery)); return pieces.some((piece) => piece.startsWith(lowerQuery));
} }
const popular_set = new Set(popular_emojis); const popular_set = new Set(popular_emojis);
@ -162,7 +162,7 @@ export function sort_emojis(objs, query) {
} }
const popular_emoji_matches = objs.filter(is_popular); const popular_emoji_matches = objs.filter(is_popular);
const others = objs.filter(obj => !is_popular(obj)); const others = objs.filter((obj) => !is_popular(obj));
const triage_results = triage( const triage_results = triage(
query, query,