js: Fix a bunch of indentation issues found by eslint.

This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
This commit is contained in:
Tim Abbott
2018-05-06 12:43:17 -07:00
parent 4d0e64ee41
commit 7ab8a8e820
68 changed files with 377 additions and 349 deletions

View File

@@ -1,3 +1,5 @@
/* eslint indent: "off" */
var bot_data = (function () {
var exports = {};

View File

@@ -1,3 +1,5 @@
/* eslint indent: "off" */
var buddy_list = (function () {
var self = {};

View File

@@ -285,8 +285,9 @@ exports.respond_to_message = function (opts) {
return;
}
msg_type = 'stream'; // Set msg_type to stream by default
// in the case of an empty home view.
// Set msg_type to stream by default in the case of an empty
// home view.
msg_type = 'stream';
if (narrow_state.narrowed_by_pm_reply()) {
msg_type = 'private';
}

View File

@@ -526,9 +526,12 @@ exports.compose_matches_sorter = function (matches) {
}
});
var recipients = typeahead_helper.sort_recipients(users, this.token,
var recipients = typeahead_helper.sort_recipients(
users,
this.token,
compose_state.stream_name(),
compose_state.subject(), groups);
compose_state.subject(),
groups);
return recipients;
} else if (this.completing === 'stream') {
return typeahead_helper.sort_streams(matches, this.token);

View File

@@ -50,9 +50,7 @@ function construct_copy_div(div, start_id, end_id) {
var should_include_start_recipient_header = false;
var last_recipient_row_id = start_recipient_row_id;
for (var row = start_row;
rows.id(row) <= end_id;
row = rows.next_visible(row)) {
for (var row = start_row; rows.id(row) <= end_id; row = rows.next_visible(row)) {
var recipient_row_id = rows.id_for_recipient_row(rows.get_message_recipient_row(row));
// if we found a message from another recipient,
// it means that we have messages from several recipients,

View File

@@ -1,3 +1,5 @@
/* eslint indent: "off" */
// This is a public instance of the `DynamicText` class.
// The `DynamicText` object serves to resize text that is set through its
// public methods so that the text won't ever overrun the parent container.

View File

@@ -192,8 +192,7 @@ function insert_hotspot_into_DOM(hotspot) {
}
// reposition on any event that might update the UI
['resize', 'scroll', 'onkeydown', 'click']
.forEach(function (event_name) {
['resize', 'scroll', 'onkeydown', 'click'].forEach(function (event_name) {
window.addEventListener(event_name, _.debounce(function () {
if (place_icon(hotspot)) {
place_popover(hotspot);

View File

@@ -1,3 +1,5 @@
/* eslint indent: "off" */
var LightboxCanvas = (function () {
var events = {
documentMouseup: [],

View File

@@ -1,3 +1,5 @@
/* eslint indent: "off" */
var list_render = (function () {
var DEFAULTS = {
INITIAL_RENDER_COUNT: 80,

View File

@@ -328,8 +328,7 @@ exports.initialize = function () {
function disable_markdown_regex(rules, name) {
rules[name] = {exec: function () {
return false;
},
};
}};
}
// Configure the marked markdown parser for our usage

View File

@@ -148,8 +148,7 @@ MessageListView.prototype = {
}
},
add_subscription_marker: function MessageListView__add_subscription_marker(
group, last_msg_container, first_msg_container) {
add_subscription_marker: function (group, last_msg_container, first_msg_container) {
if (last_msg_container === undefined) {
return;
}
@@ -980,8 +979,7 @@ MessageListView.prototype = {
trailing_bookend.remove();
},
render_trailing_bookend: function MessageListView_render_trailing_bookend(
trailing_bookend_content, subscribed, show_button) {
render_trailing_bookend: function (trailing_bookend_content, subscribed, show_button) {
var rendered_trailing_bookend = $(templates.render('bookend', {
bookend_content: trailing_bookend_content,
trailing: show_button,

View File

@@ -357,7 +357,8 @@ exports.update_selection = function (opts) {
var then_scroll = !preserve_pre_narrowing_screen_position;
message_list.narrowed.select_id(msg_id, {then_scroll: then_scroll,
message_list.narrowed.select_id(msg_id, {
then_scroll: then_scroll,
use_closest: true,
force_rerender: true,
});

View File

@@ -96,11 +96,13 @@ exports.initialize = function () {
supports_sound = true;
$("#notifications-area").append(audio);
if (audio[0].canPlayType('audio/ogg; codecs="vorbis"')) {
audio.append($("<source>").attr("type", "audio/ogg")
audio.append(
$("<source>").attr("type", "audio/ogg")
.attr("loop", "yes")
.attr("src", "/static/audio/zulip.ogg"));
} else {
audio.append($("<source>").attr("type", "audio/mpeg")
audio.append(
$("<source>").attr("type", "audio/mpeg")
.attr("loop", "yes")
.attr("src", "/static/audio/zulip.mp3"));
}
@@ -338,15 +340,16 @@ function process_notification(notification) {
if (message.type === "stream") {
title += " (to " + message.stream + " > " + message.subject + ")";
raw_operators = [{operator: "stream", operand: message.stream},
{operator: "topic", operand: message.subject}];
raw_operators = [
{operator: "stream", operand: message.stream},
{operator: "topic", operand: message.subject},
];
}
if (window.bridge === undefined && notification.webkit_notify === true) {
var icon_url = people.small_avatar_url(message);
notice_memory[key] = {
obj: notifications_api.createNotification(
icon_url, title, content, message.id),
obj: notifications_api.createNotification(icon_url, title, content, message.id),
msg_count: msg_count,
message_id: message.id,
};

View File

@@ -137,8 +137,8 @@ exports.rebuild_recent = function (active_conversation) {
if (private_messages_open) {
var max_private_messages = 5;
var private_li = get_filter_li();
var private_messages_dom = exports._build_private_messages_list(active_conversation,
max_private_messages);
var private_messages_dom = exports._build_private_messages_list(
active_conversation, max_private_messages);
private_li.append(private_messages_dom);
}

View File

@@ -1,3 +1,4 @@
/* eslint indent: "off" */
import PerfectScrollbar from 'perfect-scrollbar';
function registerCodeSection($codeSection) {

View File

@@ -1,3 +1,4 @@
/* eslint indent: "off" */
var realm_icon = (function () {
var exports = {};

View File

@@ -102,9 +102,8 @@ exports.initialize = function () {
$('#search_exit').on('click', exports.clear_search);
var query = $('#search_query');
query.on('focus', exports.focus_search)
.on('blur' , function () {
query.on('focus', exports.focus_search);
query.on('blur' , function () {
// The search query box is a visual cue as to
// whether search or narrowing is active. If
// the user blurs the search box, then we should

View File

@@ -90,7 +90,8 @@ exports.add_custom_profile_fields_to_settings = function () {
value = "";
}
var html = templates.render("custom-user-profile-field", {field: field,
var html = templates.render("custom-user-profile-field", {
field: field,
field_type: type,
field_value: value,
is_long_text_field: is_long_text,

View File

@@ -393,9 +393,11 @@ function update_dependent_subsettings(property_name) {
} else if (property_name === 'realm_invite_required') {
settings_ui.disable_sub_setting_onchange(page_params.realm_invite_required,
"id_realm_invite_by_admins_only", true);
} else if (property_name === 'realm_video_chat_provider' || property_name === 'realm_google_hangouts_domain') {
} else if (property_name === 'realm_video_chat_provider' ||
property_name === 'realm_google_hangouts_domain') {
set_video_chat_provider_dropdown();
} else if (property_name === 'realm_msg_edit_limit_setting' || property_name === 'realm_message_content_edit_limit_minutes') {
} else if (property_name === 'realm_msg_edit_limit_setting' ||
property_name === 'realm_message_content_edit_limit_minutes') {
set_msg_edit_limit_dropdown();
} else if (property_name === 'realm_msg_delete_limit_setting' ||
property_name === 'realm_message_content_delete_limit_minutes') {
@@ -654,8 +656,8 @@ function _set_up() {
var add_emoji_permission = $("#id_realm_add_emoji_by_admins_only").val();
var new_message_retention_days = $("#id_realm_message_retention_days").val();
if (parseInt(new_message_retention_days, 10).toString() !==
new_message_retention_days && new_message_retention_days !== "") {
if (parseInt(new_message_retention_days, 10).toString() !== new_message_retention_days
&& new_message_retention_days !== "") {
new_message_retention_days = "";
}

View File

@@ -84,8 +84,7 @@ exports.populate_user_groups = function () {
});
pill_container.find('.pill').hover(function () {
pill_container.find('.pill').find('.exit').css('opacity', '0.5');
}, function () {}
);
}, function () {});
}
update_membership(data.id);

View File

@@ -32,8 +32,14 @@ function Socket(url) {
that._try_to_reconnect({reason: 'unsuspend'});
});
this._supported_protocols = ['websocket', 'xdr-streaming', 'xhr-streaming',
'xdr-polling', 'xhr-polling', 'jsonp-polling'];
this._supported_protocols = [
'websocket',
'xdr-streaming',
'xhr-streaming',
'xdr-polling',
'xhr-polling',
'jsonp-polling',
];
if (page_params.test_suite) {
this._supported_protocols = _.reject(this._supported_protocols,
function (x) { return x === 'xhr-streaming'; });

View File

@@ -5,12 +5,14 @@ var exports = {};
exports.default_color = "#c2c2c2";
// Auto-assigned colors should be from the default palette so it's easy to undo
// changes, so if that palette changes, change these colors.
var stream_assignment_colors = ["#76ce90", "#fae589", "#a6c7e5", "#e79ab5",
var stream_assignment_colors = [
"#76ce90", "#fae589", "#a6c7e5", "#e79ab5",
"#bfd56f", "#f4ae55", "#b0a5fd", "#addfe5",
"#f5ce6e", "#c2726a", "#94c849", "#bd86e5",
"#ee7e4a", "#a6dcbf", "#95a5fd", "#53a063",
"#9987e1", "#e4523d", "#c2c2c2", "#4f8de4",
"#c6a8ad", "#e7cc4d", "#c8bebf", "#a47462"];
"#c6a8ad", "#e7cc4d", "#c8bebf", "#a47462",
];
// Classes which could be returned by get_color_class.
exports.color_classes = 'dark_background';
@@ -85,7 +87,8 @@ var subscriptions_table_colorpicker_options = {
exports.set_colorpicker_color = function (colorpicker, color) {
colorpicker.spectrum(_.extend(subscriptions_table_colorpicker_options,
{color: color, container: "#subscription_overlay .subscription_settings.show"}));
{color: color,
container: "#subscription_overlay .subscription_settings.show"}));
};
exports.update_stream_color = function (sub, color, opts) {

View File

@@ -178,7 +178,8 @@ function create_stream() {
loading.make_indicator($('#stream_creating_indicator'), {text: i18n.t('Creating stream...')});
ajaxSubscribeForCreation(stream_name,
ajaxSubscribeForCreation(
stream_name,
description,
principals,
is_invite_only,
@@ -408,7 +409,8 @@ exports.set_up_handlers = function () {
container.on("mouseover", "#announce-stream-docs", function (e) {
var announce_stream_docs = $("#announce-stream-docs");
announce_stream_docs.popover({placement: "right",
announce_stream_docs.popover({
placement: "right",
content: templates.render('announce_stream_docs', {
notifications_stream: page_params.notifications_stream}),
trigger: "manual"});

View File

@@ -225,8 +225,7 @@ exports.all_subscribed_streams_are_in_home_view = function () {
exports.home_view_stream_names = function () {
var home_view_subs = _.filter(exports.subscribed_subs(), function (sub) {
return sub.in_home_view;
}
);
});
return _.map(home_view_subs, function (sub) {
return sub.name;
});
@@ -554,7 +553,8 @@ exports.get_newbie_stream = function () {
};
exports.remove_default_stream = function (stream_id) {
page_params.realm_default_streams = _.reject(page_params.realm_default_streams,
page_params.realm_default_streams = _.reject(
page_params.realm_default_streams,
function (stream) {
return stream.stream_id === stream_id;
}

View File

@@ -543,8 +543,7 @@ $(function () {
function invite_failure() {
stream_subscription_info_elem.text(i18n.t("Could not add user to this stream."))
.addClass("text-error")
.removeClass("text-success");
.addClass("text-error").removeClass("text-success");
}
exports.invite_user_to_stream(principal, sub, invite_success, invite_failure);
@@ -580,8 +579,7 @@ $(function () {
function removal_failure() {
stream_subscription_info_elem.text(i18n.t("Error removing user from this stream."))
.addClass("text-error")
.removeClass("text-success");
.addClass("text-error").removeClass("text-success");
}
exports.remove_user_from_stream(principal, sub, removal_success,

View File

@@ -215,7 +215,8 @@ exports.set_in_home_view = function (stream_id, in_home) {
function build_stream_sidebar_li(sub) {
var name = sub.name;
var args = {name: name,
var args = {
name: name,
id: sub.stream_id,
uri: narrow.by_stream_uri(name),
not_in_home_view: (stream_data.in_home_view(sub.stream_id) === false),

View File

@@ -195,14 +195,9 @@ function build_all_messages_popover(e) {
}
exports.register_click_handlers = function () {
$('#stream_filters').on('click',
'.stream-sidebar-arrow', build_stream_popover);
$('#stream_filters').on('click',
'.topic-sidebar-arrow', build_topic_popover);
$('#global_filters').on('click',
'.stream-sidebar-arrow', build_all_messages_popover);
$('#stream_filters').on('click', '.stream-sidebar-arrow', build_stream_popover);
$('#stream_filters').on('click', '.topic-sidebar-arrow', build_topic_popover);
$('#global_filters').on('click', '.stream-sidebar-arrow', build_all_messages_popover);
exports.register_stream_handlers();
exports.register_topic_handlers();

View File

@@ -301,7 +301,8 @@ 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}],
{trigger: 'sidebar'});

View File

@@ -273,8 +273,8 @@ exports.sort_languages = function (matches, query) {
};
exports.sort_recipients = function (users, query, current_stream, current_subject, groups) {
var users_name_results = util.prefix_sort(query, users,
function (x) { return x.full_name; });
var users_name_results = util.prefix_sort(
query, users, function (x) { return x.full_name; });
var result = exports.sort_for_at_mentioning(
users_name_results.matches,
current_stream,

View File

@@ -192,7 +192,8 @@ $(function () {
// Scroll to place the message within the current view;
// but if this is the initial placement of the pointer,
// just place it in the very center
message_viewport.recenter_view(row, {from_scroll: event.from_scroll,
message_viewport.recenter_view(row,
{from_scroll: event.from_scroll,
force_center: event.previously_selected === -1});
}
}

View File

@@ -109,7 +109,8 @@ exports.mark_stream_as_read = function (stream_id, cont) {
url: '/json/mark_stream_as_read',
idempotent: true,
data: {stream_id: stream_id},
success: cont});
success: cont,
});
};
exports.mark_topic_as_read = function (stream_id, topic, cont) {
@@ -117,7 +118,8 @@ exports.mark_topic_as_read = function (stream_id, topic, cont) {
url: '/json/mark_topic_as_read',
idempotent: true,
data: {stream_id: stream_id, topic_name: topic},
success: cont});
success: cont,
});
};

View File

@@ -1,3 +1,4 @@
/* eslint indent: "off" */
var upload_widget = (function () {
var exports = {};

View File

@@ -2,8 +2,11 @@
// global variables from Zulip (everything is being moved into
// modules). Please don't add things here.
var home_msg_list = new message_list.MessageList('zhome',
new Filter([{operator: "in", operand: "home"}]), {muting_enabled: true}
var home_msg_list = new message_list.MessageList(
'zhome',
new Filter([{operator: "in",
operand: "home"}]),
{muting_enabled: true}
);
var current_msg_list = home_msg_list;