Add `operator-linebreak` ESLint rule

Based on the following discussion:
https://github.com/signalapp/Signal-Desktop/pull/2040#discussion_r168029106
This commit is contained in:
Daniel Gasienica 2018-02-14 11:11:50 -05:00
parent 462defbe55
commit 41b92c0a31
5 changed files with 19 additions and 17 deletions

View File

@ -37,5 +37,7 @@ module.exports = {
// though we have a logger, we still remap console to log to disk
'no-console': 'off',
'operator-linebreak': ["error", "after", { "overrides": { '?': 'before', ':': 'before' } }]
}
};

View File

@ -117,8 +117,8 @@ function eliminateOutOfDateFiles(logPath, date) {
const file = {
path: target,
start: isLineAfterDate(start, date),
end: isLineAfterDate(end[end.length - 1], date)
|| isLineAfterDate(end[end.length - 2], date),
end: isLineAfterDate(end[end.length - 1], date) ||
isLineAfterDate(end[end.length - 2], date),
};
if (!file.start && !file.end) {

View File

@ -518,9 +518,9 @@
return ev.confirm();
}
const { type, id } = data.message.group ?
{ type: 'group', id: data.message.group.id } :
{ type: 'private', id: data.source };
const { type, id } = data.message.group
? { type: 'group', id: data.message.group.id }
: { type: 'private', id: data.source };
const processedMessage = await Message.process(data.message);

View File

@ -206,9 +206,9 @@
if (file === undefined) {
return Promise.resolve();
}
const attachmentFlags = this.isVoiceNote ?
textsecure.protobuf.AttachmentPointer.Flags.VOICE_MESSAGE :
null;
const attachmentFlags = this.isVoiceNote
? textsecure.protobuf.AttachmentPointer.Flags.VOICE_MESSAGE
: null;
const setFlags = flags => (attachment) => {
const newAttachment = Object.assign({}, attachment);

18
main.js
View File

@ -157,10 +157,10 @@ function isVisible(window, bounds) {
const topClearOfUpperBound = window.y >= boundsY;
const topClearOfLowerBound = (window.y <= (boundsY + boundsHeight) - BOUNDS_BUFFER);
return rightSideClearOfLeftBound
&& leftSideClearOfRightBound
&& topClearOfUpperBound
&& topClearOfLowerBound;
return rightSideClearOfLeftBound &&
leftSideClearOfRightBound &&
topClearOfUpperBound &&
topClearOfLowerBound;
}
function createWindow() {
@ -277,8 +277,8 @@ function createWindow() {
// Emitted when the window is about to be closed.
mainWindow.on('close', (e) => {
// If the application is terminating, just do the default
if (windowState.shouldQuit()
|| config.environment === 'test' || config.environment === 'test-lib') {
if (windowState.shouldQuit() ||
config.environment === 'test' || config.environment === 'test-lib') {
return;
}
@ -422,9 +422,9 @@ app.on('before-quit', () => {
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin'
|| config.environment === 'test'
|| config.environment === 'test-lib') {
if (process.platform !== 'darwin' ||
config.environment === 'test' ||
config.environment === 'test-lib') {
app.quit();
}
});