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:
- error
- argsIgnorePattern: "^_"
curly:
- error
- all
brace-style:
- error
- 1tbs
# Rules from GJS Style Guide regarding whitespace.
# See here: https://gjs.guide/guides/gjs/style-guide.html#whitespace
func-call-spacing:

View File

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

View File

@ -31,11 +31,14 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
#associateItem(item) {
this.item = item;
// Set `this._item_name_display_label` to something nicer, if the
// associated item is an AppIndicator/KStatusNotifierItem item.
if (item.startsWith("appindicator-kstatusnotifieritem-")) this._item_name_display_label.set_label(item.replace("appindicator-kstatusnotifieritem-", ""));
// Otherwise just set it to `item`.
else this._item_name_display_label.set_label(item);
if (item.startsWith("appindicator-kstatusnotifieritem-")) {
// Set `this._item_name_display_label` to something nicer, if the
// associated item is an AppIndicator/KStatusNotifierItem item.
this._item_name_display_label.set_label(item.replace("appindicator-kstatusnotifieritem-", ""));
} 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,
// save an updated box order for the list were the drop value was in
// as well.
if (ownListBox !== valueListBox) valueListBox.saveBoxOrderToSettings();
if (ownListBox !== valueListBox) {
valueListBox.saveBoxOrderToSettings();
}
}
});

View File

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

View File

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

View File

@ -15,7 +15,9 @@ var ScrollManager = class ScrollManager {
startScrollUp() {
// 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.
this.stopScrollDown();
@ -40,7 +42,9 @@ var ScrollManager = class ScrollManager {
startScrollDown() {
// 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.
this.stopScrollUp();