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/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 ++++++++++++++-------- 8 files changed, 74 insertions(+), 52 deletions(-) (limited to 'src/features') 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); } -- cgit v1.2.3-70-g09d2