From 8de94d6b012161fdc8e0ef15566b6a4be8627c39 Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Sat, 28 Jan 2023 23:13:46 +0100 Subject: [PATCH] Other: Add whitespace rules from GJS Style Guide and fix complaints Add whitespace rules from GJS Style Guide to ESLint config and fix new complaints. See here for the GJS Style guide whitespace section: https://gjs.guide/guides/gjs/style-guide.html#whitespace --- .eslintrc.yml | 22 ++++++++++++++++++++++ src/extension.js | 4 ++-- src/extensionModules/BoxOrderManager.js | 6 +++--- src/prefsModules/PrefsBoxOrderListBox.js | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 2cfc4ef..3eaa9c5 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -20,6 +20,28 @@ rules: no-unused-vars: - error - argsIgnorePattern: "^_" + # Rules from GJS Style Guide regarding whitespace. + # See here: https://gjs.guide/guides/gjs/style-guide.html#whitespace + func-call-spacing: + - error + - never + array-bracket-spacing: + - error + - never + space-before-function-paren: + - error + - never + space-before-blocks: + - error + - always + key-spacing: + - error + - beforeColon: false + afterColon: true + mode: strict + object-curly-spacing: + - error + - always globals: imports: readonly log: readonly diff --git a/src/extension.js b/src/extension.js index e4bdd65..2e84736 100644 --- a/src/extension.js +++ b/src/extension.js @@ -26,7 +26,7 @@ class Extension { this.#overwritePanelAddToPanelBox(); // Handle changes of configured box orders. - this._settingsHandlerIds = [ ]; + this._settingsHandlerIds = []; const addConfiguredBoxOrderChangeHandler = (box) => { let handlerId = this.settings.connect(`changed::${box}-box-order`, () => { @@ -98,7 +98,7 @@ class Extension { }; // Overwrite `Panel._addToPanelBox`. - Panel.Panel.prototype._addToPanelBox = function (role, indicator, position, box) { + Panel.Panel.prototype._addToPanelBox = function(role, indicator, position, box) { // Simply call the original `_addToPanelBox` and order the top bar // and handle new items afterwards. this._originalAddToPanelBox(role, indicator, position, box); diff --git a/src/extensionModules/BoxOrderManager.js b/src/extensionModules/BoxOrderManager.js index b178e00..82c18d3 100644 --- a/src/extensionModules/BoxOrderManager.js +++ b/src/extensionModules/BoxOrderManager.js @@ -80,7 +80,7 @@ var BoxOrderManager = GObject.registerClass({ } } else { // Otherwise create a new array. - this._appIndicatorItemApplicationRoleMap.set(application, [ role ]); + this._appIndicatorItemApplicationRoleMap.set(application, [role]); } // Return the placeholder. @@ -97,7 +97,7 @@ var BoxOrderManager = GObject.registerClass({ * resolved/replaced to/with actual roles. */ #resolveAppIndicatorPlaceholders(boxOrder) { - let resolvedBoxOrder = [ ]; + let resolvedBoxOrder = []; for (const role of boxOrder) { // If the role isn't a placeholder, just add it to the resolved box // order. @@ -171,7 +171,7 @@ var BoxOrderManager = GObject.registerClass({ // Go through the box order and only add items to the valid box order, // where their indicator is present in the Gnome Shell top bar // currently. - let validBoxOrder = [ ]; + let validBoxOrder = []; for (const role of boxOrder) { // Get the indicator container associated with the current role. const associatedIndicatorContainer = Main.panel.statusArea[role]?.container; diff --git a/src/prefsModules/PrefsBoxOrderListBox.js b/src/prefsModules/PrefsBoxOrderListBox.js index 832c720..1da5fe7 100644 --- a/src/prefsModules/PrefsBoxOrderListBox.js +++ b/src/prefsModules/PrefsBoxOrderListBox.js @@ -64,7 +64,7 @@ var PrefsBoxOrderListBox = GObject.registerClass({ * `PrefsBoxOrderItemRows`) to settings. */ saveBoxOrderToSettings() { - let currentBoxOrder = [ ]; + let currentBoxOrder = []; for (let potentialPrefsBoxOrderItemRow of this) { // Only process PrefsBoxOrderItemRows. if (potentialPrefsBoxOrderItemRow.constructor.$gtype.name !== "PrefsBoxOrderItemRow") continue;