diff --git a/.eslintrc.js b/.eslintrc.js index 815bde6fba4..ea45d0fffaa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -62,6 +62,7 @@ module.exports = { 'no-extra-boolean-cast': 'error', 'no-irregular-whitespace': 'error', 'no-constant-binary-expression': 'error', + 'no-async-promise-executor': 'error', 'no-empty': 'error', 'no-prototype-builtins': 'error', '@typescript-eslint/no-empty-object-type': 'off', diff --git a/packages/suite-desktop-core/e2e/support/regtest.ts b/packages/suite-desktop-core/e2e/support/regtest.ts index 6e659613ce2..ba8f4cbcb13 100644 --- a/packages/suite-desktop-core/e2e/support/regtest.ts +++ b/packages/suite-desktop-core/e2e/support/regtest.ts @@ -16,31 +16,30 @@ export const generateBlock = () => method: 'GET', }); -export const waitForCoinjoinBackend = () => - new Promise(async (resolve, reject) => { - const limit = 60; - const error = ''; +export const waitForCoinjoinBackend = async () => { + const limit = 60; + const error = ''; - console.log('waiting for coinjoin backend'); + console.log('waiting for coinjoin backend'); - for (let i = 0; i < limit; i++) { - if (i === limit - 1) { - console.log(`waiting for coinjoin backend: ${error}\n`); - } + for (let i = 0; i < limit; i++) { + if (i === limit - 1) { + console.log(`waiting for coinjoin backend: ${error}\n`); + } - await new Promise(resolve => setTimeout(() => resolve(undefined), 1000)); + await new Promise(resolve => setTimeout(() => resolve(undefined), 1000)); - try { - const res = await fetch('http://localhost:19121/'); - if (res.status === 200) { - console.log('coinjoin backend is online'); + try { + const res = await fetch('http://localhost:19121/'); + if (res.status === 200) { + console.log('coinjoin backend is online'); - return resolve(); - } - } catch { - process.stdout.write('.'); + return; } + } catch { + process.stdout.write('.'); } + } - reject(error); - }); + throw error; +}; diff --git a/packages/trezor-user-env-link/src/websocket-client.ts b/packages/trezor-user-env-link/src/websocket-client.ts index 11705613234..bd1b6a12dc0 100644 --- a/packages/trezor-user-env-link/src/websocket-client.ts +++ b/packages/trezor-user-env-link/src/websocket-client.ts @@ -267,41 +267,39 @@ export class WebsocketClient extends TypedEmitter { this.removeAllListeners(); } - waitForTrezorUserEnv() { - return new Promise(async (resolve, reject) => { - // unfortunately, it can take incredibly long for trezor-user-env to start, we should - // do something about it - const limit = 300; - let error = ''; - - console.log('waiting for trezor-user-env'); - - for (let i = 0; i < limit; i++) { - if (i === limit - 1) { - console.log(`cant connect to trezor-user-env: ${error}\n`); + async waitForTrezorUserEnv() { + // unfortunately, it can take incredibly long for trezor-user-env to start, we should + // do something about it + const limit = 300; + let error = ''; + + console.log('waiting for trezor-user-env'); + + for (let i = 0; i < limit; i++) { + if (i === limit - 1) { + console.log(`cant connect to trezor-user-env: ${error}\n`); + } + await delay(1000); + + try { + const res = await fetch(USER_ENV_URL.DASHBOARD); + if (res.status === 200) { + console.log('trezor-user-env is online'); + + return; } - await delay(1000); - - try { - const res = await fetch(USER_ENV_URL.DASHBOARD); - if (res.status === 200) { - console.log('trezor-user-env is online'); - - return resolve(); - } - } catch (err) { - error = err.message; - // using process.stdout.write instead of console.log since the latter always prints also newline - // but in karma, this code runs in browser and process is not available. - if (typeof process !== 'undefined') { - process.stdout.write('.'); - } else { - console.log('.'); - } + } catch (err) { + error = err.message; + // using process.stdout.write instead of console.log since the latter always prints also newline + // but in karma, this code runs in browser and process is not available. + if (typeof process !== 'undefined') { + process.stdout.write('.'); + } else { + console.log('.'); } } + } - reject(error); - }); + throw error; } }