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/hipchat/index.js | 76 ++++++++++++++++++++++++++++++-------------- recipes/hipchat/package.json | 2 +- recipes/hipchat/webview.js | 12 ++++++- 3 files changed, 65 insertions(+), 25 deletions(-) (limited to 'recipes/hipchat') diff --git a/recipes/hipchat/index.js b/recipes/hipchat/index.js index ce3256b..e786bcb 100644 --- a/recipes/hipchat/index.js +++ b/recipes/hipchat/index.js @@ -1,27 +1,57 @@ -function _asyncToGenerator(fn) { return function () { const gen = Reflect.apply(fn, this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (error) => { step('throw', error); }); } } return step('next'); }); }; } +function _asyncToGenerator(fn) { + return function () { + const gen = Reflect.apply(fn, this, arguments); + return new Promise((resolve, reject) => { + function step(key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + if (info.done) { + resolve(value); + } else { + // eslint-disable-next-line consistent-return + return Promise.resolve(value).then( + value => { + step('next', value); + }, + error => { + step('throw', error); + }, + ); + } + } + return step('next'); + }); + }; +} -module.exports = Ferdium => class HipChat extends Ferdium { - validateUrl(url) { - return _asyncToGenerator(function* () { - try { - const resp = yield window.fetch(`${url}/api/features`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - }); - const data = yield resp.json(); +module.exports = Ferdium => + class HipChat extends Ferdium { + validateUrl(url) { + return _asyncToGenerator(function* () { + try { + const resp = yield window.fetch(`${url}/api/features`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }); + const data = yield resp.json(); - return Object.hasOwnProperty.call(data, 'features'); - } catch (error) { - console.error(error); - } + return Object.hasOwnProperty.call(data, 'features'); + } catch (error) { + console.error(error); + } - return false; - })(); - } + return false; + })(); + } - buildUrl(url) { - return `${url}/chat`; - } -}; + buildUrl(url) { + return `${url}/chat`; + } + }; diff --git a/recipes/hipchat/package.json b/recipes/hipchat/package.json index 0be97cc..0f9f3f0 100644 --- a/recipes/hipchat/package.json +++ b/recipes/hipchat/package.json @@ -1,7 +1,7 @@ { "id": "hipchat", "name": "HipChat", - "version": "1.2.0", + "version": "1.3.0", "license": "MIT", "config": { "serviceURL": "https://{teamId}.hipchat.com/chat", diff --git a/recipes/hipchat/webview.js b/recipes/hipchat/webview.js index 229b376..6871fbb 100644 --- a/recipes/hipchat/webview.js +++ b/recipes/hipchat/webview.js @@ -1,11 +1,21 @@ +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +const _path = _interopRequireDefault(require('path')); + module.exports = Ferdium => { const getMessages = () => { const directMessages = document.querySelectorAll('.hc-mention').length; - const allMessages = document.querySelectorAll('.aui-badge:not(.hc-mention)').length - directMessages; + const allMessages = + document.querySelectorAll('.aui-badge:not(.hc-mention)').length - + directMessages; // set Ferdium badge Ferdium.setBadge(directMessages, allMessages); }; Ferdium.loop(getMessages); + + Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); }; -- cgit v1.2.3-70-g09d2