diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-07-26 06:29:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 17:59:03 +0530 |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/grape/index.js | |
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/index.js')
-rw-r--r-- | recipes/grape/index.js | 62 |
1 files changed, 46 insertions, 16 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 | }; |