Skip to content

Commit

Permalink
eslint: Set array-bracket-spacing rule and clean project.
Browse files Browse the repository at this point in the history
  • Loading branch information
timabbott committed Oct 6, 2017
1 parent 82b708b commit cf3d035
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
}, },
"rules": { "rules": {
"array-callback-return": "error", "array-callback-return": "error",
"array-bracket-spacing": "error",
"arrow-spacing": [ "error", { "before": true, "after": true } ], "arrow-spacing": [ "error", { "before": true, "after": true } ],
"block-scoped-var": 2, "block-scoped-var": 2,
"brace-style": [ "error", "1tbs", { "allowSingleLine": true } ], "brace-style": [ "error", "1tbs", { "allowSingleLine": true } ],
Expand Down
2 changes: 1 addition & 1 deletion frontend_tests/node_tests/colorspace.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var colorspace = require('js/colorspace.js');
}()); }());


(function test_rgb_luminance() { (function test_rgb_luminance() {
var channel = [ 1, 1, 1 ]; var channel = [1, 1, 1];
var expected_value = 1; var expected_value = 1;
var actual_value = colorspace.rgb_luminance(channel); var actual_value = colorspace.rgb_luminance(channel);
assert.equal(actual_value, expected_value); assert.equal(actual_value, expected_value);
Expand Down
48 changes: 24 additions & 24 deletions frontend_tests/node_tests/composebox_typeahead.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var emoji_see_no_evil = {
emoji_url: 'TBD', emoji_url: 'TBD',
}; };


var emoji_list = [ emoji_tada, emoji_moneybag, emoji_stadium, emoji_japanese_post_office, var emoji_list = [emoji_tada, emoji_moneybag, emoji_stadium, emoji_japanese_post_office,
emoji_panda_face, emoji_see_no_evil ]; emoji_panda_face, emoji_see_no_evil];
var stream_list = ['Denmark', 'Sweden', 'The Netherlands']; var stream_list = ['Denmark', 'Sweden', 'The Netherlands'];
var sweden_stream = { var sweden_stream = {
name: 'Sweden', name: 'Sweden',
Expand Down Expand Up @@ -285,7 +285,7 @@ global.people.add(deactivated_user);
ct.add_topic('Sweden', 'more ice'); ct.add_topic('Sweden', 'more ice');
ct.add_topic('Sweden', 'even more ice'); ct.add_topic('Sweden', 'even more ice');
ct.add_topic('Sweden', '<&>'); ct.add_topic('Sweden', '<&>');
var topics = [ '<&>', 'even more ice', 'furniture', 'ice', 'kronor', 'more ice' ]; var topics = ['<&>', 'even more ice', 'furniture', 'ice', 'kronor', 'more ice'];
$('#stream').val('Sweden'); $('#stream').val('Sweden');
var actual_value = options.source(); var actual_value = options.source();
// Topics should be sorted alphabetically, not by addition order. // Topics should be sorted alphabetically, not by addition order.
Expand Down Expand Up @@ -315,22 +315,22 @@ global.people.add(deactivated_user);
// it is a result of the topics already being sorted after adding // it is a result of the topics already being sorted after adding
// them with ct.add_topic(). // them with ct.add_topic().
options.query = 'furniture'; options.query = 'furniture';
actual_value = options.sorter([ 'furniture' ]); actual_value = options.sorter(['furniture']);
expected_value = [ 'furniture' ]; expected_value = ['furniture'];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// A literal match at the beginning of an element puts it at the top. // A literal match at the beginning of an element puts it at the top.
options.query = 'ice'; options.query = 'ice';
actual_value = options.sorter([ 'even more ice', 'ice', 'more ice' ]); actual_value = options.sorter(['even more ice', 'ice', 'more ice']);
expected_value = [ 'ice', 'even more ice', 'more ice' ]; expected_value = ['ice', 'even more ice', 'more ice'];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// The sorter should return the query as the first element if there // The sorter should return the query as the first element if there
// isn't a topic with such name. // isn't a topic with such name.
// This only happens if typeahead is providing other suggestions. // This only happens if typeahead is providing other suggestions.
options.query = 'e'; // Letter present in "furniture" and "ice" options.query = 'e'; // Letter present in "furniture" and "ice"
actual_value = options.sorter([ 'furniture', 'ice' ]); actual_value = options.sorter(['furniture', 'ice']);
expected_value = [ 'e', 'furniture', 'ice' ]; expected_value = ['e', 'furniture', 'ice'];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// Don't make any suggestions if this query doesn't match any // Don't make any suggestions if this query doesn't match any
Expand All @@ -349,7 +349,7 @@ global.people.add(deactivated_user);
// //
// This should match the users added at the beginning of this test file. // This should match the users added at the beginning of this test file.
var actual_value = options.source(); var actual_value = options.source();
var expected_value = [ othello, cordelia, deactivated_user ]; var expected_value = [othello, cordelia, deactivated_user];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// options.highlighter() // options.highlighter()
Expand Down Expand Up @@ -422,14 +422,14 @@ global.people.add(deactivated_user);
// beginning first, and then the rest of them in REVERSE order of // beginning first, and then the rest of them in REVERSE order of
// the input. // the input.
options.query = 'othello'; options.query = 'othello';
actual_value = options.sorter([ othello ]); actual_value = options.sorter([othello]);
expected_value = [ othello ]; expected_value = [othello];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// A literal match at the beginning of an element puts it at the top. // A literal match at the beginning of an element puts it at the top.
options.query = 'co'; // Matches everything ("x@zulip.COm") options.query = 'co'; // Matches everything ("x@zulip.COm")
actual_value = options.sorter([ othello, deactivated_user, cordelia ]); actual_value = options.sorter([othello, deactivated_user, cordelia]);
expected_value = [ cordelia, deactivated_user, othello ]; expected_value = [cordelia, deactivated_user, othello];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


options.query = 'non-existing-user'; options.query = 'non-existing-user';
Expand Down Expand Up @@ -511,31 +511,31 @@ global.people.add(deactivated_user);


// options.sorter() // options.sorter()
fake_this = { completing: 'emoji', token: 'ta' }; fake_this = { completing: 'emoji', token: 'ta' };
actual_value = options.sorter.call(fake_this, [ emoji_stadium, emoji_tada ]); actual_value = options.sorter.call(fake_this, [emoji_stadium, emoji_tada]);
expected_value = [ emoji_tada, emoji_stadium ]; expected_value = [emoji_tada, emoji_stadium];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


fake_this = { completing: 'mention', token: 'co' }; fake_this = { completing: 'mention', token: 'co' };
actual_value = options.sorter.call(fake_this, [ othello, cordelia ]); actual_value = options.sorter.call(fake_this, [othello, cordelia]);
expected_value = [ cordelia, othello ]; expected_value = [cordelia, othello];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


fake_this = { completing: 'stream', token: 'de' }; fake_this = { completing: 'stream', token: 'de' };
actual_value = options.sorter.call(fake_this, [ sweden_stream, denmark_stream ]); actual_value = options.sorter.call(fake_this, [sweden_stream, denmark_stream]);
expected_value = [ denmark_stream, sweden_stream ]; expected_value = [denmark_stream, sweden_stream];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


// Matches in the descriptions affect the order as well. // Matches in the descriptions affect the order as well.
// Testing "co" for "cold", in both streams' description. It's at the // Testing "co" for "cold", in both streams' description. It's at the
// beginning of Sweden's description, so that one should go first. // beginning of Sweden's description, so that one should go first.
fake_this = { completing: 'stream', token: 'co' }; fake_this = { completing: 'stream', token: 'co' };
actual_value = options.sorter.call(fake_this, [ denmark_stream, sweden_stream ]); actual_value = options.sorter.call(fake_this, [denmark_stream, sweden_stream]);
expected_value = [ sweden_stream, denmark_stream ]; expected_value = [sweden_stream, denmark_stream];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


fake_this = { completing: 'syntax', token: 'ap' }; fake_this = { completing: 'syntax', token: 'ap' };
actual_value = options.sorter.call(fake_this, [ 'abap', 'applescript' ]); actual_value = options.sorter.call(fake_this, ['abap', 'applescript']);
expected_value = [ 'applescript', 'abap' ]; expected_value = ['applescript', 'abap'];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);


fake_this = { completing: 'non-existing-completion' }; fake_this = { completing: 'non-existing-completion' };
Expand Down
4 changes: 2 additions & 2 deletions frontend_tests/node_tests/markdown.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver
(function test_python_to_js_filter() { (function test_python_to_js_filter() {
// The only way to reach python_to_js_filter is indirectly, hence the call // The only way to reach python_to_js_filter is indirectly, hence the call
// to set_realm_filters. // to set_realm_filters.
markdown.set_realm_filters([[ '/a(?im)a/g'], [ '/a(?L)a/g' ]]); markdown.set_realm_filters([['/a(?im)a/g'], ['/a(?L)a/g']]);
var actual_value = (marked.InlineLexer.rules.zulip.realm_filters); var actual_value = (marked.InlineLexer.rules.zulip.realm_filters);
var expected_value = [ /\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g ]; var expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
assert.deepEqual(actual_value, expected_value); assert.deepEqual(actual_value, expected_value);
}()); }());


Expand Down
4 changes: 2 additions & 2 deletions frontend_tests/node_tests/reactions.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ set_global('current_msg_list', {
emoji_code: '2', emoji_code: '2',
emoji_name_css_class: '2', emoji_name_css_class: '2',
count: 1, count: 1,
user_ids: [ 7 ], user_ids: [7],
title: 'Cali reacted with :frown:', title: 'Cali reacted with :frown:',
emoji_alt_code: undefined, emoji_alt_code: undefined,
class: 'message_reaction', class: 'message_reaction',
Expand All @@ -154,7 +154,7 @@ set_global('current_msg_list', {
emoji_code: '1', emoji_code: '1',
emoji_name_css_class: '1', emoji_name_css_class: '1',
count: 2, count: 2,
user_ids: [ 5, 6 ], user_ids: [5, 6],
title: 'You (click to remove) and Bob van Roberts reacted with :smile:', title: 'You (click to remove) and Bob van Roberts reacted with :smile:',
emoji_alt_code: undefined, emoji_alt_code: undefined,
class: 'message_reaction reacted', class: 'message_reaction reacted',
Expand Down

0 comments on commit cf3d035

Please sign in to comment.