eslint: Enable `no-extra-parens` rule.

Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
This commit is contained in:
Shubham Dhama 2018-06-06 21:49:09 +05:30 committed by showell
parent c14d17b35b
commit dcb6254a4e
62 changed files with 141 additions and 136 deletions

View File

@ -280,7 +280,12 @@
"no-eq-null": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extra-parens": [ "error", "functions" ],
"no-extra-parens": ["error", "all",
{
"conditionalAssign": false,
"nestedBinaryExpressions": false
}
],
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,

View File

@ -179,7 +179,7 @@ exports.check_form = function (form_selector, expected, test_name) {
for (k in expected) {
if (expected.hasOwnProperty(k)) {
casper.test.assertEqual(values[k], expected[k],
test_name ? (test_name + ": " + k) : undefined);
test_name ? test_name + ": " + k : undefined);
}
}
};
@ -310,7 +310,7 @@ exports.keypress = function (code) {
exports.then_send_many = function (msgs) {
msgs.forEach(function (msg) {
exports.then_send_message(
(msg.stream !== undefined) ? 'stream' : 'private',
msg.stream !== undefined ? 'stream' : 'private',
msg);
});
};

View File

@ -410,7 +410,7 @@ casper.then(function () {
casper.waitUntilVisible(".method_row[data-method='Google'] input[type='checkbox'] + span", function () {
// Test Setting was saved
casper.test.assertEval(function () {
return !(document.querySelector(".method_row[data-method='Google'] input[type='checkbox']").checked);
return !document.querySelector(".method_row[data-method='Google'] input[type='checkbox']").checked;
});
});
});

View File

@ -104,7 +104,7 @@ casper.then(function () {
casper.test.assertSelectorHasText('#org-submit-msg-editing',
'Saved');
casper.test.assertEval(function () {
return (document.querySelector('#id_realm_msg_edit_limit_setting').value === "never");
return document.querySelector('#id_realm_msg_edit_limit_setting').value === "never";
}, 'Message editing Setting disabled');
});
});
@ -166,7 +166,7 @@ casper.then(function () {
casper.test.assertSelectorHasText('#org-submit-msg-editing',
'Saved');
casper.test.assertEval(function () {
return (document.querySelector('#id_realm_msg_edit_limit_setting').value === "upto_ten_min");
return document.querySelector('#id_realm_msg_edit_limit_setting').value === "upto_ten_min";
}, 'Allow message editing Setting re-activated and set to 10 minutes');
});
});
@ -189,7 +189,7 @@ casper.then(function () {
casper.test.assertSelectorHasText('#org-submit-msg-editing',
'Saved');
casper.test.assertEval(function () {
return (document.querySelector('#id_realm_msg_edit_limit_setting').value === "upto_one_week");
return document.querySelector('#id_realm_msg_edit_limit_setting').value === "upto_one_week";
}, 'Message edit limit set to one week');
});
});
@ -212,7 +212,7 @@ casper.then(function () {
casper.test.assertSelectorHasText('#org-submit-msg-editing',
'Saved');
casper.test.assertEval(function () {
return (document.querySelector('#id_realm_msg_edit_limit_setting').value === "any_time");
return document.querySelector('#id_realm_msg_edit_limit_setting').value === "any_time";
}, 'Message can be edited any time');
});
});

View File

@ -484,7 +484,7 @@ run_test('python_to_js_filter', () => {
// The only way to reach python_to_js_filter is indirectly, hence the call
// to set_realm_filters.
markdown.set_realm_filters([['/a(?im)a/g'], ['/a(?L)a/g']]);
var actual_value = (marked.InlineLexer.rules.zulip.realm_filters);
var actual_value = marked.InlineLexer.rules.zulip.realm_filters;
var expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
});

View File

