lint: Require folding of } on same line as else statements.

This commit is contained in:
Tim Abbott
2016-06-09 14:02:49 -07:00
parent 0c1b5006f7
commit c35781d505
15 changed files with 24 additions and 44 deletions

View File

@@ -122,11 +122,9 @@ exports.then_send_message = function (type, params) {
casper.waitForSelector('#new_message_content', function () { casper.waitForSelector('#new_message_content', function () {
if (type === "stream") { if (type === "stream") {
casper.page.sendEvent('keypress', "c"); casper.page.sendEvent('keypress', "c");
} } else if (type === "private") {
else if (type === "private") {
casper.page.sendEvent('keypress', "C"); casper.page.sendEvent('keypress', "C");
} } else {
else {
casper.test.assertTrue(false, "send_message got valid message type"); casper.test.assertTrue(false, "send_message got valid message type");
} }
casper.fill('form[action^="/json/messages"]', params); casper.fill('form[action^="/json/messages"]', params);

View File

@@ -281,32 +281,28 @@ exports.setup_page = function () {
if (data.restricted_to_domain !== undefined) { if (data.restricted_to_domain !== undefined) {
if (data.restricted_to_domain) { if (data.restricted_to_domain) {
ui.report_success("New users must have @" + page_params.domain + " e-mails!", restricted_to_domain_status); ui.report_success("New users must have @" + page_params.domain + " e-mails!", restricted_to_domain_status);
} } else {
else {
ui.report_success("New users may have arbitrary e-mails!", restricted_to_domain_status); ui.report_success("New users may have arbitrary e-mails!", restricted_to_domain_status);
} }
} }
if (data.invite_required !== undefined) { if (data.invite_required !== undefined) {
if (data.invite_required) { if (data.invite_required) {
ui.report_success("New users must be invited by e-mail!", invite_required_status); ui.report_success("New users must be invited by e-mail!", invite_required_status);
} } else {
else {
ui.report_success("New users may sign up online!", invite_required_status); ui.report_success("New users may sign up online!", invite_required_status);
} }
} }
if (data.invite_by_admins_only !== undefined) { if (data.invite_by_admins_only !== undefined) {
if (data.invite_by_admins_only) { if (data.invite_by_admins_only) {
ui.report_success("New users must be invited by an admin!", invite_by_admins_only_status); ui.report_success("New users must be invited by an admin!", invite_by_admins_only_status);
} } else {
else {
ui.report_success("Any user may now invite new users!", invite_by_admins_only_status); ui.report_success("Any user may now invite new users!", invite_by_admins_only_status);
} }
} }
if (data.create_stream_by_admins_only !== undefined) { if (data.create_stream_by_admins_only !== undefined) {
if (data.create_stream_by_admins_only) { if (data.create_stream_by_admins_only) {
ui.report_success("Only Admins may now create new streams!", create_stream_by_admins_only_status); ui.report_success("Only Admins may now create new streams!", create_stream_by_admins_only_status);
} } else {
else {
ui.report_success("Any user may now create new streams!", create_stream_by_admins_only_status); ui.report_success("Any user may now create new streams!", create_stream_by_admins_only_status);
} }
} }

View File

@@ -115,8 +115,7 @@ exports.build_widget = function (
} else { } else {
accept(file); accept(file);
} }
} } else {
else {
input_error.text('Please just upload one file.'); input_error.text('Please just upload one file.');
} }
}); });
@@ -202,8 +201,7 @@ exports.build_direct_upload_widget = function (
} else { } else {
accept(file); accept(file);
} }
} } else {
else {
input_error.text('Please just upload one file.'); input_error.text('Please just upload one file.');
} }
}); });

View File

