From 9b8f01716774a960073e944823ab727cc867a8f6 Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Wed, 26 Jul 2023 06:29:03 -0600 Subject: chore: improve lint setup (#397) - update eslint config to closely mirror the ones from ferdium-app - add .eslintignore - opt in to eslint `reportUnusedDisableDirectives` config option - remove `trailingComma: all` from `prettier` config which is default in `prettier` v3 - autofix or disable a lot of lint issues throughout codebase - add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions - upgrade all `eslint` and `prettier` related dependencies to latest - update lint:fix npm script - reformat touched files with prettier - bumped up minor version for all recipes that have changes - introduced injection of 'service.css' where it was missing in many recipes --------- Co-authored-by: Vijay A --- recipes/skype/webview.js | 51 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'recipes/skype/webview.js') diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js index db97d98..45bc005 100644 --- a/recipes/skype/webview.js +++ b/recipes/skype/webview.js @@ -1,6 +1,8 @@ -const _path = _interopRequireDefault(require('path')); +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const _path = _interopRequireDefault(require('path')); module.exports = (Ferdium, settings) => { const getMessages = () => { @@ -8,13 +10,16 @@ module.exports = (Ferdium, settings) => { const container = document.querySelector('[role="tablist"] > button > div'); if (container) { - const children = container.children; + const { children } = container; if (children.length === 3) { + // eslint-disable-next-line unicorn/prefer-at const elementContainer = children[children.length - 1]; if (elementContainer) { - const element = elementContainer.querySelector('[data-text-as-pseudo-element]'); + const element = elementContainer.querySelector( + '[data-text-as-pseudo-element]', + ); if (element && element.dataset) { count = Ferdium.safeParseInt(element.dataset.textAsPseudoElement); } @@ -31,21 +36,27 @@ module.exports = (Ferdium, settings) => { Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences - document.addEventListener('click', event => { - const link = event.target.closest('a[href^="http"]'); - const button = event.target.closest('button[title^="http"]'); - - if (link || button) { - const url = link ? link.getAttribute('href') : button.getAttribute('title'); - - event.preventDefault(); - event.stopPropagation(); - - if (settings.trapLinkClicks === true) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); + document.addEventListener( + 'click', + event => { + const link = event.target.closest('a[href^="http"]'); + const button = event.target.closest('button[title^="http"]'); + + if (link || button) { + const url = link + ? link.getAttribute('href') + : button.getAttribute('title'); + + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } } - } - }, true); + }, + true, + ); }; -- cgit v1.2.3-70-g09d2