From 2bc14d256f14ec9eeaf3fc6223495a0305f9bcd5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 18 Oct 2017 10:16:41 -0700 Subject: [PATCH] lint: Ban two spaces after comma in JS code. We exclude the frontend tests, mostly because the lint rule isn't that precise, and the test code has some sample user input that's a bit funny. --- static/js/favicon.js | 2 +- static/js/filter.js | 6 +++--- static/js/hash_util.js | 2 +- static/js/message_viewport.js | 2 +- static/js/popovers.js | 18 +++++++++--------- static/js/stats/stats.js | 2 +- static/js/topic_list.js | 2 +- tools/linter_lib/custom_check.py | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/static/js/favicon.js b/static/js/favicon.js index 6b4dfec1a1..a48ad38a98 100644 --- a/static/js/favicon.js +++ b/static/js/favicon.js @@ -22,7 +22,7 @@ exports.set = function (url) { // in re-rendering the page (see #882). $(favicon_selector).remove(); $('head').append($('') - .attr('rel', 'shortcut icon') + .attr('rel', 'shortcut icon') .attr('href', url)); } }; diff --git a/static/js/filter.js b/static/js/filter.js index a82645e34c..0fff16b38e 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -226,10 +226,10 @@ Filter.canonicalize_term = function (opts) { narrow in the URL fragment. There we do use full URI encoding to avoid problematic characters. */ function encodeOperand(operand) { - return operand.replace(/%/g, '%25') + return operand.replace(/%/g, '%25') .replace(/\+/g, '%2B') - .replace(/ /g, '+') - .replace(/"/g, '%22'); + .replace(/ /g, '+') + .replace(/"/g, '%22'); } function decodeOperand(encoded, operator) { diff --git a/static/js/hash_util.js b/static/js/hash_util.js index 7ef49cbe8e..1504840830 100644 --- a/static/js/hash_util.js +++ b/static/js/hash_util.js @@ -8,7 +8,7 @@ var exports = {}; exports.encodeHashComponent = function (str) { return encodeURIComponent(str) .replace(/\./g, '%2E') - .replace(/%/g, '.'); + .replace(/%/g, '.'); }; exports.encode_operand = function (operator, operand) { diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index 80fc370d20..2d9fe9280d 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -244,7 +244,7 @@ function make_dimen_wrapper(dimen_name, dimen_func) { } exports.height = make_dimen_wrapper('height', $(exports.message_pane).height); -exports.width = make_dimen_wrapper('width', $(exports.message_pane).width); +exports.width = make_dimen_wrapper('width', $(exports.message_pane).width); exports.stop_auto_scrolling = function () { if (in_stoppable_autoscroll) { diff --git a/static/js/popovers.js b/static/js/popovers.js index 4885fe0aff..e8b4f2e117 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -118,11 +118,11 @@ function show_user_info_popover(element, user, message) { elt.popover({ placement: placement, - template: templates.render('user_info_popover', {class: "message-info-popover"}), - title: templates.render('user_info_popover_title', - {user_avatar: "avatar/" + user.email}), - content: templates.render('user_info_popover_content', args), - trigger: "manual", + template: templates.render('user_info_popover', {class: "message-info-popover"}), + title: templates.render('user_info_popover_title', + {user_avatar: "avatar/" + user.email}), + content: templates.render('user_info_popover_content', args), + trigger: "manual", }); elt.popover("show"); @@ -451,10 +451,10 @@ exports.register_click_handlers = function () { }; target.popover({ - template: templates.render('user_info_popover', {class: "user_popover"}), - title: templates.render('user_info_popover_title', {user_avatar: "avatar/" + user_email}), - content: templates.render('user_info_popover_content', args), - trigger: "manual", + template: templates.render('user_info_popover', {class: "user_popover"}), + title: templates.render('user_info_popover_title', {user_avatar: "avatar/" + user_email}), + content: templates.render('user_info_popover_content', args), + trigger: "manual", fixed: true, placement: userlist_placement === "left" ? "right" : "left", }); diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js index 4ff8577677..70c435e9c8 100644 --- a/static/js/stats/stats.js +++ b/static/js/stats/stats.js @@ -396,7 +396,7 @@ function populate_messages_sent_by_client(data) { plot_data.values.reverse(); plot_data.labels.reverse(); plot_data.percentages.reverse(); - var annotations = { values : [], labels : [], text : []}; + var annotations = {values: [], labels: [], text: []}; for (var i=0; i 0) { annotations.values.push(plot_data.values[i]); diff --git a/static/js/topic_list.js b/static/js/topic_list.js index 9043ccf8b0..c2faf1ccaa 100644 --- a/static/js/topic_list.js +++ b/static/js/topic_list.js @@ -310,7 +310,7 @@ exports.set_click_handlers = function (callbacks) { var sub = stream_data.get_sub_by_id(stream_id); var topic = $(e.target).parents('li').attr('data-topic-name'); - narrow.activate([{operator: 'stream', operand: sub.name}, + narrow.activate([{operator: 'stream', operand: sub.name}, {operator: 'topic', operand: topic}], {select_first_unread: true, trigger: 'sidebar'}); diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index b7740bf671..64802ee811 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -146,8 +146,8 @@ def build_custom_checkers(by_lang): 'description': 'Fix tab-based whitespace'}, ] # type: RuleList comma_whitespace_rule = [ - {'pattern': ', {2,}[^# ]', - 'exclude': set(['zerver/tests']), + {'pattern': ', {2,}[^#/ ]', + 'exclude': set(['zerver/tests', 'frontend_tests/node_tests']), 'description': "Remove multiple whitespaces after ','", 'good_lines': ['foo(1, 2, 3)', 'foo = bar # some inline comment'], 'bad_lines': ['foo(1, 2, 3)', 'foo(1, 2, 3)']}, @@ -232,7 +232,7 @@ def build_custom_checkers(by_lang): ]), 'good_lines': ['#my-style {color: blue;}'], 'bad_lines': ['

Foo

', 'style = "color: blue;"']}, - ]) + whitespace_rules + ]) + whitespace_rules + comma_whitespace_rule python_rules = cast(RuleList, [ {'pattern': '^(?!#)@login_required', 'description': '@login_required is unsupported; use @zulip_login_required',