diff options
author | 2023-07-26 06:29:03 -0600 | |
---|---|---|
committer | 2023-07-26 17:59:03 +0530 | |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/grape | |
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/grape')
-rw-r--r-- | recipes/grape/index.js | 62 | ||||
-rw-r--r-- | recipes/grape/package.json | 2 | ||||
-rw-r--r-- | recipes/grape/webview.js | 8 |
3 files changed, 55 insertions, 17 deletions
diff --git a/recipes/grape/index.js b/recipes/grape/index.js index 593f026..1e2a187 100644 --- a/recipes/grape/index.js +++ b/recipes/grape/index.js | |||
@@ -1,18 +1,48 @@ | |||
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 | 2 | return function () { | |
3 | module.exports = Ferdium => class Grape extends Ferdium { | 3 | const gen = Reflect.apply(fn, this, arguments); |
4 | validateUrl(url) { | 4 | return new Promise((resolve, reject) => { |
5 | return _asyncToGenerator(function* () { | 5 | function step(key, arg) { |
6 | try { | 6 | try { |
7 | const resp = yield window.fetch(url, { | 7 | var info = gen[key](arg); |
8 | method: 'GET', | 8 | var value = info.value; |
9 | }); | 9 | } catch (error) { |
10 | return resp.status === 200; | 10 | reject(error); |
11 | } catch (error) { | 11 | return; |
12 | console.error(error); | 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 | } | ||
13 | } | 26 | } |
27 | return step('next'); | ||
28 | }); | ||
29 | }; | ||
30 | } | ||
31 | |||
32 | module.exports = Ferdium => | ||
33 | class Grape extends Ferdium { | ||
34 | validateUrl(url) { | ||
35 | return _asyncToGenerator(function* () { | ||
36 | try { | ||
37 | const resp = yield window.fetch(url, { | ||
38 | method: 'GET', | ||
39 | }); | ||
40 | return resp.status === 200; | ||
41 | } catch (error) { | ||
42 | console.error(error); | ||
43 | } | ||
14 | 44 | ||
15 | return false; | 45 | return false; |
16 | })(); | 46 | })(); |
17 | } | 47 | } |
18 | }; | 48 | }; |
diff --git a/recipes/grape/package.json b/recipes/grape/package.json index 9fe40ab..6b09778 100644 --- a/recipes/grape/package.json +++ b/recipes/grape/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "grape", | 2 | "id": "grape", |
3 | "name": "Grape", | 3 | "name": "Grape", |
4 | "version": "1.2.0", | 4 | "version": "1.3.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.chatgrape.com/chat", | 7 | "serviceURL": "https://{teamId}.chatgrape.com/chat", |
diff --git a/recipes/grape/webview.js b/recipes/grape/webview.js index 6349bd0..0115205 100644 --- a/recipes/grape/webview.js +++ b/recipes/grape/webview.js | |||
@@ -1,3 +1,9 @@ | |||
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('.c0120').length; | 9 | const directMessages = document.querySelectorAll('.c0120').length; |
@@ -7,4 +13,6 @@ module.exports = Ferdium => { | |||
7 | }; | 13 | }; |
8 | 14 | ||
9 | Ferdium.loop(getMessages); | 15 | Ferdium.loop(getMessages); |
16 | |||
17 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
10 | }; | 18 | }; |