-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frontend: add eslint rule restrict-template-expressions #2325
Changes from all commits
f8bccf4
c6ee6e0
f5930ed
58c9fc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,23 +56,22 @@ import PAXG_GREY from './assets/paxg-white.svg'; | |
import ShiftLogo from './assets/shift-cryptosecurity-logo.svg'; | ||
import style from './logo.module.css'; | ||
|
||
interface GenericProps { | ||
[property: string]: any; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed and replaced by |
||
|
||
export const BitBox = (props: GenericProps) => <img {...props} draggable={false} src={BitBoxLogo} alt="BitBox" className={style.logo} />; | ||
export const BitBox02 = (props: GenericProps) => <img {...props} draggable={false} src={BitBox02Logo} alt="BitBox02" className={style.logo} />; | ||
export const BitBox02Inverted = (props: GenericProps) => <img {...props} draggable={false} src={BitBox02InvertedLogo} alt="BitBox02" className={style.logo} />; | ||
export const AppLogo = (props: GenericProps) => <img {...props} draggable={false} src={AppLogoImg} alt="BitBox" className={style.logo} />; | ||
export const AppLogoInverted = (props: GenericProps) => <img {...props} draggable={false} src={AppLogoInvertedImg} alt="BitBox" className={style.logo} />; | ||
export const BitBoxSwiss = (props: GenericProps) => <img {...props} draggable={false} src={BitBoxSwissLogo} alt="BitBox" className={style.logo} />; | ||
export const BitBoxSwissInverted = (props: GenericProps) => <img {...props} draggable={false} src={BitBoxSwissInvertedLogo} alt="BitBox" className={style.logo} />; | ||
export const Shift = (props: GenericProps) => <img {...props} draggable={false} src={ShiftLogo} alt="Shift Crypto" className={style.logo} />; | ||
export const SwissMadeOpenSource = ({ large: boolean, className, ...props }: GenericProps) => <img {...props} draggable={false} src={SwissOpenSourceLight} alt="Swiss Made Open Source" className={`${style.swissOpenSource} ${props.large ? style.large : ''} ${className ? className : ''}`} />; | ||
export const SwissMadeOpenSourceDark = ({ large: boolean, className, ...props }: GenericProps) => <img {...props} draggable={false} src={SwissOpenSourceDark} alt="Swiss Made Open Source" className={`${style.swissOpenSource} ${props.large ? style.large : ''} ${className ? className : ''}`} />; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed ({ large, ...props }) => props.large // props.large is always undefined |
||
type ImgProps = JSX.IntrinsicElements['img']; | ||
|
||
export const BitBox = (props: ImgProps) => <img {...props} draggable={false} src={BitBoxLogo} alt="BitBox" className={style.logo} />; | ||
export const BitBox02 = (props: ImgProps) => <img {...props} draggable={false} src={BitBox02Logo} alt="BitBox02" className={style.logo} />; | ||
export const BitBox02Inverted = (props: ImgProps) => <img {...props} draggable={false} src={BitBox02InvertedLogo} alt="BitBox02" className={style.logo} />; | ||
export const AppLogo = (props: ImgProps) => <img {...props} draggable={false} src={AppLogoImg} alt="BitBox" className={style.logo} />; | ||
export const AppLogoInverted = (props: ImgProps) => <img {...props} draggable={false} src={AppLogoInvertedImg} alt="BitBox" className={style.logo} />; | ||
export const BitBoxSwiss = (props: ImgProps) => <img {...props} draggable={false} src={BitBoxSwissLogo} alt="BitBox" className={style.logo} />; | ||
export const BitBoxSwissInverted = (props: ImgProps) => <img {...props} draggable={false} src={BitBoxSwissInvertedLogo} alt="BitBox" className={style.logo} />; | ||
export const Shift = (props: ImgProps) => <img {...props} draggable={false} src={ShiftLogo} alt="Shift Crypto" className={style.logo} />; | ||
export const SwissMadeOpenSource = ({ className, ...props }: ImgProps) => <img {...props} draggable={false} src={SwissOpenSourceLight} alt="Swiss Made Open Source" className={`${style.swissOpenSource} ${className ? className : ''}`} />; | ||
export const SwissMadeOpenSourceDark = ({ className, ...props }: ImgProps) => <img {...props} draggable={false} src={SwissOpenSourceDark} alt="Swiss Made Open Source" className={`${style.swissOpenSource} ${className ? className : ''}`} />; | ||
|
||
type LogoMap = { | ||
[key in CoinCode]: string[]; | ||
[key in CoinCode]: string[]; | ||
} | ||
|
||
const logoMap: LogoMap = { | ||
|
@@ -96,20 +95,20 @@ const logoMap: LogoMap = { | |
'eth-erc20-paxg': [PAXG, PAXG_GREY], | ||
}; | ||
|
||
interface Props { | ||
active?: boolean; | ||
alt?: string; | ||
className?: string; | ||
coinCode: CoinCode; | ||
stacked?: boolean; | ||
type LogoProps = { | ||
active?: boolean; | ||
alt?: string; | ||
className?: string; | ||
coinCode: CoinCode; | ||
stacked?: boolean; | ||
} | ||
|
||
export const Logo = ({ | ||
coinCode, | ||
active, | ||
stacked, | ||
...rest | ||
}: Props) => { | ||
}: LogoProps) => { | ||
if (!logoMap[coinCode]) { | ||
console.error('logo undefined for ', coinCode); | ||
return null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,14 +54,16 @@ export const BuyReceiveCTA = ({ | |
const isMobile = useMediaQuery('(max-width: 768px)'); | ||
|
||
const onExchangeCTA = () => navigate(code ? `/exchange/info/${code}` : '/exchange/info'); | ||
const onWalletConnect = () => navigate(`/account/${code}/wallet-connect/dashboard`); | ||
const onWalletConnect = () => code && navigate(`/account/${code}/wallet-connect/dashboard`); | ||
const onReceiveCTA = () => { | ||
if (balanceList) { | ||
if (balanceList.length > 1) { | ||
navigate('/accounts/select-receive'); | ||
return; | ||
} | ||
navigate(`/account/${code}/receive`); | ||
if (code) { | ||
navigate(`/account/${code}/receive`); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks a bit weird and could be cleaned up by refatoring AddBuyReceiveOnEmptyBalances and BuyReceiveCTA component. I.e. balanceList is probably not really needed in BuyReceiveCTA and something like a boolean |
||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,9 +98,11 @@ class Restore extends Component<Props, State> { | |
route('/', true); | ||
} | ||
} else { | ||
alertUser(this.props.t(`backup.restore.error.e${code}`, { | ||
defaultValue: errorMessage, | ||
})); | ||
if (typeof code === 'string') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some un-typed BitBox01 backups specific api call. We usually know what type when we use the |
||
alertUser(this.props.t(`backup.restore.error.e${code}`, { | ||
defaultValue: errorMessage, | ||
})); | ||
} | ||
} | ||
}); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,20 @@ import { apiPost } from '../../../../../utils/request'; | |
import { A } from '../../../../../components/anchor/anchor'; | ||
import style from '../../bitbox01.module.css'; | ||
|
||
interface PairingProps { | ||
deviceID: string; | ||
deviceLocked: boolean; | ||
paired: boolean; | ||
hasMobileChannel: boolean; | ||
onPairingEnabled: () => void; | ||
type PairingProps = { | ||
deviceID: string; | ||
deviceLocked: boolean; | ||
paired: boolean; | ||
hasMobileChannel: boolean; | ||
onPairingEnabled: () => void; | ||
} | ||
|
||
type Props = PairingProps & TranslateProps; | ||
|
||
interface State { | ||
channel: string | null; | ||
status: string | boolean; | ||
showQRCode: boolean; | ||
type State = { | ||
channel: string | null; | ||
status: string | false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
showQRCode: boolean; | ||
} | ||
|
||
class MobilePairing extends Component<Props, State> { | ||
|
@@ -206,14 +206,14 @@ class MobilePairing extends Component<Props, State> { | |
); | ||
} else if (status === 'connectOnly') { | ||
content = (<QRCode tapToCopy={false} data={JSON.stringify({ channel, connectOnly: true })} />); | ||
} else { | ||
} else if (status) { | ||
content = (<p className="m-top-none">{t(`pairing.${status}.text`)}</p>); | ||
} | ||
return ( | ||
<div> | ||
<SettingsButton | ||
onClick={hasMobileChannel && !paired ? this.reconnectUnpaired : this.startPairing} | ||
optionalText={t(`deviceSettings.pairing.status.${paired}`)}> | ||
optionalText={t(`deviceSettings.pairing.status.${paired ? 'true' : 'false' }`)}> | ||
{ deviceLocked ? ( | ||
hasMobileChannel ? t('pairing.reconnectOnly.button') : t('pairing.connectOnly.button') | ||
) : ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? I guess best practice, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without converting to string somehow i.e.
String()
this will error with:We use the intrinsic element option (prob shouldn't :) ) this has the type
value?: string | readonly string[] | number | undefined;