From 89b008e3b41365f8aed0e5096533f9c0d4baa8e6 Mon Sep 17 00:00:00 2001 From: Roman Khabarov Date: Thu, 13 Jul 2023 00:03:34 +0300 Subject: [PATCH] fix: linter --- .eslintrc.json | 5 +++++ .github/workflows/test.yml | 2 +- package-lock.json | 4 ++-- src/extension.ts | 8 ++++---- src/logger.ts | 2 +- src/util.ts | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5388a45..97eea77 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,5 +3,10 @@ "extends": "marine/prettier/node", "parserOptions": { "project": "./tsconfig.eslint.json" + }, + "rules": { + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-misused-promises": "off" } } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 91d6e5c..62b23d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: - name: Install Node v14 uses: actions/setup-node@v2 with: - node-version: 14 + node-version: 18 - name: Install dependencies run: npm ci diff --git a/package-lock.json b/package-lock.json index 203703c..df26483 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discord-vscode-rpc", - "version": "1.0.4", + "version": "1.0.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "discord-vscode-rpc", - "version": "1.0.4", + "version": "1.0.7", "license": "MIT", "dependencies": { "bufferutil": "^4.0.6", diff --git a/src/extension.ts b/src/extension.ts index 43c6b54..317c681 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -28,7 +28,7 @@ async function sendActivity() { state = { ...(await activity(state)), }; - rpc.setActivity(state); + return rpc.setActivity(state); } async function login() { @@ -53,9 +53,9 @@ async function login() { rpc.on('disconnected', () => { cleanUp(); - rpc.destroy(); statusBarIcon.text = '$(pulse) Reconnect to Discord'; statusBarIcon.command = 'discord.reconnect'; + void rpc.destroy(); }); try { @@ -63,7 +63,6 @@ async function login() { } catch (error: any) { log(LogLevel.Error, `Encountered the following error while trying to login:\n${error as string}`); cleanUp(); - rpc.destroy(); if (!config[CONFIG_KEYS.SuppressNotifications]) { if (error?.message?.includes('ENOENT')) { void window.showErrorMessage('No Discord client detected'); @@ -73,6 +72,7 @@ async function login() { } statusBarIcon.text = '$(pulse) Reconnect to Discord'; statusBarIcon.command = 'discord.reconnect'; + return rpc.destroy(); } } @@ -112,7 +112,7 @@ export async function activate(context: ExtensionContext) { } log(LogLevel.Info, 'Disable: Cleaning up old listeners'); cleanUp(); - rpc.destroy(); + void rpc.destroy(); log(LogLevel.Info, 'Disable: Destroyed the rpc instance'); statusBarIcon.hide(); }; diff --git a/src/logger.ts b/src/logger.ts index aa7ed80..ffe2d4f 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -27,7 +27,7 @@ export function log(level: LogLevel, message: string | Error | object) { try { const json = JSON.stringify(message, null, 2); send(level, json); - } catch (error) { + } catch (error: unknown) { console.error(`Failed to stringify log message: ${error}`); } } diff --git a/src/util.ts b/src/util.ts index 319ceea..cfefd52 100644 --- a/src/util.ts +++ b/src/util.ts @@ -43,8 +43,8 @@ export function resolveFileIcon(document: TextDocument): string { const filename = basename(document.fileName); const findKnownExtension = Object.keys(KNOWN_EXTENSIONS) .sort((a, b) => { - const aIsRegular = KNOWN_EXTENSIONS[a].isRegular || false; - const bIsRegular = KNOWN_EXTENSIONS[b].isRegular || false; + const aIsRegular = KNOWN_EXTENSIONS[a].isRegular ?? false; + const bIsRegular = KNOWN_EXTENSIONS[b].isRegular ?? false; if (aIsRegular && !bIsRegular) { return -1;