diff options
author | 2023-07-26 06:29:03 -0600 | |
---|---|---|
committer | 2023-07-26 17:59:03 +0530 | |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/hipchat | |
parent | Add Excalidraw recipe (#393) (diff) | |
download | ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip |
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 <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/hipchat')
-rw-r--r-- | recipes/hipchat/index.js | 76 | ||||
-rw-r--r-- | recipes/hipchat/package.json | 2 | ||||
-rw-r--r-- | recipes/hipchat/webview.js | 12 |
3 files changed, 65 insertions, 25 deletions
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 @@ | |||
1 | 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'); }); }; } | 1 | function _asyncToGenerator(fn) { |
2 | return function () { | ||
3 | const gen = Reflect.apply(fn, this, arguments); | ||
4 | return new Promise((resolve, reject) => { | ||
5 | function step(key, arg) { | ||
6 | try { | ||
7 | var info = gen[key](arg); | ||
8 | var value = info.value; | ||
9 | } catch (error) { | ||
10 | reject(error); | ||
11 | return; | ||
12 | } | ||
13 | if (info.done) { | ||
14 | resolve(value); | ||
15 | } else { | ||
16 | // eslint-disable-next-line consistent-return | ||
17 | return Promise.resolve(value).then( | ||
18 | value => { | ||
19 | step('next', value); | ||
20 | }, | ||
21 | error => { | ||
22 | step('throw', error); | ||
23 | }, | ||
24 | ); | ||
25 | } | ||
26 | } | ||
27 | return step('next'); | ||
28 | }); | ||
29 | }; | ||
30 | } | ||
2 | 31 | ||
3 | module.exports = Ferdium => class HipChat extends Ferdium { | 32 | module.exports = Ferdium => |
4 | validateUrl(url) { | 33 | class HipChat extends Ferdium { |
5 | return _asyncToGenerator(function* () { | 34 | validateUrl(url) { |
6 | try { | 35 | return _asyncToGenerator(function* () { |
7 | const resp = yield window.fetch(`${url}/api/features`, { | 36 | try { |
8 | method: 'GET', | 37 | const resp = yield window.fetch(`${url}/api/features`, { |
9 | headers: { | 38 | method: 'GET', |
10 | 'Content-Type': 'application/json', | 39 | headers: { |
11 | }, | 40 | 'Content-Type': 'application/json', |
12 | }); | 41 | }, |
13 | const data = yield resp.json(); | 42 | }); |
43 | const data = yield resp.json(); | ||
14 | 44 | ||
15 | return Object.hasOwnProperty.call(data, 'features'); | 45 | return Object.hasOwnProperty.call(data, 'features'); |
16 | } catch (error) { | 46 | } catch (error) { |
17 | console.error(error); | 47 | console.error(error); |
18 | } | 48 | } |
19 | 49 | ||
20 | return false; | 50 | return false; |
21 | })(); | 51 | })(); |
22 | } | 52 | } |
23 | 53 | ||
24 | buildUrl(url) { | 54 | buildUrl(url) { |
25 | return `${url}/chat`; | 55 | return `${url}/chat`; |
26 | } | 56 | } |
27 | }; | 57 | }; |
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 @@ | |||
1 | { | 1 | { |
2 | "id": "hipchat", | 2 | "id": "hipchat", |
3 | "name": "HipChat", | 3 | "name": "HipChat", |
4 | "version": "1.2.0", | 4 | "version": "1.3.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.hipchat.com/chat", | 7 | "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 @@ | |||
1 | function _interopRequireDefault(obj) { | ||
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
1 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
2 | const getMessages = () => { | 8 | const getMessages = () => { |
3 | const directMessages = document.querySelectorAll('.hc-mention').length; | 9 | const directMessages = document.querySelectorAll('.hc-mention').length; |
4 | const allMessages = document.querySelectorAll('.aui-badge:not(.hc-mention)').length - directMessages; | 10 | const allMessages = |
11 | document.querySelectorAll('.aui-badge:not(.hc-mention)').length - | ||
12 | directMessages; | ||
5 | 13 | ||
6 | // set Ferdium badge | 14 | // set Ferdium badge |
7 | Ferdium.setBadge(directMessages, allMessages); | 15 | Ferdium.setBadge(directMessages, allMessages); |
8 | }; | 16 | }; |
9 | 17 | ||
10 | Ferdium.loop(getMessages); | 18 | Ferdium.loop(getMessages); |
19 | |||
20 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
11 | }; | 21 | }; |