Other: Disallow omitting curly braces and enforce one true brace style

Do this by updating the ESLint config accordingly and also fix new
complaints.
This commit is contained in:
Julian 2023-01-28 23:34:15 +01:00
parent 8de94d6b01
commit cedb54ed64
Signed by: julian
GPG Key ID: 094C2AC34192FA11
6 changed files with 44 additions and 19 deletions

View File

@ -20,6 +20,12 @@ rules:
no-unused-vars: no-unused-vars:
- error - error
- argsIgnorePattern: "^_" - argsIgnorePattern: "^_"
curly:
- error
- all
brace-style:
- error
- 1tbs
# Rules from GJS Style Guide regarding whitespace. # Rules from GJS Style Guide regarding whitespace.
# See here: https://gjs.guide/guides/gjs/style-guide.html#whitespace # See here: https://gjs.guide/guides/gjs/style-guide.html#whitespace
func-call-spacing: func-call-spacing:

View File

@ -176,7 +176,9 @@ var BoxOrderManager = GObject.registerClass({
// Get the indicator container associated with the current role. // Get the indicator container associated with the current role.
const associatedIndicatorContainer = Main.panel.statusArea[role]?.container; const associatedIndicatorContainer = Main.panel.statusArea[role]?.container;
if (indicatorContainerSet.has(associatedIndicatorContainer)) validBoxOrder.push(role); if (indicatorContainerSet.has(associatedIndicatorContainer)) {
validBoxOrder.push(role);
}
} }
return validBoxOrder; return validBoxOrder;
@ -218,7 +220,9 @@ var BoxOrderManager = GObject.registerClass({
// First get the role associated with the current indicator // First get the role associated with the current indicator
// container. // container.
let role = indicatorContainerRoleMap.get(indicatorContainer); let role = indicatorContainerRoleMap.get(indicatorContainer);
if (!role) continue; if (!role) {
continue;
}
// Handle an AppIndicator/KStatusNotifierItem item differently. // Handle an AppIndicator/KStatusNotifierItem item differently.
if (role.startsWith("appindicator-")) { if (role.startsWith("appindicator-")) {

View File

@ -31,11 +31,14 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
#associateItem(item) { #associateItem(item) {
this.item = item; this.item = item;
// Set `this._item_name_display_label` to something nicer, if the if (item.startsWith("appindicator-kstatusnotifieritem-")) {
// associated item is an AppIndicator/KStatusNotifierItem item. // Set `this._item_name_display_label` to something nicer, if the
if (item.startsWith("appindicator-kstatusnotifieritem-")) this._item_name_display_label.set_label(item.replace("appindicator-kstatusnotifieritem-", "")); // associated item is an AppIndicator/KStatusNotifierItem item.
// Otherwise just set it to `item`. this._item_name_display_label.set_label(item.replace("appindicator-kstatusnotifieritem-", ""));
else this._item_name_display_label.set_label(item); } else {
// Otherwise just set it to `item`.
this._item_name_display_label.set_label(item);
}
} }
/** /**
@ -133,6 +136,8 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
// If the list boxes of `this` and the drop value were different, // If the list boxes of `this` and the drop value were different,
// save an updated box order for the list were the drop value was in // save an updated box order for the list were the drop value was in
// as well. // as well.
if (ownListBox !== valueListBox) valueListBox.saveBoxOrderToSettings(); if (ownListBox !== valueListBox) {
valueListBox.saveBoxOrderToSettings();
}
} }
}); });

View File

@ -67,7 +67,9 @@ var PrefsBoxOrderListBox = GObject.registerClass({
let currentBoxOrder = []; let currentBoxOrder = [];
for (let potentialPrefsBoxOrderItemRow of this) { for (let potentialPrefsBoxOrderItemRow of this) {
// Only process PrefsBoxOrderItemRows. // Only process PrefsBoxOrderItemRows.
if (potentialPrefsBoxOrderItemRow.constructor.$gtype.name !== "PrefsBoxOrderItemRow") continue; if (potentialPrefsBoxOrderItemRow.constructor.$gtype.name !== "PrefsBoxOrderItemRow") {
continue;
}
const item = potentialPrefsBoxOrderItemRow.item; const item = potentialPrefsBoxOrderItemRow.item;
currentBoxOrder.push(item); currentBoxOrder.push(item);

View File

@ -42,14 +42,18 @@ var PrefsPage = GObject.registerClass({
// Scroll, when the pointer is in the right places. // Scroll, when the pointer is in the right places.
controller.connect("motion", (_, _x, y) => { controller.connect("motion", (_, _x, y) => {
// If the pointer is currently in the upper ten percent of this if (y <= this.get_allocated_height() * 0.1) {
// widget, then scroll up. // If the pointer is currently in the upper ten percent of this
if (y <= this.get_allocated_height() * 0.1) scrollManager.startScrollUp(); // widget, then scroll up.
// If the pointer is currently in the lower ten percent of this scrollManager.startScrollUp();
// widget, then scroll down. } else if (y >= this.get_allocated_height() * 0.9) {
else if (y >= this.get_allocated_height() * 0.9) scrollManager.startScrollDown(); // If the pointer is currently in the lower ten percent of this
// Otherwise stop scrolling. // widget, then scroll down.
else scrollManager.stopScrollAll(); scrollManager.startScrollDown();
} else {
// Otherwise stop scrolling.
scrollManager.stopScrollAll();
}
}); });
// Make sure scrolling stops, when DND operation ends. // Make sure scrolling stops, when DND operation ends.

View File

@ -15,7 +15,9 @@ var ScrollManager = class ScrollManager {
startScrollUp() { startScrollUp() {
// If the scroll up is already started, don't do anything. // If the scroll up is already started, don't do anything.
if (this._scrollUp) return; if (this._scrollUp) {
return;
}
// Make sure scroll down is stopped. // Make sure scroll down is stopped.
this.stopScrollDown(); this.stopScrollDown();
@ -40,7 +42,9 @@ var ScrollManager = class ScrollManager {
startScrollDown() { startScrollDown() {
// If the scroll down is already started, don't do anything. // If the scroll down is already started, don't do anything.
if (this._scrollDown) return; if (this._scrollDown) {
return;
}
// Make sure scroll up is stopped. // Make sure scroll up is stopped.
this.stopScrollUp(); this.stopScrollUp();