From 95df3522a15631abc51a4295cae0ea401a8d4e1e Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 14 Sep 2021 19:58:52 +0200 Subject: feat: add eslint-plugin-unicorn (#1936) --- src/webview/lib/RecipeWebview.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/webview/lib/RecipeWebview.js') diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index 157da7693..4085b925b 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js @@ -1,5 +1,5 @@ import { ipcRenderer } from 'electron'; -import { exists, pathExistsSync, readFileSync } from 'fs-extra'; +import { pathExistsSync, readFileSync, existsSync } from 'fs-extra'; const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); @@ -62,12 +62,13 @@ class RecipeWebview { * be an absolute path to the file */ injectCSS(...files) { - files.forEach(async (file) => { + // eslint-disable-next-line unicorn/no-array-for-each + files.forEach(file => { if (pathExistsSync(file)) { const styles = document.createElement('style'); styles.innerHTML = readFileSync(file, 'utf8'); - document.querySelector('head').appendChild(styles); + document.querySelector('head').append(styles); debug('Append styles', styles); } @@ -75,14 +76,16 @@ class RecipeWebview { } injectJSUnsafe(...files) { - Promise.all(files.map(async (file) => { - if (await exists(file)) { - return readFileSync(file, 'utf8'); - } - debug('Script not found', file); - return null; - })).then(async (scripts) => { - const scriptsFound = scripts.filter((script) => script !== null); + Promise.all( + files.map(file => { + if (existsSync(file)) { + return readFileSync(file, 'utf8'); + } + debug('Script not found', file); + return null; + }), + ).then(scripts => { + const scriptsFound = scripts.filter(script => script !== null); if (scriptsFound.length > 0) { debug('Inject scripts to main world', scriptsFound); ipcRenderer.sendToHost('inject-js-unsafe', ...scriptsFound); -- cgit v1.2.3-70-g09d2