eslint: change no-plusplus from warning to 2 and fix violations.

This commit is contained in:
kevv87 2016-11-30 18:05:04 +00:00 committed by Tim Abbott
parent c90da24541
commit e6369fc29b
23 changed files with 41 additions and 41 deletions

View File

@ -124,7 +124,7 @@
"no-new": 2, "no-new": 2,
"no-new-func": 2, "no-new-func": 2,
"no-native-reassign": 2, "no-native-reassign": 2,
"no-plusplus": 1, "no-plusplus": 2,
"no-delete-var": 2, "no-delete-var": 2,
"no-return-assign": 2, "no-return-assign": 2,
"no-new-object": 2, "no-new-object": 2,

View File

@ -56,7 +56,7 @@ exports.initialize_casper = function (viewport) {
casper.test.on('fail', function failure() { casper.test.on('fail', function failure() {
if (casper_failure_count <= 10) { if (casper_failure_count <= 10) {
casper.capture("var/casper/casper-failure" + casper_failure_count + ".png"); casper.capture("var/casper/casper-failure" + casper_failure_count + ".png");
casper_failure_count++; casper_failure_count += 1;
} }
}); });

View File

@ -191,7 +191,7 @@ var zero_counts = {
var num_msgs = 10000; var num_msgs = 10000;
var i; var i;
for (i = 0; i < num_msgs; ++i) { for (i = 0; i < num_msgs; i += 1) {
message.id = i+1; message.id = i+1;
unread.process_loaded_messages([message]); unread.process_loaded_messages([message]);
} }
@ -199,7 +199,7 @@ var zero_counts = {
count = unread.num_unread_for_subject('social', 'lunch'); count = unread.num_unread_for_subject('social', 'lunch');
assert.equal(count, num_msgs); assert.equal(count, num_msgs);
for (i = 0; i < num_msgs; ++i) { for (i = 0; i < num_msgs; i += 1) {
message.id = i+1; message.id = i+1;
unread.process_read_message(message); unread.process_read_message(message);
} }

View File

@ -188,19 +188,19 @@ var _ = global._;
'some_email@**everyone**.com' 'some_email@**everyone**.com'
]; ];
var i; var i;
for (i=0; i<messages_with_all_mentions.length; i++) { for (i=0; i<messages_with_all_mentions.length; i += 1) {
assert(util.is_all_or_everyone_mentioned(messages_with_all_mentions[i])); assert(util.is_all_or_everyone_mentioned(messages_with_all_mentions[i]));
} }
for (i=0; i<messages_with_everyone_mentions.length; i++) { for (i=0; i<messages_with_everyone_mentions.length; i += 1) {
assert(util.is_all_or_everyone_mentioned(messages_with_everyone_mentions[i])); assert(util.is_all_or_everyone_mentioned(messages_with_everyone_mentions[i]));
} }
for (i=0; i<messages_without_all_mentions.length; i++) { for (i=0; i<messages_without_all_mentions.length; i += 1) {
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i])); assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
} }
for (i=0; i<messages_without_everyone_mentions.length; i++) { for (i=0; i<messages_without_everyone_mentions.length; i += 1) {
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i])); assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
} }
}()); }());

View File

@ -176,7 +176,7 @@ exports.huddle_fraction_present = function (huddle, presence_info) {
if (presence_info[user_id]) { if (presence_info[user_id]) {
var status = presence_info[user_id].status; var status = presence_info[user_id].status;
if (status && (status !== 'offline')) { if (status && (status !== 'offline')) {
++num_present; num_present += 1;
} }
} }
}); });

View File

