From c5475f78eaec376da5243756c04fe6e6f10c7856 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 26 Sep 2023 23:07:22 +0200 Subject: [PATCH] Forbid promise misuse (#6360) --- .eslintrc.json | 16 +++++----------- .../src/autofill/services/autofill.service.ts | 1 + .../src/services/native-messaging.service.ts | 1 + .../settings/user-subscription.component.ts | 1 + .../src/app/vault/settings/premium.component.ts | 1 + .../clients/add-organization.component.ts | 1 + 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4fba3dd612..d6c329a94d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -34,20 +34,14 @@ } }, "rules": { - "@typescript-eslint/no-explicit-any": "off", // TODO: This should be re-enabled - "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], "@typescript-eslint/explicit-member-accessibility": [ "error", - { - "accessibility": "no-public" - } - ], - "@typescript-eslint/no-this-alias": [ - "error", - { - "allowedNames": ["self"] - } + { "accessibility": "no-public" } ], + "@typescript-eslint/no-explicit-any": "off", // TODO: This should be re-enabled + "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }], + "@typescript-eslint/no-this-alias": ["error", { "allowedNames": ["self"] }], + "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], "no-console": "error", "import/no-unresolved": "off", // TODO: Look into turning off once each package is an actual package. "import/order": [ diff --git a/apps/browser/src/autofill/services/autofill.service.ts b/apps/browser/src/autofill/services/autofill.service.ts index c494b8ece0..81bf107650 100644 --- a/apps/browser/src/autofill/services/autofill.service.ts +++ b/apps/browser/src/autofill/services/autofill.service.ts @@ -205,6 +205,7 @@ export default class AutofillService implements AutofillServiceInterface { if ( options.cipher.type !== CipherType.Login || + // eslint-disable-next-line @typescript-eslint/no-misused-promises totpPromise || !options.cipher.login.totp || (!canAccessPremium && !options.cipher.organizationUseTotp) diff --git a/apps/desktop/src/services/native-messaging.service.ts b/apps/desktop/src/services/native-messaging.service.ts index c18a67e6b4..bb92beca78 100644 --- a/apps/desktop/src/services/native-messaging.service.ts +++ b/apps/desktop/src/services/native-messaging.service.ts @@ -116,6 +116,7 @@ export class NativeMessagingService { switch (message.command) { case "biometricUnlock": { + // eslint-disable-next-line @typescript-eslint/no-misused-promises if (!this.platformUtilService.supportsBiometric()) { return this.send({ command: "biometricUnlock", response: "not supported" }, appId); } diff --git a/apps/web/src/app/billing/settings/user-subscription.component.ts b/apps/web/src/app/billing/settings/user-subscription.component.ts index d058f7f105..2871a964ba 100644 --- a/apps/web/src/app/billing/settings/user-subscription.component.ts +++ b/apps/web/src/app/billing/settings/user-subscription.component.ts @@ -53,6 +53,7 @@ export class UserSubscriptionComponent implements OnInit { return; } + // eslint-disable-next-line @typescript-eslint/no-misused-promises if (this.stateService.getHasPremiumPersonally()) { this.loading = true; this.sub = await this.apiService.getUserSubscription(); diff --git a/apps/web/src/app/vault/settings/premium.component.ts b/apps/web/src/app/vault/settings/premium.component.ts index 7fb1d16975..445925e9be 100644 --- a/apps/web/src/app/vault/settings/premium.component.ts +++ b/apps/web/src/app/vault/settings/premium.component.ts @@ -74,6 +74,7 @@ export class PremiumComponent implements OnInit { try { if (this.selfHosted) { + // eslint-disable-next-line @typescript-eslint/no-misused-promises if (!this.tokenService.getEmailVerified()) { this.platformUtilsService.showToast( "error", diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/clients/add-organization.component.ts b/bitwarden_license/bit-web/src/app/admin-console/providers/clients/add-organization.component.ts index 2f0d307674..d3eff4bc53 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/clients/add-organization.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/clients/add-organization.component.ts @@ -47,6 +47,7 @@ export class AddOrganizationComponent implements OnInit { } async add(organization: Organization) { + // eslint-disable-next-line @typescript-eslint/no-misused-promises if (this.formPromise) { return; }