From ed0bc831be822b52ec862a668cb0fd8692e889ff Mon Sep 17 00:00:00 2001 From: AZtheAsian Date: Fri, 2 Dec 2016 09:09:31 -0700 Subject: [PATCH] eslint: change one-var from warning to error and fix violations --- .eslintrc.json | 2 +- static/js/click_handlers.js | 8 ++++---- static/js/compose.js | 9 +++++---- static/js/compose_fade.js | 4 +++- static/js/copy_and_paste.js | 20 ++++++++++++++++---- static/js/custom_markdown.js | 5 ++++- static/js/filter.js | 3 ++- static/js/floating_recipient_bar.js | 4 +++- static/js/hashchange.js | 3 ++- static/js/hotkey.js | 8 +++++--- static/js/message_edit.js | 3 ++- static/js/message_list.js | 3 ++- static/js/message_list_view.js | 15 +++++++++++---- static/js/message_store.js | 6 ++++-- static/js/navigate.js | 3 ++- static/js/notifications.js | 9 +++++++-- static/js/reload.js | 3 ++- static/js/stream_color.js | 6 +++++- static/js/subs.js | 9 ++++++--- static/js/tab_bar.js | 3 ++- static/js/ui.js | 4 ++-- static/js/util.js | 5 ++++- 22 files changed, 94 insertions(+), 41 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5f66966e5d..5ed93df6ab 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -165,7 +165,7 @@ "max-statements": [0, 10], "new-cap": 1, "new-parens": 2, - "one-var": 1, + "one-var": ["error", "never"], "quotes": [1, "single"], "quote-props": 0, "radix": 2, diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index bc06d22584..4ce33c737e 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -386,10 +386,10 @@ $(function () { (function () { $("#main_div").on("click", ".message_inline_image a", function (e) { - var img = e.target, - row = rows.id($(img).closest(".message_row")), - user = current_msg_list.get(row).sender_full_name, - $target = $(this); + var img = e.target; + var row = rows.id($(img).closest(".message_row")); + var user = current_msg_list.get(row).sender_full_name; + var $target = $(this); // prevent the link from opening in a new page. e.preventDefault(); diff --git a/static/js/compose.js b/static/js/compose.js index d6e60cee2c..af68646553 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -610,7 +610,8 @@ function send_message(request) { } exports.respond_to_message = function (opts) { - var message, msg_type; + var message; + var msg_type; // Before initiating a reply to a message, if there's an // in-progress composition, snapshot it. compose.snapshot_message(); @@ -1117,9 +1118,9 @@ $(function () { if (response.uri === undefined) { return; } - var textbox = $("#new_message_content"), - split_uri = response.uri.split("/"), - filename = split_uri[split_uri.length - 1]; + var textbox = $("#new_message_content"); + var split_uri = response.uri.split("/"); + var filename = split_uri[split_uri.length - 1]; // Urgh, yet another hack to make sure we're "composing" // when text gets added into the composebox. if (!compose.composing()) { diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js index cf89ba0d03..d5eec25760 100644 --- a/static/js/compose_fade.js +++ b/static/js/compose_fade.js @@ -54,7 +54,9 @@ function change_fade_state(elt, should_fade_group) { } function _fade_messages() { - var i, first_message, first_row; + var i; + var first_message; + var first_row; var should_fade_group = false; var visible_groups = viewport.visible_groups(false); diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js index 15cdc38bed..cebe8c807a 100644 --- a/static/js/copy_and_paste.js +++ b/static/js/copy_and_paste.js @@ -3,7 +3,8 @@ var copy_and_paste = (function () { var exports = {}; // we don't actually export anything yet, but that's ok function find_boundary_tr(initial_tr, iterate_row) { - var j, skip_same_td_check = false; + var j; + var skip_same_td_check = false; var tr = initial_tr; // If the selection boundary is somewhere that does not have a @@ -37,10 +38,21 @@ function find_boundary_tr(initial_tr, iterate_row) { function copy_handler(e) { var selection = window.getSelection(); - var i, range, ranges = [], startc, endc, initial_end_tr, start_id, end_id, row, message; - var start_data, end_data; + var i; + var range; + var ranges = []; + var startc; + var endc; + var initial_end_tr; + var start_id; + var end_id; + var row; + var message; + var start_data; + var end_data; var skip_same_td_check = false; - var div = $('
'), content; + var div = $('
'); + var content; for (i = 0; i < selection.rangeCount; i += 1) { range = selection.getRangeAt(i); ranges.push(range); diff --git a/static/js/custom_markdown.js b/static/js/custom_markdown.js index 5b86fe41c2..7e9c7e53d5 100644 --- a/static/js/custom_markdown.js +++ b/static/js/custom_markdown.js @@ -81,7 +81,10 @@ var exports = {}; }); $(document).on('message_rendered.zulip', function (e) { - var $inline_subscribe, $button, stream_name, id; + var $inline_subscribe; + var $button; + var stream_name; + var id; $inline_subscribe = $(e.target).find('.inline-subscribe'); if ($inline_subscribe.length === 0) { return; diff --git a/static/js/filter.js b/static/js/filter.js index 6fe4870581..083922b496 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -217,7 +217,8 @@ Filter.parse = function (str) { return operators; } _.each(matches, function (token) { - var parts, operator; + var parts; + var operator; parts = token.split(':'); if (token[0] === '"' || parts.length === 1) { // Looks like a normal search term. diff --git a/static/js/floating_recipient_bar.js b/static/js/floating_recipient_bar.js index b653e1dbd1..8e27e573db 100644 --- a/static/js/floating_recipient_bar.js +++ b/static/js/floating_recipient_bar.js @@ -14,7 +14,9 @@ function show_floating_recipient_bar() { var old_label; function replace_floating_recipient_bar(desired_label) { - var new_label, other_label, header; + var new_label; + var other_label; + var header; if (desired_label !== old_label) { if (desired_label.children(".message_header_stream").length !== 0) { new_label = $("#current_label_stream"); diff --git a/static/js/hashchange.js b/static/js/hashchange.js index adb11e18d6..885a1d2bcc 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -83,7 +83,8 @@ exports.save_narrow = function (operators) { }; function parse_narrow(hash) { - var i, operators = []; + var i; + var operators = []; for (i=1; i 0) { - var stream, ops = narrow.operators(); + var stream; + var ops = narrow.operators(); var hash = hashchange.operators_to_hash(ops); // Second breadcrumb item var hashed = hashchange.operators_to_hash(ops.slice(0, 1)); diff --git a/static/js/ui.js b/static/js/ui.js index a3446e9f7f..f80580b240 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -295,8 +295,8 @@ exports.lightbox = function (data) { exports.lightbox_photo = function (image, user) { // image should be an Image Object in JavaScript. - var url = $(image).attr("src"), - title = $(image).parent().attr("title"); + var url = $(image).attr("src"); + var title = $(image).parent().attr("title"); $("#overlay .player-container").hide(); $("#overlay .image-actions, .image-description, .download").show(); diff --git a/static/js/util.js b/static/js/util.js index 9911133a7d..084ad82a03 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -19,7 +19,10 @@ exports.random_int = function random_int(min, max) { // Usage: lower_bound(array, value, [less]) // lower_bound(array, first, last, value, [less]) exports.lower_bound = function (array, arg1, arg2, arg3, arg4) { - var first, last, value, less; + var first; + var last; + var value; + var less; if (arg3 === undefined) { first = 0; last = array.length;