eslint: Enable arrow-body-style.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-01 16:41:40 -07:00 committed by Tim Abbott
parent aa838ec4bc
commit 615b7fcc2c
46 changed files with 226 additions and 435 deletions

View File

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

View File

@ -62,9 +62,7 @@ run_test("initialize", () => {
};
};
$("#payment-method").data = (key) => {
return document.querySelector("#payment-method").getAttribute("data-" + key);
};
$("#payment-method").data = (key) => document.querySelector("#payment-method").getAttribute("data-" + key);
jquery_init();

View File

@ -102,9 +102,7 @@ run_test('create_ajax_request', () => {
};
$("#autopay-form").serializeArray = () => {
return jquery("#autopay-form").serializeArray();
};
$("#autopay-form").serializeArray = () => jquery("#autopay-form").serializeArray();
$.post = ({url, data, success, error}) => {
assert.equal(state.form_input_section_hide, 1);

View File

@ -183,9 +183,7 @@ run_test('find_li w/force_render', () => {
assert.equal(li, stub_li);
assert(shown);
buddy_list.get_li_from_key = () => {
return {length: 0};
};
buddy_list.get_li_from_key = () => ({length: 0});
const undefined_li = buddy_list.find_li({
key: 'not-there',

View File

@ -1706,7 +1706,7 @@ run_test('nonexistent_stream_reply_error', () => {
});
run_test('narrow_button_titles', () => {
util.is_mobile = () => { return false; };
util.is_mobile = () => false;
compose.update_closed_compose_buttons_for_private();
assert.equal($("#left_bar_compose_stream_button_big").text(), i18n.t("New stream message"));

View File

@ -4,9 +4,7 @@ set_global('$', global.make_zjquery());
const noop = () => {};
const _list_render = {
create: () => {
return { init: noop };
},
create: () => ({ init: noop }),
};
set_global('list_render', _list_render);

View File

@ -152,9 +152,7 @@ function test_helper() {
assert_events: (expected_events) => {
assert.deepEqual(expected_events, events);
},
get_narrow_terms: () => {
return narrow_terms;
},
get_narrow_terms: () => narrow_terms,
};
}

View File

@ -13,11 +13,9 @@ set_global('ui_util', {
place_caret_at_end: noop,
});
set_global('getSelection', () => {
return {
anchorOffset: 0,
};
});
set_global('getSelection', () => ({
anchorOffset: 0,
}));
let id_seq = 0;
run_test('set_up_ids', () => {
@ -240,20 +238,16 @@ run_test('arrows on pills', () => {
let next_focused = false;
const pill_stub = {
prev: () => {
return {
focus: () => {
prev_focused = true;
},
};
},
next: () => {
return {
focus: () => {
next_focused = true;
},
};
},
prev: () => ({
focus: () => {
prev_focused = true;
},
}),
next: () => ({
focus: () => {
next_focused = true;
},
}),
};
container.set_find_results('.pill:focus', pill_stub);
@ -282,13 +276,11 @@ run_test('left arrow on input', () => {
let last_pill_focused = false;
container.set_find_results('.pill', {
last: () => {
return {
focus: () => {
last_pill_focused = true;
},
};
},
last: () => ({
focus: () => {
last_pill_focused = true;
},
}),
});
key_handler({
@ -498,14 +490,12 @@ run_test('exit button on pill', () => {
};
const exit_button_stub = {
to_$: () => {
return {
closest: (sel) => {
assert.equal(sel, '.pill');
return curr_pill_stub;
},
};
},
to_$: () => ({
closest: (sel) => {
assert.equal(sel, '.pill');
return curr_pill_stub;
},
}),
};
const e = {
@ -538,14 +528,12 @@ run_test('misc things', () => {
let shake_class_removed = false;
const input_stub = {
to_$: () => {
return {
removeClass: (cls) => {
assert.equal(cls, 'shake');
shake_class_removed = true;
},
};
},
to_$: () => ({
removeClass: (cls) => {
assert.equal(cls, 'shake');
shake_class_removed = true;
},
}),
};
animation_end_handler.call(input_stub);

View File

@ -59,9 +59,7 @@ run_test('single item list', () => {
cursor.adjust_scroll = () => {};
conf.list.find_li = () => {
return li_stub;
};
conf.list.find_li = () => li_stub;
cursor.go_to(valid_key);

View File

@ -198,9 +198,7 @@ run_test('filtering', () => {
const opts = {
filter: {
element: search_input,
predicate: (item, value) => {
return item.includes(value);
},
predicate: (item, value) => item.includes(value),
},
modifier: (item) => div(item),
};
@ -294,9 +292,7 @@ function sort_button(opts) {
addClass: (cls) => {
classList.add(cls);
},
hasClass: (cls) => {
return classList.has(cls);
},
hasClass: (cls) => classList.has(cls),
removeClass: (cls) => {
classList.delete(cls);
},
@ -332,11 +328,7 @@ run_test('wire up filter element', () => {
const opts = {
filter: {
filterer: (list, value) => {
return list.filter((item) => {
return item.toLowerCase().includes(value);
});
},
filterer: (list, value) => list.filter((item) => item.toLowerCase().includes(value)),
element: filter_element,
},
modifier: (s) => '(' + s + ')',
@ -372,9 +364,7 @@ run_test('sorting', () => {
const opts = {
name: 'sorting-list',
parent_container: sort_container,
modifier: (item) => {
return div(item.name) + div(item.salary);
},
modifier: (item) => div(item.name) + div(item.salary),
filter: {
predicate: () => true,
},
@ -698,9 +688,7 @@ run_test('opts.get_item', () => {
['one', 'two', 'three', 'four']
);
const predicate = (item, value) => {
return item.startsWith(value);
};
const predicate = (item, value) => item.startsWith(value);
const predicate_opts = {
get_item: (n) => items[n],
@ -719,11 +707,7 @@ run_test('opts.get_item', () => {
const filterer_opts = {
get_item: (n) => items[n],
filter: {
filterer: (items, value) => {
return items.filter((item) => {
return predicate(item, value);
});
},
filterer: (items, value) => items.filter((item) => predicate(item, value)),
},
};
@ -821,9 +805,7 @@ run_test('render item', () => {
let rendering_item = false;
const widget_3 = list_render.create(container, list, {
name: 'replace-list',
modifier: (item) => {
return rendering_item ? undefined : `${item}\n`;
},
modifier: (item) => rendering_item ? undefined : `${item}\n`,
get_item: get_item,
html_selector: (item) => `tr[data-item='${item}']`,
});

View File

@ -18,9 +18,7 @@ const with_overrides = global.with_overrides; // make lint happy
function accept_all_filter() {
const filter = {
predicate: () => {
return () => true;
},
predicate: () => () => true,
};
return filter;

View File

@ -150,16 +150,14 @@ run_test('basics', () => {
const row = {
length: 1,
offset: () => { return {top: 25}; },
offset: () => ({top: 25}),
};
current_msg_list.selected_id = () => { return -1; };
current_msg_list.get_row = () => { return row; };
current_msg_list.selected_id = () => -1;
current_msg_list.get_row = () => row;
message_list.all = {
all_messages: () => {
return messages;
},
all_messages: () => messages,
get: (msg_id) => {
assert.equal(msg_id, selected_id);
return selected_message;
@ -170,12 +168,8 @@ run_test('basics', () => {
},
},
empty: () => false,
first: () => {
return {id: 900};
},
last: () => {
return {id: 1100};
},
first: () => ({id: 900}),
last: () => ({id: 1100}),
};
let cont;
@ -214,9 +208,9 @@ run_test('basics', () => {
'tab_bar.initialize',
]);
current_msg_list.selected_id = () => { return -1; };
current_msg_list.get_row = () => { return row; };
util.sorted_ids = () => { return []; };
current_msg_list.selected_id = () => -1;
current_msg_list.get_row = () => row;
util.sorted_ids = () => [];
narrow.activate([{ operator: 'is', operand: 'private' }], {
then_select_id: selected_id,

View File

@ -855,9 +855,7 @@ run_test('get_people_for_search_bar', () => {
assert.equal(big_results.length, 20);
message_store.user_ids = () => {
return [1001, 1002, 1003, 1004, 1005, 1006];
};
message_store.user_ids = () => [1001, 1002, 1003, 1004, 1005, 1006];
const small_results = people.get_people_for_search_bar('Jones');
@ -1126,13 +1124,11 @@ run_test('get_visible_email', function () {
});
run_test('get_active_message_people', function () {
message_store.user_ids = () => {
return [
steven.user_id,
maria.user_id,
alice1.user_id,
];
};
message_store.user_ids = () => [
steven.user_id,
maria.user_id,
alice1.user_id,
];
people.add_active_user(steven);
people.add_active_user(maria);

View File

@ -10,9 +10,7 @@ set_global('stream_popover', {
set_global('unread', {});
set_global('unread_ui', {});
set_global('vdom', {
render: () => {
return 'fake-dom-for-pm-list';
},
render: () => 'fake-dom-for-pm-list',
});
set_global('pm_list_dom', {});
@ -196,14 +194,12 @@ run_test('get_active_user_ids_string', () => {
undefined);
function set_filter_result(emails) {
narrow_state.filter = () => {
return {
operands: (operand) => {
assert.equal(operand, 'pm-with');
return emails;
},
};
};
narrow_state.filter = () => ({
operands: (operand) => {
assert.equal(operand, 'pm-with');
return emails;
},
});
}
set_filter_result([]);
@ -224,14 +220,12 @@ run_test('is_all_privates', () => {
pm_list.is_all_privates(),
false);
narrow_state.filter = () => {
return {
operands: (operand) => {
assert.equal(operand, 'is');
return ['private', 'starred'];
},
};
};
narrow_state.filter = () => ({
operands: (operand) => {
assert.equal(operand, 'is');
return ['private', 'starred'];
},
});
assert.equal(
pm_list.is_all_privates(),
@ -240,9 +234,7 @@ run_test('is_all_privates', () => {
function with_fake_list(f) {
const orig = pm_list._build_private_messages_list;
pm_list._build_private_messages_list = () => {
return 'PM_LIST_CONTENTS';
};
pm_list._build_private_messages_list = () => 'PM_LIST_CONTENTS';
f();
pm_list._build_private_messages_list = orig;
}

View File

@ -63,11 +63,9 @@ const me = {
};
const target = $.create('click target');
target.offset = () => {
return {
top: 10,
};
};
target.offset = () => ({
top: 10,
});
const e = {
stopPropagation: noop,
@ -87,14 +85,12 @@ function make_image_stubber() {
function stub_image() {
const image = {};
image.to_$ = () => {
return {
on: (name, f) => {
assert.equal(name, "load");
image.load_f = f;
},
};
};
image.to_$ = () => ({
on: (name, f) => {
assert.equal(name, "load");
image.load_f = f;
},
});
images.push(image);
return image;
}

View File

@ -4,12 +4,8 @@ let next_id = 0;
const messages = [];
set_global('message_util', {
get_messages_in_topic: (stream_id, topic) => {
return messages.filter((x) => {
return x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase();
});
},
get_messages_in_topic: (stream_id, topic) => messages.filter((x) => x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase()),
});
run_test('process_message_for_senders', () => {

View File

@ -8,46 +8,36 @@ set_global('hashchange', {
exit_overlay: noop,
});
set_global('stream_data', {
get_sub_by_id: () => {
return {
color: "",
invite_only: false,
is_web_public: true,
};
},
is_muted: () => {
get_sub_by_id: () => ({
color: "",
invite_only: false,
is_web_public: true,
}),
is_muted: () =>
// We only test via muted topics for now.
// TODO: Make muted streams and test them.
return false;
},
false
,
});
set_global('overlays', {
open_overlay: (opts) => {
overlays.close_callback = opts.on_close;
},
recent_topics_open: () => {
return true;
},
recent_topics_open: () => true,
});
set_global('people', {
is_my_user_id: function (id) {
return id === 1;
},
sender_info_with_small_avatar_urls_for_sender_ids: (ids) => {
return ids;
},
sender_info_with_small_avatar_urls_for_sender_ids: (ids) => ids,
});
set_global('XDate', zrequire('XDate', 'xdate'));
set_global('timerender', {
last_seen_status_from_date: () => {
return "Just now";
},
get_full_datetime: () => {
return {
date: "date",
time: "time",
};
},
last_seen_status_from_date: () => "Just now",
get_full_datetime: () => ({
date: "date",
time: "time",
}),
});
set_global('unread', {
unread_topic_counter: {
@ -61,15 +51,11 @@ set_global('unread', {
},
});
set_global('hash_util', {
by_stream_uri: () => {
return "https://www.example.com";
},
by_stream_topic_uri: () => {
return "https://www.example.com";
},
by_stream_uri: () => "https://www.example.com",
by_stream_topic_uri: () => "https://www.example.com",
});
set_global('recent_senders', {
get_topic_recent_senders: () => { return [1, 2]; },
get_topic_recent_senders: () => [1, 2],
});
set_global('list_render', {
modifier: noop,
@ -93,9 +79,7 @@ set_global('list_render', {
return list_render;
},
hard_redraw: noop,
render_item: (item) => {
return list_render.modifier(item);
},
render_item: (item) => list_render.modifier(item),
});
// Custom Data
@ -142,9 +126,7 @@ set_global('message_list', {
},
});
set_global('message_store', {
get: (msg_id) => {
return messages[msg_id - 1];
},
get: (msg_id) => messages[msg_id - 1],
});
let id = 0;

View File

@ -9,9 +9,7 @@ run_test('basics', () => {
bar: schema.check_string,
};
const check_rec = (val) => {
return schema.check_record('my_rec', val, fields);
};
const check_rec = (val) => schema.check_record('my_rec', val, fields);
assert.equal(
check_rec({foo: 'apple', bar: 'banana'}),
@ -38,9 +36,7 @@ run_test('basics', () => {
'in my_rec bar is not a string'
);
const check_array = (val) => {
return schema.check_array('lst', val, schema.check_string);
};
const check_array = (val) => schema.check_array('lst', val, schema.check_string);
assert.equal(
check_array(['foo', 'bar']),

View File

@ -73,22 +73,18 @@ run_test('scroll_element_into_container', () => {
const elem1 = {
innerHeight: () => 25,
position: () => {
return {
top: 0,
};
},
position: () => ({
top: 0,
}),
};
scroll_util.scroll_element_into_container(elem1, container);
assert.equal(container.scrollTop(), 3);
const elem2 = {
innerHeight: () => 15,
position: () => {
return {
top: 250,
};
},
position: () => ({
top: 250,
}),
};
scroll_util.scroll_element_into_container(elem2, container);
assert.equal(container.scrollTop(), 250 - 100 + 3 + 15);

View File

@ -155,9 +155,7 @@ run_test('initialize', () => {
assert.deepEqual(raw_operators, operators);
assert.deepEqual(options, {trigger: 'search'});
};
search_pill.get_search_string_for_current_filter = () => {
return search_box_val;
};
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
operators = [{
@ -230,9 +228,7 @@ run_test('initialize', () => {
assert.deepEqual(raw_operators, operators);
assert.deepEqual(options, {trigger: 'search'});
};
search_pill.get_search_string_for_current_filter = () => {
return search_box_val;
};
search_pill.get_search_string_for_current_filter = () => search_box_val;
};
operators = [{
@ -277,9 +273,7 @@ run_test('initialize', () => {
};
const search_pill_stub = $.create('.pill');
search_pill_stub.closest = () => {
return { data: noop };
};
search_pill_stub.closest = () => ({ data: noop });
const stub_event = {
relatedTarget: search_pill_stub,
};

View File

@ -387,11 +387,9 @@ run_test('group_suggestions', () => {
function message(user_ids, timestamp) {
return {
type: 'private',
display_recipient: user_ids.map((id) => {
return {
id: id,
};
}),
display_recipient: user_ids.map((id) => ({
id: id,
})),
timestamp: timestamp,
};
}

View File

@ -390,11 +390,9 @@ run_test('group_suggestions', () => {
function message(user_ids, timestamp) {
return {
type: 'private',
display_recipient: user_ids.map((id) => {
return {
id: id,
};
}),
display_recipient: user_ids.map((id) => ({
id: id,
})),
timestamp: timestamp,
};
}

View File

@ -116,9 +116,7 @@ function set_up() {
$('#config_inputbox').children = () => {
const mock_children = {
hide: () => {
return;
},
hide: () => {},
};
return mock_children;
};

View File

@ -57,9 +57,7 @@ const _realm_logo = {
};
const _list_render = {
create: () => {
return { init: noop };
},
create: () => ({ init: noop }),
};
set_global('channel', _channel);
@ -221,25 +219,19 @@ function test_submit_settings_form(submit_form) {
let stubs = createSaveButtons(subsection);
let save_button = stubs.save_button;
save_button.attr('id', `org-submit-${subsection}`);
save_button.replace = () => {
return `${subsection}`;
};
save_button.replace = () => `${subsection}`;
$("#id_realm_waiting_period_threshold").val(10);
const invite_to_stream_policy_elem = $("#id_realm_invite_to_stream_policy");
invite_to_stream_policy_elem.val('1');
invite_to_stream_policy_elem.attr("id", 'id_realm_invite_to_stream_policy');
invite_to_stream_policy_elem.data = () => {
return "number";
};
invite_to_stream_policy_elem.data = () => "number";
const create_stream_policy_elem = $("#id_realm_create_stream_policy");
create_stream_policy_elem.val('2');
create_stream_policy_elem.attr("id", 'id_realm_create_stream_policy');
create_stream_policy_elem.data = () => {
return "number";
};
create_stream_policy_elem.data = () => "number";
const add_emoji_by_admins_only_elem = $("#id_realm_add_emoji_by_admins_only");
add_emoji_by_admins_only_elem.val("by_anyone");
@ -248,15 +240,11 @@ function test_submit_settings_form(submit_form) {
const bot_creation_policy_elem = $("#id_realm_bot_creation_policy");
bot_creation_policy_elem.val("1");
bot_creation_policy_elem.attr('id', 'id_realm_bot_creation_policy');
bot_creation_policy_elem.data = () => {
return "number";
};
bot_creation_policy_elem.data = () => "number";
const email_address_visibility_elem = $("#id_realm_email_address_visibility");
email_address_visibility_elem.val("1");
email_address_visibility_elem.attr('id', 'id_realm_email_address_visibility');
email_address_visibility_elem.data = () => {
return "number";
};
email_address_visibility_elem.data = () => "number";
let subsection_elem = $(`#org-${subsection}`);
subsection_elem.closest = () => subsection_elem;
@ -290,15 +278,11 @@ function test_submit_settings_form(submit_form) {
const realm_default_language_elem = $("#id_realm_default_language");
realm_default_language_elem.val("en");
realm_default_language_elem.attr('id', 'id_realm_default_language');
realm_default_language_elem.data = () => {
return "string";
};
realm_default_language_elem.data = () => "string";
const realm_default_twenty_four_hour_time_elem = $("#id_realm_default_twenty_four_hour_time");
realm_default_twenty_four_hour_time_elem.val('true');
realm_default_twenty_four_hour_time_elem.attr('id', 'id_realm_default_twenty_four_hour_time');
realm_default_twenty_four_hour_time_elem.data = () => {
return "boolean";
};
realm_default_twenty_four_hour_time_elem.data = () => "boolean";
subsection_elem = $(`#org-${subsection}`);
subsection_elem.closest = () => subsection_elem;
@ -732,10 +716,8 @@ function test_discard_changes_button(discard_changes) {
run_test('set_up', () => {
const callbacks = {};
const set_callback = (name) => {
return (f) => {
callbacks[name] = f;
};
const set_callback = (name) => (f) => {
callbacks[name] = f;
};
const verify_realm_domains = simulate_realm_domains_table();
@ -784,12 +766,10 @@ run_test('set_up', () => {
};
const dropdown_list_widget_backup = dropdown_list_widget;
window.dropdown_list_widget = () => {
return {
render: noop,
update: noop,
};
};
window.dropdown_list_widget = () => ({
render: noop,
update: noop,
});
$("#id_realm_message_content_edit_limit_minutes").set_parent($.create('<stub edit limit parent>'));
$("#id_realm_message_content_delete_limit_minutes").set_parent($.create('<stub delete limit parent>'));
$("#id_realm_message_retention_days").set_parent($.create('<stub retention period parent>'));
@ -1018,9 +998,7 @@ run_test('misc', () => {
dropdown_list_parent.set_find_results('.dropdown_list_reset_button:not([disabled])', $.create('<disable button>'));
widget_settings.forEach((name) => {
const elem = $.create(`#${name}_widget #${name}_name`);
elem.closest = () => {
return dropdown_list_parent;
};
elem.closest = () => dropdown_list_parent;
});
// We do not define any settings we need in page_params yet, but we don't need to for this test.

View File

@ -1075,7 +1075,7 @@ run_test('all_topics_in_cache', () => {
message_list.all.data.add_messages(messages);
assert.equal(stream_data.all_topics_in_cache(sub), false);
message_list.all.data.fetch_status.has_found_newest = () => {return true;};
message_list.all.data.fetch_status.has_found_newest = () => true;
assert.equal(stream_data.all_topics_in_cache(sub), true);
sub.first_message_id = 0;

View File

@ -718,9 +718,7 @@ run_test('refresh_pin', () => {
const li_stub = $.create('li stub');
li_stub.length = 0;
global.stub_templates(() => {
return {to_$: () => li_stub};
});
global.stub_templates(() => ({to_$: () => li_stub}));
stream_list.update_count_in_dom = noop;
$('#stream_filters').append = noop;

View File

@ -92,9 +92,7 @@ run_test('is_complete_for_stream_id', () => {
has_found_newest: () => true,
},
},
first: () => {
return {id: 5};
},
first: () => ({id: 5}),
};
assert.equal(
@ -102,9 +100,7 @@ run_test('is_complete_for_stream_id', () => {
true);
// Now simulate a more recent message id.
message_list.all.first = () => {
return {id: sub.first_message_id + 1};
};
message_list.all.first = () => ({id: sub.first_message_id + 1});
// Note that we'll return `true` here due to
// fetched_stream_ids having the stream_id now.

View File

@ -80,9 +80,7 @@ run_test('get_list_info unreads', () => {
// Going forward, we just stub get_recent_topic_names
// for simpler test setup.
stream_topic_history.get_recent_topic_names = () => {
return _.range(15).map((i) => 'topic ' + i);
};
stream_topic_history.get_recent_topic_names = () => _.range(15).map((i) => 'topic ' + i);
const unread_cnt = new Map();
unread.num_unread_for_topic = (stream_id, topic_name) => {

View File

@ -88,17 +88,11 @@ run_test("initialize", () => {
assert.equal(schedule, "monthly");
};
$('input[type=radio][name=license_management]:checked').val = () => {
return document.querySelector("input[type=radio][name=license_management]:checked").value;
};
$('input[type=radio][name=license_management]:checked').val = () => document.querySelector("input[type=radio][name=license_management]:checked").value;
$('input[type=radio][name=schedule]:checked').val = () => {
return document.querySelector("input[type=radio][name=schedule]:checked").value;
};
$('input[type=radio][name=schedule]:checked').val = () => document.querySelector("input[type=radio][name=schedule]:checked").value;
$("#autopay-form").data = (key) => {
return document.querySelector("#autopay-form").getAttribute("data-" + key);
};
$("#autopay-form").data = (key) => document.querySelector("#autopay-form").getAttribute("data-" + key);
jquery_init();
@ -110,16 +104,12 @@ run_test("initialize", () => {
const invoice_click_handler = $('#invoice-button').get_on_handler('click');
const request_sponsorship_click_handler = $('#sponsorship-button').get_on_handler('click');
helpers.is_valid_input = () => {
return true;
};
helpers.is_valid_input = () => true;
add_card_click_handler(e);
invoice_click_handler(e);
helpers.is_valid_input = () => {
return false;
};
helpers.is_valid_input = () => false;
add_card_click_handler(e);
invoice_click_handler(e);

View File

@ -436,23 +436,17 @@ run_test('uppy_events', () => {
on: (event_name, callback) => {
callbacks[event_name] = callback;
},
getFiles: () => {
return [...files];
},
getFiles: () => [...files],
removeFile: (file_id) => {
files = files.filter((file) => {
return file.id !== file_id;
});
},
getState: () => {
return {
info: {
type: state.type,
details: state.details,
message: state.message,
},
};
files = files.filter((file) => file.id !== file_id);
},
getState: () => ({
info: {
type: state.type,
details: state.details,
message: state.message,
},
}),
};
}
uppy_stub.Plugin = plugin_stub;

View File

@ -102,13 +102,9 @@ run_test('attribute updates', () => {
});
function make_child(i, name) {
const render = () => {
return '<li>' + name + '</li>';
};
const render = () => '<li>' + name + '</li>';
const eq = (other) => {
return name === other.name;
};
const eq = (other) => name === other.name;
return {
key: i,
@ -207,22 +203,18 @@ run_test('partial updates', () => {
let patched_html;
find = () => {
return {
children: () => {
find = () => ({
children: () => ({
eq: (i) => {
assert.equal(i, 0);
return {
eq: (i) => {
assert.equal(i, 0);
return {
replaceWith: (html) => {
patched_html = html;
},
};
replaceWith: (html) => {
patched_html = html;
},
};
},
};
};
}),
});
const new_nodes = make_children([1, 2, 3]);
new_nodes[0] = make_child(1, 'modified1');

View File

@ -212,8 +212,8 @@ run_test('extensions', () => {
// using direct syntax:
const rect = $.create('rectangle');
rect.width = () => { return 5; };
rect.height = () => { return 7; };
rect.width = () => 5;
rect.height = () => 7;
assert.equal(rect.width(), 5);
assert.equal(rect.height(), 7);

View File

@ -17,9 +17,7 @@ const _ = global._;
// Create a helper function to avoid sneaky delays in tests.
function immediate(f) {
return () => {
return f();
};
return () => f();
}
// Find the files we need to run.

View File

@ -165,12 +165,10 @@ class MarkdownComparer {
function returnComparer() {
if (!_markdownComparerInstance) {
_markdownComparerInstance = new MarkdownComparer((actual, expected) => {
return [
"Actual and expected output do not match. Showing diff",
mdiff.diff_strings(actual, expected),
].join('\n');
});
_markdownComparerInstance = new MarkdownComparer((actual, expected) => [
"Actual and expected output do not match. Showing diff",
mdiff.diff_strings(actual, expected),
].join('\n'));
}
return _markdownComparerInstance;
}

View File

@ -19,9 +19,9 @@ function apply_color(input_string, changes) {
input_string = input_string.slice(2);
const formatter = new Map([
["delete", (string) => { return "\u001b[31m" + string + "\u001b[0m"; }],
["insert", (string) => { return "\u001b[32m" + string + "\u001b[0m"; }],
["replace", (string) => { return "\u001b[33m" + string + "\u001b[0m"; }],
["delete", (string) => "\u001b[31m" + string + "\u001b[0m"],
["insert", (string) => "\u001b[32m" + string + "\u001b[0m"],
["replace", (string) => "\u001b[33m" + string + "\u001b[0m"],
]);
changes.forEach((change) => {
if (formatter.has(change.tag)) {
@ -114,9 +114,7 @@ function diff_strings(string_0, string_1) {
}
});
const emphasize_codes = (string) => {
return "\u001b[34m" + string.slice(0, 1) + "\u001b[0m" + string.slice(1);
};
const emphasize_codes = (string) => "\u001b[34m" + string.slice(0, 1) + "\u001b[0m" + string.slice(1);
output_lines = output_lines.map(emphasize_codes);
return output_lines.join("\n");

View File

@ -75,9 +75,7 @@ exports.make_zblueslip = function () {
}
};
lib.get_test_logs = (name) => {
return lib.test_logs[name];
};
lib.get_test_logs = (name) => lib.test_logs[name];
// Create logging functions
for (const name of names) {
@ -113,13 +111,9 @@ exports.make_zblueslip = function () {
return ex.message;
};
lib.start_timing = () => {
return () => {};
};
lib.start_timing = () => () => {};
lib.preview_node = (node) => {
return 'node:' + node;
};
lib.preview_node = (node) => 'node:' + node;
return lib;
};

View File

@ -916,9 +916,7 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
const error_area = $("#compose_invite_users");
const existing_invites_area = $('#compose_invite_users .compose_invite_user');
const existing_invites = Array.from($(existing_invites_area), (user_row) => {
return parseInt($(user_row).data('user-id'), 10);
});
const existing_invites = Array.from($(existing_invites_area), (user_row) => parseInt($(user_row).data('user-id'), 10));
if (!existing_invites.includes(user_id)) {
const context = {

View File

@ -442,13 +442,9 @@ exports.get_pm_people = function (query) {
exports.get_person_suggestions = function (query, opts) {
query = typeahead.clean_query_lowercase(query);
const person_matcher = (item) => {
return exports.query_matches_person(query, item);
};
const person_matcher = (item) => exports.query_matches_person(query, item);
const group_matcher = (item) => {
return query_matches_name_description(query, item);
};
const group_matcher = (item) => query_matches_name_description(query, item);
function filter_persons(all_persons) {
let persons;

View File

@ -665,9 +665,7 @@ Filter.prototype = {
},
_fix_redundant_is_private: function (terms) {
const is_pm_with = (term) => {
return Filter.term_type(term) === 'pm-with';
};
const is_pm_with = (term) => Filter.term_type(term) === 'pm-with';
if (!terms.some(is_pm_with)) {
return terms;

View File

@ -45,9 +45,7 @@ exports.get_filtered_items = (value, list, opts) => {
return opts.filter.filterer(list, value);
}
const predicate = (item) => {
return opts.filter.predicate(item, value);
};
const predicate = (item) => opts.filter.predicate(item, value);
if (get_item) {
const result = [];
@ -65,32 +63,28 @@ exports.get_filtered_items = (value, list, opts) => {
return list.filter(predicate);
};
exports.alphabetic_sort = (prop) => {
return function (a, b) {
// The conversion to uppercase helps make the sorting case insensitive.
const str1 = a[prop].toUpperCase();
const str2 = b[prop].toUpperCase();
exports.alphabetic_sort = (prop) => function (a, b) {
// The conversion to uppercase helps make the sorting case insensitive.
const str1 = a[prop].toUpperCase();
const str2 = b[prop].toUpperCase();
if (str1 === str2) {
return 0;
} else if (str1 > str2) {
return 1;
}
if (str1 === str2) {
return 0;
} else if (str1 > str2) {
return 1;
}
return -1;
};
return -1;
};
exports.numeric_sort = (prop) => {
return function (a, b) {
if (parseFloat(a[prop]) > parseFloat(b[prop])) {
return 1;
} else if (parseFloat(a[prop]) === parseFloat(b[prop])) {
return 0;
}
exports.numeric_sort = (prop) => function (a, b) {
if (parseFloat(a[prop]) > parseFloat(b[prop])) {
return 1;
} else if (parseFloat(a[prop]) === parseFloat(b[prop])) {
return 0;
}
return -1;
};
return -1;
};
exports.valid_filter_opts = (opts) => {

View File

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

View File

@ -1,13 +1,9 @@
const render_pm_list_item = require('../templates/pm_list_item.hbs');
exports.keyed_pm_li = (convo) => {
const render = () => {
return render_pm_list_item(convo);
};
const render = () => render_pm_list_item(convo);
const eq = (other) => {
return _.isEqual(convo, other.convo);
};
const eq = (other) => _.isEqual(convo, other.convo);
const key = convo.user_ids_string;

View File

@ -114,7 +114,7 @@ exports.get_topic_recent_senders = function (stream_id, topic) {
}
const sorted_senders = Array.from(sender_message_ids.entries()).sort(
(s1, s2) => { return s1[1] - s2[1]; }
(s1, s2) => s1[1] - s2[1]
);
const recent_senders = [];
for (const item of sorted_senders) {

View File

@ -558,7 +558,7 @@ exports.init_dropdown_widgets = () => {
exports.save_discard_widget_status_handler($(`#org-notifications`));
},
default_text: i18n.t("Disabled"),
render_text: (x) => {return `#${x}`;},
render_text: (x) => `#${x}`,
null_value: -1,
};
exports.notifications_stream_widget = dropdown_list_widget(
@ -575,12 +575,10 @@ exports.init_dropdown_widgets = () => {
notification_stream_options));
exports.default_code_language_widget = dropdown_list_widget({
widget_name: 'realm_default_code_block_language',
data: Object.keys(pygments_data.langs).map((x) => {
return {
name: x,
value: x,
};
}),
data: Object.keys(pygments_data.langs).map((x) => ({
name: x,
value: x,
})),
value: page_params.realm_default_code_block_language,
on_update: () => {
exports.save_discard_widget_status_handler($(`#org-other-settings`));

View File

@ -55,13 +55,9 @@ exports.zoom_out = function () {
};
exports.keyed_topic_li = (convo) => {
const render = () => {
return render_topic_list_item(convo);
};
const render = () => render_topic_list_item(convo);
const eq = (other) => {
return _.isEqual(convo, other.convo);
};
const eq = (other) => _.isEqual(convo, other.convo);
const key = 't:' + convo.topic_name;
@ -74,16 +70,12 @@ exports.keyed_topic_li = (convo) => {
};
exports.more_li = (more_topics_unreads) => {
const render = () => {
return render_more_topics({
more_topics_unreads: more_topics_unreads,
});
};
const render = () => render_more_topics({
more_topics_unreads: more_topics_unreads,
});
const eq = (other) => {
return other.more_items &&
const eq = (other) => other.more_items &&
more_topics_unreads === other.more_topics_unreads;
};
const key = 'more';
@ -97,13 +89,9 @@ exports.more_li = (more_topics_unreads) => {
};
exports.spinner_li = () => {
const render = () => {
return render_more_topics_spinner();
};
const render = () => render_more_topics_spinner();
const eq = (other) => {
return other.spinner;
};
const eq = (other) => other.spinner;
const key = 'more';

View File

@ -16,12 +16,10 @@ exports.eq_array = (a, b, eq) => {
return a.every((item, i) => eq(item, b[i]));
};
exports.ul = (opts) => {
return {
tag_name: 'ul',
opts: opts,
};
};
exports.ul = (opts) => ({
tag_name: 'ul',
opts: opts,
});
exports.render_tag = (tag) => {
/*