From 7f8f1234ae16c633a1ed8a2aba56e7a998b5b9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 28 Feb 2019 18:34:24 +0100 Subject: [PATCH] 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/gnome-shell-extensions/merge_requests/57 --- extensions/apps-menu/extension.js | 6 +++--- extensions/auto-move-windows/extension.js | 4 ++-- extensions/places-menu/placeDisplay.js | 8 ++++---- extensions/window-list/extension.js | 8 ++++---- lint/eslintrc-shell.json | 7 ------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js index fb335ccf..9e78933a 100644 --- a/extensions/apps-menu/extension.js +++ b/extensions/apps-menu/extension.js @@ -529,7 +529,7 @@ class ApplicationsButton extends PanelMenu.Button { Main.wm.setCustomKeybindingHandler('panel-main-menu', Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, - () => { this.menu.toggle(); }); + () => this.menu.toggle()); } _redisplay() { @@ -616,8 +616,8 @@ class ApplicationsButton extends PanelMenu.Button { style_class: 'vfade' }); this.categoriesScrollBox.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); vscroll = this.categoriesScrollBox.get_vscroll_bar(); - vscroll.connect('scroll-start', () => { this.menu.passEvents = true; }); - vscroll.connect('scroll-stop', () => { this.menu.passEvents = false; }); + vscroll.connect('scroll-start', () => this.menu.passEvents = true); + vscroll.connect('scroll-stop', () => this.menu.passEvents = false); this.leftBox.add(this.categoriesScrollBox, { expand: true, x_fill: true, y_fill: true, y_align: St.Align.START }); diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js index 35979971..646156aa 100644 --- a/extensions/auto-move-windows/extension.js +++ b/extensions/auto-move-windows/extension.js @@ -125,9 +125,9 @@ function myCheckWorkspaces() { } // make sure the original method only removes empty workspaces at the end - keepAliveWorkspaces.forEach(ws => { ws._keepAliveId = 1; }); + keepAliveWorkspaces.forEach(ws => ws._keepAliveId = 1); prevCheckWorkspaces.call(this); - keepAliveWorkspaces.forEach(ws => { delete ws._keepAliveId; }); + keepAliveWorkspaces.forEach(ws => delete ws._keepAliveId); return false; } diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js index dbd3308c..c1302118 100644 --- a/extensions/places-menu/placeDisplay.js +++ b/extensions/places-menu/placeDisplay.js @@ -45,7 +45,7 @@ class PlaceInfo { } catch (e) { if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_MOUNTED)) { let source = { - get_icon: () => { return this.icon; } + get_icon: () => this.icon }; let op = new ShellMountOperation.ShellMountOperation(source); this.file.mount_enclosing_volume(0, op.mountOp, null, (file, result) => { @@ -325,7 +325,7 @@ var PlacesManager = class { } _updateSpecials() { - this._places.special.forEach(p => { p.destroy(); }); + this._places.special.forEach(p => p.destroy()); this._places.special = []; let homePath = GLib.get_home_dir(); @@ -367,9 +367,9 @@ var PlacesManager = class { let networkMounts = []; let networkVolumes = []; - this._places.devices.forEach(p => { p.destroy(); }); + this._places.devices.forEach(p => p.destroy()); this._places.devices = []; - this._places.network.forEach(p => { p.destroy(); }); + this._places.network.forEach(p => p.destroy()); this._places.network = []; /* Add standard places */ diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js index 493970a4..ff7e774b 100644 --- a/extensions/window-list/extension.js +++ b/extensions/window-list/extension.js @@ -401,13 +401,13 @@ class AppContextMenu extends PopupMenu.PopupMenu { this._minimizeItem = new PopupMenu.PopupMenuItem(_("Minimize all")); this._minimizeItem.connect('activate', () => { - this._appButton.getWindowList().forEach(w => { w.minimize(); }); + this._appButton.getWindowList().forEach(w => w.minimize()); }); this.addMenuItem(this._minimizeItem); this._unminimizeItem = new PopupMenu.PopupMenuItem(_("Unminimize all")); this._unminimizeItem.connect('activate', () => { - this._appButton.getWindowList().forEach(w => { w.unminimize(); }); + this._appButton.getWindowList().forEach(w => w.unminimize()); }); this.addMenuItem(this._unminimizeItem); @@ -538,7 +538,7 @@ class AppButton extends BaseButton { let rect = this._getIconGeometry(); let windows = this.app.get_windows(); - windows.forEach(w => { w.set_icon_geometry(rect); }); + windows.forEach(w => w.set_icon_geometry(rect)); } getWindowList() { @@ -1205,7 +1205,7 @@ class Extension { } _buildWindowLists() { - this._windowLists.forEach(list => { list.actor.destroy(); }); + this._windowLists.forEach(list => list.actor.destroy()); this._windowLists = []; let showOnAllMonitors = this._settings.get_boolean('show-on-all-monitors'); diff --git a/lint/eslintrc-shell.json b/lint/eslintrc-shell.json index 9821bf4a..eb96266a 100644 --- a/lint/eslintrc-shell.json +++ b/lint/eslintrc-shell.json @@ -1,13 +1,6 @@ { "rules": { "arrow-spacing": "error", - "brace-style": [ - "error", - "1tbs", - { - "allowSingleLine": true - } - ], "camelcase": [ "error", {