diff --git a/.eslintrc.json b/.eslintrc.json index 0c324d9ddc..7c9e5f9b82 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -158,6 +158,7 @@ }, "rules": { "array-callback-return": "error", + "array-bracket-spacing": "error", "arrow-spacing": [ "error", { "before": true, "after": true } ], "block-scoped-var": 2, "brace-style": [ "error", "1tbs", { "allowSingleLine": true } ], diff --git a/frontend_tests/node_tests/colorspace.js b/frontend_tests/node_tests/colorspace.js index 467e629230..7d64ed5805 100644 --- a/frontend_tests/node_tests/colorspace.js +++ b/frontend_tests/node_tests/colorspace.js @@ -13,7 +13,7 @@ var colorspace = require('js/colorspace.js'); }()); (function test_rgb_luminance() { - var channel = [ 1, 1, 1 ]; + var channel = [1, 1, 1]; var expected_value = 1; var actual_value = colorspace.rgb_luminance(channel); assert.equal(actual_value, expected_value); diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js index 3ee25cfc17..aa842727a0 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/frontend_tests/node_tests/composebox_typeahead.js @@ -25,8 +25,8 @@ var emoji_see_no_evil = { emoji_url: 'TBD', }; -var emoji_list = [ emoji_tada, emoji_moneybag, emoji_stadium, emoji_japanese_post_office, - emoji_panda_face, emoji_see_no_evil ]; +var emoji_list = [emoji_tada, emoji_moneybag, emoji_stadium, emoji_japanese_post_office, + emoji_panda_face, emoji_see_no_evil]; var stream_list = ['Denmark', 'Sweden', 'The Netherlands']; var sweden_stream = { name: 'Sweden', @@ -285,7 +285,7 @@ global.people.add(deactivated_user); ct.add_topic('Sweden', 'more ice'); ct.add_topic('Sweden', 'even more ice'); 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'); var actual_value = options.source(); // Topics should be sorted alphabetically, not by addition order. @@ -315,22 +315,22 @@ global.people.add(deactivated_user); // it is a result of the topics already being sorted after adding // them with ct.add_topic(). options.query = 'furniture'; - actual_value = options.sorter([ 'furniture' ]); - expected_value = [ 'furniture' ]; + actual_value = options.sorter(['furniture']); + expected_value = ['furniture']; assert.deepEqual(actual_value, expected_value); // A literal match at the beginning of an element puts it at the top. options.query = 'ice'; - actual_value = options.sorter([ 'even more ice', 'ice', 'more ice' ]); - expected_value = [ 'ice', 'even more ice', 'more ice' ]; + actual_value = options.sorter(['even more ice', 'ice', 'more ice']); + expected_value = ['ice', 'even more ice', 'more ice']; assert.deepEqual(actual_value, expected_value); // The sorter should return the query as the first element if there // isn't a topic with such name. // This only happens if typeahead is providing other suggestions. options.query = 'e'; // Letter present in "furniture" and "ice" - actual_value = options.sorter([ 'furniture', 'ice' ]); - expected_value = [ 'e', 'furniture', 'ice' ]; + actual_value = options.sorter(['furniture', 'ice']); + expected_value = ['e', 'furniture', 'ice']; assert.deepEqual(actual_value, expected_value); // Don't make any suggestions if this query doesn't match any @@ -349,7 +349,7 @@ global.people.add(deactivated_user); // // This should match the users added at the beginning of this test file. 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); // options.highlighter() @@ -422,14 +422,14 @@ global.people.add(deactivated_user); // beginning first, and then the rest of them in REVERSE order of // the input. options.query = 'othello'; - actual_value = options.sorter([ othello ]); - expected_value = [ othello ]; + actual_value = options.sorter([othello]); + expected_value = [othello]; assert.deepEqual(actual_value, expected_value); // A literal match at the beginning of an element puts it at the top. options.query = 'co'; // Matches everything ("x@zulip.COm") - actual_value = options.sorter([ othello, deactivated_user, cordelia ]); - expected_value = [ cordelia, deactivated_user, othello ]; + actual_value = options.sorter([othello, deactivated_user, cordelia]); + expected_value = [cordelia, deactivated_user, othello]; assert.deepEqual(actual_value, expected_value); options.query = 'non-existing-user'; @@ -511,31 +511,31 @@ global.people.add(deactivated_user); // options.sorter() fake_this = { completing: 'emoji', token: 'ta' }; - actual_value = options.sorter.call(fake_this, [ emoji_stadium, emoji_tada ]); - expected_value = [ emoji_tada, emoji_stadium ]; + actual_value = options.sorter.call(fake_this, [emoji_stadium, emoji_tada]); + expected_value = [emoji_tada, emoji_stadium]; assert.deepEqual(actual_value, expected_value); fake_this = { completing: 'mention', token: 'co' }; - actual_value = options.sorter.call(fake_this, [ othello, cordelia ]); - expected_value = [ cordelia, othello ]; + actual_value = options.sorter.call(fake_this, [othello, cordelia]); + expected_value = [cordelia, othello]; assert.deepEqual(actual_value, expected_value); fake_this = { completing: 'stream', token: 'de' }; - actual_value = options.sorter.call(fake_this, [ sweden_stream, denmark_stream ]); - expected_value = [ denmark_stream, sweden_stream ]; + actual_value = options.sorter.call(fake_this, [sweden_stream, denmark_stream]); + expected_value = [denmark_stream, sweden_stream]; assert.deepEqual(actual_value, expected_value); // Matches in the descriptions affect the order as well. // Testing "co" for "cold", in both streams' description. It's at the // beginning of Sweden's description, so that one should go first. fake_this = { completing: 'stream', token: 'co' }; - actual_value = options.sorter.call(fake_this, [ denmark_stream, sweden_stream ]); - expected_value = [ sweden_stream, denmark_stream ]; + actual_value = options.sorter.call(fake_this, [denmark_stream, sweden_stream]); + expected_value = [sweden_stream, denmark_stream]; assert.deepEqual(actual_value, expected_value); fake_this = { completing: 'syntax', token: 'ap' }; - actual_value = options.sorter.call(fake_this, [ 'abap', 'applescript' ]); - expected_value = [ 'applescript', 'abap' ]; + actual_value = options.sorter.call(fake_this, ['abap', 'applescript']); + expected_value = ['applescript', 'abap']; assert.deepEqual(actual_value, expected_value); fake_this = { completing: 'non-existing-completion' }; diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index b161f5f5f5..d28366a994 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -357,9 +357,9 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver (function test_python_to_js_filter() { // The only way to reach python_to_js_filter is indirectly, hence the call // 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 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); }()); diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js index 2bfa3c8b55..10bd5077ca 100644 --- a/frontend_tests/node_tests/reactions.js +++ b/frontend_tests/node_tests/reactions.js @@ -143,7 +143,7 @@ set_global('current_msg_list', { emoji_code: '2', emoji_name_css_class: '2', count: 1, - user_ids: [ 7 ], + user_ids: [7], title: 'Cali reacted with :frown:', emoji_alt_code: undefined, class: 'message_reaction', @@ -154,7 +154,7 @@ set_global('current_msg_list', { emoji_code: '1', emoji_name_css_class: '1', count: 2, - user_ids: [ 5, 6 ], + user_ids: [5, 6], title: 'You (click to remove) and Bob van Roberts reacted with :smile:', emoji_alt_code: undefined, class: 'message_reaction reacted',