[polari/wip/fmuellner/more-style-changes: 1/3] style: Stop using braces for single-line arrow functions



commit 46e5b94a024f9a2fd34bf285b6d9f4317f1b0928
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 28 19:31:57 2019 +0100

    style: Stop using braces for single-line arrow functions
    
    Braces are optional for single-line arrow functions, but there's a
    subtle difference:
    Without braces, the expression is implicitly used as return value; with
    braces, the function returns nothing unless there's an explicit return.
    
    We currently reflect that in our style by only omitting braces when the
    function is expected to have a return value, but that's not very obvious,
    not an important differentiation to make, and not easy to express in an
    automatic rule.
    
    So just omit braces consistently as mandated by gjs' coding style.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/95

 lint/eslintrc-polari.json |  7 -------
 src/accountsMonitor.js    |  2 +-
 src/appNotifications.js   |  4 ++--
 src/application.js        |  8 ++++----
 src/chatView.js           |  6 +++---
 src/connections.js        |  4 ++--
 src/initialSetup.js       |  2 +-
 src/roomList.js           | 12 ++++++------
 src/roomManager.js        |  2 +-
 src/roomStack.js          |  2 +-
 src/telepathyClient.js    |  6 +++---
 src/userList.js           |  4 ++--
 src/userTracker.js        |  6 +++---
 13 files changed, 29 insertions(+), 36 deletions(-)
