From c96b60d4d33adb2baba40fb1f266b35e2b37df84 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Tue, 12 Mar 2024 15:36:47 +0100 Subject: [PATCH] refactor: Enable callback-return rule --- eslint/general.js | 1 + src/util/SliceStream.ts | 2 +- templates/scripts/util.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eslint/general.js b/eslint/general.js index 2930769b9..4bb61b991 100644 --- a/eslint/general.js +++ b/eslint/general.js @@ -4,6 +4,7 @@ module.exports = { 'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false }], 'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true }], + 'callback-return': 'error', 'consistent-this': 'error', curly: [ 'error', 'all' ], 'default-case': 'error', diff --git a/src/util/SliceStream.ts b/src/util/SliceStream.ts index 0586b7008..f26b1477a 100644 --- a/src/util/SliceStream.ts +++ b/src/util/SliceStream.ts @@ -65,8 +65,8 @@ export class SliceStream extends Transform { this.binarySlice(chunk as Buffer); } - callback(); this.source.resume(); + callback(); } protected binarySlice(chunk: Buffer): void { diff --git a/templates/scripts/util.js b/templates/scripts/util.js index bd0571ac6..f55e7716f 100644 --- a/templates/scripts/util.js +++ b/templates/scripts/util.js @@ -62,7 +62,7 @@ function addPostListener(callback, formId = 'mainForm', errorId = 'error') { event.preventDefault(); try { - await callback(); + return await callback(); } catch (error) { setError(error.message, errorId); }