From 1c750d274e91737de4706afbc20d90786d87bd5d Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Thu, 2 Oct 2025 12:18:10 +0100 Subject: [PATCH] refactor: replace ts-ignore with ts-expect-error for improved type safety in Handlebars helpers and test mocks --- App/FeatureSet/Notification/Utils/Handlebars.ts | 8 ++++---- Common/Tests/Server/Services/BillingService.test.ts | 8 ++++---- .../Server/TestingUtils/Services/BillingServiceHelper.ts | 4 ++-- Nginx/Jobs/AcmeWriteCertificates.ts | 1 - Nginx/Jobs/WriteCustomCertsToDisk.ts | 1 - eslint.config.js | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/App/FeatureSet/Notification/Utils/Handlebars.ts b/App/FeatureSet/Notification/Utils/Handlebars.ts index e177b95ab5..ad36ba0051 100644 --- a/App/FeatureSet/Notification/Utils/Handlebars.ts +++ b/App/FeatureSet/Notification/Utils/Handlebars.ts @@ -42,10 +42,10 @@ loadPartials().catch((err: Error) => { Handlebars.registerHelper("ifCond", function (v1, v2, options) { if (v1 === v2) { - //@ts-ignore + //@ts-expect-error - Handlebars uses dynamic this context for template helpers return options.fn(this); } - //@ts-ignore + //@ts-expect-error - Handlebars uses dynamic this context for template helpers return options.inverse(this); }); @@ -56,9 +56,9 @@ Handlebars.registerHelper("concat", (v1: any, v2: any) => { Handlebars.registerHelper("ifNotCond", function (v1, v2, options) { if (v1 !== v2) { - //@ts-ignore + //@ts-expect-error - Handlebars uses dynamic this context for template helpers return options.fn(this); } - //@ts-ignore + //@ts-expect-error - Handlebars uses dynamic this context for template helpers return options.inverse(this); }); diff --git a/Common/Tests/Server/Services/BillingService.test.ts b/Common/Tests/Server/Services/BillingService.test.ts index b0060f06f2..3c1fd8e23c 100644 --- a/Common/Tests/Server/Services/BillingService.test.ts +++ b/Common/Tests/Server/Services/BillingService.test.ts @@ -856,9 +856,9 @@ describe("BillingService", () => { it("should successfully retrieve subscription items for a given subscription", async () => { mockSubscription.items.data = [ - // @ts-ignore + // @ts-expect-error - Simplified mock object for testing without all required Stripe SubscriptionItem properties { id: "item_1", price: { id: "price_123" } }, - // @ts-ignore + // @ts-expect-error - Simplified mock object for testing without all required Stripe SubscriptionItem properties { id: "item_2", price: { id: "price_456" } }, ]; mockStripe.subscriptions.retrieve = @@ -1025,14 +1025,14 @@ describe("BillingService", () => { { id: "pm_123", type: "card", - // @ts-ignore + // @ts-expect-error - Simplified mock card object for testing without all required Stripe card properties card: { last4: "4242", brand: "mastercard" }, isDefault: true, }, { id: "pm_456", type: "card", - // @ts-ignore + // @ts-expect-error - Simplified mock card object for testing without all required Stripe card properties card: { last4: "4343", brand: "mastercard" }, isDefault: true, }, diff --git a/Common/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts b/Common/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts index f372ee60da..6b343dae26 100644 --- a/Common/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +++ b/Common/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts @@ -68,7 +68,7 @@ const getStripeSubscription: GetStripeSubscriptionFunction = data: [ { id: Faker.generateRandomObjectID().toString(), - // @ts-ignore + // @ts-expect-error - Simplified mock price object for testing without all required Stripe Price properties price: { id: new BillingService().getMeteredPlanPriceId( ProductType.ActiveMonitoring, @@ -100,7 +100,7 @@ const getSubscriptionPlanData: GetSubscriptionPlanDataFunction = type GetStripeInvoiceFunction = () => Stripe.Invoice; const getStripeInvoice: GetStripeInvoiceFunction = (): Stripe.Invoice => { - // @ts-ignore + // @ts-expect-error - Simplified mock invoice object for testing without all required Stripe Invoice properties return { id: Faker.generateRandomObjectID().toString(), amount_due: Faker.getNumberBetweenMinAndMax({ min: 1, max: 100 }), diff --git a/Nginx/Jobs/AcmeWriteCertificates.ts b/Nginx/Jobs/AcmeWriteCertificates.ts index ee2edbae21..b9f53fc719 100644 --- a/Nginx/Jobs/AcmeWriteCertificates.ts +++ b/Nginx/Jobs/AcmeWriteCertificates.ts @@ -4,7 +4,6 @@ import { IsDevelopment } from "Common/Server/EnvironmentConfig"; import AcmeCertificateService from "Common/Server/Services/AcmeCertificateService"; import BasicCron from "Common/Server/Utils/BasicCron"; import LocalFile from "Common/Server/Utils/LocalFile"; -// @ts-ignore import logger from "Common/Server/Utils/Logger"; import AcmeCertificate from "Common/Models/DatabaseModels/AcmeCertificate"; diff --git a/Nginx/Jobs/WriteCustomCertsToDisk.ts b/Nginx/Jobs/WriteCustomCertsToDisk.ts index 9697c09c15..34a75e9a52 100644 --- a/Nginx/Jobs/WriteCustomCertsToDisk.ts +++ b/Nginx/Jobs/WriteCustomCertsToDisk.ts @@ -4,7 +4,6 @@ import { IsDevelopment } from "Common/Server/EnvironmentConfig"; import StatusPageDomainService from "Common/Server/Services/StatusPageDomainService"; import BasicCron from "Common/Server/Utils/BasicCron"; import LocalFile from "Common/Server/Utils/LocalFile"; -// @ts-ignore import logger from "Common/Server/Utils/Logger"; import StatusPageDomain from "Common/Models/DatabaseModels/StatusPageDomain"; import QueryHelper from "Common/Server/Types/Database/QueryHelper"; diff --git a/eslint.config.js b/eslint.config.js index 87fff296d3..4b7f6194b1 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -59,7 +59,7 @@ export default tseslint.config( "@typescript-eslint/no-var-requires": "off", // TODO: Remove this rule "@typescript-eslint/no-duplicate-enum-values": "off", // TODO: Remove this rule "no-constant-binary-expression": "off", // TODO: Remove this rule - "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/ban-ts-comment": "error", "multiline-comment-style": "error", "@typescript-eslint/no-floating-promises": "off", // TODO: Remove this rule "no-fallthrough": "error",