From 343c239ca0333fd3f47104c8df14d7c0ad68791f Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Fri, 10 Jan 2025 15:48:53 +0100 Subject: [PATCH] Enable noDoubleEquals --- biome.json | 1 - clients/banking/src/components/CardWizard.tsx | 2 +- .../src/components/CardWizardDelivery.tsx | 2 +- .../src/components/CardWizardSettings.tsx | 2 +- clients/banking/src/components/ErrorView.tsx | 2 +- .../src/components/MerchantProfileEditor.tsx | 2 +- .../src/components/TransferBulkUpload.tsx | 2 +- clients/banking/src/utils/projectId.ts | 2 +- clients/onboarding/src/components/ErrorView.tsx | 2 +- clients/onboarding/src/utils/projectId.ts | 2 +- clients/onboarding/src/utils/validation.ts | 2 +- clients/payment/src/components/ErrorView.tsx | 2 +- clients/payment/src/utils/projectId.ts | 2 +- server/src/api/oauth2.swan.ts | 2 +- server/src/api/partner.ts | 2 +- server/src/app.ts | 16 ++++++++-------- server/src/index.swan.ts | 6 +++--- 17 files changed, 25 insertions(+), 26 deletions(-) diff --git a/biome.json b/biome.json index 18337e2b6..627ec8b93 100644 --- a/biome.json +++ b/biome.json @@ -63,7 +63,6 @@ "noConfusingVoidType": "off", "noShadowRestrictedNames": "off", - "noDoubleEquals": "off", "noGlobalIsNan": "off" } } diff --git a/clients/banking/src/components/CardWizard.tsx b/clients/banking/src/components/CardWizard.tsx index fcb8a3ec5..959fc82ec 100644 --- a/clients/banking/src/components/CardWizard.tsx +++ b/clients/banking/src/components/CardWizard.tsx @@ -282,7 +282,7 @@ export const CardWizard = ({ const card = input.cards[0]; - if (input.cards.length === 1 && card != undefined) { + if (input.cards.length === 1 && card != null) { return addSingleUseCard({ input: { name: card.name, diff --git a/clients/banking/src/components/CardWizardDelivery.tsx b/clients/banking/src/components/CardWizardDelivery.tsx index 94f5f86ad..433b4185e 100644 --- a/clients/banking/src/components/CardWizardDelivery.tsx +++ b/clients/banking/src/components/CardWizardDelivery.tsx @@ -60,7 +60,7 @@ export const CardWizardDelivery = forwardRef( ( { const [requestId] = useState>(() => { - if (error == undefined) { + if (error == null) { return Option.None(); } return Array.findMap(ClientError.toArray(error), error => diff --git a/clients/banking/src/components/MerchantProfileEditor.tsx b/clients/banking/src/components/MerchantProfileEditor.tsx index 5342b31ae..4ac25201b 100644 --- a/clients/banking/src/components/MerchantProfileEditor.tsx +++ b/clients/banking/src/components/MerchantProfileEditor.tsx @@ -142,7 +142,7 @@ export const MerchantProfileEditor = forwardRef accentColor, }) => { const base64Logo = - merchantLogoUrl == undefined + merchantLogoUrl == null ? Future.value(Option.None()) : Future.make>(resolve => { const reader = new FileReader(); diff --git a/clients/banking/src/components/TransferBulkUpload.tsx b/clients/banking/src/components/TransferBulkUpload.tsx index 9ae0df03c..586655b03 100644 --- a/clients/banking/src/components/TransferBulkUpload.tsx +++ b/clients/banking/src/components/TransferBulkUpload.tsx @@ -65,7 +65,7 @@ const parseCsv = (text: string): Result = } if ( reference != null && - reference.trim() != "" && + reference.trim() !== "" && validateTransferReference(reference.trim()) != null ) { return Result.Error({ type: "InvalidReference", line: index + 1 } as const); diff --git a/clients/banking/src/utils/projectId.ts b/clients/banking/src/utils/projectId.ts index d03ce7f8b..e1219cf82 100644 --- a/clients/banking/src/utils/projectId.ts +++ b/clients/banking/src/utils/projectId.ts @@ -1,7 +1,7 @@ import { Option, Result } from "@swan-io/boxed"; export const projectConfiguration = Result.fromExecution(() => { - if (typeof __env.SWAN_PROJECT_ID == "string") { + if (typeof __env.SWAN_PROJECT_ID === "string") { return __env.SWAN_PROJECT_ID; } else { throw new Error(); diff --git a/clients/onboarding/src/components/ErrorView.tsx b/clients/onboarding/src/components/ErrorView.tsx index 8ca29db20..32260a71b 100644 --- a/clients/onboarding/src/components/ErrorView.tsx +++ b/clients/onboarding/src/components/ErrorView.tsx @@ -24,7 +24,7 @@ type Props = { export const ErrorView = ({ error, style }: Props) => { const [requestId] = useState>(() => { - if (error == undefined) { + if (error == null) { return Option.None(); } return Array.findMap(ClientError.toArray(error), error => diff --git a/clients/onboarding/src/utils/projectId.ts b/clients/onboarding/src/utils/projectId.ts index d03ce7f8b..e1219cf82 100644 --- a/clients/onboarding/src/utils/projectId.ts +++ b/clients/onboarding/src/utils/projectId.ts @@ -1,7 +1,7 @@ import { Option, Result } from "@swan-io/boxed"; export const projectConfiguration = Result.fromExecution(() => { - if (typeof __env.SWAN_PROJECT_ID == "string") { + if (typeof __env.SWAN_PROJECT_ID === "string") { return __env.SWAN_PROJECT_ID; } else { throw new Error(); diff --git a/clients/onboarding/src/utils/validation.ts b/clients/onboarding/src/utils/validation.ts index 5d2be8a06..8b806b4c5 100644 --- a/clients/onboarding/src/utils/validation.ts +++ b/clients/onboarding/src/utils/validation.ts @@ -12,7 +12,7 @@ import { import { locale, t } from "./i18n"; export const validateRequiredBoolean: Validator = value => { - if (typeof value != "boolean") { + if (typeof value !== "boolean") { return t("error.requiredField"); } }; diff --git a/clients/payment/src/components/ErrorView.tsx b/clients/payment/src/components/ErrorView.tsx index 8ca29db20..32260a71b 100644 --- a/clients/payment/src/components/ErrorView.tsx +++ b/clients/payment/src/components/ErrorView.tsx @@ -24,7 +24,7 @@ type Props = { export const ErrorView = ({ error, style }: Props) => { const [requestId] = useState>(() => { - if (error == undefined) { + if (error == null) { return Option.None(); } return Array.findMap(ClientError.toArray(error), error => diff --git a/clients/payment/src/utils/projectId.ts b/clients/payment/src/utils/projectId.ts index d03ce7f8b..e1219cf82 100644 --- a/clients/payment/src/utils/projectId.ts +++ b/clients/payment/src/utils/projectId.ts @@ -1,7 +1,7 @@ import { Option, Result } from "@swan-io/boxed"; export const projectConfiguration = Result.fromExecution(() => { - if (typeof __env.SWAN_PROJECT_ID == "string") { + if (typeof __env.SWAN_PROJECT_ID === "string") { return __env.SWAN_PROJECT_ID; } else { throw new Error(); diff --git a/server/src/api/oauth2.swan.ts b/server/src/api/oauth2.swan.ts index d4fa0edc5..030484308 100644 --- a/server/src/api/oauth2.swan.ts +++ b/server/src/api/oauth2.swan.ts @@ -39,7 +39,7 @@ export const exchangeToken = (originalAccessToken: string, config: ExchangeToken ), headers: { "Content-Type": "application/json", - ...(additionalEnv.SWAN_AUTH_TOKEN != undefined + ...(additionalEnv.SWAN_AUTH_TOKEN != null ? { "x-swan-frontend": additionalEnv.SWAN_AUTH_TOKEN } : undefined), }, diff --git a/server/src/api/partner.ts b/server/src/api/partner.ts index ee8e24de3..ee796e7aa 100644 --- a/server/src/api/partner.ts +++ b/server/src/api/partner.ts @@ -21,7 +21,7 @@ let projectId: Future< >; export const getProjectId = () => { - if (projectId != undefined) { + if (projectId != null) { return projectId; } projectId = getClientAccessToken() diff --git a/server/src/app.ts b/server/src/app.ts index 197b7700e..5ab548b02 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -248,7 +248,7 @@ export const start = async ({ const refreshToken = request.session.get("refreshToken"); const expiresAt = request.session.get("expiresAt") ?? 0; - if (typeof refreshToken == "string" && expiresAt < Date.now() + TEN_SECONDS) { + if (typeof refreshToken === "string" && expiresAt < Date.now() + TEN_SECONDS) { refreshAccessToken({ refreshToken, redirectUri: `${env.BANKING_URL}/auth/callback`, @@ -349,7 +349,7 @@ export const start = async ({ return reply.from(env.PARTNER_API_URL, { rewriteRequestHeaders: (_req, headers) => ({ ...headers, - ...(request.accessToken != undefined + ...(request.accessToken != null ? { Authorization: `Bearer ${request.accessToken}` } : undefined), }), @@ -363,7 +363,7 @@ export const start = async ({ return reply.from(env.PARTNER_ADMIN_API_URL, { rewriteRequestHeaders: (_req, headers) => ({ ...headers, - ...(request.accessToken != undefined + ...(request.accessToken != null ? { Authorization: `Bearer ${request.accessToken}` } : undefined), }), @@ -561,7 +561,7 @@ export const start = async ({ return reply.redirect( createAuthUrl({ - scope: scope.split(" ").filter(item => item != null && item != ""), + scope: scope.split(" ").filter(item => item != null && item !== ""), params: { ...(email != null ? { email } : null), ...(onboardingId != null ? { onboardingId } : null), @@ -639,7 +639,7 @@ export const start = async ({ Ok: ({ redirectUrl, state, accountMembershipId, oAuthClientId }) => { const queryString = new URLSearchParams(); - if (redirectUrl != undefined) { + if (redirectUrl != null) { const redirectHost = new URL(redirectUrl).hostname; // When onboarding from the dashboard, we don't yet have a OAuth2 client, @@ -659,7 +659,7 @@ export const start = async ({ } } - if (accountMembershipId != undefined) { + if (accountMembershipId != null) { queryString.append("accountMembershipId", accountMembershipId); } @@ -689,7 +689,7 @@ export const start = async ({ Ok: ({ redirectUrl, state, accountMembershipId }) => { const queryString = new URLSearchParams(); - if (redirectUrl != undefined) { + if (redirectUrl != null) { const authUri = createAuthUrl({ scope: [], redirectUri: redirectUrl, @@ -700,7 +700,7 @@ export const start = async ({ queryString.append("redirectUrl", authUri); } - if (accountMembershipId != undefined) { + if (accountMembershipId != null) { queryString.append("accountMembershipId", accountMembershipId); } diff --git a/server/src/index.swan.ts b/server/src/index.swan.ts index 340d6d378..697c05fe6 100644 --- a/server/src/index.swan.ts +++ b/server/src/index.swan.ts @@ -199,7 +199,7 @@ start({ app.post<{ Params: { projectId: string } }>( "/api/projects/:projectId/partner", async (request, reply) => { - if (request.accessToken == undefined) { + if (request.accessToken == null) { return reply.status(401).send("Unauthorized"); } const projectUserToken = await exchangeToken(request.accessToken, { @@ -224,7 +224,7 @@ start({ app.post<{ Params: { projectId: string } }>( "/api/projects/:projectId/partner-admin", async (request, reply) => { - if (request.accessToken == undefined) { + if (request.accessToken == null) { return reply.status(401).send("Unauthorized"); } const projectUserToken = await exchangeToken(request.accessToken, { @@ -261,7 +261,7 @@ start({ if (inviterAccountMembershipId == null) { return reply.status(400).send("Missing inviterAccountMembershipId"); } - if (request.accessToken == undefined) { + if (request.accessToken == null) { return reply.status(401).send("Unauthorized"); } try {