mirror of https://github.com/zulip/zulip.git
js: Convert vars declared separately and assigned once to const.
Because of the separate declarations, ESLint would convert them to `let` and then trigger the `prefer-const` error. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
c3b4c0a229
commit
4d37dfcf85
|
@ -77,11 +77,8 @@ run_test('operators_round_trip', () => {
|
|||
});
|
||||
|
||||
run_test('operators_trailing_slash', () => {
|
||||
var hash;
|
||||
var narrow;
|
||||
|
||||
hash = '#narrow/stream/devel/topic/algol/';
|
||||
narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
const hash = '#narrow/stream/devel/topic/algol/';
|
||||
const narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'devel', negated: false},
|
||||
{operator: 'topic', operand: 'algol', negated: false},
|
||||
|
@ -91,7 +88,6 @@ run_test('operators_trailing_slash', () => {
|
|||
run_test('people_slugs', () => {
|
||||
var operators;
|
||||
var hash;
|
||||
var narrow;
|
||||
|
||||
var alice = {
|
||||
email: 'alice@example.com',
|
||||
|
@ -105,7 +101,7 @@ run_test('people_slugs', () => {
|
|||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/sender/42-alice');
|
||||
narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
const narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'sender', operand: 'alice@example.com', negated: false},
|
||||
]);
|
||||
|
|
|
@ -74,7 +74,6 @@ exports.make_event_store = (selector) => {
|
|||
// (event_name, handler) or
|
||||
// (event_name, sel, handler)
|
||||
var event_name = arguments[0];
|
||||
var sel;
|
||||
var handler;
|
||||
|
||||
if (arguments.length === 2) {
|
||||
|
@ -93,7 +92,7 @@ exports.make_event_store = (selector) => {
|
|||
throw Error('wrong number of arguments passed in');
|
||||
}
|
||||
|
||||
sel = arguments[1];
|
||||
const sel = arguments[1];
|
||||
handler = arguments[2];
|
||||
assert.equal(typeof sel, 'string', 'String selectors expected here.');
|
||||
assert.equal(typeof handler, 'function', 'An handler function expected here.');
|
||||
|
|
|
@ -273,13 +273,12 @@ exports.cancel = function () {
|
|||
};
|
||||
|
||||
exports.respond_to_message = function (opts) {
|
||||
var message;
|
||||
var msg_type;
|
||||
// Before initiating a reply to a message, if there's an
|
||||
// in-progress composition, snapshot it.
|
||||
drafts.update_draft();
|
||||
|
||||
message = current_msg_list.selected_message();
|
||||
const message = current_msg_list.selected_message();
|
||||
|
||||
if (message === undefined) { // empty narrow implementation
|
||||
if (!narrow_state.narrowed_by_pm_reply() &&
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
exports.initialize_pill = function () {
|
||||
var pill;
|
||||
var container = $("#private_message_recipient").parent();
|
||||
|
||||
pill = input_pill.create({
|
||||
const pill = input_pill.create({
|
||||
container: container,
|
||||
create_item_from_text: user_pill.create_item_from_email,
|
||||
get_text_from_item: user_pill.get_email_from_item,
|
||||
|
|
|
@ -261,9 +261,8 @@ Filter.parse = function (str) {
|
|||
return operators;
|
||||
}
|
||||
_.each(matches, function (token) {
|
||||
var parts;
|
||||
var operator;
|
||||
parts = token.split(':');
|
||||
const parts = token.split(':');
|
||||
if (token[0] === '"' || parts.length === 1) {
|
||||
// Looks like a normal search term.
|
||||
search_term.push(token);
|
||||
|
@ -607,15 +606,13 @@ Filter.sorted_term_types = function (term_types) {
|
|||
};
|
||||
|
||||
Filter.operator_to_prefix = function (operator, negated) {
|
||||
var verb;
|
||||
|
||||
operator = Filter.canonicalize_operator(operator);
|
||||
|
||||
if (operator === 'search') {
|
||||
return negated ? 'exclude' : 'search for';
|
||||
}
|
||||
|
||||
verb = negated ? 'exclude ' : '';
|
||||
const verb = negated ? 'exclude ' : '';
|
||||
|
||||
switch (operator) {
|
||||
case 'stream':
|
||||
|
|
|
@ -649,7 +649,6 @@ MessageListView.prototype = {
|
|||
var table_name = self.table_name;
|
||||
var table = rows.get_table(table_name);
|
||||
var orig_scrolltop_offset;
|
||||
var message_containers;
|
||||
|
||||
// If we start with the message feed scrolled up (i.e.
|
||||
// the bottom message is not visible), then we will respect
|
||||
|
@ -661,7 +660,7 @@ MessageListView.prototype = {
|
|||
// all messages lists. To prevent having both list views overwriting
|
||||
// each others data we will make a new message object to add data to
|
||||
// for rendering.
|
||||
message_containers = _.map(messages, function (message) {
|
||||
const message_containers = _.map(messages, function (message) {
|
||||
if (message.starred) {
|
||||
message.starred_status = i18n.t("Unstar");
|
||||
} else {
|
||||
|
|
|
@ -252,7 +252,6 @@ exports.initiate = function (options) {
|
|||
var unconditional_timeout = 1000 * 60 * 30 + util.random_int(0, 1000 * 60 * 5);
|
||||
var composing_timeout = 1000 * 60 * 5 + util.random_int(0, 1000 * 60);
|
||||
var home_timeout = 1000 * 60 + util.random_int(0, 1000 * 60);
|
||||
var compose_done_handler;
|
||||
var compose_started_handler;
|
||||
|
||||
function reload_from_idle() {
|
||||
|
@ -266,7 +265,7 @@ exports.initiate = function (options) {
|
|||
// Make sure we always do a reload eventually
|
||||
setTimeout(reload_from_idle, unconditional_timeout);
|
||||
|
||||
compose_done_handler = function () {
|
||||
const compose_done_handler = function () {
|
||||
idle_control.cancel();
|
||||
idle_control = $(document).idle({idle: home_timeout,
|
||||
onIdle: reload_from_idle});
|
||||
|
|
|
@ -201,7 +201,6 @@ exports.resize_stream_filters_container = function (h) {
|
|||
};
|
||||
|
||||
exports.resize_page_components = function () {
|
||||
var h;
|
||||
var sidebar;
|
||||
|
||||
if (page_params.left_side_userlist) {
|
||||
|
@ -232,7 +231,7 @@ exports.resize_page_components = function () {
|
|||
}
|
||||
}
|
||||
|
||||
h = narrow_window ? left_userlist_get_new_heights() : get_new_heights();
|
||||
const h = narrow_window ? left_userlist_get_new_heights() : get_new_heights();
|
||||
|
||||
exports.resize_bottom_whitespace(h);
|
||||
$("#buddy_list_wrapper").css('max-height', h.buddy_list_wrapper_max_height);
|
||||
|
|
|
@ -121,8 +121,6 @@ function get_group_suggestions(all_persons, last, operators) {
|
|||
//
|
||||
// We only generate group suggestions when there's more than one part, and
|
||||
// we only use the last part to generate suggestions.
|
||||
var all_but_last_part;
|
||||
var last_part;
|
||||
|
||||
var last_comma_index = operand.lastIndexOf(',');
|
||||
if (last_comma_index < 0) {
|
||||
|
@ -130,8 +128,8 @@ function get_group_suggestions(all_persons, last, operators) {
|
|||
}
|
||||
|
||||
// Neither all_but_last_part nor last_part include the final comma.
|
||||
all_but_last_part = operand.slice(0, last_comma_index);
|
||||
last_part = operand.slice(last_comma_index + 1);
|
||||
const all_but_last_part = operand.slice(0, last_comma_index);
|
||||
const last_part = operand.slice(last_comma_index + 1);
|
||||
|
||||
// We don't suggest a person if their email is already present in the
|
||||
// operand (not including the last part).
|
||||
|
@ -565,7 +563,6 @@ exports.get_suggestions = function (base_query, query) {
|
|||
// with information for subsequent callbacks.
|
||||
var result = [];
|
||||
var suggestion;
|
||||
var base; //base, default suggestion
|
||||
var suggestions;
|
||||
|
||||
// base_query_operators correspond to the existing pills. query_operators correspond
|
||||
|
@ -632,7 +629,7 @@ exports.get_suggestions = function (base_query, query) {
|
|||
base_operators = operators.slice(0, -1);
|
||||
}
|
||||
|
||||
base = get_default_suggestion(query_operators.slice(0, -1));
|
||||
const base = get_default_suggestion(query_operators.slice(0, -1));
|
||||
|
||||
// Get all individual suggestions, and then attach_suggestions
|
||||
// mutates the list 'result' to add a properly-formatted suggestion
|
||||
|
@ -708,7 +705,6 @@ exports.get_suggestions_legacy = function (query) {
|
|||
// with information for subsequent callbacks.
|
||||
var result = [];
|
||||
var suggestion;
|
||||
var base; //base, default suggestion
|
||||
var suggestions;
|
||||
|
||||
// Add an entry for narrow by operators.
|
||||
|
@ -755,7 +751,7 @@ exports.get_suggestions_legacy = function (query) {
|
|||
if (operators.length > 1) {
|
||||
base_operators = operators.slice(0, -1);
|
||||
}
|
||||
base = get_default_suggestion_legacy(base_operators);
|
||||
const base = get_default_suggestion_legacy(base_operators);
|
||||
|
||||
// Get all individual suggestions, and then attach_suggestions
|
||||
// mutates the list 'result' to add a properly-formatted suggestion
|
||||
|
|
|
@ -115,14 +115,13 @@ exports.render_bots = function () {
|
|||
|
||||
exports.generate_zuliprc_uri = function (bot_id) {
|
||||
var bot = bot_data.get(bot_id);
|
||||
var data;
|
||||
var token;
|
||||
// For outgoing webhooks, include the token in the zuliprc.
|
||||
// It's needed for authenticating to the Botserver.
|
||||
if (bot.bot_type === 3) {
|
||||
token = bot_data.get_services(bot_id)[0].token;
|
||||
}
|
||||
data = exports.generate_zuliprc_content(bot.email, bot.api_key, token);
|
||||
const data = exports.generate_zuliprc_content(bot.email, bot.api_key, token);
|
||||
return exports.encode_zuliprc_as_uri(data);
|
||||
};
|
||||
|
||||
|
|
|
@ -127,7 +127,6 @@ exports.initialize = function () {
|
|||
exports.get_color_class = _.memoize(function (color) {
|
||||
var match;
|
||||
var i;
|
||||
var lightness;
|
||||
var channel = [0, 0, 0];
|
||||
var mult = 1;
|
||||
|
||||
|
@ -151,7 +150,7 @@ exports.get_color_class = _.memoize(function (color) {
|
|||
}
|
||||
|
||||
// Compute perceived lightness as CIE L*.
|
||||
lightness = colorspace.luminance_to_lightness(
|
||||
const lightness = colorspace.luminance_to_lightness(
|
||||
colorspace.rgb_luminance(channel));
|
||||
|
||||
// Determine if we're past the midpoint between the
|
||||
|
|
|
@ -16,8 +16,6 @@ function message_unhover() {
|
|||
}
|
||||
|
||||
function message_hover(message_row) {
|
||||
var message;
|
||||
|
||||
var id = parseInt(message_row.attr("zid"), 10);
|
||||
if (current_message_hover && message_row && current_message_hover.attr("zid") === message_row.attr("zid")) {
|
||||
return;
|
||||
|
@ -26,7 +24,7 @@ function message_hover(message_row) {
|
|||
if (message_row.hasClass('local')) {
|
||||
return;
|
||||
}
|
||||
message = current_msg_list.get(rows.id(message_row));
|
||||
const message = current_msg_list.get(rows.id(message_row));
|
||||
message_unhover();
|
||||
current_message_hover = message_row;
|
||||
|
||||
|
|
Loading…
Reference in New Issue