From e399474b4e2e2dffc625a0414232031ed290b81c Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 13 Mar 2020 23:57:34 +0000 Subject: [PATCH] Tools: Apply "curly" eslint rule --- .eslintrc.js | 1 + ElectronClient/checkForUpdates.js | 12 +++++++----- ElectronClient/gui/NoteTextViewer.jsx | 10 ++++++---- ElectronClient/gui/PromptDialog.jsx | 9 ++++++--- ReactNativeClient/lib/components/global-style.js | 5 +++-- ReactNativeClient/lib/components/screens/note.js | 9 ++++++--- .../lib/components/side-menu-content.js | 3 ++- ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js | 10 ++++++---- ReactNativeClient/lib/reducer.js | 8 ++++---- Tools/build-welcome.js | 10 ++++++---- 10 files changed, 47 insertions(+), 30 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 391628f04..47d4070bd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -68,6 +68,7 @@ module.exports = { // ------------------------------- "space-in-parens": ["error", "never"], "space-infix-ops": ["error"], + "curly": ["error", "multi-line", "consistent"], "semi": ["error", "always"], "eol-last": ["error", "always"], "quotes": ["error", "single"], diff --git a/ElectronClient/checkForUpdates.js b/ElectronClient/checkForUpdates.js index ee318cc07..1f571c6f5 100644 --- a/ElectronClient/checkForUpdates.js +++ b/ElectronClient/checkForUpdates.js @@ -132,11 +132,13 @@ function checkForUpdates(inBackground, window, logFilePath, options) { autoUpdateLogger_.info('Is Pre-release:', release.prerelease); if (compareVersions(release.version, packageInfo.version) <= 0) { - if (!checkInBackground_) await dialog.showMessageBox({ - type: 'info', - message: _('Current version is up-to-date.'), - buttons: [_('OK')], - }); + if (!checkInBackground_) { + await dialog.showMessageBox({ + type: 'info', + message: _('Current version is up-to-date.'), + buttons: [_('OK')], + }); + } } else { const fullReleaseNotes = release.notes.trim() ? `\n\n${release.notes.trim()}` : ''; const MAX_RELEASE_NOTES_LENGTH = 1000; diff --git a/ElectronClient/gui/NoteTextViewer.jsx b/ElectronClient/gui/NoteTextViewer.jsx index ec7533857..a301c97ab 100644 --- a/ElectronClient/gui/NoteTextViewer.jsx +++ b/ElectronClient/gui/NoteTextViewer.jsx @@ -36,10 +36,12 @@ class NoteTextViewerComponent extends React.Component { const callName = event.data.name; const args = event.data.args; - if (this.props.onIpcMessage) this.props.onIpcMessage({ - channel: callName, - args: args, - }); + if (this.props.onIpcMessage) { + this.props.onIpcMessage({ + channel: callName, + args: args, + }); + } } domReady() { diff --git a/ElectronClient/gui/PromptDialog.jsx b/ElectronClient/gui/PromptDialog.jsx index 9d2127c9e..4393a113b 100644 --- a/ElectronClient/gui/PromptDialog.jsx +++ b/ElectronClient/gui/PromptDialog.jsx @@ -230,24 +230,27 @@ class PromptDialog extends React.Component { } const buttonComps = []; - if (buttonTypes.indexOf('ok') >= 0) + if (buttonTypes.indexOf('ok') >= 0) { buttonComps.push( ); - if (buttonTypes.indexOf('cancel') >= 0) + } + if (buttonTypes.indexOf('cancel') >= 0) { buttonComps.push( ); - if (buttonTypes.indexOf('clear') >= 0) + } + if (buttonTypes.indexOf('clear') >= 0) { buttonComps.push( ); + } return (
diff --git a/ReactNativeClient/lib/components/global-style.js b/ReactNativeClient/lib/components/global-style.js index 242e22f68..c6300a1fb 100644 --- a/ReactNativeClient/lib/components/global-style.js +++ b/ReactNativeClient/lib/components/global-style.js @@ -123,8 +123,9 @@ function themeStyle(theme) { if (themeCache_[theme]) return themeCache_[theme]; const output = Object.assign({}, globalStyle); - if (theme == Setting.THEME_LIGHT) return addExtraStyles(output); - else if (theme == Setting.THEME_OLED_DARK) { + if (theme == Setting.THEME_LIGHT) { + return addExtraStyles(output); + } else if (theme == Setting.THEME_OLED_DARK) { output.backgroundColor = '#000000'; output.color = '#dddddd'; output.colorFaded = '#777777'; diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index c160335f9..53e5cd360 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -640,13 +640,14 @@ class NoteScreenComponent extends BaseScreenComponent { this.showOnMap_onPress(); }, }); - if (note.source_url) + if (note.source_url) { output.push({ title: _('Go to source URL'), onPress: () => { this.showSource_onPress(); }, }); + } return output; } @@ -695,26 +696,28 @@ class NoteScreenComponent extends BaseScreenComponent { this.share_onPress(); }, }); - if (isSaved) + if (isSaved) { output.push({ title: _('Tags'), onPress: () => { this.tags_onPress(); }, }); + } output.push({ title: isTodo ? _('Convert to note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); }, }); - if (isSaved) + if (isSaved) { output.push({ title: _('Copy Markdown link'), onPress: () => { this.copyMarkdownLink_onPress(); }, }); + } output.push({ title: _('Properties'), onPress: () => { diff --git a/ReactNativeClient/lib/components/side-menu-content.js b/ReactNativeClient/lib/components/side-menu-content.js index 34affcaa4..42c8b768d 100644 --- a/ReactNativeClient/lib/components/side-menu-content.js +++ b/ReactNativeClient/lib/components/side-menu-content.js @@ -336,12 +336,13 @@ class SideMenuContentComponent extends Component { items.push(this.renderSideBarButton('synchronize_button', !this.props.syncStarted ? _('Synchronise') : _('Cancel'), 'md-sync', this.synchronize_press)); - if (fullReport.length) + if (fullReport.length) { items.push( {fullReport.join('\n')} ); + } return {items}; } diff --git a/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js b/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js index 7cf7713a4..e5e1d67a2 100644 --- a/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js +++ b/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js @@ -73,10 +73,12 @@ class HtmlToHtml { this.cache_.put(cacheKey, html, 1000 * 60 * 10); - if (options.bodyOnly) return { - html: html, - pluginAssets: [], - }; + if (options.bodyOnly) { + return { + html: html, + pluginAssets: [], + }; + } let cssStrings = noteStyle(theme, options); diff --git a/ReactNativeClient/lib/reducer.js b/ReactNativeClient/lib/reducer.js index dab6c9464..1dcda4639 100644 --- a/ReactNativeClient/lib/reducer.js +++ b/ReactNativeClient/lib/reducer.js @@ -209,8 +209,7 @@ function handleItemDelete(state, action) { function updateOneItem(state, action, keyName = '') { let itemsKey = null; - if (keyName) itemsKey = keyName; - else { + if (keyName) { itemsKey = keyName; } else { if (action.type === 'TAG_UPDATE_ONE') itemsKey = 'tags'; if (action.type === 'FOLDER_UPDATE_ONE') itemsKey = 'folders'; if (action.type === 'MASTERKEY_UPDATE_ONE') itemsKey = 'masterKeys'; @@ -397,10 +396,11 @@ const reducer = (state = defaultState, action) => { case 'NOTE_SELECT_ALL_TOGGLE': { newState = Object.assign({}, state); const allSelected = state.notes.every(n => state.selectedNoteIds.includes(n.id)); - if (allSelected) + if (allSelected) { newState.selectedNoteIds = []; - else + } else { newState.selectedNoteIds = newState.notes.map(n => n.id); + } break; } diff --git a/Tools/build-welcome.js b/Tools/build-welcome.js index 76ff3ae04..19abd8ed2 100644 --- a/Tools/build-welcome.js +++ b/Tools/build-welcome.js @@ -119,10 +119,12 @@ async function main() { for (let j = 0; j < note.tags.length; j++) { const tagTitle = note.tags[j]; const tagId = itemIdFromPath(tagTitle); - if (!tagIdsToTag[tagId]) tagIdsToTag[tagId] = { - id: tagId, - title: tagTitle, - }; + if (!tagIdsToTag[tagId]) { + tagIdsToTag[tagId] = { + id: tagId, + title: tagTitle, + }; + } } notes.push(note);