eslint: Add key-spacing linter rule.

Apparently, we didn't have one of these, and thus had a moderate
number of generally very old violations in the codebase.  Fix this and
clear the ones that exist..
This commit is contained in:
Tim Abbott 2018-12-18 10:34:45 -08:00
parent 392175d6e8
commit bdb3da4504
45 changed files with 152 additions and 145 deletions

View File

@ -245,6 +245,12 @@
"FunctionExpression": {"parameters": "first"},
"FunctionDeclaration": {"parameters": "first"}
}],
"key-spacing": [ "error",
{
"beforeColon": false,
"afterColon": true
}
],
"keyword-spacing": [ "error",
{
"before": true,

View File

@ -169,7 +169,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
});
tah.select();
}, {field_selector:field_selector, str: str, item: item});
}, {field_selector: field_selector, str: str, item: item});
});
};

View File

@ -68,7 +68,7 @@ casper.then(function () {
casper.then(function () {
casper.waitUntilVisible('#get_api_key_button', function () {
casper.fill('#get_api_key_form', {password:test_credentials.default_user.password});
casper.fill('#get_api_key_form', {password: test_credentials.default_user.password});
casper.click('#get_api_key_button');
});
});

View File

@ -5,8 +5,8 @@ zrequire('components');
var noop = function () {};
var LEFT_KEY = { which: 37, preventDefault: noop, stopPropagation:noop };
var RIGHT_KEY = { which: 39, preventDefault: noop, stopPropagation:noop };
var LEFT_KEY = { which: 37, preventDefault: noop, stopPropagation: noop };
var RIGHT_KEY = { which: 39, preventDefault: noop, stopPropagation: noop };
run_test('basics', () => {
var keydown_f;

View File

@ -324,7 +324,7 @@ run_test('marked', () => {
{input: 'T\n@**Cordelia Lear**',
expected: '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
{input: '@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.',
expected:'<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>'},
expected: '<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>'},
{input: '@**Invalid User|1234**',
expected: '<p>@**Invalid User|1234**</p>'},
{input: '@**Cordelia Lear|103** has a wrong user_id.',

View File

@ -219,7 +219,7 @@ run_test('updates', () => {
run_test('nth_most_recent_id', () => {
var list = new MessageList({});
list.append([{id:10}, {id:20}, {id:30}]);
list.append([{id: 10}, {id: 20}, {id: 30}]);
assert.equal(list.nth_most_recent_id(1), 30);
assert.equal(list.nth_most_recent_id(2), 20);
assert.equal(list.nth_most_recent_id(3), 10);
@ -269,8 +269,9 @@ run_test('last_sent_by_me', () => {
run_test('local_echo', () => {
var list = new MessageList({});
list.append([{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40}, {id:50}, {id:60}]);
list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03}};
list.append([{id: 10}, {id: 20}, {id: 30}, {id: 20.02},
{id: 20.03}, {id: 40}, {id: 50}, {id: 60}]);
list._local_only = {20.02: {id: 20.02}, 20.03: {id: 20.03}};
assert.equal(list.closest_id(10), 10);
assert.equal(list.closest_id(20), 20);
@ -292,9 +293,9 @@ run_test('local_echo', () => {
list = new MessageList({});
list.append([
{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40},
{id:50}, {id: 50.01}, {id: 50.02}, {id:60}]);
list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03},
{id: 10}, {id: 20}, {id: 30}, {id: 20.02}, {id: 20.03}, {id: 40},
{id: 50}, {id: 50.01}, {id: 50.02}, {id: 60}]);
list._local_only = {20.02: {id: 20.02}, 20.03: {id: 20.03},
50.01: {id: 50.01}, 50.02: {id: 50.02}};
assert.equal(list.closest_id(10), 10);

View File

@ -26,7 +26,7 @@ set_global('timerender', {
}
return [{outerHTML: String(time1.getTime()) + ' - ' + String(time2.getTime())}];
},
stringify_time : function (time) {
stringify_time: function (time) {
if (page_params.twenty_four_hour_time) {
return time.toString('HH:mm');
}

View File

@ -2,8 +2,8 @@ set_global("page_params", {
realm_uri: "https://chat.example.com",
realm_embedded_bots: [
{name: "converter", config: {}},
{name:"giphy", config: {key: "12345678"}},
{name:"foobot", config: {bar: "baz", qux: "quux"}},
{name: "giphy", config: {key: "12345678"}},
{name: "foobot", config: {bar: "baz", qux: "quux"}},
],
realm_bots: [{api_key: 'QadL788EkiottHmukyhHgePUFHREiu8b',
email: 'error-bot@zulip.org',

View File

@ -210,22 +210,22 @@ run_test('sort_recipients', () => {
// For splitting based on recency
global.recent_senders.process_message_for_senders({
sender_id : 7,
stream_id : 1,
subject : "Dev Topic",
id : _.uniqueId(),
sender_id: 7,
stream_id: 1,
subject: "Dev Topic",
id: _.uniqueId(),
});
global.recent_senders.process_message_for_senders({
sender_id : 5,
stream_id : 1,
subject : "Dev Topic",
id : _.uniqueId(),
sender_id: 5,
stream_id: 1,
subject: "Dev Topic",
id: _.uniqueId(),
});
global.recent_senders.process_message_for_senders({
sender_id : 6,
stream_id : 1,
subject : "Dev Topic",
id : _.uniqueId(),
sender_id: 6,
stream_id: 1,
subject: "Dev Topic",
id: _.uniqueId(),
});
// Typeahead for stream message [query, stream-name, topic-name]
@ -240,16 +240,16 @@ run_test('sort_recipients', () => {
]);
global.recent_senders.process_message_for_senders({
sender_id : 5,
stream_id : 2,
subject : "Linux Topic",
id : _.uniqueId(),
sender_id: 5,
stream_id: 2,
subject: "Linux Topic",
id: _.uniqueId(),
});
global.recent_senders.process_message_for_senders({
sender_id : 7,
stream_id : 2,
subject : "Linux Topic",
id : _.uniqueId(),
sender_id: 7,
stream_id: 2,
subject: "Linux Topic",
id: _.uniqueId(),
});
// No match

View File

@ -446,7 +446,7 @@ run_test('mentions', () => {
stream_id: 999,
subject: 'lunch',
mentioned: true,
unread:true,
unread: true,
};
unread.process_loaded_messages([message]);

View File

@ -53,7 +53,7 @@ run_test('lower_bound', () => {
assert.equal(util.lower_bound(arr, 55), 5);
assert.equal(util.lower_bound(arr, 2, 4, 31), 3);
arr = [{x: 10}, {x: 20}, {x:30}];
arr = [{x: 10}, {x: 20}, {x: 30}];
function compare(a, b) {
return a.x < b;

View File

@ -118,8 +118,8 @@ class MarkdownComparer {
are_equivalent = this._haveEqualContents(element_actual, element_expected);
if (!are_equivalent) {
html = {
actual : this._reorderAttributes(element_actual).innerHTML,
expected : this._reorderAttributes(element_expected).innerHTML,
actual: this._reorderAttributes(element_actual).innerHTML,
expected: this._reorderAttributes(element_expected).innerHTML,
};
}
@ -137,7 +137,7 @@ class MarkdownComparer {
if (comparison_results.are_equivalent === false) {
throw new assert.AssertionError({
message : message + this._output_formatter(
message: message + this._output_formatter(
comparison_results.html.actual,
comparison_results.html.expected
),
@ -153,7 +153,7 @@ class MarkdownComparer {
if (comparison_results.are_equivalent) {
throw new assert.AssertionError({
message : message + [
message: message + [
"actual and expected output produce semantially identical HTML",
actual,
"==",

View File

@ -20,9 +20,9 @@ function apply_color(input_string, changes) {
input_string = input_string.slice(2);
const formatter = {
delete : (string) => { return "\u001b[31m" + string + "\u001b[0m"; },
insert : (string) => { return "\u001b[32m" + string + "\u001b[0m"; },
replace : (string) => { return "\u001b[33m" + string + "\u001b[0m"; },
delete: (string) => { return "\u001b[31m" + string + "\u001b[0m"; },
insert: (string) => { return "\u001b[32m" + string + "\u001b[0m"; },
replace: (string) => { return "\u001b[33m" + string + "\u001b[0m"; },
};
changes.forEach((change) => {
if (formatter.hasOwnProperty(change.tag)) {
@ -57,16 +57,16 @@ function parse_questionmark_line(questionmark_line) {
const changes_list = [];
const aliases = {
"^" : "replace",
"+" : "insert",
"-" : "delete",
"^": "replace",
"+": "insert",
"-": "delete",
};
const add_change = () => {
if (current_sequence) {
changes_list.push({
tag : aliases[current_sequence],
tag: aliases[current_sequence],
beginning_index,
ending_index : index,
ending_index: index,
});
current_sequence = "";
}

View File

@ -14,7 +14,7 @@ var admin_settings_label = {
// Organization permissions
realm_name_changes_disabled: i18n.t("Prevent users from changing their name"),
realm_email_changes_disabled : i18n.t("Prevent users from changing their email address"),
realm_email_changes_disabled: i18n.t("Prevent users from changing their email address"),
};
exports.build_page = function () {

View File

@ -370,7 +370,7 @@ function integration_events() {
$(".integrations .searchbar input[type='text']")
.focus()
.on('input', function (e) {
dispatch('UPDATE_QUERY', { query : e.target.value.toLowerCase() });
dispatch('UPDATE_QUERY', { query: e.target.value.toLowerCase() });
});
$(window).scroll(function () {

View File

@ -3,10 +3,10 @@ var settings_notifications = (function () {
var exports = {};
var stream_notification_settings = [
{setting: "enable_stream_desktop_notifications", notifications:"desktop_notifications"},
{setting: "enable_stream_push_notifications", notifications:"push_notifications"},
{setting: "enable_stream_sounds", notifications:"audible_notifications"},
{setting: "enable_stream_email_notifications", notifications:"email_notifications"},
{setting: "enable_stream_desktop_notifications", notifications: "desktop_notifications"},
{setting: "enable_stream_push_notifications", notifications: "push_notifications"},
{setting: "enable_stream_sounds", notifications: "audible_notifications"},
{setting: "enable_stream_email_notifications", notifications: "email_notifications"},
];
var pm_mention_notification_settings = [

View File

@ -1084,7 +1084,7 @@ exports.build_page = function () {
overlays.close_modal('deactivate-realm-modal');
}
channel.post({
url:'/json/realm/deactivate',
url: '/json/realm/deactivate',
error: function (xhr) {
ui_report.error(
i18n.t("Failed"), xhr, $('#admin-realm-deactivation-status').expectOne()