cleanup: "Only" use two indentation styles for object literals

We currently use no less than three different ways of indenting
object literals:

    let obj1 = {
        foo: 42,
        bar: 23,
    };

    let obj2 = { foo: 42,
                 bar: 23 };

    let obj3 = { foo: 42,
                 bar: 23
               };

The first is the one we want to use everywhere eventually, while the
second is the most commonly used "legacy" style.

It is the third one that is most problematic, as it throws off eslint
fairly badly: It violates both the rule to have consistent line breaks
in braces as well as the indentation style of both regular and legacy
configurations.

Fortunately the third style was mostly used for tween parameters, so
is quite rare after the Tweener purge. Get rid of the remaining ones
to cut down on pre-existing eslint errors.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/716
This commit is contained in:
Florian Müllner 2019-02-12 15:02:09 +01:00
parent 2fc4987c73
commit 451f4e3636
18 changed files with 170 additions and 152 deletions

View File

@ -1158,11 +1158,10 @@ var AppSearchProvider = class AppSearchProvider {
if (id.endsWith('.desktop')) { if (id.endsWith('.desktop')) {
let app = this._appSys.lookup_app(id); let app = this._appSys.lookup_app(id);
metas.push({ 'id': app.get_id(), metas.push({
'name': app.get_name(), id: app.get_id(),
'createIcon'(size) { name: app.get_name(),
return app.create_icon_texture(size); createIcon: size => app.create_icon_texture(size),
}
}); });
} else { } else {
let name = this._systemActions.getName(id); let name = this._systemActions.getName(id);

View File

@ -147,12 +147,11 @@ class AppFavorites {
let app = Shell.AppSystem.get_default().lookup_app(appId); let app = Shell.AppSystem.get_default().lookup_app(appId);
Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()), let msg = _("%s has been added to your favorites.").format(app.get_name());
{ forFeedback: true, Main.overview.setMessage(msg, {
undoCallback: () => { forFeedback: true,
this._removeFavorite(appId); undoCallback: () => this._removeFavorite(appId),
} });
});
} }
addFavorite(appId) { addFavorite(appId) {
@ -181,12 +180,11 @@ class AppFavorites {
if (!this._removeFavorite(appId)) if (!this._removeFavorite(appId))
return; return;
Main.overview.setMessage(_("%s has been removed from your favorites.").format(app.get_name()), let msg = _("%s has been removed from your favorites.").format(app.get_name());
{ forFeedback: true, Main.overview.setMessage(msg, {
undoCallback: () => { forFeedback: true,
this._addFavorite(appId, pos); undoCallback: () => this._addFavorite(appId, pos),
} });
});
} }
} }
Signals.addSignalMethods(AppFavorites.prototype); Signals.addSignalMethods(AppFavorites.prototype);

View File

