From f64f1b3bd9bec4036748b98ff8ac0f0431749f30 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 2 Dec 2021 23:57:13 +0100 Subject: chore: upgrade commitlint and eslint-plugin-unicorn to latest (#2295) - upgrade commitlint and eslint-plugin-unicorn dependencies - update prepare-code script to run lint:fix instead of lint - fix unicorn/no-await-expression-member lint issues - various whitespace formatting fixes due to lint:fix --- src/components/services/tabs/TabItem.js | 2 +- .../settings/recipes/RecipesDashboard.js | 3 +- src/containers/settings/EditSettingsScreen.js | 4 ++- .../app/Controllers/Http/RecipeController.js | 25 +++++++++-------- .../app/Controllers/Http/ServiceController.js | 32 +++++++++++++--------- .../app/Controllers/Http/UserController.js | 7 +++-- .../app/Controllers/Http/WorkspaceController.js | 13 ++++++--- src/lib/Menu.js | 11 ++++++-- src/lib/Tray.js | 11 ++++++-- 9 files changed, 69 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 5381d7c2b..14be37153 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js @@ -276,7 +276,7 @@ class TabItem extends Component { service.isEnabled ? messages.disableService : messages.enableService, ), click: () => (service.isEnabled ? disableService() : enableService()), - accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+S`, + accelerator: `${cmdOrCtrlShortcutKey()}+${shiftKey()}+S`, }, { label: intl.formatMessage( diff --git a/src/components/settings/recipes/RecipesDashboard.js b/src/components/settings/recipes/RecipesDashboard.js index b865bce73..7ec285431 100644 --- a/src/components/settings/recipes/RecipesDashboard.js +++ b/src/components/settings/recipes/RecipesDashboard.js @@ -51,7 +51,8 @@ const messages = defineMessages({ }, customRecipeIntro: { id: 'settings.recipes.customService.intro', - defaultMessage: 'To add a custom service, copy the service recipe folder inside:', + defaultMessage: + 'To add a custom service, copy the service recipe folder inside:', }, openFolder: { id: 'settings.recipes.customService.openFolder', diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 719c71561..720f2c8a1 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js @@ -621,7 +621,9 @@ class EditSettingsScreen extends Component { default: DEFAULT_APP_SETTINGS.splitMode, }, splitColumns: { - label: `${intl.formatMessage(messages.splitColumns)} (${SPLIT_COLUMNS_MIN}-${SPLIT_COLUMNS_MAX})`, + label: `${intl.formatMessage( + messages.splitColumns, + )} (${SPLIT_COLUMNS_MIN}-${SPLIT_COLUMNS_MAX})`, value: settings.all.app.splitColumns, default: DEFAULT_APP_SETTINGS.splitColumns, }, diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index 1b0ac7035..7e35e6831 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js @@ -13,8 +13,10 @@ const RECIPES_URL = `${LIVE_FERDI_API}/${API_VERSION}/recipes`; class RecipeController { // List official and custom recipes async list({ response }) { - const officialRecipes = JSON.parse(await (await fetch(RECIPES_URL)).text()); - const customRecipesArray = (await Recipe.all()).rows; + const recipesUrlFetch = await fetch(RECIPES_URL); + const officialRecipes = JSON.parse(await recipesUrlFetch).text(); + const allRecipes = await Recipe.all(); + const customRecipesArray = allRecipes.rows; const customRecipes = customRecipesArray.map(recipe => ({ id: recipe.recipeId, name: recipe.name, @@ -46,7 +48,8 @@ class RecipeController { let results; if (needle === 'ferdi:custom') { - const dbResults = (await Recipe.all()).toJSON(); + const allRecipes = await Recipe.all(); + const dbResults = allRecipes.toJSON(); results = dbResults.map(recipe => ({ id: recipe.recipeId, name: recipe.name, @@ -56,20 +59,18 @@ class RecipeController { let remoteResults = []; // eslint-disable-next-line eqeqeq if (Env.get('CONNECT_WITH_FRANZ') == 'true') { - remoteResults = JSON.parse( - await ( - await fetch( - `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, - ) - ).text(), + const recipesUrlFetch = await fetch( + `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, ); + remoteResults = JSON.parse(await recipesUrlFetch.text()); } debug('remoteResults:', remoteResults); - const localResultsArray = ( - await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch() - ).toJSON(); + const recipeQuery = await Recipe.query() + .where('name', 'LIKE', `%${needle}%`) + .fetch(); + const localResultsArray = recipeQuery.toJSON(); const localResults = localResultsArray.map(recipe => ({ id: recipe.recipeId, name: recipe.name, diff --git a/src/internal-server/app/Controllers/Http/ServiceController.js b/src/internal-server/app/Controllers/Http/ServiceController.js index c4ca5a113..a3add4464 100644 --- a/src/internal-server/app/Controllers/Http/ServiceController.js +++ b/src/internal-server/app/Controllers/Http/ServiceController.js @@ -34,6 +34,7 @@ class ServiceController { do { serviceId = uuid(); } while ( + // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member (await Service.query().where('serviceId', serviceId).fetch()).rows .length > 0 ); @@ -68,7 +69,8 @@ class ServiceController { // List all services a user has created async list({ response }) { - const services = (await Service.all()).rows; + const allServices = await Service.all(); + const services = allServices.rows; // Convert to array with all data Franz wants const servicesArray = services.map(service => { const settings = @@ -111,8 +113,8 @@ class ServiceController { size: '2mb', }); const { id } = params; - const service = (await Service.query().where('serviceId', id).fetch()) - .rows[0]; + const serviceQuery = await Service.query().where('serviceId', id).fetch(); + const service = serviceQuery.rows[0]; const settings = typeof service.settings === 'string' ? JSON.parse(service.settings) @@ -166,8 +168,8 @@ class ServiceController { const { id } = params; // Get current settings from db - const serviceData = (await Service.query().where('serviceId', id).fetch()) - .rows[0]; + const serviceQuery = await Service.query().where('serviceId', id).fetch(); + const serviceData = serviceQuery.rows[0]; const settings = { ...(typeof serviceData.settings === 'string' @@ -185,8 +187,10 @@ class ServiceController { }); // Get updated row - const service = (await Service.query().where('serviceId', id).fetch()) - .rows[0]; + const anotherServiceQuery = await Service.query() + .where('serviceId', id) + .fetch(); + const service = anotherServiceQuery.rows[0]; return response.send({ data: { @@ -218,11 +222,12 @@ class ServiceController { for (const service of Object.keys(data)) { // Get current settings from db - const serviceData = ( - await Service.query() // eslint-disable-line no-await-in-loop - .where('serviceId', service) - .fetch() - ).rows[0]; + // eslint-disable-next-line no-await-in-loop + const serviceQuery = await Service.query() + .where('serviceId', service) + .fetch(); + + const serviceData = serviceQuery.rows[0]; const settings = { ...JSON.parse(serviceData.settings), @@ -238,7 +243,8 @@ class ServiceController { } // Get new services - const services = (await Service.all()).rows; + const allServices = await Service.all(); + const services = allServices.rows; // Convert to array with all data Franz wants const servicesArray = services.map(service => { const settings = diff --git a/src/internal-server/app/Controllers/Http/UserController.js b/src/internal-server/app/Controllers/Http/UserController.js index 2ecc8241c..abfbc2470 100644 --- a/src/internal-server/app/Controllers/Http/UserController.js +++ b/src/internal-server/app/Controllers/Http/UserController.js @@ -1,3 +1,4 @@ +/* eslint-disable no-await-in-loop, unicorn/no-await-expression-member */ const User = use('App/Models/User'); const Service = use('App/Models/Service'); const Workspace = use('App/Models/Workspace'); @@ -230,8 +231,10 @@ class UserController { auth, response, }) { - const services = (await Service.all()).toJSON(); - const workspaces = (await Workspace.all()).toJSON(); + const allServices = await Service.all(); + const services = allServices.toJSON(); + const allWorkspaces = await Workspace.all(); + const workspaces = allWorkspaces.toJSON(); const exportData = { username: 'Ferdi', diff --git a/src/internal-server/app/Controllers/Http/WorkspaceController.js b/src/internal-server/app/Controllers/Http/WorkspaceController.js index 528721f13..9ba2b174e 100644 --- a/src/internal-server/app/Controllers/Http/WorkspaceController.js +++ b/src/internal-server/app/Controllers/Http/WorkspaceController.js @@ -25,11 +25,13 @@ class WorkspaceController { do { workspaceId = uuid(); } while ( + // eslint-disable-next-line no-await-in-loop, unicorn/no-await-expression-member (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows .length > 0 ); - const order = (await Workspace.all()).rows.length; + const allWorkspaces = await Workspace.all(); + const order = allWorkspaces.rows.length; const { name } = data; delete data.name; @@ -76,8 +78,10 @@ class WorkspaceController { }); // Get updated row - const workspace = (await Workspace.query().where('workspaceId', id).fetch()) - .rows[0]; + const workspaceQuery = await Workspace.query() + .where('workspaceId', id) + .fetch(); + const workspace = workspaceQuery.rows[0]; return response.send({ id: workspace.workspaceId, @@ -118,7 +122,8 @@ class WorkspaceController { // List all workspaces a user has created async list({ response }) { - const workspaces = (await Workspace.all()).rows; + const allWorkspaces = await Workspace.all(); + const workspaces = allWorkspaces.rows; // Convert to array with all data Franz wants let workspacesArray = []; if (workspaces) { diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 892b2ff3c..8e529d859 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -1,5 +1,11 @@ import { clipboard } from 'electron'; -import { app, Menu, dialog, systemPreferences, getCurrentWindow } from '@electron/remote'; +import { + app, + Menu, + dialog, + systemPreferences, + getCurrentWindow, +} from '@electron/remote'; import { autorun, observable } from 'mobx'; import { defineMessages } from 'react-intl'; import { @@ -950,7 +956,8 @@ class FranzMenu { click: () => { this.actions.service.setActive({ serviceId: service.id }); - if (isMac && i === 0) { // feat(Mac): Open Window with Cmd+1 + if (isMac && i === 0) { + // feat(Mac): Open Window with Cmd+1 getCurrentWindow().restore(); } }, diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 655dc416f..63382483e 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js @@ -33,15 +33,20 @@ export default class TrayIcon { mainWindow = null; - trayMenuTemplate = (tray) => [ + trayMenuTemplate = tray => [ { - label: (tray.mainWindow.isVisible() && tray.mainWindow.isFocused()) ? 'Hide Ferdi' : 'Show Ferdi', + label: + tray.mainWindow.isVisible() && tray.mainWindow.isFocused() + ? 'Hide Ferdi' + : 'Show Ferdi', click() { tray._toggleWindow(); }, }, { - label: tray.isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio', + label: tray.isAppMuted + ? 'Enable Notifications && Audio' + : 'Disable Notifications && Audio', click() { if (!tray.mainWindow) return; tray.mainWindow.webContents.send('muteApp'); -- cgit v1.2.3-70-g09d2