From dd322b5aaca9ff8793e6a3d4daa04ed1cce5697a Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 20 Dec 2022 11:58:27 -0600 Subject: [PATCH] tree-wide: use noopener instead of noreferrer for target="_blank" This will allow us to see when users click links to the pybricks.com website from the app. --- .eslintrc.js | 1 + src/alerts/UnexpectedErrorAlert.tsx | 1 + src/ble/alerts/NoHub.tsx | 1 + src/firmware/alerts/NoDfuHub.tsx | 2 ++ .../bootloaderInstructions/BootloaderInstructions.tsx | 2 +- src/notifications/sagas.ts | 3 ++- src/sponsor/SponsorDialog.tsx | 8 ++++---- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 88caf32e..42005484 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,6 +27,7 @@ module.exports = { 'sort-imports': ['error', { ignoreDeclarationSort: true }], 'import/order': ['error', { alphabetize: { order: 'asc' } }], 'react-hooks/exhaustive-deps': 'error', + 'react/jsx-no-target-blank': ['error', { allowReferrer: true }], }, settings: { react: { version: 'detect' }, diff --git a/src/alerts/UnexpectedErrorAlert.tsx b/src/alerts/UnexpectedErrorAlert.tsx index 76dafb8f..9e862b9b 100644 --- a/src/alerts/UnexpectedErrorAlert.tsx +++ b/src/alerts/UnexpectedErrorAlert.tsx @@ -67,6 +67,7 @@ const UnexpectedErrorAlert: React.VoidFunctionComponent {i18n.translate('reportBug')} diff --git a/src/ble/alerts/NoHub.tsx b/src/ble/alerts/NoHub.tsx index 70680a81..1de1cfa0 100644 --- a/src/ble/alerts/NoHub.tsx +++ b/src/ble/alerts/NoHub.tsx @@ -28,6 +28,7 @@ const NoHub: React.VoidFunctionComponent = ({ onFlashFirmware }) => icon="help" href={pybricksBluetoothTroubleshootingUrl} target="_blank" + rel="noopener" > {i18n.translate('noHub.troubleshootButton')} diff --git a/src/firmware/alerts/NoDfuHub.tsx b/src/firmware/alerts/NoDfuHub.tsx index f027acd1..2c31a827 100644 --- a/src/firmware/alerts/NoDfuHub.tsx +++ b/src/firmware/alerts/NoDfuHub.tsx @@ -38,6 +38,7 @@ const NoDfuHub: React.VoidFunctionComponent = ({ icon="help" href={pybricksUsbLinuxUdevRulesUrl} target="_blank" + rel="noopener" > {i18n.translate('noDfuHub.configureUdevRulesButton')} @@ -47,6 +48,7 @@ const NoDfuHub: React.VoidFunctionComponent = ({ icon="help" href={pybricksUsbDfuTroubleshootingUrl} target="_blank" + rel="noopener" > {i18n.translate('noDfuHub.troubleshootButton')} diff --git a/src/firmware/bootloaderInstructions/BootloaderInstructions.tsx b/src/firmware/bootloaderInstructions/BootloaderInstructions.tsx index f1337b5c..866b2051 100644 --- a/src/firmware/bootloaderInstructions/BootloaderInstructions.tsx +++ b/src/firmware/bootloaderInstructions/BootloaderInstructions.tsx @@ -348,7 +348,7 @@ const BootloaderInstructions: React.VoidFunctionComponent< {i18n.translate('warning.linux.learnMore')} diff --git a/src/notifications/sagas.ts b/src/notifications/sagas.ts index d8aad6ae..db6f7f00 100644 --- a/src/notifications/sagas.ts +++ b/src/notifications/sagas.ts @@ -75,11 +75,12 @@ function mapIcon(level: Level): IconName | undefined { * Converts a URL to an action that can be passed to `ToasterInstance.show()`. * @param helpUrl A URL. */ -function helpAction(helpUrl: string): ActionProps & LinkProps { +function helpAction(helpUrl: string): ActionProps & LinkProps & { rel: string } { return { icon: 'help', href: helpUrl, target: '_blank', + rel: 'noopener', }; } diff --git a/src/sponsor/SponsorDialog.tsx b/src/sponsor/SponsorDialog.tsx index f474603a..2bb3182e 100644 --- a/src/sponsor/SponsorDialog.tsx +++ b/src/sponsor/SponsorDialog.tsx @@ -38,7 +38,7 @@ const SponsorDialog: React.VoidFunctionComponent = () => { {i18n.translate('whoAreWe.team.team')} @@ -74,7 +74,7 @@ const SponsorDialog: React.VoidFunctionComponent = () => { fill={true} href="https://github.com/sponsors/pybricks" target="_blank" - rel="noreferrer" + rel="noopener" > GitHub Sponsors @@ -86,7 +86,7 @@ const SponsorDialog: React.VoidFunctionComponent = () => { fill={true} href="https://www.patreon.com/pybricks" target="_blank" - rel="noreferrer" + rel="noopener" > Patreon @@ -98,7 +98,7 @@ const SponsorDialog: React.VoidFunctionComponent = () => { fill={true} href="https://paypal.me/pybricks" target="_blank" - rel="noreferrer" + rel="noopener" > Paypal