From f8bccf4abab96abbe5601c746aa112a05d767a46 Mon Sep 17 00:00:00 2001 From: thisconnect Date: Tue, 31 Oct 2023 11:44:45 +0100 Subject: [PATCH 1/4] frontend: add eslint rule restrict-template-expressions So that we do not accidentally pass undefined, null, booleans or just any type in tempalte literals, see: `all these should error ${false} ${undefined} ${[]} ${null}` This is a eslint rule, so only make weblint will check. --- frontends/web/.eslintrc.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontends/web/.eslintrc.json b/frontends/web/.eslintrc.json index 1fdeb8e2ad..104229a2b7 100644 --- a/frontends/web/.eslintrc.json +++ b/frontends/web/.eslintrc.json @@ -57,7 +57,16 @@ "overrides": [ { "files": ["**/*.ts?(x)"], - "rules": { } + "rules": { + "@typescript-eslint/restrict-template-expressions": ["error", { + "allowAny": false, + "allowBoolean": false, + "allowNullish": false + }] + }, + "parserOptions": { + "project": ["./tsconfig.json"] + } }, { "files": ["**/*.test.ts?(x)"], From c6ee6e07d593e5a1a0dac0601275be24e0cf4651 Mon Sep 17 00:00:00 2001 From: thisconnect Date: Mon, 2 Dec 2024 14:19:00 +0100 Subject: [PATCH 2/4] frontend: fix restrict-template-expressions Last commit introduced restrict-template-expressions, with this all reported problems should be fixed. --- frontends/web/src/api/subscribe.ts | 2 +- frontends/web/src/components/forms/select.tsx | 2 +- frontends/web/src/components/icon/logo.tsx | 41 +++++++++---------- .../web/src/contexts/WCWeb3WalletProvider.tsx | 12 +++--- frontends/web/src/i18n/i18n.test.tsx | 2 +- .../src/routes/account/info/buyReceiveCTA.tsx | 6 ++- .../web/src/routes/account/info/info.tsx | 17 +++++--- .../src/routes/account/send/feetargets.tsx | 28 ++++++------- .../incoming-pairing/incoming-pairing.tsx | 3 +- .../src/routes/device/bitbox01/restore.tsx | 8 ++-- .../settings/components/mobile-pairing.tsx | 24 +++++------ .../src/routes/device/bitbox01/setup/goal.jsx | 2 +- .../device/bitbox01/setup/initialize.tsx | 18 ++++---- .../bitbox01/setup/security-information.tsx | 18 ++++---- .../device/bitbox01/setup/seed-create-new.jsx | 2 +- .../device/bitbox01/setup/seed-restore.jsx | 2 +- .../routes/device/bitbox01/setup/success.jsx | 2 +- .../src/routes/device/bitbox02/passphrase.tsx | 8 ++-- .../src/routes/device/bitbox02/setup/name.tsx | 2 +- .../defaultCurrencyDropdownSetting.tsx | 3 +- .../appearance/languageDropdownSetting.tsx | 2 +- .../attestation-check-setting.tsx | 2 +- 22 files changed, 110 insertions(+), 96 deletions(-) diff --git a/frontends/web/src/api/subscribe.ts b/frontends/web/src/api/subscribe.ts index 59122cf557..602a893c23 100644 --- a/frontends/web/src/api/subscribe.ts +++ b/frontends/web/src/api/subscribe.ts @@ -42,7 +42,7 @@ export const subscribeEndpoint = ( .catch(console.error); break; default: - throw new Error(`Event: ${event} not supported`); + throw new Error(`Event: ${JSON.stringify(event)} not supported`); } }); }; diff --git a/frontends/web/src/components/forms/select.tsx b/frontends/web/src/components/forms/select.tsx index 6e7e22269f..43ec5d09e6 100644 --- a/frontends/web/src/components/forms/select.tsx +++ b/frontends/web/src/components/forms/select.tsx @@ -41,7 +41,7 @@ export const Select = ({