@ -264,7 +264,7 @@ function _setup_page() {
var domains_string = stringify_list_with_conjunction(page_params.domains, "or"); var domains_string = stringify_list_with_conjunction(page_params.domains, "or");
var atdomains = page_params.domains.slice(); var atdomains = page_params.domains.slice();
var i; var i;
for (i = 0; i < atdomains.length; i++) { for (i = 0; i < atdomains.length; i += 1) {
atdomains[i] = '@' + atdomains[i]; atdomains[i] = '@' + atdomains[i];
} }
var atdomains_string = stringify_list_with_conjunction(atdomains, "or"); var atdomains_string = stringify_list_with_conjunction(atdomains, "or");

View File

@ -61,7 +61,7 @@ function _fade_messages() {
normal_display = false; normal_display = false;
// Update the visible messages first, before the compose box opens // Update the visible messages first, before the compose box opens
for (i = 0; i < visible_groups.length; i++) { for (i = 0; i < visible_groups.length; i += 1) {
first_row = rows.first_message_in_group(visible_groups[i]); first_row = rows.first_message_in_group(visible_groups[i]);
first_message = current_msg_list.get(rows.id(first_row)); first_message = current_msg_list.get(rows.id(first_row));
should_fade_group = !fade_heuristic(focused_recipient, first_message); should_fade_group = !fade_heuristic(focused_recipient, first_message);
@ -83,7 +83,7 @@ function _fade_messages() {
// Note: The below algorithm relies on the fact that all_elts is // Note: The below algorithm relies on the fact that all_elts is
// sorted as it would be displayed in the message view // sorted as it would be displayed in the message view
for (i = 0; i < all_groups.length; i++) { for (i = 0; i < all_groups.length; i += 1) {
var group_elt = $(all_groups[i]); var group_elt = $(all_groups[i]);
should_fade_group = !fade_heuristic(focused_recipient, rows.recipient_from_group(group_elt)); should_fade_group = !fade_heuristic(focused_recipient, rows.recipient_from_group(group_elt));
change_fade_state(group_elt, should_fade_group); change_fade_state(group_elt, should_fade_group);

View File

@ -19,7 +19,7 @@ function find_boundary_tr(initial_tr, iterate_row) {
// To ensure we can't enter an infinite loop, bail out (and let the // 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 // browser handle the copy-paste on its own) if we don't hit what we
// are looking for within 10 rows. // are looking for within 10 rows.
for (j = 0; (!tr.is('.message_row')) && j < 10; j++) { for (j = 0; (!tr.is('.message_row')) && j < 10; j += 1) {
tr = iterate_row(tr); tr = iterate_row(tr);
} }
if (j === 10) { if (j === 10) {
@ -41,7 +41,7 @@ function copy_handler(e) {
var start_data, end_data; var start_data, end_data;
var skip_same_td_check = false; var skip_same_td_check = false;
var div = $('<div>'), content; var div = $('<div>'), content;
for (i = 0; i < selection.rangeCount; i++) { for (i = 0; i < selection.rangeCount; i += 1) {
range = selection.getRangeAt(i); range = selection.getRangeAt(i);
ranges.push(range); ranges.push(range);

View File

@ -103,7 +103,7 @@ function add_subject_links(message) {
var current_group = i + 1; var current_group = i + 1;
var back_ref = "\\" + current_group; var back_ref = "\\" + current_group;
link_url = link_url.replace(back_ref, matched_group); link_url = link_url.replace(back_ref, matched_group);
i++; i += 1;
} }
links.push(link_url); links.push(link_url);
} }
@ -352,7 +352,7 @@ function handleRealmFilter(pattern, matches) {
_.each(matches, function (match) { _.each(matches, function (match) {
var back_ref = "\\" + current_group; var back_ref = "\\" + current_group;
url = url.replace(back_ref, match); url = url.replace(back_ref, match);
current_group++; current_group += 1;
}); });
return url; return url;
@ -373,7 +373,7 @@ function python_to_js_filter(pattern, url) {
match = named_group_re.exec(pattern); match = named_group_re.exec(pattern);
current_group++; current_group += 1;
} }
// Convert any python in-regex flags to RegExp flags // Convert any python in-regex flags to RegExp flags
var js_flags = 'g'; var js_flags = 'g';

View File

@ -239,7 +239,7 @@ function edit_message (row, raw_content) {
// since otherwise there is a noticeable lag // since otherwise there is a noticeable lag
message_edit_countdown_timer.text(timer_text(seconds_left)); message_edit_countdown_timer.text(timer_text(seconds_left));
var countdown_timer = setInterval(function () { var countdown_timer = setInterval(function () {
if (--seconds_left <= 0) { if (seconds_left - 1 <= 0) {
clearInterval(countdown_timer); clearInterval(countdown_timer);
message_edit_content.prop("readonly", "readonly"); message_edit_content.prop("readonly", "readonly");
if (message.type === 'stream') { if (message.type === 'stream') {

View File

@ -260,7 +260,7 @@ exports.MessageList.prototype = {
// for lower_bound purposes, find the real leftmost index (first non-local id) // for lower_bound purposes, find the real leftmost index (first non-local id)
do { do {
potential_closest_matches.push(closest); potential_closest_matches.push(closest);
closest--; closest -= 1;
} while (closest > 0 && this._is_localonly_id(items[closest - 1].id)); } while (closest > 0 && this._is_localonly_id(items[closest - 1].id));
} }
potential_closest_matches.push(closest); potential_closest_matches.push(closest);
@ -308,7 +308,7 @@ exports.MessageList.prototype = {
break; break;
} }
next_msg_id = msg_id; next_msg_id = msg_id;
++idx; idx += 1;
} }
if (next_msg_id > 0) { if (next_msg_id > 0) {

View File

@ -29,7 +29,7 @@ exports.get_private_message_recipient = function (message, attr, fallback_attr)
if (recipient === undefined && fallback_attr !== undefined) { if (recipient === undefined && fallback_attr !== undefined) {
recipient = other_recipients[0][fallback_attr]; recipient = other_recipients[0][fallback_attr];
} }
for (i = 1; i < other_recipients.length; i++) { for (i = 1; i < other_recipients.length; i += 1) {
var attr_value = other_recipients[i][attr]; var attr_value = other_recipients[i][attr];
if (attr_value === undefined && fallback_attr !== undefined) { if (attr_value === undefined && fallback_attr !== undefined) {
attr_value = other_recipients[i][fallback_attr]; attr_value = other_recipients[i][fallback_attr];
@ -384,7 +384,7 @@ exports.insert_new_messages = function insert_new_messages(messages) {
// Iterate backwards to find the last message sent_by_me, stopping at // Iterate backwards to find the last message sent_by_me, stopping at
// the pointer position. // the pointer position.
for (i = messages.length-1; i>=0; i--) { for (i = messages.length-1; i>=0; i -= 1) {
var id = messages[i].id; var id = messages[i].id;
if (id <= selected_id) { if (id <= selected_id) {
break; break;

View File

@ -276,7 +276,7 @@ function process_notification(notification) {
if (content.length > 150) { if (content.length > 150) {
// Truncate content at a word boundary // Truncate content at a word boundary
for (i = 150; i > 0; i--) { for (i = 150; i > 0; i -= 1) {
if (content[i] === ' ') { if (content[i] === ' ') {
break; break;
} }

View File

@ -131,9 +131,9 @@ exports.actions_menu_handle_keyboard = function (key) {
if (index === -1) { if (index === -1) {
index = 0; index = 0;
} else if ((key === 'down_arrow' || key === 'vim_down') && index < items.length - 1) { } else if ((key === 'down_arrow' || key === 'vim_down') && index < items.length - 1) {
++index; index += 1;
} else if ((key === 'up_arrow' || key === 'vim_up') && index > 0) { } else if ((key === 'up_arrow' || key === 'vim_up') && index > 0) {
--index; index -= 1;
} }
items.eq(index).focus(); items.eq(index).focus();
}; };

View File

@ -26,12 +26,12 @@ exports.update_state = function (granted, used) {
$("#referral-form input").attr('placeholder', _.shuffle(placeholder_invitees).pop()); $("#referral-form input").attr('placeholder', _.shuffle(placeholder_invitees).pop());
$("#invite-hearts").empty(); $("#invite-hearts").empty();
var i; var i;
for (i = 0; i < used; i++) { for (i = 0; i < used; i += 1) {
$("#invite-hearts").append($('<i class="icon-vector-heart"> </i>')); $("#invite-hearts").append($('<i class="icon-vector-heart"> </i>'));
} }
var invites_left = Math.max(0, granted - used); var invites_left = Math.max(0, granted - used);
for (i = 0; i < invites_left; i++) { for (i = 0; i < invites_left; i += 1) {
$("#invite-hearts").append($('<i class="icon-vector-heart-empty"> </i>')); $("#invite-hearts").append($('<i class="icon-vector-heart-empty"> </i>'));
} }

View File

@ -13,7 +13,7 @@ function phrase_match(phrase, q) {
} }
var parts = phrase.split(' '); var parts = phrase.split(' ');
for (i = 0; i < parts.length; i++) { for (i = 0; i < parts.length; i += 1) {
if (parts[i].indexOf(q) === 0) { if (parts[i].indexOf(q) === 0) {
return true; return true;
} }
@ -304,7 +304,7 @@ function get_operator_subset_suggestions(query, operators) {
var i; var i;
var suggestions = []; var suggestions = [];
for (i = operators.length - 1; i >= 1; --i) { for (i = operators.length - 1; i >= 1; i -= 1) {
var subset = operators.slice(0, i); var subset = operators.slice(0, i);
var search_string = Filter.unparse(subset); var search_string = Filter.unparse(subset);
var description = Filter.describe(subset); var description = Filter.describe(subset);

View File

@ -89,7 +89,7 @@ Socket.prototype = {
_get_next_req_id: function Socket__get_next_req_id() { _get_next_req_id: function Socket__get_next_req_id() {
var req_id = page_params.event_queue_id + ':' + this._next_req_id_counter; var req_id = page_params.event_queue_id + ':' + this._next_req_id_counter;
this._next_req_id_counter++; this._next_req_id_counter += 1;
return req_id; return req_id;
}, },
@ -239,7 +239,7 @@ Socket.prototype = {
}; };
request.error = function (type, resp) { request.error = function (type, resp) {
blueslip.info("Could not authenticate with server: " + resp.msg); blueslip.info("Could not authenticate with server: " + resp.msg);
that._connection_failures++; that._connection_failures += 1;
that._try_to_reconnect({reason: 'auth_fail', that._try_to_reconnect({reason: 'auth_fail',
wait_time: that._reconnect_wait_time()}); wait_time: that._reconnect_wait_time()});
}; };
@ -277,7 +277,7 @@ Socket.prototype = {
blueslip.info("SockJS connection lost. Attempting to reconnect soon." blueslip.info("SockJS connection lost. Attempting to reconnect soon."
+ " (" + event.code.toString() + ", " + event.reason + ")"); + " (" + event.code.toString() + ", " + event.reason + ")");
that._connection_failures++; that._connection_failures += 1;
that._is_reconnecting = false; that._is_reconnecting = false;
// We don't need to specify a reason because the Socket is already closed // We don't need to specify a reason because the Socket is already closed
that._try_to_reconnect({wait_time: that._reconnect_wait_time()}); that._try_to_reconnect({wait_time: that._reconnect_wait_time()});

View File

@ -39,7 +39,7 @@
}, function () { }, function () {
var i; var i;
initialized = true; initialized = true;
for (i=0; i<callbacks.length; i++) { for (i=0; i<callbacks.length; i += 1) {
callbacks[i](); callbacks[i]();
} }
}); });

View File

@ -172,7 +172,7 @@ exports.get_color_class = _.memoize(function (color) {
// CSS colors are specified in the sRGB color space. // CSS colors are specified in the sRGB color space.
// Convert to linear intensity values. // Convert to linear intensity values.
for (i=0; i<3; i++) { for (i=0; i<3; i += 1) {
channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i+1], 16)); channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i+1], 16));
} }

View File

@ -54,7 +54,7 @@ Handlebars.registerHelper('if_and', function () {
// {{/if_and}} // {{/if_and}}
var options = arguments[arguments.length - 1]; var options = arguments[arguments.length - 1];
var i; var i;
for (i = 0; i < arguments.length - 1; i++) { for (i = 0; i < arguments.length - 1; i += 1) {
if (!arguments[i]) { if (!arguments[i]) {
return options.inverse(this); return options.inverse(this);
} }
@ -70,7 +70,7 @@ Handlebars.registerHelper('if_or', function () {
// {{/if_or}} // {{/if_or}}
var options = arguments[arguments.length - 1]; var options = arguments[arguments.length - 1];
var i; var i;
for (i = 0; i < arguments.length - 1; i++) { for (i = 0; i < arguments.length - 1; i += 1) {
if (arguments[i]) { if (arguments[i]) {
return options.fn(this); return options.fn(this);

View File

@ -89,7 +89,7 @@ function render_date_span(elem, time_str, time_above_str) {
// okay since to update the time later we look up the node by its id.) // okay since to update the time later we look up the node by its id.)
exports.render_date = function (time, time_above) { exports.render_date = function (time, time_above) {
var id = "timerender" + next_timerender_id; var id = "timerender" + next_timerender_id;
next_timerender_id++; next_timerender_id += 1;
var rendered_time = exports.render_now(time); var rendered_time = exports.render_now(time);
var node = $("<span />").attr('id', id); var node = $("<span />").attr('id', id);
if (time_above !== undefined) { if (time_above !== undefined) {

View File

@ -50,7 +50,7 @@ exports.highlight_query_in_phrase = function (query, phrase) {
var result = ""; var result = "";
var parts = phrase.split(' '); var parts = phrase.split(' ');
for (i = 0; i < parts.length; i++) { for (i = 0; i < parts.length; i += 1) {
if (i > 0) { if (i > 0) {
result += " "; result += " ";
} }

View File

@ -45,7 +45,7 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
middle = first + step; middle = first + step;
if (less(array[middle], value, middle)) { if (less(array[middle], value, middle)) {
first = middle; first = middle;
first++; first += 1;
len = len - step - 1; len = len - step - 1;
} else { } else {
len = step; len = step;
@ -144,7 +144,7 @@ exports.robust_uri_decode = function (str) {
if (!(e instanceof URIError)) { if (!(e instanceof URIError)) {
throw e; throw e;
} }
end--; end -= 1;
} }
} }
return ''; return '';
@ -177,7 +177,7 @@ exports.array_compare = function util_array_compare(a, b) {
return false; return false;
} }
var i; var i;
for (i = 0; i < a.length; ++i) { for (i = 0; i < a.length; i += 1) {
if (a[i] !== b[i]) { if (a[i] !== b[i]) {
return false; return false;
} }