From fb9e058196f5c360710c4c357feec4f940f4ba80 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:57:37 -0600 Subject: [PATCH] fix: errors caught by promise rules --- .eslintrc.js | 2 -- lib/build.js | 5 +++-- lib/parse-elm-worker.js | 7 +++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d93691833..98563b7b6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -142,8 +142,6 @@ module.exports = { '@typescript-eslint/no-misused-promises': 'off', '@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/prefer-promise-reject-errors': 'off', - 'promise/catch-or-return': 'off', - 'promise/always-return': 'off', // TODO(@lishaduck): Security issues that should eventually get fixed. 'security/detect-object-injection': 'off', diff --git a/lib/build.js b/lib/build.js index 7d3b13cb4..92eb0b9ed 100644 --- a/lib/build.js +++ b/lib/build.js @@ -584,12 +584,13 @@ async function buildElmParser(options, reviewElmJson) { // Needed when the user has `"type": "module"` in their package.json. // Our output is CommonJS. // TODO(@lishaduck): Switch to a .cjs file instead. - FS.mkdirp(options.generatedCodePackageJson()).then(async () => { + async () => { + await FS.mkdirp(options.generatedCodePackageJson()); await FS.writeFile( path.join(options.generatedCodePackageJson(), 'package.json'), '{"type":"commonjs"}' ); - }) + } ]); await compileElmProject( diff --git a/lib/parse-elm-worker.js b/lib/parse-elm-worker.js index efee2997b..2ad93aa6b 100644 --- a/lib/parse-elm-worker.js +++ b/lib/parse-elm-worker.js @@ -22,10 +22,9 @@ if (parentPort) { * @returns {void} */ function subscribe(parentPort) { - parentPort.on('message', (queueItem) => { - workerParseElm(queueItem).then((result) => { - parentPort.postMessage(result); - }); + parentPort.on('message', async (queueItem) => { + const result = await workerParseElm(queueItem); + parentPort.postMessage(result); }); }