[polari/wip/fmuellner/more-style-changes: 3/7] style: Don't exempt ternary expressions from indent rule
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/more-style-changes: 3/7] style: Don't exempt ternary expressions from indent rule
- Date: Wed, 27 Feb 2019 16:14:30 +0000 (UTC)
commit 58caf67a0fe6ac65411e518ec3d5da7a3db3713f
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 27 15:58:22 2019 +0100
style: Don't exempt ternary expressions from indent rule
It turns out we can comply with gjs' coding style and still align the
branches if line breaks are required, so do that to reduce diversion
from the canonical GNOME style.
https://gitlab.gnome.org/GNOME/polari/merge_requests/93
lint/eslintrc-legacy.json | 1 -
lint/eslintrc-polari.json | 3 +--
src/accountsMonitor.js | 9 +++++----
src/chatView.js | 15 +++++++++------
src/connections.js | 6 ++++--
src/entryArea.js | 5 +++--
src/initialSetup.js | 4 ++--
src/joinDialog.js | 15 +++++++--------
src/networksManager.js | 3 +--
src/roomList.js | 4 ++--
src/roomManager.js | 4 ++--
src/serverRoomManager.js | 4 ++--
src/telepathyClient.js | 5 +++--
src/userTracker.js | 13 +++++++------
14 files changed, 48 insertions(+), 43 deletions(-)
---
diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json
index ad2c560..42b54fb 100644
--- a/lint/eslintrc-legacy.json
+++ b/lint/eslintrc-legacy.json
@@ -5,7 +5,6 @@
4,
{
"ignoredNodes": [
- "ConditionalExpression",
"CallExpression > ArrowFunctionExpression",
"CallExpression[callee.object.name=GObject][callee.property.name=registerClass] >
ClassExpression:first-child"
],
diff --git a/lint/eslintrc-polari.json b/lint/eslintrc-polari.json
index 98f4199..96af463 100644
--- a/lint/eslintrc-polari.json
+++ b/lint/eslintrc-polari.json
@@ -20,8 +20,7 @@
4,
{
"ignoredNodes": [
- "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] >
ClassExpression:first-child",
- "ConditionalExpression"
+ "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] >
ClassExpression:first-child"
],
"MemberExpression": "off"
}
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index b45371f..c572e14 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -124,8 +124,9 @@ var AccountsMonitor = class {
});
account._visibleNotifyId =
account.connect('notify::visible', () => {
- this.emit(account.visible ? 'account-shown'
- : 'account-hidden', account);
+ let signal = account.visible ?
+ 'account-shown' : 'account-hidden';
+ this.emit(signal, account);
this.emit('accounts-changed');
});
this._accounts.set(account.object_path, account);
@@ -151,8 +152,8 @@ var AccountsMonitor = class {
_accountEnabledChanged(am, account) {
if (!this._accounts.has(account.object_path))
return;
- this.emit(account.enabled ? 'account-enabled'
- : 'account-disabled', account);
+ let signal = account.enabled ? 'account-enabled' : 'account-disabled';
+ this.emit(signal, account);
this.emit('accounts-changed');
}
};
diff --git a/src/chatView.js b/src/chatView.js
index e32760a..eb378c2 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -913,8 +913,9 @@ var ChatView = GObject.registerClass({
this._channel = this._room.channel;
- let nick = this._channel ? this._channel.connection.self_contact.alias
- : this._room.account.nickname;
+ let nick = this._channel ?
+ this._channel.connection.self_contact.alias :
+ this._room.account.nickname;
this._updateMaxNickChars(nick.length);
if (!this._channel)
@@ -952,15 +953,17 @@ var ChatView = GObject.registerClass({
_onMemberKicked(room, member, actor) {
let [kicked, kicker] = [member.alias, actor ? actor.alias : null];
- let msg = kicker ? _("%s has been kicked by %s").format(kicked, kicker)
- : _("%s has been kicked").format(kicked);
+ let msg = kicker ?
+ _("%s has been kicked by %s").format(kicked, kicker) :
+ _("%s has been kicked").format(kicked);
this._insertStatus(msg, kicked, 'left');
}
_onMemberBanned(room, member, actor) {
let [banned, banner] = [member.alias, actor ? actor.alias : null];
- let msg = banner ? _("%s has been banned by %s").format(banned, banner)
- : _("%s has been banned").format(banned);
+ let msg = banner ?
+ _("%s has been banned by %s").format(banned, banner) :
+ _("%s has been banned").format(banned);
this._insertStatus(msg, banned, 'left');
}
diff --git a/src/connections.js b/src/connections.js
index ea4bea8..f7f7140 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -21,8 +21,10 @@ function getAccountParams(account) {
params[p] = params[p].deep_unpack();
params['use-ssl'] = !!params['use-ssl'];
- params['port'] = params['port'] || params['use-ssl'] ? DEFAULT_SSL_PORT
- : DEFAULT_PORT;
+
+ let defaultPort = params['use-ssl'] ? DEFAULT_SSL_PORT : DEFAULT_PORT;
+ params['port'] = params['port'] || defaultPort;
+
return params;
}
diff --git a/src/entryArea.js b/src/entryArea.js
index 9097342..f22fbb5 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -474,8 +474,9 @@ var EntryArea = GObject.registerClass({
_updateNick() {
let channel = this._room ? this._room.channel : null;
- let nick = channel ? channel.connection.self_contact.alias
- : this._room ? this._room.account.nickname : '';
+ let nick = channel ?
+ channel.connection.self_contact.alias :
+ this._room ? this._room.account.nickname : '';
this._nickLabel.width_chars = Math.max(nick.length, this._maxNickChars);
this._nickLabel.label = nick;
diff --git a/src/initialSetup.js b/src/initialSetup.js
index 2e1911f..fd856d3 100644
--- a/src/initialSetup.js
+++ b/src/initialSetup.js
@@ -63,8 +63,8 @@ var InitialSetupWindow = GObject.registerClass({
_onNetworkAvailableChanged() {
if (this._networkMonitor.network_available)
- this._setPage(this._currentAccount ? SetupPage.ROOM
- : SetupPage.CONNECTION);
+ this._setPage(this._currentAccount ?
+ SetupPage.ROOM : SetupPage.CONNECTION);
else
this._setPage(SetupPage.OFFLINE);
}
diff --git a/src/joinDialog.js b/src/joinDialog.js
index ccc34da..bd122de 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -120,8 +120,8 @@ var JoinDialog = GObject.registerClass({
this._customToggle.connect('notify::active', () => {
let isCustom = this._customToggle.active;
- this._connectionStack.visible_child_name = isCustom ? 'custom'
- : 'predefined';
+ let childName = isCustom ? 'custom' : 'predefined';
+ this._connectionStack.visible_child_name = childName;
if (isCustom) {
this._addButton.grab_default();
this._details.reset();
@@ -187,8 +187,8 @@ var JoinDialog = GObject.registerClass({
this._connectionCombo.append(names[i], names[i]);
this._connectionCombo.sensitive = names.length > 1;
- let activeRoom = this.transient_for ? this.transient_for.active_room
- : null;
+ let activeRoom = this.transient_for ?
+ this.transient_for.active_room : null;
let activeIndex = 0;
if (activeRoom)
activeIndex = Math.max(names.indexOf(activeRoom.account.display_name), 0);
@@ -203,8 +203,8 @@ var JoinDialog = GObject.registerClass({
this._serverRoomList.can_join;
this._joinButton.sensitive = sensitive;
- this.set_default_response(sensitive ? Gtk.ResponseType.OK
- : Gtk.ResponseType.NONE);
+ this.set_default_response(sensitive ?
+ Gtk.ResponseType.OK : Gtk.ResponseType.NONE);
}
get _page() {
@@ -226,8 +226,7 @@ var JoinDialog = GObject.registerClass({
this._joinButton.visible = isMain;
this._cancelButton.visible = isMain || isAccountsEmpty;
this._backButton.visible = !(isMain || isAccountsEmpty);
- this.title = isMain ? _("Join Chat Room")
- : _("Add Network");
+ this.title = isMain ? _("Join Chat Room") : _("Add Network");
this._mainStack.visible_child_name = isMain ? 'main' : 'connection';
this._updateCanJoin();
}
diff --git a/src/networksManager.js b/src/networksManager.js
index be3009c..efa6340 100644
--- a/src/networksManager.js
+++ b/src/networksManager.js
@@ -93,8 +93,7 @@ var NetworksManager = class {
getNetworkServers(id) {
let network = this._lookupNetwork(id);
let sslServers = network.servers.filter(s => s.ssl);
- return sslServers.length > 0 ? sslServers
- : network.servers.slice();
+ return sslServers.length > 0 ? sslServers : network.servers.slice();
}
getNetworkMatchTerms(id) {
diff --git a/src/roomList.js b/src/roomList.js
index b2c03e1..22de603 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -563,8 +563,8 @@ class RoomList extends Gtk.ListBox {
let index = this._rowToRoomIndex(row.get_index());
this.select_row(row);
- this._moveSelection(index == 0 ? Gtk.DirectionType.DOWN
- : Gtk.DirectionType.UP);
+ this._moveSelection(index == 0 ?
+ Gtk.DirectionType.DOWN : Gtk.DirectionType.UP);
let newSelected = this.get_selected_row();
if (newSelected != row)
diff --git a/src/roomManager.js b/src/roomManager.js
index 47ab5b2..6214531 100644
--- a/src/roomManager.js
+++ b/src/roomManager.js
@@ -187,8 +187,8 @@ var RoomManager = class {
ensureRoomForChannel(channel, time) {
let accountPath = channel.connection.get_account().object_path;
let targetContact = channel.target_contact;
- let channelName = targetContact ? targetContact.alias
- : channel.identifier;
+ let channelName = targetContact ?
+ targetContact.alias : channel.identifier;
let [, handleType] = channel.get_handle();
let room = this._ensureRoom(accountPath, channelName, handleType, time);
room.channel = channel;
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index e6985cc..592d345 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -335,8 +335,8 @@ var ServerRoomList = GObject.registerClass({
[checked, name, count, sensitive]);
store.move_before(iter, this._customRoomItem);
- let maxTime = this._filterTerms.length > 0 ? MS_PER_FILTER_IDLE
- : MS_PER_IDLE;
+ let maxTime = this._filterTerms.length > 0 ?
+ MS_PER_FILTER_IDLE : MS_PER_IDLE;
// Limit time spent in idle to leave room for drawing etc.
if (GLib.get_monotonic_time() - startTime > 1000 * maxTime)
return GLib.SOURCE_CONTINUE;
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 71b6bc8..6549738 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -199,8 +199,9 @@ class TelepathyClient extends Tp.BaseClient {
}
_onNetworkChanged(mon, connected) {
- let presence = connected ? Tp.ConnectionPresenceType.AVAILABLE
- : Tp.ConnectionPresenceType.OFFLINE;
+ let presence = connected ?
+ Tp.ConnectionPresenceType.AVAILABLE :
+ Tp.ConnectionPresenceType.OFFLINE;
debug(`Network changed to ${connected ? 'available' : 'unavailable'}`);
this._accountsMonitor.visibleAccounts.forEach(a => {
diff --git a/src/userTracker.js b/src/userTracker.js
index 8548b5b..c9328d7 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -255,8 +255,9 @@ const UserTracker = GObject.registerClass({
let baseNick = Polari.util_get_basenick(nickName);
let contacts = this._baseNickContacts.get(baseNick) || [];
- return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE
- : Tp.ConnectionPresenceType.AVAILABLE;
+ return contacts.length == 0 ?
+ Tp.ConnectionPresenceType.OFFLINE :
+ Tp.ConnectionPresenceType.AVAILABLE;
}
getNickRoomStatus(nickName, room) {
@@ -265,8 +266,9 @@ const UserTracker = GObject.registerClass({
this._ensureRoomMappingForRoom(room);
let contacts = this._getRoomContacts(room).get(baseNick) || [];
- return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE
- : Tp.ConnectionPresenceType.AVAILABLE;
+ return contacts.length == 0 ?
+ Tp.ConnectionPresenceType.OFFLINE :
+ Tp.ConnectionPresenceType.AVAILABLE;
}
lookupContact(nickName) {
@@ -317,8 +319,7 @@ const UserTracker = GObject.registerClass({
_shouldNotifyNick(nickName) {
let actionName = this._getNotifyActionNameInternal(nickName);
let state = this._app.get_action_state(actionName);
- return state ? state.get_boolean()
- : false;
+ return state ? state.get_boolean() : false;
}
_setNotifyActionEnabled(nickName, enabled) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]