From d23658045c38cac5437731eaf110807b0c01cfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=CC=8Ctefan=20S=CC=8Cimek?= Date: Sat, 18 Jan 2025 16:20:41 +0100 Subject: [PATCH] style: configure prefer-promise-reject-errors rule, remove a bit of dead code --- eslint.config.mjs | 6 +++++- src/backend/linux/console.ts | 24 ------------------------ 2 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 src/backend/linux/console.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index 0e70e6df..15cf174b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -39,6 +39,11 @@ export default tseslint.config( rules: { '@typescript-eslint/no-base-to-string': 'off', // 1 instance + '@typescript-eslint/prefer-promise-reject-errors': ['error', { + // for catch (e) { reject(e); } scenarios, until promises are refactored + allowThrowingAny: true, + allowThrowingUnknown: true, + }], '@stylistic/indent-binary-ops': 'off', // this is a weird rule '@stylistic/max-len': ['error', { @@ -73,7 +78,6 @@ export default tseslint.config( '@typescript-eslint/no-misused-promises': 'off', // 53 instances '@typescript-eslint/no-floating-promises': 'off', // 48 instances 'no-async-promise-executor': 'off', // 25 instances - '@typescript-eslint/prefer-promise-reject-errors': 'off', // 19 instances } }, { diff --git a/src/backend/linux/console.ts b/src/backend/linux/console.ts deleted file mode 100644 index 066fb035..00000000 --- a/src/backend/linux/console.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as ChildProcess from 'child_process'; -import * as fs from 'fs'; - -export function spawnTerminalEmulator(preferedEmulator: string): Thenable { - return new Promise((resolve, reject) => { - const ttyFileOutput = '/tmp/vscode-gdb-tty-0' + Math.floor(Math.random() * 100000000).toString(36); - ChildProcess.spawn(preferedEmulator || 'x-terminal-emulator', ['-e', 'sh -c "tty > ' + ttyFileOutput + ' && sleep 4294967294"']); - let it = 0; - const interval = setInterval(() => { - if (fs.existsSync(ttyFileOutput)) { - clearInterval(interval); - const tty = fs.readFileSync(ttyFileOutput).toString('utf8'); - fs.unlink(ttyFileOutput, (err) => { - console.log('Error unlinking terminal session'); - }); - return resolve(tty); - } - it++; - if (it > 500) { - reject(); - } - }, 10); - }); -}