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/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 +- 6 files changed, 70 insertions(+), 37 deletions(-) (limited to 'src/stores') 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() {} -- cgit v1.2.3-70-g09d2