@ -615,7 +615,7 @@ run_test('updates', () => {
assert.equal(all_people.length, 2);
person = _.filter(all_people, function (p) {
return (p.email === new_email);
return p.email === new_email;
})[0];
assert.equal(person.full_name, 'Foo Barson');

View File

@ -93,7 +93,7 @@ function test_create_bot_type_input_box_toggle(f) {
$('#create_bot_type :selected').val(GENERIC_BOT_TYPE);
f.apply();
assert(!(create_payload_url.hasClass('required')));
assert(!create_payload_url.hasClass('required'));
assert(!payload_url_inputbox.visible());
assert(!config_inputbox.visible());
}

View File

@ -47,7 +47,7 @@ stream_data.add_sub(weaving.name, weaving);
with_overrides(function (override) {
override('stream_data.is_active', function (sub) {
return (sub.name !== "pneumonia");
return sub.name !== "pneumonia";
});
// Test sorting into categories/alphabetized

View File

@ -147,7 +147,7 @@ run_test('fchain', () => {
return {
next: function () {
ret += n;
return (ret <= 100) ? ret : undefined;
return ret <= 100 ? ret : undefined;
},
};
};
@ -284,7 +284,7 @@ run_test('topics', () => {
};
global.stream_data.name_in_home_view = function (stream_name) {
return (stream_name !== 'muted');
return stream_name !== 'muted';
};
global.unread.topic_has_any_unread = function (stream_id) {
@ -292,7 +292,7 @@ run_test('topics', () => {
};
global.muting.is_topic_muted = function (stream_name, topic) {
return (topic === 'muted');
return topic === 'muted';
};
var next_item = tg.get_next_topic('announce', 'whatever');

View File

@ -33,7 +33,7 @@ exports.find_files_to_run = function () {
}
testsDifference.forEach(function (filename) {
throw (filename + ".js does not exist");
throw filename + ".js does not exist";
});
tests.sort();

View File

@ -406,7 +406,7 @@ exports.make_zjquery = function (opts) {
(selector === 'document-stub') ||
(selector === 'body') ||
(selector === 'html') ||
(selector.location) ||
selector.location ||
(selector.indexOf('#') >= 0) ||
(selector.indexOf('.') >= 0) ||
(selector.indexOf('[') >= 0 && selector.indexOf(']') >= selector.indexOf('['));

View File

@ -302,7 +302,7 @@ function focus_ping(want_redraw) {
}
channel.post({
url: '/json/users/me/presence',
data: {status: (exports.has_focus) ? exports.ACTIVE : exports.IDLE,
data: {status: exports.has_focus ? exports.ACTIVE : exports.IDLE,
ping_only: !want_redraw,
new_user_input: exports.new_user_input},
idempotent: true,

View File

@ -39,8 +39,8 @@ exports.initialize = function () {
all_message_groups.push(current_message_group);
current_message_group = {};
current_message_group.message_containers = [];
current_message_group.show_date = (
timerender.render_date(time, prev_time, today))[0].outerHTML;
current_message_group.show_date =
timerender.render_date(time, prev_time, today)[0].outerHTML;
current_message_group.show_date_separator = true;
current_message_group.display_recipient = stream_name;
current_message_group.subject = topic;

View File

@ -86,7 +86,7 @@ function filter_user_ids(filter_text, user_ids) {
exports.matches_filter = function (filter_text, user_id) {
// This is a roundabout way of checking a user if you look
// too hard at it, but it should be fine for now.
return (filter_user_ids(filter_text, [user_id]).length === 1);
return filter_user_ids(filter_text, [user_id]).length === 1;
};
function get_num_unread(user_id) {

View File

@ -33,8 +33,8 @@ exports.password_quality = function (password, bar, password_field) {
var min_guesses = password_field.data('minGuesses');
var result = zxcvbn(password);
var acceptable = (password.length >= min_length
&& result.guesses >= min_guesses);
var acceptable = password.length >= min_length
&& result.guesses >= min_guesses;
if (bar !== undefined) {
var t = result.crack_times_seconds.offline_slow_hashing_1e4_per_second;

View File

@ -446,9 +446,9 @@ exports.content_typeahead_selected = function (item) {
if (beginning.lastIndexOf(":") === 0 ||
beginning.charAt(beginning.lastIndexOf(":") - 1) === " " ||
beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n") {
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + ":" + item.emoji_name + ": ");
beginning = beginning.substring(0, beginning.length - this.token.length - 1) + ":" + item.emoji_name + ": ";
} else {
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ");
beginning = beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ";
}
} else if (this.completing === 'mention') {
beginning = beginning.substring(0, beginning.length - this.token.length - 1);
@ -613,7 +613,7 @@ exports.initialize = function () {
// The matcher for "stream" is strictly prefix-based,
// because we want to avoid mixing up streams.
var q = this.query.trim().toLowerCase();
return (item.toLowerCase().indexOf(q) === 0);
return item.toLowerCase().indexOf(q) === 0;
},
});

View File

@ -20,7 +20,7 @@ function find_boundary_tr(initial_tr, iterate_row) {
// To ensure we can't enter an infinite loop, bail out (and let the
// browser handle the copy-paste on its own) if we don't hit what we
// are looking for within 10 rows.
for (j = 0; (!tr.is('.message_row')) && j < 10; j += 1) {
for (j = 0; !tr.is('.message_row') && j < 10; j += 1) {
tr = iterate_row(tr);
}
if (j === 10) {

View File

@ -116,7 +116,7 @@ IterationProfiler.prototype = {
if (this.sections[label] === undefined) {
this.sections[label] = 0;
}
this.sections[label] += (now - this.last_time);
this.sections[label] += now - this.last_time;
this.last_time = now;
},

View File

@ -222,7 +222,7 @@ exports.setup_page = function (callback) {
// In case there is no stream for the draft, we need a
// single space char for proper rendering of the stream label
var space_string = new Handlebars.SafeString("&nbsp;");
var stream = (draft.stream.length > 0 ? draft.stream : space_string);
var stream = draft.stream.length > 0 ? draft.stream : space_string;
var draft_topic = draft.subject.length === 0 ?
compose.empty_topic_placeholder() : draft.subject;

View File

@ -274,7 +274,7 @@ function get_alias_to_be_used(message_id, emoji_name) {
}
var user_id = page_params.user_id;
var reaction = _.find(message.reactions, function (reaction) {
return (reaction.user.id === user_id) && (_.contains(aliases, reaction.emoji_name));
return (reaction.user.id === user_id) && _.contains(aliases, reaction.emoji_name);
});
if (reaction) {
return reaction.emoji_name;
@ -322,7 +322,7 @@ exports.toggle_selected_emoji = function () {
};
function round_off_to_previous_multiple(number_to_round, multiple) {
return (number_to_round - (number_to_round % multiple));
return number_to_round - (number_to_round % multiple);
}
function reset_emoji_showcase() {
@ -392,7 +392,7 @@ function get_next_emoji_coordinates(move_by) {
var prev_multiple = round_off_to_previous_multiple(max_len, 6);
next_index = prev_multiple + current_index;
next_index = next_index >= max_len
? (prev_multiple + current_index - 6)
? prev_multiple + current_index - 6
: next_index;
}
}

View File

@ -48,7 +48,7 @@ function message_matches_search_term(message, operator, operand) {
switch (operator) {
case 'is':
if (operand === 'private') {
return (message.type === 'private');
return message.type === 'private';
} else if (operand === 'starred') {
return message.starred;
} else if (operand === 'mentioned') {
@ -73,7 +73,7 @@ function message_matches_search_term(message, operator, operand) {
return true;
case 'id':
return (message.id.toString() === operand);
return message.id.toString() === operand;
case 'stream':
if (message.type !== 'stream') {
@ -89,13 +89,13 @@ function message_matches_search_term(message, operator, operand) {
// the operand.
var stream_id = stream_data.get_stream_id(operand);
if (stream_id) {
return (message.stream_id === stream_id);
return message.stream_id === stream_id;
}
// We need this fallback logic in case we have a message
// loaded for a stream that we are no longer
// subscribed to (or that was deleted).
return (message.stream.toLowerCase() === operand);
return message.stream.toLowerCase() === operand;
case 'topic':
if (message.type !== 'stream') {
@ -106,7 +106,7 @@ function message_matches_search_term(message, operator, operand) {
if (page_params.realm_is_zephyr_mirror_realm) {
return zephyr_topic_name_match(message, operand);
}
return (message.subject.toLowerCase() === operand);
return message.subject.toLowerCase() === operand;
case 'sender':
@ -121,7 +121,7 @@ function message_matches_search_term(message, operator, operand) {
if (!user_ids) {
return false;
}
return (user_ids.indexOf(operand_ids[0]) !== -1);
return user_ids.indexOf(operand_ids[0]) !== -1;
// We should also check if the current user is in the recipient list (user_ids) of the
// message, but it is implicit by the fact that the current user has access to the message.
@ -360,7 +360,7 @@ Filter.prototype = {
has_operator: function (operator) {
return _.any(this._operators, function (elem) {
if (elem.negated && (!_.contains(['search', 'has'], elem.operator))) {
if (elem.negated && !_.contains(['search', 'has'], elem.operator)) {
return false;
}
return elem.operator === operator;
@ -372,7 +372,7 @@ Filter.prototype = {
},
can_apply_locally: function () {
return (!this.is_search()) && (!this.has_operator('has'));
return !this.is_search() && !this.has_operator('has');
},
_canonicalize_operators: function (operators_mixed_case) {

View File

@ -19,7 +19,7 @@ exports.encode_operand = function (operator, operand) {
}
}
if ((operator === 'stream')) {
if (operator === 'stream') {
return exports.encode_stream_name(operand);
}

View File

@ -241,7 +241,7 @@ function should_ignore(hash) {
var ignore_list = ["streams", "drafts", "settings", "organization", "invite"];
var main_hash = get_main_hash(hash);
return (ignore_list.indexOf(main_hash) > -1);
return ignore_list.indexOf(main_hash) > -1;
}
function hashchanged(from_reload, e) {

View File

@ -204,7 +204,7 @@ function insert_hotspot_into_DOM(hotspot) {
}
}, 10), true);
});
}, (hotspot.delay * 1000));
}, hotspot.delay * 1000);
}
exports.is_open = function () {

View File

@ -126,8 +126,8 @@ var LightboxCanvas = (function () {
// find the percent of movement relative to the canvas width
// since e.movementX, e.movementY are in px.
var percentMovement = {
x: (e.movementX / canvas.width),
y: (e.movementY / canvas.height),
x: e.movementX / canvas.width,
y: e.movementY / canvas.height,
};
// add the percentMovement to the meta coordinates but divide

View File

@ -1,7 +1,7 @@
var list_cursor = function (opts) {
var self = {};
var config_ok = (
var config_ok =
opts.highlight_class &&
opts.list &&
opts.list.container &&
@ -9,7 +9,7 @@ var list_cursor = function (opts) {
opts.list.first_key &&
opts.list.prev_key &&
opts.list.next_key
);
;
if (!config_ok) {
blueslip.error('Programming error');

View File

@ -122,10 +122,10 @@ exports.add_subject_links = function (message) {
};
exports.is_status_message = function (raw_content, content) {
return (raw_content.indexOf('/me ') === 0 &&
return raw_content.indexOf('/me ') === 0 &&
raw_content.indexOf('\n') === -1 &&
content.indexOf('<p>') === 0 &&
content.lastIndexOf('</p>') === content.length - 4);
content.lastIndexOf('</p>') === content.length - 4;
};
function handleUnicodeEmoji(unicode_emoji) {

View File

@ -123,7 +123,7 @@ exports.save = function (row, from_topic_edited_only) {
} else {
new_topic = row.find(".message_edit_topic").val();
}
topic_changed = (new_topic !== message.subject && new_topic.trim() !== "");
topic_changed = new_topic !== message.subject && new_topic.trim() !== "";
}
// Editing a not-yet-acked message (because the original send attempt failed)
// just results in the in-memory message being changed
@ -237,15 +237,15 @@ function edit_message(row, raw_content) {
// zerver.views.messages.update_message_backend
var seconds_left_buffer = 5;
var editability = get_editability(message, seconds_left_buffer);
var is_editable = (editability === message_edit.editability_types.TOPIC_ONLY ||
editability === message_edit.editability_types.FULL);
var is_editable = editability === message_edit.editability_types.TOPIC_ONLY ||
editability === message_edit.editability_types.FULL;
var form = $(templates.render(
'message_edit_form',
{is_stream: (message.type === 'stream'),
{is_stream: message.type === 'stream',
message_id: message.id,
is_editable: is_editable,
has_been_editable: (editability !== editability_types.NO),
has_been_editable: editability !== editability_types.NO,
topic: message.subject,
content: raw_content,
minutes_to_edit: Math.floor(page_params.realm_message_content_edit_limit_seconds / 60)}));

View File

@ -91,7 +91,7 @@ MessageListData.prototype = {
var last_msg = this._items[n - 1];
return (last_msg.id === this._selected_id);
return last_msg.id === this._selected_id;
},
nth_most_recent_id: function (n) {

View File

@ -64,13 +64,13 @@ function add_display_time(group, message_container, prev) {
var prev_time = new XDate(prev.msg.timestamp * 1000);
if (time.toDateString() !== prev_time.toDateString()) {
// NB: show_date is HTML, inserted into the document without escaping.
group.show_date = (timerender.render_date(time, prev_time, today))[0].outerHTML;
group.show_date = timerender.render_date(time, prev_time, today)[0].outerHTML;
group.show_date_separator = true;
}
} else {
// Show the date in the recipient bar, but not a date separator bar.
group.show_date_separator = false;
group.show_date = (timerender.render_date(time, undefined, today))[0].outerHTML;
group.show_date = timerender.render_date(time, undefined, today)[0].outerHTML;
}
if (message_container.timestr === undefined) {
@ -143,7 +143,7 @@ MessageListView.prototype = {
var last_edit_time = new XDate(message_container.msg.last_edit_timestamp * 1000);
var today = new XDate();
message_container.last_edit_timestr =
(timerender.render_date(last_edit_time, undefined, today))[0].textContent
timerender.render_date(last_edit_time, undefined, today)[0].textContent
+ " at " + timerender.stringify_time(last_edit_time);
}
},
@ -811,7 +811,7 @@ MessageListView.prototype = {
// viewable window and the selected message
var old_offset;
var selected_row = this.selected_row();
var selected_in_view = (selected_row.length > 0);
var selected_in_view = selected_row.length > 0;
if (selected_in_view) {
old_offset = selected_row.offset().top;
}

View File

@ -11,7 +11,7 @@ var in_stoppable_autoscroll = false;
exports.last_movement_direction = 1;
exports.at_top = function () {
return (exports.scrollTop() <= 0);
return exports.scrollTop() <= 0;
};
exports.message_viewport_info = function () {
@ -106,12 +106,12 @@ exports.set_message_position = function (message_top, message_height, viewport_i
function in_viewport_or_tall(rect, top_of_feed, bottom_of_feed,
require_fully_visible) {
if (require_fully_visible) {
return ((rect.top > top_of_feed) && // Message top is in view and
return (rect.top > top_of_feed) && // Message top is in view and
((rect.bottom < bottom_of_feed) || // message is fully in view or
((rect.height > bottom_of_feed - top_of_feed) &&
(rect.top < bottom_of_feed)))); // message is tall.
(rect.top < bottom_of_feed))); // message is tall.
}
return (rect.bottom > top_of_feed && rect.top < bottom_of_feed);
return rect.bottom > top_of_feed && rect.top < bottom_of_feed;
}
function add_to_visible(candidates, visible,

View File

@ -198,7 +198,7 @@ exports.activate = function (raw_operators, opts) {
then_select_offset = opts.then_select_offset;
}
var select_immediately = (id_info.local_select_id !== undefined);
var select_immediately = id_info.local_select_id !== undefined;
(function fetch_messages() {
var anchor;

View File

@ -286,8 +286,8 @@ exports.narrowed_to_pms = function () {
if (current_filter === undefined) {
return false;
}
return (current_filter.has_operator("pm-with") ||
current_filter.has_operand("is", "private"));
return current_filter.has_operator("pm-with") ||
current_filter.has_operand("is", "private");
};
exports.narrowed_by_pm_reply = function () {
@ -295,8 +295,8 @@ exports.narrowed_by_pm_reply = function () {
return false;
}
var operators = current_filter.operators();
return (operators.length === 1 &&
current_filter.has_operator('pm-with'));
return operators.length === 1 &&
current_filter.has_operator('pm-with');
};
exports.narrowed_by_topic_reply = function () {
@ -304,16 +304,16 @@ exports.narrowed_by_topic_reply = function () {
return false;
}
var operators = current_filter.operators();
return (operators.length === 2 &&
return operators.length === 2 &&
current_filter.operands("stream").length === 1 &&
current_filter.operands("topic").length === 1);
current_filter.operands("topic").length === 1;
};
// We auto-reply under certain conditions, namely when you're narrowed
// to a PM (or huddle), and when you're narrowed to some stream/subject pair
exports.narrowed_by_reply = function () {
return (exports.narrowed_by_pm_reply() ||
exports.narrowed_by_topic_reply());
return exports.narrowed_by_pm_reply() ||
exports.narrowed_by_topic_reply();
};
exports.narrowed_by_stream_reply = function () {
@ -321,16 +321,16 @@ exports.narrowed_by_stream_reply = function () {
return false;
}
var operators = current_filter.operators();
return (operators.length === 1 &&
current_filter.operands("stream").length === 1);
return operators.length === 1 &&
current_filter.operands("stream").length === 1;
};
exports.narrowed_to_topic = function () {
if (current_filter === undefined) {
return false;
}
return (current_filter.has_operator("stream") &&
current_filter.has_operator("topic"));
return current_filter.has_operator("stream") &&
current_filter.has_operator("topic");
};
exports.narrowed_to_search = function () {
@ -338,8 +338,8 @@ exports.narrowed_to_search = function () {
};
exports.muting_enabled = function () {
return (!exports.narrowed_to_topic() && !exports.narrowed_to_search() &&
!exports.narrowed_to_pms());
return !exports.narrowed_to_topic() && !exports.narrowed_to_search() &&
!exports.narrowed_to_pms();
};
exports.is_for_stream_id = function (stream_id) {
@ -352,7 +352,7 @@ exports.is_for_stream_id = function (stream_id) {
return false;
}
return (stream_id === narrow_stream_id);
return stream_id === narrow_stream_id;
};
return exports;

View File

@ -46,11 +46,11 @@ if (window.webkitNotifications) {
function browser_desktop_notifications_on() {
return (notifications_api &&
return notifications_api &&
// Firefox on Ubuntu claims to do webkitNotifications but its notifications are terrible
/webkit/i.test(navigator.userAgent) &&
// 0 is PERMISSION_ALLOWED
notifications_api.checkPermission() === 0);
notifications_api.checkPermission() === 0;
}
function cancel_notification_object(notification_object) {
@ -121,7 +121,7 @@ exports.redraw_title = function () {
// Update window title and favicon to reflect unread messages in current view
var n;
var new_title = (new_message_count ? ("(" + new_message_count + ") ") : "")
var new_title = (new_message_count ? "(" + new_message_count + ") " : "")
+ narrow.narrow_title + " - "
+ page_params.realm_name + " - "
+ "Zulip";
@ -139,7 +139,7 @@ exports.redraw_title = function () {
// Make sure we're working with a number, as a defensive programming
// measure. And we don't have images above 99, so display those as
// 'infinite'.
n = (+new_message_count);
n = +new_message_count;
if (n > 99) {
n = 'infinite';
}
@ -463,9 +463,9 @@ function should_send_audible_notification(message) {
}
exports.granted_desktop_notifications_permission = function () {
return (notifications_api &&
return notifications_api &&
// 0 is PERMISSION_ALLOWED
notifications_api.checkPermission() === 0);
notifications_api.checkPermission() === 0;
};

View File

@ -35,7 +35,7 @@ exports.open = function ($process) {
$("[data-process]").hide();
var should_show_notifications = (
var should_show_notifications =
// notifications *basically* don't work on any mobile platforms, so don't
// event show the banners. This prevents trying to access things that
// don't exist like `Notification.permission`.
@ -44,7 +44,7 @@ exports.open = function ($process) {
!notifications.granted_desktop_notifications_permission() &&
// if permission is allowed to be requested (e.g. not in "denied" state).
notifications.permission_state() !== "denied"
);
;
if (localstorage.supported()) {
// if the user said to never show banner on this computer again, it will

View File

@ -73,7 +73,7 @@ exports.id_matches_email_operand = function (user_id, email) {
return false;
}
return (person.user_id === user_id);
return person.user_id === user_id;
};
exports.update_email = function (user_id, new_email) {
@ -137,7 +137,7 @@ exports.huddle_string = function (message) {
function is_huddle_recip(user_id) {
return user_id &&
people_by_user_id_dict.has(user_id) &&
(!exports.is_my_user_id(user_id));
!exports.is_my_user_id(user_id);
}
user_ids = _.filter(user_ids, is_huddle_recip);

View File

@ -103,7 +103,7 @@ function calculate_info_popover_placement(size, elt) {
if (!((ypos + (size / 2) < message_viewport.height()) &&
(ypos > (size / 2)))) {
if (((ypos + size) < message_viewport.height())) {
if ((ypos + size) < message_viewport.height()) {
return 'bottom';
} else if (ypos > size) {
return 'top';
@ -345,7 +345,7 @@ exports.toggle_actions_popover = function (element, id) {
var ypos = elt.offset().top;
elt.popover({
// Popover height with 7 items in it is ~190 px
placement: ((message_viewport.height() - ypos) < 220) ? 'top' : 'bottom',
placement: (message_viewport.height() - ypos) < 220 ? 'top' : 'bottom',
title: "",
content: templates.render('actions_popover_content', args),
trigger: "manual",
@ -368,7 +368,7 @@ exports.render_actions_remind_popover = function (element, id) {
var ypos = elt.offset().top;
elt.popover({
// Popover height with 7 items in it is ~190 px
placement: ((message_viewport.height() - ypos) < 220) ? 'top' : 'bottom',
placement: (message_viewport.height() - ypos) < 220 ? 'top' : 'bottom',
title: "",
content: templates.render('remind_me_popover_content', args),
trigger: "manual",
@ -664,7 +664,7 @@ exports.register_click_handlers = function () {
is_active: people.is_active_user_for_popover(user_id),
is_bot: user.is_bot,
is_sender_popover: false,
show_user_profile: (!user.is_bot && page_params.custom_profile_fields),
show_user_profile: !user.is_bot && page_params.custom_profile_fields,
};
target.popover({

View File

@ -282,7 +282,7 @@ exports.view.insert_new_reaction = function (opts) {
context.count = 1;
context.title = new_title;
context.local_id = exports.get_local_reaction_id(opts);
context.emoji_alt_code = (page_params.emojiset === 'text');
context.emoji_alt_code = page_params.emojiset === 'text';
if (opts.user_id === page_params.user_id) {
context.class = "message_reaction reacted";
@ -412,7 +412,7 @@ exports.get_message_reactions = function (message) {
reaction.emoji_code = reaction.emoji_code;
reaction.count = reaction.user_ids.length;
reaction.title = generate_title(reaction.emoji_name, reaction.user_ids);
reaction.emoji_alt_code = (page_params.emojiset === 'text');
reaction.emoji_alt_code = page_params.emojiset === 'text';
if (reaction.reaction_type !== 'unicode_emoji') {
reaction.is_realm_emoji = true;

View File

@ -20,8 +20,8 @@ exports.deferred_message_types = deferred_message_types;
exports.is_deferred_delivery = function (message_content) {
var reminders_test = deferred_message_types.reminders.test;
var scheduled_test = deferred_message_types.scheduled.test;
return (reminders_test.test(message_content) ||
scheduled_test.test(message_content));
return reminders_test.test(message_content) ||
scheduled_test.test(message_content);
};
function patch_request_for_scheduling(request) {

View File

@ -45,7 +45,7 @@ $(function () {
$(".fixed-app .column-middle").css("margin-left", (250 + sbWidth) + "px");
$(".column-right").css("right", sbWidth + "px");
$(".app-main .right-sidebar").css({"margin-left": (sbWidth) + "px",
$(".app-main .right-sidebar").css({"margin-left": sbWidth + "px",
width: (250 - sbWidth) + "px"});
$("#compose").css("left", "-" + sbWidth + "px");

View File

@ -264,7 +264,7 @@ function get_topic_suggestions(last, operators) {
var operator = Filter.canonicalize_operator(last.operator);
var operand = last.operand;
var negated = (operator === 'topic') && (last.negated);
var negated = (operator === 'topic') && last.negated;
var stream;
var guess;
var filter = new Filter(operators);
@ -392,7 +392,7 @@ function get_special_filter_suggestions(last, operators, suggestions) {
// e.g for `att` search query, `has:attachment` should be suggested.
var show_operator_suggestions = last.operator === 'search' && suggestion_operand.toLowerCase().indexOf(last_string) === 0;
return (s.search_string.toLowerCase().indexOf(last_string) === 0) ||
(show_operator_suggestions) ||
show_operator_suggestions ||
(s.description.toLowerCase().indexOf(last_string) === 0);
});

View File

@ -93,8 +93,8 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
settings_org.sync_realm_settings(event.property);
if (event.property === 'create_stream_by_admins_only') {
if (!page_params.is_admin) {
page_params.can_create_streams = (
!page_params.realm_create_stream_by_admins_only);
page_params.can_create_streams =
!page_params.realm_create_stream_by_admins_only;
}
} else if (event.property === 'notifications_stream_id') {
settings_org.render_notifications_stream_ui(

View File

@ -117,7 +117,7 @@ exports.generate_zuliprc_content = function (email, api_key, token) {
"\nemail=" + email +
"\nkey=" + api_key +
"\nsite=" + page_params.realm_uri +
(token === undefined ? "" : ("\ntoken=" + token)) +
(token === undefined ? "" : "\ntoken=" + token) +
// Some tools would not work in files without a trailing new line.
"\n";
};

View File

@ -9,7 +9,7 @@ var meta = {
function change_display_setting(data, status_element, success_msg, sticky) {
var $status_el = $(status_element);
var status_is_sticky = $status_el.data('is_sticky');
var display_message = (status_is_sticky) ? $status_el.data('sticky_msg') : success_msg;
var display_message = status_is_sticky ? $status_el.data('sticky_msg') : success_msg;
var opts = {
success_msg: display_message,
sticky: status_is_sticky || sticky,

View File

@ -266,7 +266,7 @@ exports.populate_realm_domains = function (realm_domains) {
}
var domains_list = _.map(realm_domains, function (realm_domain) {
return (realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain);
return realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain;
});
var domains = domains_list.join(', ');
if (domains.length === 0) {
@ -582,7 +582,7 @@ exports.set_up = function () {
});
var save_btn_controls = subsection.find('.subsection-header .save-button-controls');
var button_state = (show_change_process_button) ? "unsaved" : "saved";
var button_state = show_change_process_button ? "unsaved" : "saved";
exports.change_save_button_state(save_btn_controls, button_state);
});

View File

@ -22,7 +22,7 @@ exports.reload = function () {
exports.can_edit = function (group_id) {
var me = people.get_person_from_user_id(people.my_current_user_id());
return (user_groups.is_member_of(group_id, people.my_current_user_id()) || me.is_admin);
return user_groups.is_member_of(group_id, people.my_current_user_id()) || me.is_admin;
};
exports.populate_user_groups = function () {

View File

@ -65,7 +65,7 @@ $(function () {
};
$.fn.within = function (sel) {
return ($(this).is(sel) || $(this).closest(sel).length);
return $(this).is(sel) || $(this).closest(sel).length;
};
}

View File

@ -189,7 +189,7 @@ exports.get_color_class = _.memoize(function (color) {
// Determine if we're past the midpoint between the
// dark and light label lightness.
return (lightness < lightness_threshold) ? 'dark_background' : '';
return lightness < lightness_threshold ? 'dark_background' : '';
});
return exports;

View File

@ -191,8 +191,8 @@ function create_stream() {
created_stream = stream_name;
var announce = (!!page_params.notifications_stream &&
$('#announce-new-stream input').prop('checked'));
var announce = !!page_params.notifications_stream &&
$('#announce-new-stream input').prop('checked');
loading.make_indicator($('#stream_creating_indicator'), {text: i18n.t('Creating stream...')});

View File

@ -358,7 +358,7 @@ exports.add_subscriber = function (stream_name, user_id) {
};
exports.remove_deactivated_user_from_all_streams = function (user_id) {
(stream_info.values()).forEach(function (stream) {
stream_info.values().forEach(function (stream) {
if (exports.is_user_subscribed(stream.name, user_id)) {
exports.remove_subscriber(stream.name, user_id);
var sub = exports.get_sub(stream.name);

View File

@ -207,7 +207,7 @@ function show_subscription_settings(sub_row) {
var email = person.email.toLocaleLowerCase();
var full_name = person.full_name.toLowerCase();
return (email.indexOf(value) > -1 || full_name.indexOf(value) > -1);
return email.indexOf(value) > -1 || full_name.indexOf(value) > -1;
}
},
},
@ -514,8 +514,8 @@ exports.initialize = function () {
is_announcement_only: stream.is_announcement_only,
is_public: !stream.invite_only,
is_private: stream.invite_only && !stream.history_public_to_subscribers,
is_private_with_public_history: (stream.invite_only &&
stream.history_public_to_subscribers),
is_private_with_public_history: stream.invite_only &&
stream.history_public_to_subscribers,
};
var change_privacy_modal = templates.render("subscription_stream_privacy_modal", template_data);
$("#stream_privacy_modal").remove();

View File

@ -219,7 +219,7 @@ function build_stream_sidebar_li(sub) {
name: name,
id: sub.stream_id,
uri: narrow.by_stream_uri(name),
not_in_home_view: (stream_data.in_home_view(sub.stream_id) === false),
not_in_home_view: stream_data.in_home_view(sub.stream_id) === false,
invite_only: sub.invite_only,
color: stream_data.get_color(name),
pin_to_top: sub.pin_to_top,
@ -383,7 +383,7 @@ exports.get_sidebar_stream_topic_info = function (filter) {
result.stream_id = stream_id;
var op_subject = filter.operands('topic');
result.topic_selected = (op_subject.length === 1);
result.topic_selected = op_subject.length === 1;
return result;
};

View File

@ -69,11 +69,11 @@ exports.sort_groups = function (search_term) {
normal_streams.sort(util.strcmp);
dormant_streams.sort(util.strcmp);
var same_as_before = (
var same_as_before =
previous_pinned !== undefined &&
util.array_compare(previous_pinned, pinned_streams) &&
util.array_compare(previous_normal, normal_streams) &&
util.array_compare(previous_dormant, dormant_streams));
util.array_compare(previous_dormant, dormant_streams);
if (!same_as_before) {
previous_pinned = pinned_streams;

View File

@ -29,9 +29,9 @@ function make_tab_data() {
}
function in_all() {
return (filter !== undefined &&
return filter !== undefined &&
(filtered_to_non_home_view_stream() ||
filter.has_operand("in", "all")));
filter.has_operand("in", "all"));
}
if (in_all()) {

View File

@ -43,7 +43,7 @@ Handlebars.registerHelper('partial', function (template_name) {
});
Handlebars.registerHelper('plural', function (condition, one, other) {
return (condition === 1) ? one : other;
return condition === 1 ? one : other;
});
Handlebars.registerHelper('if_and', function () {

View File

@ -58,7 +58,7 @@ var tictactoe_data_holder = function () {
[square(7), square(8), square(9)],
];
var token = (num_filled % 2 === 0) ? 'X' : 'O';
var token = num_filled % 2 === 0 ? 'X' : 'O';
var move_status = token + "'s turn";
if (game_over) {
@ -92,13 +92,13 @@ var tictactoe_data_holder = function () {
return;
}
var token = (num_filled % 2 === 0) ? 'X' : 'O';
var token = num_filled % 2 === 0 ? 'X' : 'O';
if (square_values[idx]) {
return;
}
waiting = (sender_id === me);
waiting = sender_id === me;
square_values[idx] = token;
num_filled += 1;

View File

@ -278,7 +278,7 @@ exports.set_full_datetime = function timerender_set_full_datetime(message, time_
message.full_date_str = time.toLocaleDateString();
message.full_time_str = time.toLocaleTimeString() +
' (UTC' + ((tz_offset < 0) ? '' : '+') + tz_offset + ')';
' (UTC' + (tz_offset < 0 ? '' : '+') + tz_offset + ')';
time_elem.attr('title', message.full_date_str + ' ' + message.full_time_str);
};

View File

@ -236,7 +236,7 @@ exports.zoom_in = function () {
var before_count = active_widget.num_items();
function on_success() {
if ((!active_widget) || (stream_id !== active_widget.get_stream_id())) {
if (!active_widget || (stream_id !== active_widget.get_stream_id())) {
blueslip.warn('User re-narrowed before topic history was returned.');
return;
}

View File

@ -167,7 +167,7 @@ exports.switchToFullWidth = function () {
$('head').append('<style id="full-width-style" type="text/css">' +
'#home .alert-bar, .recipient-bar-content, #compose-container, .app-main, .header-main { max-width: none; }' +
'</style>');
return ("Switched to full width");
return "Switched to full width";
};
/* END OF EXPERIMENTS */

View File

@ -55,7 +55,7 @@ exports.get_user_group_from_name = function (name) {
exports.get_realm_user_groups = function () {
return user_group_by_id_dict.values().sort(function (a, b) {
return (a.id - b.id);
return a.id - b.id;
});
};

View File

@ -115,8 +115,8 @@ exports.set_up_typeahead_on_pills = function (input, pills, update_func) {
},
matcher: function (item) {
var query = this.query.toLowerCase();
return (item.email.toLowerCase().indexOf(query) !== -1
|| item.full_name.toLowerCase().indexOf(query) !== -1);
return item.email.toLowerCase().indexOf(query) !== -1
|| item.full_name.toLowerCase().indexOf(query) !== -1;
},
sorter: function (matches) {
return typeahead_helper.sort_recipientbox_typeahead(

View File

@ -58,8 +58,8 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
exports.same_stream_and_topic = function util_same_stream_and_topic(a, b) {
// Streams and topics are case-insensitive.
return ((a.stream_id === b.stream_id) &&
(a.subject.toLowerCase() === b.subject.toLowerCase()));
return (a.stream_id === b.stream_id) &&
(a.subject.toLowerCase() === b.subject.toLowerCase());
};
exports.is_pm_recipient = function (email, message) {
@ -96,8 +96,8 @@ exports.same_recipient = function util_same_recipient(a, b) {
};
exports.same_sender = function util_same_sender(a, b) {
return ((a !== undefined) && (b !== undefined) &&
(a.sender_email.toLowerCase() === b.sender_email.toLowerCase()));
return (a !== undefined) && (b !== undefined) &&
(a.sender_email.toLowerCase() === b.sender_email.toLowerCase());
};
exports.normalize_recipients = function (recipients) {
@ -147,7 +147,7 @@ exports.make_strcmp = function () {
}
return function util_strcmp(a, b) {
return (a < b ? -1 : (a > b ? 1 : 0));
return a < b ? -1 : a > b ? 1 : 0;
};
};
exports.strcmp = exports.make_strcmp();