@@ -176,8 +176,7 @@ function _update_faded_messages() {
_display_messages_normally(); _display_messages_normally();
_display_users_normally(); _display_users_normally();
} }
} } else {
else {
_fade_messages(); _fade_messages();
_fade_users(); _fade_users();
} }
@@ -212,8 +211,7 @@ exports.clear_compose = function () {
exports.update_message_list = function () { exports.update_message_list = function () {
if (_want_normal_display()) { if (_want_normal_display()) {
_display_messages_normally(); _display_messages_normally();
} } else {
else {
_fade_messages(); _fade_messages();
} }
}; };

View File

@@ -82,8 +82,7 @@ function copy_handler(e) {
if (!skip_same_td_check && if (!skip_same_td_check &&
startc.parents('.selectable_row>div')[0] === endc.parents('.selectable_row>div')[0]) { startc.parents('.selectable_row>div')[0] === endc.parents('.selectable_row>div')[0]) {
return; return;
} } else {
else {
// Construct a div for what we want to copy (div) // Construct a div for what we want to copy (div)
for (row = current_msg_list.get_row(start_id); for (row = current_msg_list.get_row(start_id);

View File

@@ -892,8 +892,7 @@ MessageListView.prototype = {
// Slice the '<p>/me ' off the front, and '</p>' off the end // Slice the '<p>/me ' off the front, and '</p>' off the end
message_container.status_message = message_container.msg.content.slice(4 + 3, -4); message_container.status_message = message_container.msg.content.slice(4 + 3, -4);
message_container.include_sender = true; message_container.include_sender = true;
} } else {
else {
message_container.status_message = false; message_container.status_message = false;
} }
} }

View File

@@ -177,8 +177,7 @@ exports.activate = function (raw_operators, opts) {
if (!had_message_content) { if (!had_message_content) {
compose.cancel(); compose.cancel();
} } else {
else {
compose_fade.update_message_list(); compose_fade.update_message_list();
} }
@@ -336,8 +335,7 @@ exports.activate = function (raw_operators, opts) {
if (!had_message_content && opts.trigger === 'sidebar' && exports.narrowed_by_reply()) { if (!had_message_content && opts.trigger === 'sidebar' && exports.narrowed_by_reply()) {
if (exports.narrowed_to_topic()) { if (exports.narrowed_to_topic()) {
compose.start('stream'); compose.start('stream');
} } else {
else {
compose.start('private'); compose.start('private');
} }
} }

View File

@@ -54,8 +54,7 @@ exports.to_end = function () {
exports.page_up = function () { exports.page_up = function () {
if (viewport.at_top() && !current_msg_list.empty()) { if (viewport.at_top() && !current_msg_list.empty()) {
current_msg_list.select_id(current_msg_list.first().id, {then_scroll: false}); current_msg_list.select_id(current_msg_list.first().id, {then_scroll: false});
} } else {
else {
ui.page_up_the_right_amount(); ui.page_up_the_right_amount();
} }
}; };
@@ -64,8 +63,7 @@ exports.page_down = function () {
if (viewport.at_bottom() && !current_msg_list.empty()) { if (viewport.at_bottom() && !current_msg_list.empty()) {
current_msg_list.select_id(current_msg_list.last().id, {then_scroll: false}); current_msg_list.select_id(current_msg_list.last().id, {then_scroll: false});
unread.mark_current_list_as_read(); unread.mark_current_list_as_read();
} } else {
else {
ui.page_down_the_right_amount(); ui.page_down_the_right_amount();
} }
}; };

View File

@@ -110,8 +110,7 @@ exports.initialize = function () {
asked_permission_already = true; asked_permission_already = true;
}); });
}); });
} } else {
else {
notifications_api.requestPermission(function () { notifications_api.requestPermission(function () {
asked_permission_already = true; asked_permission_already = true;
}); });

View File

@@ -122,8 +122,7 @@ function get_private_suggestions(all_people, operators, person_operator_matches)
if (query === undefined) { if (query === undefined) {
return []; return [];
} }
} } else {
else {
return []; return [];
} }

View File

@@ -191,8 +191,7 @@ exports.redraw_stream_privacy = function (stream_name) {
if (sub.invite_only) { if (sub.invite_only) {
swatch.addClass("private-stream-swatch"); swatch.addClass("private-stream-swatch");
} } else {
else {
swatch.removeClass("private-stream-swatch"); swatch.removeClass("private-stream-swatch");
} }

View File

@@ -78,8 +78,7 @@ function prefix_sort(query, objs, get_item) {
var item; var item;
if (get_item) { if (get_item) {
item = get_item(obj); item = get_item(obj);
} } else {
else {
item = obj; item = obj;
} }
if (item.indexOf(query) === 0) { if (item.indexOf(query) === 0) {

View File

@@ -149,8 +149,7 @@ exports.get_counts = function () {
if (narrow.active()) { if (narrow.active()) {
res.unread_in_current_view = exports.num_unread_current_messages(); res.unread_in_current_view = exports.num_unread_current_messages();
} } else {
else {
res.unread_in_current_view = res.home_unread_messages; res.unread_in_current_view = res.home_unread_messages;
} }

View File

@@ -47,8 +47,7 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
first = middle; first = middle;
first++; first++;
len = len - step - 1; len = len - step - 1;
} } else {
else {
len = step; len = step;
} }
} }

View File

@@ -151,6 +151,8 @@ js_rules = [
'description': 'Missing space between if and ('}, 'description': 'Missing space between if and ('},
{'pattern': 'else{$', {'pattern': 'else{$',
'description': 'Missing space between else and {'}, 'description': 'Missing space between else and {'},
{'pattern': '^else {$',
'description': 'Write JS else statements on same line as }'},
] + whitespace_rules ] + whitespace_rules
python_rules = [ python_rules = [
{'pattern': '^(?!#)@login_required', {'pattern': '^(?!#)@login_required',