diff --git a/.eslintrc.json b/.eslintrc.json index ca46d1a47f..039667f844 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -124,7 +124,7 @@ "no-new": 2, "no-new-func": 2, "no-native-reassign": 2, - "no-plusplus": 1, + "no-plusplus": 2, "no-delete-var": 2, "no-return-assign": 2, "no-new-object": 2, diff --git a/frontend_tests/casper_lib/common.js b/frontend_tests/casper_lib/common.js index 547ac48246..8f76f0e8cc 100644 --- a/frontend_tests/casper_lib/common.js +++ b/frontend_tests/casper_lib/common.js @@ -56,7 +56,7 @@ exports.initialize_casper = function (viewport) { casper.test.on('fail', function failure() { if (casper_failure_count <= 10) { casper.capture("var/casper/casper-failure" + casper_failure_count + ".png"); - casper_failure_count++; + casper_failure_count += 1; } }); diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index 34ceefff47..feca534562 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -191,7 +191,7 @@ var zero_counts = { var num_msgs = 10000; var i; - for (i = 0; i < num_msgs; ++i) { + for (i = 0; i < num_msgs; i += 1) { message.id = i+1; unread.process_loaded_messages([message]); } @@ -199,7 +199,7 @@ var zero_counts = { count = unread.num_unread_for_subject('social', 'lunch'); assert.equal(count, num_msgs); - for (i = 0; i < num_msgs; ++i) { + for (i = 0; i < num_msgs; i += 1) { message.id = i+1; unread.process_read_message(message); } diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js index 15b2d66f8d..02de5937a0 100644 --- a/frontend_tests/node_tests/util.js +++ b/frontend_tests/node_tests/util.js @@ -188,19 +188,19 @@ var _ = global._; 'some_email@**everyone**.com' ]; var i; - for (i=0; i'), content; - for (i = 0; i < selection.rangeCount; i++) { + for (i = 0; i < selection.rangeCount; i += 1) { range = selection.getRangeAt(i); ranges.push(range); diff --git a/static/js/echo.js b/static/js/echo.js index fcea0c5f5e..4a1f185e3c 100644 --- a/static/js/echo.js +++ b/static/js/echo.js @@ -103,7 +103,7 @@ function add_subject_links(message) { var current_group = i + 1; var back_ref = "\\" + current_group; link_url = link_url.replace(back_ref, matched_group); - i++; + i += 1; } links.push(link_url); } @@ -352,7 +352,7 @@ function handleRealmFilter(pattern, matches) { _.each(matches, function (match) { var back_ref = "\\" + current_group; url = url.replace(back_ref, match); - current_group++; + current_group += 1; }); return url; @@ -373,7 +373,7 @@ function python_to_js_filter(pattern, url) { match = named_group_re.exec(pattern); - current_group++; + current_group += 1; } // Convert any python in-regex flags to RegExp flags var js_flags = 'g'; diff --git a/static/js/message_edit.js b/static/js/message_edit.js index a19a36afd1..5ff8c51684 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -239,7 +239,7 @@ function edit_message (row, raw_content) { // since otherwise there is a noticeable lag message_edit_countdown_timer.text(timer_text(seconds_left)); var countdown_timer = setInterval(function () { - if (--seconds_left <= 0) { + if (seconds_left - 1 <= 0) { clearInterval(countdown_timer); message_edit_content.prop("readonly", "readonly"); if (message.type === 'stream') { diff --git a/static/js/message_list.js b/static/js/message_list.js index bfc8a676b6..24cc02f0c9 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -260,7 +260,7 @@ exports.MessageList.prototype = { // for lower_bound purposes, find the real leftmost index (first non-local id) do { potential_closest_matches.push(closest); - closest--; + closest -= 1; } while (closest > 0 && this._is_localonly_id(items[closest - 1].id)); } potential_closest_matches.push(closest); @@ -308,7 +308,7 @@ exports.MessageList.prototype = { break; } next_msg_id = msg_id; - ++idx; + idx += 1; } if (next_msg_id > 0) { diff --git a/static/js/message_store.js b/static/js/message_store.js index 4c639d8e65..36ef034cc7 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -29,7 +29,7 @@ exports.get_private_message_recipient = function (message, attr, fallback_attr) if (recipient === undefined && fallback_attr !== undefined) { 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]; if (attr_value === undefined && fallback_attr !== undefined) { 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 // 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; if (id <= selected_id) { break; diff --git a/static/js/notifications.js b/static/js/notifications.js index 6a416a46ff..fc8b3f61ca 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -276,7 +276,7 @@ function process_notification(notification) { if (content.length > 150) { // Truncate content at a word boundary - for (i = 150; i > 0; i--) { + for (i = 150; i > 0; i -= 1) { if (content[i] === ' ') { break; } diff --git a/static/js/popovers.js b/static/js/popovers.js index 59d7a4a43d..2c8f51221e 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -131,9 +131,9 @@ exports.actions_menu_handle_keyboard = function (key) { if (index === -1) { index = 0; } 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) { - --index; + index -= 1; } items.eq(index).focus(); }; diff --git a/static/js/referral.js b/static/js/referral.js index b1699dd3e8..b7abe29a4c 100644 --- a/static/js/referral.js +++ b/static/js/referral.js @@ -26,12 +26,12 @@ exports.update_state = function (granted, used) { $("#referral-form input").attr('placeholder', _.shuffle(placeholder_invitees).pop()); $("#invite-hearts").empty(); var i; - for (i = 0; i < used; i++) { + for (i = 0; i < used; i += 1) { $("#invite-hearts").append($(' ')); } 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($(' ')); } diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.js index eafbd1c288..35a6ae261b 100644 --- a/static/js/search_suggestion.js +++ b/static/js/search_suggestion.js @@ -13,7 +13,7 @@ function phrase_match(phrase, q) { } 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) { return true; } @@ -304,7 +304,7 @@ function get_operator_subset_suggestions(query, operators) { var i; 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 search_string = Filter.unparse(subset); var description = Filter.describe(subset); diff --git a/static/js/socket.js b/static/js/socket.js index 72320fa781..b5f1f6e4a6 100644 --- a/static/js/socket.js +++ b/static/js/socket.js @@ -89,7 +89,7 @@ Socket.prototype = { _get_next_req_id: function Socket__get_next_req_id() { 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; }, @@ -239,7 +239,7 @@ Socket.prototype = { }; request.error = function (type, resp) { blueslip.info("Could not authenticate with server: " + resp.msg); - that._connection_failures++; + that._connection_failures += 1; that._try_to_reconnect({reason: 'auth_fail', wait_time: that._reconnect_wait_time()}); }; @@ -277,7 +277,7 @@ Socket.prototype = { blueslip.info("SockJS connection lost. Attempting to reconnect soon." + " (" + event.code.toString() + ", " + event.reason + ")"); - that._connection_failures++; + that._connection_failures += 1; that._is_reconnecting = false; // We don't need to specify a reason because the Socket is already closed that._try_to_reconnect({wait_time: that._reconnect_wait_time()}); diff --git a/static/js/src/main.js b/static/js/src/main.js index 19e4986299..9bc744bf15 100644 --- a/static/js/src/main.js +++ b/static/js/src/main.js @@ -39,7 +39,7 @@ }, function () { var i; initialized = true; - for (i=0; i").attr('id', id); if (time_above !== undefined) { diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js index f14174dc56..7c20244b65 100644 --- a/static/js/typeahead_helper.js +++ b/static/js/typeahead_helper.js @@ -50,7 +50,7 @@ exports.highlight_query_in_phrase = function (query, phrase) { var result = ""; var parts = phrase.split(' '); - for (i = 0; i < parts.length; i++) { + for (i = 0; i < parts.length; i += 1) { if (i > 0) { result += " "; } diff --git a/static/js/util.js b/static/js/util.js index 30cdc8e025..9911133a7d 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -45,7 +45,7 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) { middle = first + step; if (less(array[middle], value, middle)) { first = middle; - first++; + first += 1; len = len - step - 1; } else { len = step; @@ -144,7 +144,7 @@ exports.robust_uri_decode = function (str) { if (!(e instanceof URIError)) { throw e; } - end--; + end -= 1; } } return ''; @@ -177,7 +177,7 @@ exports.array_compare = function util_array_compare(a, b) { return false; } var i; - for (i = 0; i < a.length; ++i) { + for (i = 0; i < a.length; i += 1) { if (a[i] !== b[i]) { return false; }