---
diff --git a/lint/eslintrc-polari.json b/lint/eslintrc-polari.json
index 96af463..4400389 100644
--- a/lint/eslintrc-polari.json
+++ b/lint/eslintrc-polari.json
@@ -1,13 +1,6 @@
 {
     "rules": {
         "arrow-spacing": "error",
-        "brace-style": [
-            "error",
-            "1tbs",
-            {
-                "allowSingleLine": true
-            }
-        ],
         "camelcase": [
             "error",
             {
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 5165200..a2bd730 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -93,7 +93,7 @@ var AccountsMonitor = class {
         am.connect('account-enabled', this._accountEnabledChanged.bind(this));
         am.connect('account-disabled', this._accountEnabledChanged.bind(this));
 
-        this._preparedCallbacks.forEach(callback => { callback(); });
+        this._preparedCallbacks.forEach(callback => callback());
     }
 
     _onPrepareShutdown() {
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 0039a36..aca9e23 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -82,9 +82,9 @@ var UndoNotification = GObject.registerClass({
         this._undo = false;
         this._closed = false;
 
-        this.connect('destroy', () => { this.close(); });
+        this.connect('destroy', () => this.close());
 
-        this.addButton(_('Undo'), () => { this._undo = true; });
+        this.addButton(_('Undo'), () => this._undo = true);
     }
 
     close() {
diff --git a/src/application.js b/src/application.js
index 2b3e579..ba1c8db 100644
--- a/src/application.js
+++ b/src/application.js
@@ -193,7 +193,7 @@ var Application = GObject.registerClass({
             parameter_type: GLib.VariantType.new('(ss)') },
           { name: 'leave-current-room',
             activate: this._onLeaveCurrentRoom.bind(this),
-            create_hook: (a) => { a.enabled = false; },
+            create_hook: (a) => a.enabled = false,
             accels: ['<Primary>w'] },
           { name: 'authenticate-account',
             parameter_type: GLib.VariantType.new('(os)') },
@@ -355,9 +355,9 @@ var Application = GObject.registerClass({
                     this.emit('prepare-shutdown');
                 });
                 window.connect('notify::active-room',
-                               () => { this.emit('room-focus-changed'); });
+                               () => this.emit('room-focus-changed'));
                 window.connect('notify::is-active',
-                               () => { this.emit('room-focus-changed'); });
+                               () => this.emit('room-focus-changed'));
             }
         }
 
@@ -828,7 +828,7 @@ var Application = GObject.registerClass({
             this.disconnect(this._windowRemovedId);
         this._windowRemovedId = 0;
 
-        this.get_windows().reverse().forEach(w => { w.destroy(); });
+        this.get_windows().reverse().forEach(w => w.destroy());
         this.emit('prepare-shutdown');
     }
 });
diff --git a/src/chatView.js b/src/chatView.js
index 59d9df6..456c1cf 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -231,7 +231,7 @@ const HoverFilterTag = GObject.registerClass({
 
         super._init(params);
 
-        this.connect('notify::hover', () => { this._updateColor(); });
+        this.connect('notify::hover', () => this._updateColor());
     }
 
     _updateColor() {
@@ -443,7 +443,7 @@ var ChatView = GObject.registerClass({
             justification: Gtk.Justification.CENTER }
             /* eslint-enable indent */
         ];
-        tags.forEach(tagProps => { tagTable.add(new Gtk.TextTag(tagProps)); });
+        tags.forEach(tagProps => tagTable.add(new Gtk.TextTag(tagProps)));
     }
 
     _onStyleUpdated() {
@@ -805,7 +805,7 @@ var ChatView = GObject.registerClass({
         else
             hoveredButtonTags = [];
 
-        hoveredButtonTags.forEach(t => { t.hover = true; });
+        hoveredButtonTags.forEach(t => t.hover = true);
         this._hoveredButtonTags.forEach(t => {
             t.hover = hoveredButtonTags.includes(t);
         });
diff --git a/src/connections.js b/src/connections.js
index b217494..2d15bc7 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -191,7 +191,7 @@ var ConnectionsList = GObject.registerClass({
     }
 
     _networksChanged() {
-        this._list.foreach(w => { w.destroy(); });
+        this._list.foreach(w => w.destroy());
 
         let accounts = this._accountsMonitor.accounts;
         let usedNetworks = accounts.filter(a => {
@@ -542,7 +542,7 @@ var ConnectionProperties = GObject.registerClass({
                                  this._syncErrorMessage.bind(this));
         this._syncErrorMessage(account);
 
-        this.connect('destroy', () => { account.disconnect(id); });
+        this.connect('destroy', () => account.disconnect(id));
     }
 
     _syncErrorMessage(account) {
diff --git a/src/initialSetup.js b/src/initialSetup.js
index 45df25d..b3389ca 100644
--- a/src/initialSetup.js
+++ b/src/initialSetup.js
@@ -32,7 +32,7 @@ var InitialSetupWindow = GObject.registerClass({
             this._serverRoomList.setAccount(account);
         });
 
-        this.connect('destroy', () => { this._unsetAccount(); });
+        this.connect('destroy', () => this._unsetAccount());
 
         this._serverRoomList.connect('notify::can-join',
                                      this._updateNextSensitivity.bind(this));
diff --git a/src/roomList.js b/src/roomList.js
index 2b9670f..4592775 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -467,16 +467,16 @@ class RoomList extends Gtk.ListBox {
                                   this._roomAdded.bind(this));
         this._roomManager.connect('room-removed',
                                   this._roomRemoved.bind(this));
-        this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
+        this._roomManager.rooms.forEach(r => this._roomAdded(this._roomManager, r));
 
         let app = Gio.Application.get_default();
         let actions = [
             { name: 'next-room',
-              handler: () => { this._moveSelection(Gtk.DirectionType.DOWN); } },
+              handler: () => this._moveSelection(Gtk.DirectionType.DOWN) },
             { name: 'previous-room',
-              handler: () => { this._moveSelection(Gtk.DirectionType.UP); } },
+              handler: () => this._moveSelection(Gtk.DirectionType.UP) },
             { name: 'first-room',
-              handler: () => { this._selectRoomAtIndex(0); } },
+              handler: () => this._selectRoomAtIndex(0) },
             { name: 'last-room',
               handler: () => {
                   let nRows = this._roomManager.roomCount;
@@ -536,7 +536,7 @@ class RoomList extends Gtk.ListBox {
     }
 
     _moveSelection(direction) {
-        this._moveSelectionFull(direction, () => { return true; });
+        this._moveSelectionFull(direction, () => true);
     }
 
     _moveSelectionFull(direction, testFunction) {
@@ -624,7 +624,7 @@ class RoomList extends Gtk.ListBox {
         this.add(row);
         this._roomRows.set(room.id, row);
 
-        row.connect('destroy', w => { this._roomRows.delete(w.room.id); });
+        row.connect('destroy', w => this._roomRows.delete(w.room.id));
         this._placeholders.get(room.account).hide();
     }
 
diff --git a/src/roomManager.js b/src/roomManager.js
index 79d3729..964c08c 100644
--- a/src/roomManager.js
+++ b/src/roomManager.js
@@ -45,7 +45,7 @@ var RoomManager = class {
             this._removeRooms(account.object_path);
             this._removeSavedChannelsForAccount(account.object_path);
         });
-        this._accountsMonitor.prepare(() => { this._restoreRooms(); });
+        this._accountsMonitor.prepare(() => this._restoreRooms());
     }
 
     lookupRoom(id) {
diff --git a/src/roomStack.js b/src/roomStack.js
index e58023b..5d0abd0 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -28,7 +28,7 @@ var RoomStack = GObject.registerClass({
             this._roomManager.connect('room-added', this._roomAdded.bind(this));
         this._roomRemovedId =
             this._roomManager.connect('room-removed', this._roomRemoved.bind(this));
-        this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
+        this._roomManager.rooms.forEach(r => this._roomAdded(this._roomManager, r));
 
         this.add_named(new ChatPlaceholder(this._sizeGroup), 'placeholder');
 
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 8d11fb4..a70032a 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -108,8 +108,8 @@ class TelepathyClient extends Tp.BaseClient {
     _init(params) {
         this._app = Gio.Application.get_default();
         this._app.connect('prepare-shutdown', () => {
-            [...this._pendingRequests.values()].forEach(r => { r.cancel(); });
-            [...this._pendingBotPasswords.keys()].forEach(a => { this._discardIdentifyPassword(a); });
+            [...this._pendingRequests.values()].forEach(r => r.cancel());
+            [...this._pendingBotPasswords.keys()].forEach(a => this._discardIdentifyPassword(a));
             this._app.release();
         });
         this._app.hold();
@@ -357,7 +357,7 @@ class TelepathyClient extends Tp.BaseClient {
     _onReconnectAccountActivated(action, parameter) {
         let accountPath = parameter.deep_unpack();
         let account = this._accountsMonitor.lookupAccount(accountPath);
-        account.reconnect_async((a, res) => { a.reconnect_finish(res); });
+        account.reconnect_async((a, res) => a.reconnect_finish(res));
     }
 
     _onAuthenticateAccountActivated(action, parameter) {
diff --git a/src/userList.js b/src/userList.js
index 47c4257..bbd8784 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -16,7 +16,7 @@ class UserListPopover extends Gtk.Popover {
 
         this._createWidget();
 
-        this.connect('closed', () => { this._entry.text = ''; });
+        this.connect('closed', () => this._entry.text = '');
         this.connect('map', () => {
             this._revealer.transition_duration = 0;
             this._ensureUserList();
@@ -681,7 +681,7 @@ class UserList extends Gtk.ScrolledWindow {
     }
 
     _onChannelChanged(room) {
-        this._list.foreach(w => { w.destroy(); });
+        this._list.foreach(w => w.destroy());
         this._rows.clear();
 
         if (!room.channel)
diff --git a/src/userTracker.js b/src/userTracker.js
index a77e5ce..73eeba2 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -123,7 +123,7 @@ const UserTracker = GObject.registerClass({
         if (!this._roomData.has(room))
             return;
 
-        this._getRoomSignals(room).forEach(id => { room.disconnect(id); });
+        this._getRoomSignals(room).forEach(id => room.disconnect(id));
         this._clearUsersFromRoom(room);
         this._roomData.delete(room);
     }
@@ -142,13 +142,13 @@ const UserTracker = GObject.registerClass({
 
         /*keep track of initial members in the room, both locally and
         globally*/
-        members.forEach(m => { this._trackMember(m, room); });
+        members.forEach(m => this._trackMember(m, room));
     }
 
     _clearUsersFromRoom(room) {
         let map = this._getRoomContacts(room);
         for (let [, contacts] of map)
-            contacts.slice().forEach((m) => { this._untrackMember(m, room); });
+            contacts.slice().forEach((m) => this._untrackMember(m, room));
     }
 
     _ensureRoomMappingForRoom(room) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]