1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Tools: Add eslint rule prefer-await-to-then

This commit is contained in:
Laurent Cozic
2022-09-30 17:23:14 +01:00
parent cc6620a7e1
commit 44a96f347a
34 changed files with 65 additions and 0 deletions

View File

@ -36,6 +36,7 @@ export default class JoplinPlugins {
// We don't use `await` when calling onStart because the plugin might be awaiting
// in that call too (for example, when opening a dialog on startup) so we don't
// want to get stuck here.
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
void script.onStart({}).catch((error: any) => {
// For some reason, error thrown from the executed script do not have the type "Error"
// but are instead plain object. So recreate the Error object here so that it can
@ -43,6 +44,7 @@ export default class JoplinPlugins {
const newError: Error = new Error(error.message);
newError.stack = error.stack;
logger.error(`Uncaught exception in plugin "${this.plugin.id}":`, newError);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
}).then(() => {
logger.info(`Finished running onStart handler: ${this.plugin.id} (Took ${Date.now() - startTime}ms)`);
this.plugin.emit('started');