From 14d2364fc69e0222133115c55a36286986006098 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Fri, 15 Oct 2021 09:48:06 +0200 Subject: chore: update eslint setup (#2074) --- src/actions/user.ts | 8 ++- src/components/layout/Sidebar.js | 4 +- .../services/content/ErrorHandlers/styles.ts | 2 +- src/components/services/content/ServiceView.js | 2 +- src/components/services/content/ServiceWebview.js | 36 ++++++---- src/components/services/tabs/TabBarSortableList.js | 10 +-- .../settings/settings/EditSettingsForm.js | 16 +++-- src/components/ui/Modal/styles.ts | 2 +- src/components/ui/ServiceIcon.js | 18 ++--- src/components/ui/WebviewLoader/styles.ts | 2 +- src/components/util/ErrorBoundary/styles.js | 2 +- src/containers/settings/EditSettingsScreen.js | 8 ++- src/containers/settings/RecipesScreen.js | 22 +++--- src/electron/exception.ts | 2 +- src/electron/ipc-api/sessionStorage.ts | 6 +- src/enforce-macos-app-location.ts | 18 +++-- src/environment-remote.ts | 18 ++++- src/features/settingsWS/actions.ts | 11 +-- src/features/todos/components/TodosWebview.js | 15 ++-- src/features/todos/containers/TodosScreen.js | 17 +++-- src/features/utils/ActionBinding.ts | 5 +- src/features/utils/FeatureStore.test.js | 21 +++--- .../workspaces/components/WorkspaceDrawerItem.js | 8 +-- .../workspaces/components/WorkspacesDashboard.js | 3 +- src/features/workspaces/store.js | 46 +++++++----- src/helpers/array-helpers.ts | 9 +-- src/helpers/async-helpers.ts | 4 +- src/helpers/routing-helpers.ts | 3 +- src/helpers/schedule-helpers.ts | 53 ++++---------- src/helpers/url-helpers.ts | 5 +- .../app/Controllers/Http/RecipeController.js | 2 - .../app/Controllers/Http/ServiceController.js | 2 +- .../app/Controllers/Http/UserController.js | 5 +- .../app/Controllers/Http/WorkspaceController.js | 2 +- src/internal-server/config/app.js | 1 - src/internal-server/config/bodyParser.js | 12 +--- .../database/migrations/1503250034279_user.js | 2 +- .../migrations/1566385379883_service_schema.js | 2 +- .../migrations/1566554231482_recipe_schema.js | 2 +- .../migrations/1566554359294_workspace_schema.js | 2 +- src/internal-server/start/app.js | 9 +-- src/jsUtils.ts | 17 ++++- src/lib/Tray.js | 53 ++++++++++---- src/models/Recipe.ts | 67 +++++++++++++----- src/models/User.ts | 3 +- src/models/UserAgent.js | 8 ++- src/stores/RecipePreviewsStore.js | 12 +++- src/stores/ServicesStore.js | 2 +- src/stores/SettingsStore.js | 6 +- src/stores/UserStore.js | 2 - src/stores/lib/Request.js | 82 ++++++++++++++-------- src/stores/lib/Store.js | 3 +- src/webview/badge.ts | 13 ++-- src/webview/contextMenuBuilder.ts | 4 +- src/webview/spellchecker.ts | 6 +- 55 files changed, 416 insertions(+), 279 deletions(-) (limited to 'src') diff --git a/src/actions/user.ts b/src/actions/user.ts index 20d27ee53..15a9216bd 100644 --- a/src/actions/user.ts +++ b/src/actions/user.ts @@ -25,8 +25,10 @@ export default { userData: PropTypes.object.isRequired, }, resetStatus: {}, - importLegacyServices: PropTypes.arrayOf(PropTypes.shape({ - recipe: PropTypes.string.isRequired, - })).isRequired, + importLegacyServices: PropTypes.arrayOf( + PropTypes.shape({ + recipe: PropTypes.string.isRequired, + }), + ).isRequired, delete: {}, }; diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js index 76edcf2e1..fc33a3c58 100644 --- a/src/components/layout/Sidebar.js +++ b/src/components/layout/Sidebar.js @@ -177,7 +177,7 @@ class Sidebar extends Component { > - ) : null} + ) : null} {workspaceStore.isFeatureEnabled ? ( {this.state.tooltipEnabled && ( diff --git a/src/components/services/content/ErrorHandlers/styles.ts b/src/components/services/content/ErrorHandlers/styles.ts index 72d62f5e3..9e2509ee5 100644 --- a/src/components/services/content/ErrorHandlers/styles.ts +++ b/src/components/services/content/ErrorHandlers/styles.ts @@ -1,4 +1,4 @@ -export default (theme) => ({ +export default theme => ({ component: { left: 0, position: 'absolute', diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js index 8e44efc5f..1bc1fbf5f 100644 --- a/src/components/services/content/ServiceView.js +++ b/src/components/services/content/ServiceView.js @@ -123,7 +123,7 @@ class ServiceView extends Component { service.isFirstLoad && !service.isServiceAccessRestricted && ( - )} + )} {service.isError && ( ( - this.webview - ), + () => this.webview, () => { if (this.webview && this.webview.view) { - this.webview.view.addEventListener('console-message', (e) => { + this.webview.view.addEventListener('console-message', e => { debug('Service logged a message:', e.message); }); } @@ -55,20 +53,26 @@ class ServiceWebview extends Component { }; render() { - const { - service, - setWebviewReference, - isSpellcheckerEnabled, - } = this.props; + const { service, setWebviewReference, isSpellcheckerEnabled } = this.props; - const preloadScript = join(__dirname, '..', '..', '..', 'webview', 'recipe.js'); + const preloadScript = join( + __dirname, + '..', + '..', + '..', + 'webview', + 'recipe.js', + ); return ( { + ref={webview => { this.webview = webview; if (webview && webview.view) { - webview.view.addEventListener('did-stop-loading', this.refocusWebview); + webview.view.addEventListener( + 'did-stop-loading', + this.refocusWebview, + ); } }} autosize @@ -83,10 +87,14 @@ class ServiceWebview extends Component { }} onUpdateTargetUrl={this.updateTargetUrl} useragent={service.userAgent} - disablewebsecurity={service.recipe.disablewebsecurity ? true : undefined} + disablewebsecurity={ + service.recipe.disablewebsecurity ? true : undefined + } allowpopups nodeintegration - webpreferences={`spellcheck=${isSpellcheckerEnabled ? 1 : 0}, contextIsolation=1, enableRemoteModule=1`} + webpreferences={`spellcheck=${ + isSpellcheckerEnabled ? 1 : 0 + }, contextIsolation=1, enableRemoteModule=1`} /> ); } diff --git a/src/components/services/tabs/TabBarSortableList.js b/src/components/services/tabs/TabBarSortableList.js index 146cd93eb..69a12e982 100644 --- a/src/components/services/tabs/TabBarSortableList.js +++ b/src/components/services/tabs/TabBarSortableList.js @@ -22,7 +22,7 @@ class TabBarSortableList extends Component { wakeUpService: PropTypes.func.isRequired, showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, - } + }; render() { const { @@ -43,9 +43,7 @@ class TabBarSortableList extends Component { } = this.props; return ( -
    +
      {services.map((service, index) => ( reload({ serviceId: service.id })} - toggleNotifications={() => toggleNotifications({ serviceId: service.id })} + toggleNotifications={() => + toggleNotifications({ serviceId: service.id }) + } toggleAudio={() => toggleAudio({ serviceId: service.id })} toggleDarkMode={() => toggleDarkMode({ serviceId: service.id })} deleteService={() => deleteService({ serviceId: service.id })} diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 40242858a..948e9ccd5 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js @@ -12,13 +12,17 @@ import ToggleRaw from '../../ui/ToggleRaw'; import Select from '../../ui/Select'; import Input from '../../ui/Input'; -import { DEFAULT_APP_SETTINGS, FRANZ_TRANSLATION, GITHUB_FRANZ_URL } from '../../../config'; import { - isMac, - isWindows, - lockFerdiShortcutKey, -} from '../../../environment'; -import { ferdiVersion, userDataPath, userDataRecipesPath } from '../../../environment-remote'; + DEFAULT_APP_SETTINGS, + FRANZ_TRANSLATION, + GITHUB_FRANZ_URL, +} from '../../../config'; +import { isMac, isWindows, lockFerdiShortcutKey } from '../../../environment'; +import { + ferdiVersion, + userDataPath, + userDataRecipesPath, +} from '../../../environment-remote'; import { openPath } from '../../../helpers/url-helpers'; import globalMessages from '../../../i18n/globalMessages'; diff --git a/src/components/ui/Modal/styles.ts b/src/components/ui/Modal/styles.ts index f32c075ce..c2bebf9bb 100644 --- a/src/components/ui/Modal/styles.ts +++ b/src/components/ui/Modal/styles.ts @@ -1,4 +1,4 @@ -export default (theme) => ({ +export default theme => ({ component: { zIndex: 500, position: 'absolute', diff --git a/src/components/ui/ServiceIcon.js b/src/components/ui/ServiceIcon.js index 2e9312d27..f067f8955 100644 --- a/src/components/ui/ServiceIcon.js +++ b/src/components/ui/ServiceIcon.js @@ -6,7 +6,7 @@ import classnames from 'classnames'; import ServiceModel from '../../models/Service'; -const styles = (theme) => ({ +const styles = theme => ({ root: { height: 'auto', }, @@ -24,7 +24,8 @@ const styles = (theme) => ({ }, }); -@injectSheet(styles) @observer +@injectSheet(styles) +@observer class ServiceIcon extends Component { static propTypes = { classes: PropTypes.object.isRequired, @@ -37,19 +38,10 @@ class ServiceIcon extends Component { }; render() { - const { - classes, - className, - service, - } = this.props; + const { classes, className, service } = this.props; return ( -
      +
      ({ +export default theme => ({ component: { background: theme.colorWebviewLoaderBackground, padding: 20, diff --git a/src/components/util/ErrorBoundary/styles.js b/src/components/util/ErrorBoundary/styles.js index 51b36fdf3..0960546ff 100644 --- a/src/components/util/ErrorBoundary/styles.js +++ b/src/components/util/ErrorBoundary/styles.js @@ -1,4 +1,4 @@ -export default (theme) => ({ +export default theme => ({ component: { display: 'flex', width: '100%', diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 889f3f87f..aea077a1e 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js @@ -297,7 +297,9 @@ class EditSettingsScreen extends Component { scheduledDNDStart: settingsData.scheduledDNDStart, scheduledDNDEnd: settingsData.scheduledDNDEnd, enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration), - enableGlobalHideShortcut: Boolean(settingsData.enableGlobalHideShortcut), + enableGlobalHideShortcut: Boolean( + settingsData.enableGlobalHideShortcut, + ), showDisabledServices: Boolean(settingsData.showDisabledServices), darkMode: Boolean(settingsData.darkMode), adaptableDarkMode: Boolean(settingsData.adaptableDarkMode), @@ -305,7 +307,9 @@ class EditSettingsScreen extends Component { splitMode: Boolean(settingsData.splitMode), serviceRibbonWidth: Number(settingsData.serviceRibbonWidth), iconSize: Number(settingsData.iconSize), - enableLongPressServiceHint: Boolean(settingsData.enableLongPressServiceHint), + enableLongPressServiceHint: Boolean( + settingsData.enableLongPressServiceHint, + ), useVerticalStyle: Boolean(settingsData.useVerticalStyle), alwaysShowWorkspaces: Boolean(settingsData.alwaysShowWorkspaces), accentColor: settingsData.accentColor, diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index 832c2db10..7f55e54c5 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js @@ -130,21 +130,21 @@ class RecipesScreen extends Component { const allRecipes = this.state.needle ? this.prepareRecipes([ - // All search recipes from server - ...recipePreviews.searchResults, - // All search recipes from local recipes - ...this.createPreviews( - this.customRecipes.filter( - service => - service.name - .toLowerCase() - .includes(this.state.needle.toLowerCase()) || + // All search recipes from server + ...recipePreviews.searchResults, + // All search recipes from local recipes + ...this.createPreviews( + this.customRecipes.filter( + service => + service.name + .toLowerCase() + .includes(this.state.needle.toLowerCase()) || (service.aliases || []).some(alias => alias.toLowerCase().includes(this.state.needle.toLowerCase()), ), + ), ), - ), - ]).sort(this._sortByName) + ]).sort(this._sortByName) : recipeFilter; const customWebsiteRecipe = recipePreviews.all.find( diff --git a/src/electron/exception.ts b/src/electron/exception.ts index 0065e2604..ada98d17b 100644 --- a/src/electron/exception.ts +++ b/src/electron/exception.ts @@ -1,4 +1,4 @@ -process.on('uncaughtException', (err) => { +process.on('uncaughtException', err => { // handle the error safely console.error(err); }); diff --git a/src/electron/ipc-api/sessionStorage.ts b/src/electron/ipc-api/sessionStorage.ts index 3eda568a1..1ff0a51ea 100644 --- a/src/electron/ipc-api/sessionStorage.ts +++ b/src/electron/ipc-api/sessionStorage.ts @@ -6,7 +6,11 @@ const debug = require('debug')('Ferdi:ipcApi:sessionStorage'); function deduceSession(serviceId: string | undefined | null): Session { if (serviceId) { - return session.fromPartition(serviceId === TODOS_PARTITION_ID ? TODOS_PARTITION_ID : `persist:service-${serviceId}`); + return session.fromPartition( + serviceId === TODOS_PARTITION_ID + ? TODOS_PARTITION_ID + : `persist:service-${serviceId}`, + ); } return session.defaultSession; } diff --git a/src/enforce-macos-app-location.ts b/src/enforce-macos-app-location.ts index 0f858013d..0e6bf9ecc 100644 --- a/src/enforce-macos-app-location.ts +++ b/src/enforce-macos-app-location.ts @@ -12,11 +12,9 @@ export function enforceMacOSAppLocation() { const clickedButtonIndex = api.dialog.showMessageBoxSync({ type: 'error', message: 'Move to Applications folder?', - detail: 'Ferdi must live in the Applications folder to be able to run correctly.', - buttons: [ - 'Move to Applications folder', - 'Quit Ferdi', - ], + detail: + 'Ferdi must live in the Applications folder to be able to run correctly.', + buttons: ['Move to Applications folder', 'Quit Ferdi'], defaultId: 0, cancelId: 1, }); @@ -28,13 +26,13 @@ export function enforceMacOSAppLocation() { api.app.moveToApplicationsFolder({ conflictHandler: conflict => { - if (conflict === 'existsAndRunning') { // Can't replace the active version of the app + if (conflict === 'existsAndRunning') { + // Can't replace the active version of the app api.dialog.showMessageBoxSync({ type: 'error', - message: 'Another version of Ferdi is currently running. Quit it, then launch this version of the app again.', - buttons: [ - 'OK', - ], + message: + 'Another version of Ferdi is currently running. Quit it, then launch this version of the app again.', + buttons: ['OK'], }); api.app.quit(); diff --git a/src/environment-remote.ts b/src/environment-remote.ts index 192510f37..c87e89772 100644 --- a/src/environment-remote.ts +++ b/src/environment-remote.ts @@ -14,7 +14,13 @@ import { LOCAL_TODOS_FRONTEND_URL, PRODUCTION_TODOS_FRONTEND_URL, } from './config'; -import { chromeVersion, electronVersion, isWindows, nodeVersion, osArch } from './environment'; +import { + chromeVersion, + electronVersion, + isWindows, + nodeVersion, + osArch, +} from './environment'; // @ts-expect-error Cannot find module './buildInfo.json' or its corresponding type declarations. import * as buildInfo from './buildInfo.json'; @@ -28,14 +34,20 @@ if (process.env.FERDI_APPDATA_DIR != null) { app.setPath('appData', process.env.FERDI_APPDATA_DIR); app.setPath('userData', app.getPath('appData')); } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { - app.setPath('appData', join(process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`)); + app.setPath( + 'appData', + join(process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`), + ); app.setPath('userData', join(app.getPath('appData'), `${app.name}AppData`)); } else if (isWindows && process.env.APPDATA != null) { app.setPath('appData', process.env.APPDATA); app.setPath('userData', join(app.getPath('appData'), app.name)); } -export const isDevMode = process.env.ELECTRON_IS_DEV !== undefined ? Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1 : !app.isPackaged; +export const isDevMode = + process.env.ELECTRON_IS_DEV !== undefined + ? Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1 + : !app.isPackaged; if (isDevMode) { app.setPath('userData', join(app.getPath('appData'), `${app.name}Dev`)); } diff --git a/src/features/settingsWS/actions.ts b/src/features/settingsWS/actions.ts index 631670c8a..03a398eb5 100755 --- a/src/features/settingsWS/actions.ts +++ b/src/features/settingsWS/actions.ts @@ -1,10 +1,13 @@ import PropTypes from 'prop-types'; import { createActionsFromDefinitions } from '../../actions/lib/actions'; -export const settingsWSActions = createActionsFromDefinitions({ - greet: { - name: PropTypes.string.isRequired, +export const settingsWSActions = createActionsFromDefinitions( + { + greet: { + name: PropTypes.string.isRequired, + }, }, -}, PropTypes.checkPropTypes); + PropTypes.checkPropTypes, +); export default settingsWSActions; diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js index b31c7d858..1d423544b 100644 --- a/src/features/todos/components/TodosWebview.js +++ b/src/features/todos/components/TodosWebview.js @@ -7,14 +7,15 @@ import classnames from 'classnames'; import { TODOS_PARTITION_ID } from '../../../config'; -const styles = (theme) => ({ +const styles = theme => ({ root: { background: theme.colorBackground, position: 'relative', borderLeft: [1, 'solid', theme.todos.todosLayer.borderLeftColor], zIndex: 300, - transform: ({ isVisible, width, isTodosServiceActive }) => `translateX(${isVisible || isTodosServiceActive ? 0 : width}px)`, + transform: ({ isVisible, width, isTodosServiceActive }) => + `translateX(${isVisible || isTodosServiceActive ? 0 : width}px)`, '& webview': { height: '100%', @@ -79,7 +80,7 @@ class TodosWebview extends Component { this.node.addEventListener('mouseleave', this.stopResize.bind(this)); } - startResize = (event) => { + startResize = event => { this.setState({ isDragging: true, initialPos: event.clientX, @@ -126,7 +127,7 @@ class TodosWebview extends Component { startListeningToIpcMessages() { const { handleClientMessage } = this.props; if (!this.webview) return; - this.webview.addEventListener('ipc-message', (e) => { + this.webview.addEventListener('ipc-message', e => { // console.log(e); handleClientMessage({ channel: e.channel, message: e.args[0] }); }); @@ -159,7 +160,7 @@ class TodosWebview extends Component { })} style={{ width: displayedWidth }} onMouseUp={() => this.stopResize()} - ref={(node) => { + ref={node => { this.node = node; }} id="todos-panel" @@ -170,7 +171,7 @@ class TodosWebview extends Component { left: delta, ...(isDragging ? { width: 600, marginLeft: -200 } : {}), }} // This hack is required as resizing with webviews beneath behaves quite bad - onMouseDown={(e) => this.startResize(e)} + onMouseDown={e => this.startResize(e)} /> {isDragging && (
      { + ref={webview => { this.webview = webview ? webview.view : null; }} useragent={userAgent} diff --git a/src/features/todos/containers/TodosScreen.js b/src/features/todos/containers/TodosScreen.js index c2b6a5af4..536810d2d 100644 --- a/src/features/todos/containers/TodosScreen.js +++ b/src/features/todos/containers/TodosScreen.js @@ -10,24 +10,31 @@ import { TODOS_MIN_WIDTH } from '../../../config'; import { todoActions } from '../actions'; import ServicesStore from '../../../stores/ServicesStore'; -@inject('stores', 'actions') @observer +@inject('stores', 'actions') +@observer class TodosScreen extends Component { render() { - if (!todosStore || !todosStore.isFeatureActive || todosStore.isTodosPanelForceHidden) { + if ( + !todosStore || + !todosStore.isFeatureActive || + todosStore.isTodosPanelForceHidden + ) { return null; } return ( todoActions.setTodosWebview({ webview })} + setTodosWebview={webview => todoActions.setTodosWebview({ webview })} width={todosStore.width} minWidth={TODOS_MIN_WIDTH} - resize={(width) => todoActions.resize({ width })} + resize={width => todoActions.resize({ width })} userAgent={todosStore.userAgent} todoUrl={todosStore.todoUrl} isTodoUrlValid={todosStore.isTodoUrlValid} diff --git a/src/features/utils/ActionBinding.ts b/src/features/utils/ActionBinding.ts index 787166d44..16308fae4 100644 --- a/src/features/utils/ActionBinding.ts +++ b/src/features/utils/ActionBinding.ts @@ -24,6 +24,5 @@ export default class ActionBinding { } } -export const createActionBindings = (actions) => ( - actions.map((a) => new ActionBinding(a)) -); +export const createActionBindings = actions => + actions.map(a => new ActionBinding(a)); diff --git a/src/features/utils/FeatureStore.test.js b/src/features/utils/FeatureStore.test.js index 92308bf52..1995431bd 100644 --- a/src/features/utils/FeatureStore.test.js +++ b/src/features/utils/FeatureStore.test.js @@ -5,9 +5,12 @@ import { createActionsFromDefinitions } from '../../actions/lib/actions'; import { createActionBindings } from './ActionBinding'; import { createReactions } from '../../stores/lib/Reaction'; -const actions = createActionsFromDefinitions({ - countUp: {}, -}, PropTypes.checkPropTypes); +const actions = createActionsFromDefinitions( + { + countUp: {}, + }, + PropTypes.checkPropTypes, +); class TestFeatureStore extends FeatureStore { @observable count = 0; @@ -15,12 +18,10 @@ class TestFeatureStore extends FeatureStore { reactionInvokedCount = 0; start() { - this._registerActions(createActionBindings([ - [actions.countUp, this._countUp], - ])); - this._registerReactions(createReactions([ - this._countReaction, - ])); + this._registerActions( + createActionBindings([[actions.countUp, this._countUp]]), + ); + this._registerReactions(createReactions([this._countReaction])); } _countUp = () => { @@ -29,7 +30,7 @@ class TestFeatureStore extends FeatureStore { _countReaction = () => { this.reactionInvokedCount += 1; - } + }; } describe('FeatureStore', () => { diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.js b/src/features/workspaces/components/WorkspaceDrawerItem.js index 237f9488b..d3c9fa767 100644 --- a/src/features/workspaces/components/WorkspaceDrawerItem.js +++ b/src/features/workspaces/components/WorkspaceDrawerItem.js @@ -118,14 +118,12 @@ class WorkspaceDrawerItem extends Component { isActive ? classes.isActiveItem : null, ])} onClick={onClick} - onContextMenu={() => - onContextMenuEditClick && contextMenu.popup() - } + onContextMenu={() => onContextMenuEditClick && contextMenu.popup()} data-tip={`${ shortcutIndex <= 9 ? `(${cmdOrCtrlShortcutKey(false)}+${altKey( - false, - )}+${shortcutIndex})` + false, + )}+${shortcutIndex})` : '' }`} > diff --git a/src/features/workspaces/components/WorkspacesDashboard.js b/src/features/workspaces/components/WorkspacesDashboard.js index 78b758e7d..8ab9174d3 100644 --- a/src/features/workspaces/components/WorkspacesDashboard.js +++ b/src/features/workspaces/components/WorkspacesDashboard.js @@ -40,7 +40,8 @@ const messages = defineMessages({ }, workspaceFeatureInfo: { id: 'settings.workspaces.workspaceFeatureInfo', - defaultMessage: 'Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time. You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.', + defaultMessage: + 'Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time. You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.', }, workspaceFeatureHeadline: { id: 'settings.workspaces.workspaceFeatureHeadline', diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index db2b69f99..0fa43b723 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js @@ -124,7 +124,7 @@ export default class WorkspacesStore extends FeatureStore { this.isFeatureActive = false; } - filterServicesByActiveWorkspace = (services) => { + filterServicesByActiveWorkspace = services => { const { activeWorkspace, isFeatureActive } = this; if (isFeatureActive && activeWorkspace) { return this.getWorkspaceServices(activeWorkspace); @@ -134,14 +134,14 @@ export default class WorkspacesStore extends FeatureStore { getWorkspaceServices(workspace) { const { services } = this.stores; - return workspace.services.map((id) => services.one(id)).filter((s) => !!s); + return workspace.services.map(id => services.one(id)).filter(s => !!s); } // ========== PRIVATE METHODS ========= // - _getWorkspaceById = (id) => this.workspaces.find((w) => w.id === id); + _getWorkspaceById = id => this.workspaces.find(w => w.id === id); - _updateSettings = (changes) => { + _updateSettings = changes => { localStorage.setItem('workspaces', { ...this.settings, ...changes, @@ -191,9 +191,15 @@ export default class WorkspacesStore extends FeatureStore { this.isSwitchingWorkspace = false; this.nextWorkspace = null; if (this.stores.settings.app.splitMode) { - const serviceNames = new Set(this.getWorkspaceServices(workspace).map(service => service.name)); - for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { - wrapper.style.display = serviceNames.has(wrapper.dataset.name) ? '' : 'none'; + const serviceNames = new Set( + this.getWorkspaceServices(workspace).map(service => service.name), + ); + for (const wrapper of document.querySelectorAll( + '.services__webview-wrapper', + )) { + wrapper.style.display = serviceNames.has(wrapper.dataset.name) + ? '' + : 'none'; } } }, 1000); @@ -212,7 +218,9 @@ export default class WorkspacesStore extends FeatureStore { setTimeout(() => { this.isSwitchingWorkspace = false; if (this.stores.settings.app.splitMode) { - for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { + for (const wrapper of document.querySelectorAll( + '.services__webview-wrapper', + )) { wrapper.style.display = ''; } } @@ -262,7 +270,8 @@ export default class WorkspacesStore extends FeatureStore { const activeService = this.stores.services.active; const workspaceServices = this.getWorkspaceServices(this.activeWorkspace); if (workspaceServices.length <= 0) return; - const isActiveServiceInWorkspace = workspaceServices.includes(activeService); + const isActiveServiceInWorkspace = + workspaceServices.includes(activeService); if (!isActiveServiceInWorkspace) { this.actions.service.setActive({ serviceId: workspaceServices[0].id, @@ -288,8 +297,10 @@ export default class WorkspacesStore extends FeatureStore { const isWorkspaceSettingsRoute = router.location.pathname.includes( WORKSPACES_ROUTES.ROOT, ); - const isSwitchingToSettingsRoute = !this.isSettingsRouteActive && isWorkspaceSettingsRoute; - const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this.isSettingsRouteActive; + const isSwitchingToSettingsRoute = + !this.isSettingsRouteActive && isWorkspaceSettingsRoute; + const isLeavingSettingsRoute = + !isWorkspaceSettingsRoute && this.isSettingsRouteActive; if (isSwitchingToSettingsRoute) { this.isSettingsRouteActive = true; @@ -300,8 +311,8 @@ export default class WorkspacesStore extends FeatureStore { } else if (isLeavingSettingsRoute) { this.isSettingsRouteActive = false; if ( - !this._wasDrawerOpenBeforeSettingsRoute - && this.isWorkspaceDrawerOpen + !this._wasDrawerOpenBeforeSettingsRoute && + this.isWorkspaceDrawerOpen ) { workspaceActions.toggleWorkspaceDrawer(); } @@ -311,14 +322,15 @@ export default class WorkspacesStore extends FeatureStore { _cleanupInvalidServiceReferences = () => { const { services } = this.stores; const { allServicesRequest } = services; - const servicesHaveBeenLoaded = allServicesRequest.wasExecuted && !allServicesRequest.isError; + const servicesHaveBeenLoaded = + allServicesRequest.wasExecuted && !allServicesRequest.isError; // Loop through all workspaces and remove invalid service ids (locally) for (const workspace of this.workspaces) { for (const serviceId of workspace.services) { if ( - servicesHaveBeenLoaded - && !services.one(serviceId) - && serviceId !== KEEP_WS_LOADED_USID + servicesHaveBeenLoaded && + !services.one(serviceId) && + serviceId !== KEEP_WS_LOADED_USID ) { workspace.services.remove(serviceId); } diff --git a/src/helpers/array-helpers.ts b/src/helpers/array-helpers.ts index ae5d8d99f..3f8806176 100644 --- a/src/helpers/array-helpers.ts +++ b/src/helpers/array-helpers.ts @@ -1,4 +1,5 @@ -export const shuffleArray = (arr: any[]) => arr - .map((a) => [Math.random(), a]) - .sort((a, b) => a[0] - b[0]) - .map((a) => a[1]); +export const shuffleArray = (arr: any[]) => + arr + .map(a => [Math.random(), a]) + .sort((a, b) => a[0] - b[0]) + .map(a => a[1]); diff --git a/src/helpers/async-helpers.ts b/src/helpers/async-helpers.ts index aae3c3928..6b1f24b5a 100644 --- a/src/helpers/async-helpers.ts +++ b/src/helpers/async-helpers.ts @@ -1,5 +1,3 @@ -/* eslint-disable import/prefer-default-export */ - export function sleep(ms: number = 0) { - return new Promise((r) => setTimeout(r, ms)); + return new Promise(r => setTimeout(r, ms)); } diff --git a/src/helpers/routing-helpers.ts b/src/helpers/routing-helpers.ts index 18169f01b..46895aa6b 100644 --- a/src/helpers/routing-helpers.ts +++ b/src/helpers/routing-helpers.ts @@ -1,3 +1,4 @@ import RouteParser from 'route-parser'; -export const matchRoute = (pattern: string, path: string) => new RouteParser(pattern).match(path); +export const matchRoute = (pattern: string, path: string) => + new RouteParser(pattern).match(path); diff --git a/src/helpers/schedule-helpers.ts b/src/helpers/schedule-helpers.ts index 55b7c1e6f..37caffd79 100644 --- a/src/helpers/schedule-helpers.ts +++ b/src/helpers/schedule-helpers.ts @@ -1,17 +1,9 @@ -/* eslint-disable import/prefer-default-export */ - export function isInTimeframe(start: string, end: string) { - const [ - startHourStr, - startMinuteStr, - ] = start.split(':'); + const [startHourStr, startMinuteStr] = start.split(':'); const startHour = Number.parseInt(startHourStr, 10); const startMinute = Number.parseInt(startMinuteStr, 10); - const [ - endHourStr, - endMinuteStr, - ] = end.split(':'); + const [endHourStr, endMinuteStr] = end.split(':'); const endHour = Number.parseInt(endHourStr, 10); const endMinute = Number.parseInt(endMinuteStr, 10); @@ -20,46 +12,31 @@ export function isInTimeframe(start: string, end: string) { // Check if the end time is before the start time (scheduled overnight) // as we need to change our checks based on this - const endBeforeStart = (startHour > endHour || (startHour === endHour && startMinute > endMinute)); + const endBeforeStart = + startHour > endHour || (startHour === endHour && startMinute > endMinute); if ( // End is after start (e.g. 09:00-17:00) - !endBeforeStart + !endBeforeStart && // Check if past start - && ((currentHour > startHour - || ( - currentHour === startHour - && currentMinute >= startMinute - ) - ) - // Check that not past end - && (currentHour < endHour - || ( - currentHour === endHour - && currentMinute < endMinute - ) - )) + (currentHour > startHour || + (currentHour === startHour && currentMinute >= startMinute)) && + // Check that not past end + (currentHour < endHour || + (currentHour === endHour && currentMinute < endMinute)) ) { // We are in scheduled timeframe return true; } if ( // End is before start (e.g. 17:00-09:00) - endBeforeStart + endBeforeStart && // Check if past start - && ((currentHour > startHour - || ( - currentHour === startHour - && currentMinute >= startMinute - ) - ) + (currentHour > startHour || + (currentHour === startHour && currentMinute >= startMinute) || // Check that we are not past end - || (currentHour < endHour - || ( - currentHour === endHour - && currentMinute < endMinute - ) - )) + currentHour < endHour || + (currentHour === endHour && currentMinute < endMinute)) ) { // We are also in scheduled timeframe return true; diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts index 1e87ecabb..135f06cbf 100644 --- a/src/helpers/url-helpers.ts +++ b/src/helpers/url-helpers.ts @@ -29,7 +29,10 @@ export async function openPath(folderName: string) { } // TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check -export function openExternalUrl(url: string | URL, skipValidityCheck: boolean = false) { +export function openExternalUrl( + url: string | URL, + skipValidityCheck: boolean = false, +) { debug('Open url:', url, 'with skipValidityCheck:', skipValidityCheck); if (skipValidityCheck || isValidExternalURL(url)) { shell.openExternal(url.toString()); diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index d44839db1..1b0ac7035 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js @@ -56,7 +56,6 @@ class RecipeController { let remoteResults = []; // eslint-disable-next-line eqeqeq if (Env.get('CONNECT_WITH_FRANZ') == 'true') { - // eslint-disable-line eqeqeq remoteResults = JSON.parse( await ( await fetch( @@ -112,7 +111,6 @@ class RecipeController { } // eslint-disable-next-line eqeqeq if (Env.get('CONNECT_WITH_FRANZ') == 'true') { - // eslint-disable-line eqeqeq return response.redirect(`${RECIPES_URL}/download/${service}`); } return response.status(400).send({ diff --git a/src/internal-server/app/Controllers/Http/ServiceController.js b/src/internal-server/app/Controllers/Http/ServiceController.js index 133473b68..dedb5a12b 100644 --- a/src/internal-server/app/Controllers/Http/ServiceController.js +++ b/src/internal-server/app/Controllers/Http/ServiceController.js @@ -36,7 +36,7 @@ class ServiceController { } while ( (await Service.query().where('serviceId', serviceId).fetch()).rows .length > 0 - ); // eslint-disable-line no-await-in-loop + ); await Service.create({ serviceId, diff --git a/src/internal-server/app/Controllers/Http/UserController.js b/src/internal-server/app/Controllers/Http/UserController.js index 25b5277bd..2ecc8241c 100644 --- a/src/internal-server/app/Controllers/Http/UserController.js +++ b/src/internal-server/app/Controllers/Http/UserController.js @@ -171,7 +171,6 @@ class UserController { return response.status(401).send(errorMessage); } - // eslint-disable-next-line prefer-destructuring token = content.token; } catch (error) { return response.status(401).send({ @@ -300,7 +299,7 @@ class UserController { } while ( (await Workspace.query().where('workspaceId', newWorkspaceId).fetch()) .rows.length > 0 - ); // eslint-disable-line no-await-in-loop + ); if ( workspace.services && @@ -340,7 +339,7 @@ class UserController { } while ( (await Service.query().where('serviceId', newServiceId).fetch()).rows .length > 0 - ); // eslint-disable-line no-await-in-loop + ); // store the old serviceId as the key for future lookup serviceIdTranslation[service.serviceId] = newServiceId; diff --git a/src/internal-server/app/Controllers/Http/WorkspaceController.js b/src/internal-server/app/Controllers/Http/WorkspaceController.js index 9d461135e..528721f13 100644 --- a/src/internal-server/app/Controllers/Http/WorkspaceController.js +++ b/src/internal-server/app/Controllers/Http/WorkspaceController.js @@ -27,7 +27,7 @@ class WorkspaceController { } while ( (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows .length > 0 - ); // eslint-disable-line no-await-in-loop + ); const order = (await Workspace.all()).rows.length; const { name } = data; diff --git a/src/internal-server/config/app.js b/src/internal-server/config/app.js index 0a1644932..379190734 100644 --- a/src/internal-server/config/app.js +++ b/src/internal-server/config/app.js @@ -2,7 +2,6 @@ const Env = use('Env'); module.exports = { - /* |-------------------------------------------------------------------------- | Application Name diff --git a/src/internal-server/config/bodyParser.js b/src/internal-server/config/bodyParser.js index 8a5406f9e..ef2eedf40 100644 --- a/src/internal-server/config/bodyParser.js +++ b/src/internal-server/config/bodyParser.js @@ -58,9 +58,7 @@ module.exports = { | */ raw: { - types: [ - 'text/*', - ], + types: ['text/*'], }, /* @@ -72,9 +70,7 @@ module.exports = { | */ form: { - types: [ - 'application/x-www-form-urlencoded', - ], + types: ['application/x-www-form-urlencoded'], }, /* @@ -86,9 +82,7 @@ module.exports = { | */ files: { - types: [ - 'multipart/form-data', - ], + types: ['multipart/form-data'], /* |-------------------------------------------------------------------------- diff --git a/src/internal-server/database/migrations/1503250034279_user.js b/src/internal-server/database/migrations/1503250034279_user.js index 80b49020a..d502e4fa0 100644 --- a/src/internal-server/database/migrations/1503250034279_user.js +++ b/src/internal-server/database/migrations/1503250034279_user.js @@ -3,7 +3,7 @@ const Schema = use('Schema'); class UserSchema extends Schema { up() { - this.create('users', (table) => { + this.create('users', table => { table.increments(); table.json('settings'); table.timestamps(); diff --git a/src/internal-server/database/migrations/1566385379883_service_schema.js b/src/internal-server/database/migrations/1566385379883_service_schema.js index d887ef193..d8087248f 100644 --- a/src/internal-server/database/migrations/1566385379883_service_schema.js +++ b/src/internal-server/database/migrations/1566385379883_service_schema.js @@ -3,7 +3,7 @@ const Schema = use('Schema'); class ServiceSchema extends Schema { up() { - this.create('services', (table) => { + this.create('services', table => { table.increments(); table.string('serviceId', 80).notNullable(); table.string('name', 80).notNullable(); diff --git a/src/internal-server/database/migrations/1566554231482_recipe_schema.js b/src/internal-server/database/migrations/1566554231482_recipe_schema.js index 514d57600..41bebdacb 100644 --- a/src/internal-server/database/migrations/1566554231482_recipe_schema.js +++ b/src/internal-server/database/migrations/1566554231482_recipe_schema.js @@ -3,7 +3,7 @@ const Schema = use('Schema'); class RecipeSchema extends Schema { up() { - this.create('recipes', (table) => { + this.create('recipes', table => { table.increments(); table.string('name', 80).notNullable(); table.string('recipeId', 254).notNullable().unique(); diff --git a/src/internal-server/database/migrations/1566554359294_workspace_schema.js b/src/internal-server/database/migrations/1566554359294_workspace_schema.js index 421a406b5..3e5385f45 100644 --- a/src/internal-server/database/migrations/1566554359294_workspace_schema.js +++ b/src/internal-server/database/migrations/1566554359294_workspace_schema.js @@ -3,7 +3,7 @@ const Schema = use('Schema'); class WorkspaceSchema extends Schema { up() { - this.create('workspaces', (table) => { + this.create('workspaces', table => { table.increments(); table.string('workspaceId', 80).notNullable().unique(); table.string('name', 80).notNullable(); diff --git a/src/internal-server/start/app.js b/src/internal-server/start/app.js index 8b1a49f57..7ca544085 100644 --- a/src/internal-server/start/app.js +++ b/src/internal-server/start/app.js @@ -28,9 +28,7 @@ const providers = [ | Providers for migrations, tests etc. | */ -const aceProviders = [ - '@adonisjs/lucid/providers/MigrationsProvider', -]; +const aceProviders = ['@adonisjs/lucid/providers/MigrationsProvider']; /* |-------------------------------------------------------------------------- @@ -57,5 +55,8 @@ const aliases = {}; const commands = []; module.exports = { - providers, aceProviders, aliases, commands, + providers, + aceProviders, + aliases, + commands, }; diff --git a/src/jsUtils.ts b/src/jsUtils.ts index b1baad7c5..d7ea4eb40 100644 --- a/src/jsUtils.ts +++ b/src/jsUtils.ts @@ -1,3 +1,14 @@ -export const ifUndefinedString = (source: string | undefined | null, defaultValue: string): string => (source !== undefined && source !== null ? source : defaultValue); -export const ifUndefinedBoolean = (source: boolean | undefined | null, defaultValue: boolean): boolean => Boolean(source !== undefined && source !== null ? source : defaultValue); -export const ifUndefinedNumber = (source: number | undefined | null, defaultValue: number): number => Number(source !== undefined && source !== null ? source : defaultValue); +export const ifUndefinedString = ( + source: string | undefined | null, + defaultValue: string, +): string => (source !== undefined && source !== null ? source : defaultValue); +export const ifUndefinedBoolean = ( + source: boolean | undefined | null, + defaultValue: boolean, +): boolean => + Boolean(source !== undefined && source !== null ? source : defaultValue); +export const ifUndefinedNumber = ( + source: number | undefined | null, + defaultValue: number, +): number => + Number(source !== undefined && source !== null ? source : defaultValue); diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 7360611cd..e7afc3552 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js @@ -1,5 +1,11 @@ import { - app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, + app, + Menu, + nativeImage, + nativeTheme, + systemPreferences, + Tray, + ipcMain, } from 'electron'; import { join } from 'path'; import macosVersion from 'macos-version'; @@ -65,7 +71,9 @@ export default class TrayIcon { if (appSettings.type === 'app') { const { isAppMuted } = appSettings.data; - this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; + this.trayMenuTemplate[1].label = isAppMuted + ? 'Enable Notifications && Audio' + : 'Disable Notifications && Audio'; this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); if (isLinux) { this.trayIcon.setContextMenu(this.trayMenu); @@ -108,9 +116,12 @@ export default class TrayIcon { } if (isMac) { - this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { - this._refreshIcon(); - }); + this.themeChangeSubscriberId = systemPreferences.subscribeNotification( + 'AppleInterfaceThemeChangedNotification', + () => { + this._refreshIcon(); + }, + ); } } @@ -150,7 +161,8 @@ export default class TrayIcon { _getAssetFromIndicator(indicator) { if (indicator === '•') { return INDICATOR_TRAY_INDIRECT; - } if (indicator !== 0) { + } + if (indicator !== 0) { return INDICATOR_TRAY_UNREAD; } return INDICATOR_TRAY_PLAIN; @@ -159,11 +171,16 @@ export default class TrayIcon { _refreshIcon() { if (!this.trayIcon) return; - this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); + this.trayIcon.setImage( + this._getAsset('tray', this._getAssetFromIndicator(this.indicator)), + ); if (isMac) { this.trayIcon.setPressedImage( - this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), + this._getAsset( + 'tray', + `${this._getAssetFromIndicator(this.indicator)}-active`, + ), ); } } @@ -171,12 +188,24 @@ export default class TrayIcon { _getAsset(type, asset) { let { platform } = process; - if (isMac && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { + if ( + isMac && + (nativeTheme.shouldUseDarkColors || + macosVersion.isGreaterThanOrEqualTo('11')) + ) { platform = `${platform}-dark`; } - return nativeImage.createFromPath(join( - __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, - )); + return nativeImage.createFromPath( + join( + __dirname, + '..', + 'assets', + 'images', + type, + platform, + `${asset}.${FILE_EXTENSION}`, + ), + ); } } diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index 859c75df0..e45977f24 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts @@ -1,10 +1,7 @@ import semver from 'semver'; import { pathExistsSync } from 'fs-extra'; import { join } from 'path'; -import { - ifUndefinedString, - ifUndefinedBoolean, -} from '../jsUtils'; +import { ifUndefinedString, ifUndefinedBoolean } from '../jsUtils'; interface IRecipe { id: string; @@ -75,7 +72,8 @@ export default class Recipe { message: string = ''; - allowFavoritesDelineationInUnreadCount: boolean = DEFAULT_RECIPE_SETTINGS.allowFavoritesDelineationInUnreadCount; + allowFavoritesDelineationInUnreadCount: boolean = + DEFAULT_RECIPE_SETTINGS.allowFavoritesDelineationInUnreadCount; disablewebsecurity: boolean = DEFAULT_RECIPE_SETTINGS.disablewebsecurity; @@ -98,7 +96,9 @@ export default class Recipe { } if (!semver.valid(data.version)) { - throw new Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); + throw new Error( + `Version ${data.version} of recipe '${data.name}' is not a valid semver version`, + ); } // from the recipe @@ -106,19 +106,52 @@ export default class Recipe { this.name = ifUndefinedString(data.name, this.name); this.version = ifUndefinedString(data.version, this.version); this.aliases = data.aliases || this.aliases; - this.serviceURL = ifUndefinedString(data.config.serviceURL, this.serviceURL); - this.hasDirectMessages = ifUndefinedBoolean(data.config.hasDirectMessages, this.hasDirectMessages); - this.hasIndirectMessages = ifUndefinedBoolean(data.config.hasIndirectMessages, this.hasIndirectMessages); - this.hasNotificationSound = ifUndefinedBoolean(data.config.hasNotificationSound, this.hasNotificationSound); + this.serviceURL = ifUndefinedString( + data.config.serviceURL, + this.serviceURL, + ); + this.hasDirectMessages = ifUndefinedBoolean( + data.config.hasDirectMessages, + this.hasDirectMessages, + ); + this.hasIndirectMessages = ifUndefinedBoolean( + data.config.hasIndirectMessages, + this.hasIndirectMessages, + ); + this.hasNotificationSound = ifUndefinedBoolean( + data.config.hasNotificationSound, + this.hasNotificationSound, + ); this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId); - this.hasCustomUrl = ifUndefinedBoolean(data.config.hasCustomUrl, this.hasCustomUrl); - this.hasHostedOption = ifUndefinedBoolean(data.config.hasHostedOption, this.hasHostedOption); - this.urlInputPrefix = ifUndefinedString(data.config.urlInputPrefix, this.urlInputPrefix); - this.urlInputSuffix = ifUndefinedString(data.config.urlInputSuffix, this.urlInputSuffix); - this.disablewebsecurity = ifUndefinedBoolean(data.config.disablewebsecurity, this.disablewebsecurity); - this.autoHibernate = ifUndefinedBoolean(data.config.autoHibernate, this.autoHibernate); + this.hasCustomUrl = ifUndefinedBoolean( + data.config.hasCustomUrl, + this.hasCustomUrl, + ); + this.hasHostedOption = ifUndefinedBoolean( + data.config.hasHostedOption, + this.hasHostedOption, + ); + this.urlInputPrefix = ifUndefinedString( + data.config.urlInputPrefix, + this.urlInputPrefix, + ); + this.urlInputSuffix = ifUndefinedString( + data.config.urlInputSuffix, + this.urlInputSuffix, + ); + this.disablewebsecurity = ifUndefinedBoolean( + data.config.disablewebsecurity, + this.disablewebsecurity, + ); + this.autoHibernate = ifUndefinedBoolean( + data.config.autoHibernate, + this.autoHibernate, + ); this.message = ifUndefinedString(data.config.message, this.message); - this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean(data.config.allowFavoritesDelineationInUnreadCount, this.allowFavoritesDelineationInUnreadCount); + this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean( + data.config.allowFavoritesDelineationInUnreadCount, + this.allowFavoritesDelineationInUnreadCount, + ); // computed this.path = data.path; diff --git a/src/models/User.ts b/src/models/User.ts index a04d46d3c..571f1f847 100644 --- a/src/models/User.ts +++ b/src/models/User.ts @@ -59,7 +59,8 @@ export default class User { this.beta = data.beta || this.beta; this.locale = data.locale || this.locale; - this.isSubscriptionOwner = data.isSubscriptionOwner || this.isSubscriptionOwner; + this.isSubscriptionOwner = + data.isSubscriptionOwner || this.isSubscriptionOwner; this.team = data.team || this.team; } diff --git a/src/models/UserAgent.js b/src/models/UserAgent.js index 33bf9d072..02ff97db1 100644 --- a/src/models/UserAgent.js +++ b/src/models/UserAgent.js @@ -63,8 +63,12 @@ export default class UserAgent { } @computed get userAgent() { - return this.serviceUserAgentPref - || (this.chromelessUserAgent ? this.userAgentWithoutChromeVersion : this.defaultUserAgent); + return ( + this.serviceUserAgentPref || + (this.chromelessUserAgent + ? this.userAgentWithoutChromeVersion + : this.defaultUserAgent) + ); } @action setWebviewReference(webview) { diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js index f4e39306c..e01e8fc6f 100644 --- a/src/stores/RecipePreviewsStore.js +++ b/src/stores/RecipePreviewsStore.js @@ -5,9 +5,15 @@ import CachedRequest from './lib/CachedRequest'; import Request from './lib/Request'; export default class RecipePreviewsStore extends Store { - @observable allRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'all'); + @observable allRecipePreviewsRequest = new CachedRequest( + this.api.recipePreviews, + 'all', + ); - @observable searchRecipePreviewsRequest = new Request(this.api.recipePreviews, 'search'); + @observable searchRecipePreviewsRequest = new Request( + this.api.recipePreviews, + 'search', + ); constructor(...args) { super(...args); @@ -25,7 +31,7 @@ export default class RecipePreviewsStore extends Store { } @computed get dev() { - return this.stores.recipes.all.filter((r) => r.local); + return this.stores.recipes.all.filter(r => r.local); } // Actions diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index e27567e8f..5ed9e3534 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -394,7 +394,7 @@ export default class ServicesStore extends Store { } // set default values for serviceData - // eslint-disable-next-line prefer-object-spread + // TODO: How is this different from the defaults of the recipe in 'src/models/Recipe' file? serviceData = { isEnabled: true, diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index ec80fee7c..ac9356404 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -2,7 +2,11 @@ import { ipcRenderer } from 'electron'; import { getCurrentWindow } from '@electron/remote'; import { action, computed, observable, reaction } from 'mobx'; import localStorage from 'mobx-localstorage'; -import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; +import { + DEFAULT_APP_SETTINGS, + FILE_SYSTEM_SETTINGS_TYPES, + LOCAL_SERVER, +} from '../config'; import { hash } from '../helpers/password-helpers'; import Request from './lib/Request'; import Store from './lib/Store'; diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 9f222d2d3..9a5d8cb30 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js @@ -273,13 +273,11 @@ export default class UserStore extends Store { // Install recipes for (const recipe of recipes) { - // eslint-disable-line no-unused-vars // eslint-disable-next-line no-await-in-loop await this.stores.recipes._install({ recipeId: recipe }); } for (const service of services) { - // eslint-disable-line no-unused-vars this.actions.service.createFromLegacyService({ data: service, }); diff --git a/src/stores/lib/Request.js b/src/stores/lib/Request.js index 39f32729a..65871ea17 100644 --- a/src/stores/lib/Request.js +++ b/src/stores/lib/Request.js @@ -38,42 +38,56 @@ export default class Request { if (this._isWaitingForResponse) return this; if (!this._api[this._method]) { - throw new Error(`Missing method <${this._method}> on api object:`, this._api); + throw new Error( + `Missing method <${this._method}> on api object:`, + this._api, + ); } // This timeout is necessary to avoid warnings from mobx // regarding triggering actions as side-effect of getters - setTimeout(action(() => { - this.isExecuting = true; - }), 0); + setTimeout( + action(() => { + this.isExecuting = true; + }), + 0, + ); // Issue api call & save it as promise that is handled to update the results of the operation this._promise = new Promise((resolve, reject) => { this._api[this._method](...callArgs) - .then((result) => { - setTimeout(action(() => { - this.result = result; - if (this._currentApiCall) this._currentApiCall.result = result; - this.isExecuting = false; - this.isError = false; - this.wasExecuted = true; - this._isWaitingForResponse = false; - this._triggerHooks(); - resolve(result); - }), 1); + .then(result => { + setTimeout( + action(() => { + this.result = result; + if (this._currentApiCall) this._currentApiCall.result = result; + this.isExecuting = false; + this.isError = false; + this.wasExecuted = true; + this._isWaitingForResponse = false; + this._triggerHooks(); + resolve(result); + }), + 1, + ); return result; }) - .catch(action((error) => { - setTimeout(action(() => { - this.error = error; - this.isExecuting = false; - this.isError = true; - this.wasExecuted = true; - this._isWaitingForResponse = false; - this._triggerHooks(); - reject(error); - }), 1); - })); + .catch( + action(error => { + setTimeout( + action(() => { + this.error = error; + this.isExecuting = false; + this.isError = true; + this.wasExecuted = true; + this._isWaitingForResponse = false; + this._triggerHooks(); + reject(error); + }), + 1, + ); + }), + ); }); this._isWaitingForResponse = true; @@ -89,7 +103,11 @@ export default class Request { retry = () => this.reload(); isExecutingWithArgs(...args) { - return this.isExecuting && this._currentApiCall && isEqual(this._currentApiCall.args, args); + return ( + this.isExecuting && + this._currentApiCall && + isEqual(this._currentApiCall.args, args) + ); } @computed get isExecutingFirstTime() { @@ -97,12 +115,18 @@ export default class Request { } then(...args) { - if (!this._promise) throw new Error('You have to call Request::execute before you can access it as promise'); + if (!this._promise) + throw new Error( + 'You have to call Request::execute before you can access it as promise', + ); return this._promise.then(...args); } catch(...args) { - if (!this._promise) throw new Error('You have to call Request::execute before you can access it as promise'); + if (!this._promise) + throw new Error( + 'You have to call Request::execute before you can access it as promise', + ); return this._promise.catch(...args); } diff --git a/src/stores/lib/Store.js b/src/stores/lib/Store.js index b39070ce8..a867c3a46 100644 --- a/src/stores/lib/Store.js +++ b/src/stores/lib/Store.js @@ -28,7 +28,8 @@ export default class Store { } registerReactions(reactions) { - for (const reaction of reactions) this._reactions.push(new Reaction(reaction)); + for (const reaction of reactions) + this._reactions.push(new Reaction(reaction)); } setup() {} diff --git a/src/webview/badge.ts b/src/webview/badge.ts index 8e8b66c0c..fb696723d 100644 --- a/src/webview/badge.ts +++ b/src/webview/badge.ts @@ -3,7 +3,7 @@ import { ipcRenderer } from 'electron'; const debug = require('debug')('Ferdi:Plugin:BadgeHandler'); export class BadgeHandler { - countCache: { direct: number; indirect: number; }; + countCache: { direct: number; indirect: number }; constructor() { this.countCache = { @@ -26,14 +26,19 @@ export class BadgeHandler { return Math.max(adjustedNumber, 0); } - setBadge(direct: string | number | undefined | null, indirect: string | number | undefined | null) { + setBadge( + direct: string | number | undefined | null, + indirect: string | number | undefined | null, + ) { const count = { direct: this.safeParseInt(direct), indirect: this.safeParseInt(indirect), }; - if (this.countCache.direct.toString() === count.direct.toString() - && this.countCache.indirect.toString() === count.indirect.toString()) { + if ( + this.countCache.direct.toString() === count.direct.toString() && + this.countCache.indirect.toString() === count.indirect.toString() + ) { return; } diff --git a/src/webview/contextMenuBuilder.ts b/src/webview/contextMenuBuilder.ts index fda5fa8b8..7b8c6cb2d 100644 --- a/src/webview/contextMenuBuilder.ts +++ b/src/webview/contextMenuBuilder.ts @@ -6,7 +6,7 @@ * * Source: https://github.com/electron-userland/electron-spellchecker/blob/master/src/context-menu-builder.js */ -// eslint-disable-next-line no-unused-vars + import { clipboard, ipcRenderer, nativeImage, WebContents } from 'electron'; import { Menu, MenuItem } from '@electron/remote'; import { cmdOrCtrlShortcutKey, isMac } from '../environment'; @@ -311,7 +311,7 @@ export class ContextMenuBuilder { menu.append( new MenuItem({ label: suggestion, - // eslint-disable-next-line no-loop-func + click: () => webContents.replaceMisspelling(suggestion), }), ); diff --git a/src/webview/spellchecker.ts b/src/webview/spellchecker.ts index 468a1b4ae..ee70589d5 100644 --- a/src/webview/spellchecker.ts +++ b/src/webview/spellchecker.ts @@ -5,7 +5,11 @@ import { isMac } from '../environment'; const debug = require('debug')('Ferdi:spellchecker'); export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { - const locales = Object.keys(SPELLCHECKER_LOCALES).filter((key) => key.toLocaleLowerCase() === identifier.toLowerCase() || key.split('-')[0] === identifier.toLowerCase()); + const locales = Object.keys(SPELLCHECKER_LOCALES).filter( + key => + key.toLocaleLowerCase() === identifier.toLowerCase() || + key.split('-')[0] === identifier.toLowerCase(), + ); return locales.length > 0 ? locales[0] : null; } -- cgit v1.2.3-54-g00ecf