diff --git a/.eslintrc.json b/.eslintrc.json index 3cd4207645..79e21a8b26 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -331,6 +331,7 @@ // Updated regex expressions are currently being tested in casper // files and will decide about a potential future enforcement of this rule. "no-useless-escape": 0, + "space-unary-ops": 2, "no-whitespace-before-property": 2, "no-with": 2, "one-var": [ "error", "never" ], diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index ac0980a448..ff6c5c35c8 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -566,8 +566,8 @@ run_test('send_message', () => { stub_state.send_msg_called += 1; }; echo.reify_message_id = function (local_id, message_id) { - assert.equal(typeof(local_id), 'number'); - assert.equal(typeof(message_id), 'number'); + assert.equal(typeof (local_id), 'number'); + assert.equal(typeof (message_id), 'number'); stub_state.reify_message_id_checked += 1; }; @@ -779,11 +779,11 @@ function verify_filedrop_payload(payload) { assert.equal(payload.maxfilesize, 512); assert.equal(payload.data.csrfmiddlewaretoken, 'fake-csrf-token'); assert.deepEqual(payload.raw_droppable, ['text/uri-list', 'text/plain']); - assert.equal(typeof(payload.drop), 'function'); - assert.equal(typeof(payload.progressUpdated), 'function'); - assert.equal(typeof(payload.error), 'function'); - assert.equal(typeof(payload.uploadFinished), 'function'); - assert.equal(typeof(payload.rawDrop), 'function'); + assert.equal(typeof (payload.drop), 'function'); + assert.equal(typeof (payload.progressUpdated), 'function'); + assert.equal(typeof (payload.error), 'function'); + assert.equal(typeof (payload.uploadFinished), 'function'); + assert.equal(typeof (payload.rawDrop), 'function'); } function test_raw_file_drop(raw_drop_func) { diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js index b19b77bd8b..47f6b97cb7 100644 --- a/frontend_tests/node_tests/compose_pm_pill.js +++ b/frontend_tests/node_tests/compose_pm_pill.js @@ -100,7 +100,7 @@ run_test('pills', () => { get_by_email_called = false; var res = handler(iago.email, pills.items()); assert(get_by_email_called); - assert.equal(typeof(res), 'object'); + assert.equal(typeof (res), 'object'); assert.equal(res.user_id, iago.user_id); assert.equal(res.display_value, iago.full_name); }()); diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js index 9a83802cab..a9c7b8a329 100644 --- a/frontend_tests/node_tests/filter.js +++ b/frontend_tests/node_tests/filter.js @@ -78,8 +78,8 @@ run_test('basics', () => { filter = new Filter(operators); assert(filter.is_search()); - assert(! filter.can_apply_locally()); - assert(! filter.is_exactly('stream')); + assert(!filter.can_apply_locally()); + assert(!filter.is_exactly('stream')); // If our only stream operator is negated, then for all intents and purposes, // we don't consider ourselves to have a stream operator, because we don't diff --git a/frontend_tests/node_tests/settings_muting.js b/frontend_tests/node_tests/settings_muting.js index d65a0d7c27..09d2625db4 100644 --- a/frontend_tests/node_tests/settings_muting.js +++ b/frontend_tests/node_tests/settings_muting.js @@ -18,7 +18,7 @@ run_test('settings', () => { settings_muting.set_up(); var click_handler = $('body').get_on_handler('click', '.settings-unmute-topic'); - assert.equal(typeof(click_handler), 'function'); + assert.equal(typeof (click_handler), 'function'); var event = { stopImmediatePropagation: noop, diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js index c2211dcbc2..f1f4eb82d5 100644 --- a/frontend_tests/node_tests/settings_user_groups.js +++ b/frontend_tests/node_tests/settings_user_groups.js @@ -154,11 +154,11 @@ run_test('populate_user_groups', () => { assert(config.fixed); assert(config.dropup); assert(config.stopAdvance); - assert.equal(typeof(config.source), 'function'); - assert.equal(typeof(config.highlighter), 'function'); - assert.equal(typeof(config.matcher), 'function'); - assert.equal(typeof(config.sorter), 'function'); - assert.equal(typeof(config.updater), 'function'); + assert.equal(typeof (config.source), 'function'); + assert.equal(typeof (config.highlighter), 'function'); + assert.equal(typeof (config.matcher), 'function'); + assert.equal(typeof (config.sorter), 'function'); + assert.equal(typeof (config.updater), 'function'); (function test_highlighter() { var fake_person = $.create('fake-person'); @@ -210,10 +210,10 @@ run_test('populate_user_groups', () => { saved_fade_out_called = true; }; $(cancel_selector).css = function (data) { - if (typeof(data) === 'string') { + if (typeof (data) === 'string') { assert.equal(data, 'display'); } - assert.equal(typeof(data), 'object'); + assert.equal(typeof (data), 'object'); assert.equal(data.display, 'inline-block'); assert.equal(data.opacity, '0'); return $(cancel_selector); @@ -222,10 +222,10 @@ run_test('populate_user_groups', () => { cancel_fade_to_called = true; }; $(instructions_selector).css = function (data) { - if (typeof(data) === 'string') { + if (typeof (data) === 'string') { assert.equal(data, 'display'); } - assert.equal(typeof(data), 'object'); + assert.equal(typeof (data), 'object'); assert.equal(data.display, 'block'); assert.equal(data.opacity, '0'); return $(instructions_selector); @@ -258,7 +258,7 @@ run_test('populate_user_groups', () => { 'Expected user email to be of Alice or Iago here.'); }; pills.onPillCreate = function (handler) { - assert.equal(typeof(handler), 'function'); + assert.equal(typeof (handler), 'function'); handler(); }; @@ -273,7 +273,7 @@ run_test('populate_user_groups', () => { get_by_email_called = false; var res = handler(bob.email, pills.items()); assert(get_by_email_called); - assert.equal(typeof(res), 'object'); + assert.equal(typeof (res), 'object'); assert.equal(res.user_id, bob.user_id); assert.equal(res.display_value, bob.full_name); }()); @@ -298,9 +298,9 @@ run_test('populate_user_groups', () => { test_create_item(create_item_handler); // Tests for settings_user_groups.set_up workflow. - assert.equal(typeof($('.organization form.admin-user-group-form').get_on_handler("submit")), 'function'); - assert.equal(typeof($('#user-groups').get_on_handler('click', '.delete')), 'function'); - assert.equal(typeof($('#user-groups').get_on_handler('keypress', '.user-group h4 > span')), 'function'); + assert.equal(typeof ($('.organization form.admin-user-group-form').get_on_handler("submit")), 'function'); + assert.equal(typeof ($('#user-groups').get_on_handler('click', '.delete')), 'function'); + assert.equal(typeof ($('#user-groups').get_on_handler('keypress', '.user-group h4 > span')), 'function'); }); run_test('with_external_user', () => { @@ -392,8 +392,8 @@ run_test('with_external_user', () => { callback = one; empty_fn = two; pill_hover_called = true; - assert.equal(typeof(one), 'function'); - assert.equal(typeof(two), 'function'); + assert.equal(typeof (one), 'function'); + assert.equal(typeof (two), 'function'); }; var exit_button = $.create('fake-pill-exit'); @@ -716,10 +716,10 @@ run_test('on_events', () => { cancel_fade_out_called = true; }; $(saved_selector).css = function (data) { - if (typeof(data) === 'string') { + if (typeof (data) === 'string') { assert.equal(data, 'display'); } - assert.equal(typeof(data), 'object'); + assert.equal(typeof (data), 'object'); assert.equal(data.display, 'inline-block'); assert.equal(data.opacity, '0'); return $(saved_selector); diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js index 561317f79d..93e97e82d7 100644 --- a/frontend_tests/zjsunit/zjquery.js +++ b/frontend_tests/zjsunit/zjquery.js @@ -18,7 +18,7 @@ exports.make_event_store = (selector) => { var child_on_functions = new Dict(); function generic_event(event_name, arg) { - if (typeof(arg) === 'function') { + if (typeof (arg) === 'function') { on_functions.set(event_name, arg); } else { var handler = on_functions.get(event_name); @@ -94,8 +94,8 @@ exports.make_event_store = (selector) => { event_name = arguments[0]; sel = arguments[1]; handler = arguments[2]; - assert.equal(typeof(sel), 'string', 'String selectors expected here.'); - assert.equal(typeof(handler), 'function', 'An handler function expected here.'); + assert.equal(typeof (sel), 'string', 'String selectors expected here.'); + assert.equal(typeof (handler), 'function', 'An handler function expected here.'); var child_on = child_on_functions.setdefault(sel, new Dict()); funcs = child_on.setdefault(event_name, []); funcs.push(handler); diff --git a/static/js/archive.js b/static/js/archive.js index 057fc18f76..4f1f74118e 100644 --- a/static/js/archive.js +++ b/static/js/archive.js @@ -84,7 +84,7 @@ exports.initialize = function () { if (prev_sender !== undefined) { var first_group_msg = $(this).find('.message_row').first(); var message_sender = first_group_msg.find('.message_sender'); - if (! message_sender.find('.inline_profile_picture').length) { + if (!message_sender.find('.inline_profile_picture').length) { message_sender.replaceWith(prev_sender.clone()); } } diff --git a/static/js/compose.js b/static/js/compose.js index 526e569753..bd51bd4ead 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -310,7 +310,7 @@ exports.finish = function () { return; } - if (! compose.validate()) { + if (!compose.validate()) { return false; } diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js index 897f3c565b..55b63b4b26 100644 --- a/static/js/compose_actions.js +++ b/static/js/compose_actions.js @@ -31,7 +31,7 @@ function hide_box() { function get_focus_area(msg_type, opts) { // Set focus to "Topic" when narrowed to a stream+topic and "New topic" button clicked. - if (msg_type === 'stream' && opts.stream && ! opts.subject) { + if (msg_type === 'stream' && opts.stream && !opts.subject) { return 'subject'; } else if ((msg_type === 'stream' && opts.stream) || (msg_type === 'private' && opts.private_message_recipient)) { diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index b313398f9b..f7cc32ff29 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -22,11 +22,11 @@ exports.add_topic = function (uc_stream, uc_topic) { var stream = uc_stream.toLowerCase(); var topic = uc_topic.toLowerCase(); - if (! seen_topics.has(stream)) { + if (!seen_topics.has(stream)) { seen_topics.set(stream, new Dict()); } var topic_dict = seen_topics.get(stream); - if (! topic_dict.has(topic)) { + if (!topic_dict.has(topic)) { topic_dict.set(topic, uc_topic); } }; diff --git a/static/js/dict.js b/static/js/dict.js index b7485f853b..efb5d2fe6f 100644 --- a/static/js/dict.js +++ b/static/js/dict.js @@ -41,7 +41,7 @@ Dict.from = function Dict_from(obj, opts) { * passed to the Dict constructor. */ Dict.from_array = function Dict_from_array(xs, opts) { - if (! (xs instanceof Array)) { + if (!(xs instanceof Array)) { throw new TypeError("Argument is not an array"); } diff --git a/static/js/filter.js b/static/js/filter.js index 7cbc1e6654..d5d614c8e3 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -471,7 +471,7 @@ Filter.prototype = { _build_predicate: function () { var operators = this._operators; - if (! this.can_apply_locally()) { + if (!this.can_apply_locally()) { return function () { return true; }; } diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js index d2ef245ab8..df02fe9a23 100644 --- a/static/js/message_fetch.js +++ b/static/js/message_fetch.js @@ -63,7 +63,7 @@ function get_messages_success(data, opts) { // don't bother processing the newly arrived messages. return; } - if (! data) { + if (!data) { // The server occasionally returns no data during a // restart. Ignore those responses and try again setTimeout(function () { diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 7630dca589..49dd61fe30 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -791,7 +791,7 @@ MessageListView.prototype = { // of the bottom of the currently rendered window and the // bottom of the window does not abut the end of the // message list - if (! (((selected_idx - this._render_win_start < this._RENDER_THRESHOLD) + if (!(((selected_idx - this._render_win_start < this._RENDER_THRESHOLD) && (this._render_win_start !== 0)) || ((this._render_win_end - selected_idx <= this._RENDER_THRESHOLD) && (this._render_win_end !== this.list.num_items())))) { diff --git a/static/js/message_scroll.js b/static/js/message_scroll.js index cbb45fc01d..8fea209c53 100644 --- a/static/js/message_scroll.js +++ b/static/js/message_scroll.js @@ -6,7 +6,7 @@ var actively_scrolling = false; var loading_more_messages_indicator_showing = false; exports.show_loading_older = function () { - if (! loading_more_messages_indicator_showing) { + if (!loading_more_messages_indicator_showing) { loading.make_indicator($('#loading_more_messages_indicator'), {abs_positioned: true}); loading_more_messages_indicator_showing = true; diff --git a/static/js/narrow.js b/static/js/narrow.js index fe87a4ee5c..c9021ca9c3 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -177,7 +177,7 @@ exports.activate = function (raw_operators, opts) { var msg_list = new message_list.MessageList({ data: msg_data, table_name: 'zfilt', - collapse_messages: ! narrow_state.get_current_filter().is_search(), + collapse_messages: !narrow_state.get_current_filter().is_search(), }); msg_list.start_time = start_time; diff --git a/static/js/pm_list.js b/static/js/pm_list.js index 63be6c1c4b..42b1a591d9 100644 --- a/static/js/pm_list.js +++ b/static/js/pm_list.js @@ -154,7 +154,7 @@ exports.rebuild_recent = function (active_conversation) { exports.update_private_messages = function () { exports._build_private_messages_list(); - if (! narrow_state.active()) { + if (!narrow_state.active()) { return; } diff --git a/static/js/rows.js b/static/js/rows.js index 3def66b8e6..3193273b37 100644 --- a/static/js/rows.js +++ b/static/js/rows.js @@ -55,7 +55,7 @@ var valid_table_names = { }; exports.get_table = function (table_name) { - if (! valid_table_names.hasOwnProperty(table_name)) { + if (!valid_table_names.hasOwnProperty(table_name)) { return $(); } diff --git a/static/js/socket.js b/static/js/socket.js index 025169fbd3..fc184f75d2 100644 --- a/static/js/socket.js +++ b/static/js/socket.js @@ -77,7 +77,7 @@ Socket.prototype = { request.error = error; this._save_request(request); - if (! this._can_send()) { + if (!this._can_send()) { this._try_to_reconnect({reason: 'cant_send'}); return; } diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 09dda83b4b..8fecf7c3dc 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -398,19 +398,19 @@ function change_stream_privacy(e) { function stream_desktop_notifications_clicked(e) { var sub = get_sub_for_target(e.target); - sub.desktop_notifications = ! sub.desktop_notifications; + sub.desktop_notifications = !sub.desktop_notifications; exports.set_stream_property(sub, 'desktop_notifications', sub.desktop_notifications); } function stream_audible_notifications_clicked(e) { var sub = get_sub_for_target(e.target); - sub.audible_notifications = ! sub.audible_notifications; + sub.audible_notifications = !sub.audible_notifications; exports.set_stream_property(sub, 'audible_notifications', sub.audible_notifications); } function stream_push_notifications_clicked(e) { var sub = get_sub_for_target(e.target); - sub.push_notifications = ! sub.push_notifications; + sub.push_notifications = !sub.push_notifications; exports.set_stream_property(sub, 'push_notifications', sub.push_notifications); } diff --git a/static/js/stream_list.js b/static/js/stream_list.js index a5852bd81c..064375aa83 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -305,7 +305,7 @@ exports.update_streams_sidebar = function () { exports.build_stream_list(); exports.stream_cursor.redraw(); - if (! narrow_state.active()) { + if (!narrow_state.active()) { return; } diff --git a/static/js/stream_muting.js b/static/js/stream_muting.js index 06675903f5..bb0729a8ff 100644 --- a/static/js/stream_muting.js +++ b/static/js/stream_muting.js @@ -43,7 +43,7 @@ exports.update_in_home_view = function (sub, value) { pointer.recenter_pointer_on_display = true; pointer.suppress_scroll_pointer_update = true; - if (! home_msg_list.empty()) { + if (!home_msg_list.empty()) { message_util.do_unread_count_updates(home_msg_list.all_messages()); } }, 0); diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index c973475b44..95b3cfe792 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -77,7 +77,7 @@ function update_spectrum(popover, update_func) { var popover_root = popover.closest(".popover"); var current_top_px = parseFloat(popover_root.css('top').replace('px', '')); - var height_delta = - (after_height - initial_height) * 0.5; + var height_delta = -(after_height - initial_height) * 0.5; popover_root.css('top', (current_top_px + height_delta) + "px"); } diff --git a/static/js/subs.js b/static/js/subs.js index e7a31a110d..de511dd3e6 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -107,7 +107,7 @@ exports.active_stream = function () { }; exports.toggle_home = function (sub) { - stream_muting.update_in_home_view(sub, ! sub.in_home_view); + stream_muting.update_in_home_view(sub, !sub.in_home_view); stream_edit.set_stream_property(sub, 'in_home_view', sub.in_home_view); }; @@ -829,7 +829,7 @@ exports.initialize = function () { // A hack. Don't change the state of the checkbox if we // clicked on the checkbox itself. if (control[0] !== e.target) { - control.prop("checked", ! control.prop("checked")); + control.prop("checked", !control.prop("checked")); } }); diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js index af40746c2e..62992337b6 100644 --- a/static/js/tab_bar.js +++ b/static/js/tab_bar.js @@ -64,7 +64,7 @@ function make_tab_data() { if (filter.has_operator("pm-with")) { var emails = filter.operands("pm-with")[0].split(','); var names = _.map(emails, function (email) { - if (! people.get_by_email(email)) { + if (!people.get_by_email(email)) { return email; } return people.get_by_email(email).full_name; diff --git a/static/js/ui.js b/static/js/ui.js index 84046e373c..465c20d883 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -52,7 +52,7 @@ function update_message_in_all_views(message_id, callback) { exports.show_error_for_unsupported_platform = function () { // Check if the user is using old desktop app - if (typeof(bridge) !== 'undefined') { + if (typeof (bridge) !== 'undefined') { // We don't internationalize this string because it is long, // and few users will have both the old desktop app and an // internationalized version of Zulip anyway. diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js index b5ee214cdd..1283a5a07f 100644 --- a/static/js/unread_ops.js +++ b/static/js/unread_ops.js @@ -87,7 +87,7 @@ exports.notify_server_message_read = function (message, options) { // If we ever materially change the algorithm for this function, we // may need to update notifications.received_messages as well. exports.process_visible = function () { - if (! notifications.window_has_focus()) { + if (!notifications.window_has_focus()) { return; }