@ -441,20 +441,21 @@ var Background = class Background {
} }
_loadAnimation(file) { _loadAnimation(file) {
this._cache.getAnimation({ file: file, this._cache.getAnimation({
settingsSchema: this._settings.schema_id, file: file,
onLoaded: animation => { settingsSchema: this._settings.schema_id,
this._animation = animation; onLoaded: animation => {
this._animation = animation;
if (!this._animation || this._cancellable.is_cancelled()) { if (!this._animation || this._cancellable.is_cancelled()) {
this._setLoaded(); this._setLoaded();
return; return;
} }
this._updateAnimation(); this._updateAnimation();
this._watchFile(file); this._watchFile(file);
} }
}); });
} }
_loadImage(file) { _loadImage(file) {
@ -748,13 +749,14 @@ var BackgroundManager = class BackgroundManager {
_createBackgroundActor() { _createBackgroundActor() {
let background = this._backgroundSource.getBackground(this._monitorIndex); let background = this._backgroundSource.getBackground(this._monitorIndex);
let backgroundActor = new Meta.BackgroundActor({ meta_display: global.display, let backgroundActor = new Meta.BackgroundActor({
monitor: this._monitorIndex, meta_display: global.display,
background: background.background, monitor: this._monitorIndex,
vignette: this._vignette, background: background.background,
vignette_sharpness: 0.5, vignette: this._vignette,
brightness: 0.5, vignette_sharpness: 0.5,
}); brightness: 0.5,
});
this._container.add_child(backgroundActor); this._container.add_child(backgroundActor);

View File

@ -325,10 +325,10 @@ var AutorunNotification = class extends MessageTray.Notification {
style_class: 'hotplug-notification-item-icon' }); style_class: 'hotplug-notification-item-icon' });
box.add(icon); box.add(icon);
let label = new St.Bin({ y_align: St.Align.MIDDLE, let label = new St.Bin({
child: new St.Label y_align: St.Align.MIDDLE,
({ text: _("Open with %s").format(app.get_name()) }) child: new St.Label({ text: _("Open with %s").format(app.get_name()) }),
}); });
box.add(label); box.add(label);
let button = new St.Button({ child: box, let button = new St.Button({ child: box,

View File

@ -112,16 +112,17 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog {
expand: true }); expand: true });
} }
this._okButton = { label: _("Connect"), this._okButton = {
action: this._onOk.bind(this), label: _("Connect"),
default: true action: this._onOk.bind(this),
}; default: true,
};
this.setButtons([{ label: _("Cancel"), this.setButtons([{
action: this.cancel.bind(this), label: _("Cancel"),
key: Clutter.KEY_Escape, action: this.cancel.bind(this),
}, key: Clutter.KEY_Escape,
this._okButton]); }, this._okButton]);
this._updateOkButton(); this._updateOkButton();
} }
@ -551,11 +552,12 @@ var VPNRequestHandler = class {
let shouldAsk = keyfile.get_boolean(groups[i], 'ShouldAsk'); let shouldAsk = keyfile.get_boolean(groups[i], 'ShouldAsk');
if (shouldAsk) { if (shouldAsk) {
contentOverride.secrets.push({ label: keyfile.get_string(groups[i], 'Label'), contentOverride.secrets.push({
key: groups[i], label: keyfile.get_string(groups[i], 'Label'),
value: value, key: groups[i],
password: keyfile.get_boolean(groups[i], 'IsSecret') value: value,
}); password: keyfile.get_boolean(groups[i], 'IsSecret'),
});
} else { } else {
if (!value.length) // Ignore empty secrets if (!value.length) // Ignore empty secrets
continue; continue;
@ -609,10 +611,11 @@ Signals.addSignalMethods(VPNRequestHandler.prototype);
var NetworkAgent = class { var NetworkAgent = class {
constructor() { constructor() {
this._native = new Shell.NetworkAgent({ identifier: 'org.gnome.Shell.NetworkAgent', this._native = new Shell.NetworkAgent({
capabilities: NM.SecretAgentCapabilities.VPN_HINTS, identifier: 'org.gnome.Shell.NetworkAgent',
auto_register: false capabilities: NM.SecretAgentCapabilities.VPN_HINTS,
}); auto_register: false,
});
this._dialogs = { }; this._dialogs = { };
this._vpnRequests = { }; this._vpnRequests = { };

View File

@ -30,11 +30,13 @@ var TodayButton = class TodayButton {
// Having the ability to go to the current date if the user is already // Having the ability to go to the current date if the user is already
// on the current date can be confusing. So don't make the button reactive // on the current date can be confusing. So don't make the button reactive
// until the selected date changes. // until the selected date changes.
this.actor = new St.Button({ style_class: 'datemenu-today-button', this.actor = new St.Button({
x_expand: true, x_align: St.Align.START, style_class: 'datemenu-today-button',
can_focus: true, x_align: St.Align.START,
reactive: false x_expand: true,
}); can_focus: true,
reactive: false,
});
this.actor.connect('clicked', () => { this.actor.connect('clicked', () => {
this._calendar.setDate(new Date(), false); this._calendar.setDate(new Date(), false);
}); });

View File

@ -449,14 +449,16 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
for (let i = 0; i < dialogContent.confirmButtons.length; i++) { for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
let signal = dialogContent.confirmButtons[i].signal; let signal = dialogContent.confirmButtons[i].signal;
let label = dialogContent.confirmButtons[i].label; let label = dialogContent.confirmButtons[i].label;
buttons.push({ action: () => { buttons.push({
this.close(true); action: () => {
let signalId = this.connect('closed', () => { this.close(true);
this.disconnect(signalId); let signalId = this.connect('closed', () => {
this._confirm(signal); this.disconnect(signalId);
}); this._confirm(signal);
}, });
label: label }); },
label: label,
});
} }
this.setButtons(buttons); this.setButtons(buttons);

View File

@ -186,14 +186,15 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog {
this._info = info; this._info = info;
this._invocation = invocation; this._invocation = invocation;
this.setButtons([{ label: _("Cancel"), this.setButtons([{
action: this._onCancelButtonPressed.bind(this), label: _("Cancel"),
key: Clutter.Escape action: this._onCancelButtonPressed.bind(this),
}, key: Clutter.Escape,
{ label: _("Install"), }, {
action: this._onInstallButtonPressed.bind(this), label: _("Install"),
default: true action: this._onInstallButtonPressed.bind(this),
}]); default: true,
}]);
let content = new Dialog.MessageDialogContent({ let content = new Dialog.MessageDialogContent({
title: _("Download and install “%s” from extensions.gnome.org?").format(info.name), title: _("Download and install “%s” from extensions.gnome.org?").format(info.name),

View File

@ -238,11 +238,12 @@ var LayoutManager = GObject.registerClass({
reactive: true }); reactive: true });
this.addChrome(this.overviewGroup); this.addChrome(this.overviewGroup);
this.screenShieldGroup = new St.Widget({ name: 'screenShieldGroup', this.screenShieldGroup = new St.Widget({
visible: false, name: 'screenShieldGroup',
clip_to_allocation: true, visible: false,
layout_manager: new Clutter.BinLayout(), clip_to_allocation: true,
}); layout_manager: new Clutter.BinLayout(),
});
this.addChrome(this.screenShieldGroup); this.addChrome(this.screenShieldGroup);
this.panelBox = new St.BoxLayout({ name: 'panelBox', this.panelBox = new St.BoxLayout({ name: 'panelBox',

View File

@ -108,12 +108,13 @@ var RadialShaderEffect = GObject.registerClass({
*/ */
var Lightbox = class Lightbox { var Lightbox = class Lightbox {
constructor(container, params) { constructor(container, params) {
params = Params.parse(params, { inhibitEvents: false, params = Params.parse(params, {
width: null, inhibitEvents: false,
height: null, width: null,
fadeFactor: DEFAULT_FADE_FACTOR, height: null,
radialEffect: false, fadeFactor: DEFAULT_FADE_FACTOR,
}); radialEffect: false,
});
this._container = container; this._container = container;
this._children = container.get_children(); this._children = container.get_children();

View File

@ -136,13 +136,14 @@ var FocusGrabber = class FocusGrabber {
// A notification without a policy object will inherit the default one. // A notification without a policy object will inherit the default one.
var NotificationPolicy = class NotificationPolicy { var NotificationPolicy = class NotificationPolicy {
constructor(params) { constructor(params) {
params = Params.parse(params, { enable: true, params = Params.parse(params, {
enableSound: true, enable: true,
showBanners: true, enableSound: true,
forceExpanded: false, showBanners: true,
showInLockScreen: true, forceExpanded: false,
detailsInLockScreen: false showInLockScreen: true,
}); detailsInLockScreen: false,
});
Object.getOwnPropertyNames(params).forEach(key => { Object.getOwnPropertyNames(params).forEach(key => {
let desc = Object.getOwnPropertyDescriptor(params, key); let desc = Object.getOwnPropertyDescriptor(params, key);
Object.defineProperty(this, `_${key}`, desc); Object.defineProperty(this, `_${key}`, desc);

View File

@ -42,9 +42,10 @@ var ShellInfo = class {
} }
setMessage(text, options) { setMessage(text, options) {
options = Params.parse(options, { undoCallback: null, options = Params.parse(options, {
forFeedback: false undoCallback: null,
}); forFeedback: false,
});
let undoCallback = options.undoCallback; let undoCallback = options.undoCallback;
let forFeedback = options.forFeedback; let forFeedback = options.forFeedback;

View File

@ -67,12 +67,13 @@ var PopupBaseMenuItem = GObject.registerClass({
} }
}, class PopupBaseMenuItem extends St.BoxLayout { }, class PopupBaseMenuItem extends St.BoxLayout {
_init(params) { _init(params) {
params = Params.parse (params, { reactive: true, params = Params.parse (params, {
activate: true, reactive: true,
hover: true, activate: true,
style_class: null, hover: true,
can_focus: true style_class: null,
}); can_focus: true,
});
super._init({ style_class: 'popup-menu-item', super._init({ style_class: 'popup-menu-item',
reactive: params.reactive, reactive: params.reactive,
track_hover: params.reactive, track_hover: params.reactive,
@ -331,9 +332,10 @@ var PopupSwitchMenuItem = GObject.registerClass({
this._statusBin = new St.Bin({ x_align: St.Align.END }); this._statusBin = new St.Bin({ x_align: St.Align.END });
this.add(this._statusBin, { expand: true, x_align: St.Align.END }); this.add(this._statusBin, { expand: true, x_align: St.Align.END });
this._statusLabel = new St.Label({ text: '', this._statusLabel = new St.Label({
style_class: 'popup-status-menu-item' text: '',
}); style_class: 'popup-status-menu-item',
});
this._statusBin.child = this._switch; this._statusBin.child = this._switch;
} }

View File

@ -94,9 +94,11 @@ class RunDialog extends ModalDialog.ModalDialog {
this._errorBox.hide(); this._errorBox.hide();
this.setButtons([{ action: this.close.bind(this), this.setButtons([{
label: _("Close"), action: this.close.bind(this),
key: Clutter.Escape }]); label: _("Close"),
key: Clutter.Escape,
}]);
this._pathCompleter = new Gio.FilenameCompleter(); this._pathCompleter = new Gio.FilenameCompleter();

View File

@ -429,13 +429,14 @@ var ScreenShield = class {
this.actor = Main.layoutManager.screenShieldGroup; this.actor = Main.layoutManager.screenShieldGroup;
this._lockScreenState = MessageTray.State.HIDDEN; this._lockScreenState = MessageTray.State.HIDDEN;
this._lockScreenGroup = new St.Widget({ x_expand: true, this._lockScreenGroup = new St.Widget({
y_expand: true, x_expand: true,
reactive: true, y_expand: true,
can_focus: true, reactive: true,
name: 'lockScreenGroup', can_focus: true,
visible: false, name: 'lockScreenGroup',
}); visible: false,
});
this._lockScreenGroup.connect('key-press-event', this._lockScreenGroup.connect('key-press-event',
this._onLockScreenKeyPress.bind(this)); this._onLockScreenKeyPress.bind(this));
this._lockScreenGroup.connect('scroll-event', this._lockScreenGroup.connect('scroll-event',

View File

@ -26,9 +26,10 @@ function _setButtonsForChoices(dialog, choices) {
for (let idx = 0; idx < choices.length; idx++) { for (let idx = 0; idx < choices.length; idx++) {
let button = idx; let button = idx;
buttons.unshift({ label: choices[idx], buttons.unshift({
action: () => dialog.emit('response', button) label: choices[idx],
}); action: () => dialog.emit('response', button),
});
} }
dialog.setButtons(buttons); dialog.setButtons(buttons);
@ -387,24 +388,26 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._rememberChoice = null; this._rememberChoice = null;
} }
this._defaultButtons = [{ label: _("Cancel"), this._defaultButtons = [{
action: this._onCancelButton.bind(this), label: _("Cancel"),
key: Clutter.Escape action: this._onCancelButton.bind(this),
}, key: Clutter.Escape,
{ label: _("Unlock"), }, {
action: this._onUnlockButton.bind(this), label: _("Unlock"),
default: true action: this._onUnlockButton.bind(this),
}]; default: true,
}];
this._usesKeyfilesButtons = [{ label: _("Cancel"), this._usesKeyfilesButtons = [{
action: this._onCancelButton.bind(this), label: _("Cancel"),
key: Clutter.Escape action: this._onCancelButton.bind(this),
}, key: Clutter.Escape,
{ /* Translators: %s is the Disks application */ }, {
label: _("Open %s").format(disksApp.get_name()), /* Translators: %s is the Disks application */
action: this._onOpenDisksButton.bind(this), label: _("Open %s").format(disksApp.get_name()),
default: true action: this._onOpenDisksButton.bind(this),
}]; default: true,
}];
this.setButtons(this._defaultButtons); this.setButtons(this._defaultButtons);
} }

View File

@ -1073,13 +1073,14 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
this._resortItems(); this._resortItems();
} else { } else {
network = { ssid: accessPoint.get_ssid(), network = {
mode: accessPoint.mode, ssid: accessPoint.get_ssid(),
security: this._getApSecurityType(accessPoint), mode: accessPoint.mode,
connections: [], security: this._getApSecurityType(accessPoint),
item: null, connections: [],
accessPoints: [accessPoint] item: null,
}; accessPoints: [accessPoint],
};
network.ssidText = ssidToLabel(network.ssid); network.ssidText = ssidToLabel(network.ssid);
this._checkConnections(network, accessPoint); this._checkConnections(network, accessPoint);

View File

@ -309,12 +309,10 @@ var ViewSelector = class {
if (params.a11yFocus) if (params.a11yFocus)
Main.ctrlAltTabManager.addGroup(params.a11yFocus, name, a11yIcon); Main.ctrlAltTabManager.addGroup(params.a11yFocus, name, a11yIcon);
else else
Main.ctrlAltTabManager.addGroup(actor, name, a11yIcon, Main.ctrlAltTabManager.addGroup(actor, name, a11yIcon, {
{ proxy: this.actor, proxy: this.actor,
focusCallback: () => { focusCallback: () => this._a11yFocusPage(page),
this._a11yFocusPage(page); });
}
});
page.hide(); page.hide();
this.actor.add_actor(page); this.actor.add_actor(page);
return page; return page;