From b42d7ca1541b4d00e88c54cc6e22db06aa6dfcd4 Mon Sep 17 00:00:00 2001 From: mrbot22 Date: Fri, 5 Mar 2021 16:17:48 +0200 Subject: [PATCH] fix es linter messages --- src/components/CurrencyLogo/index.tsx | 8 +++----- src/components/Header/index.tsx | 4 ++-- src/components/WalletModal/index.tsx | 4 ++-- src/components/earn/PoolCard.tsx | 22 +++++++++++----------- src/components/swap/ConfirmSwapModal.tsx | 2 ++ src/components/swap/SwapModalFooter.tsx | 2 ++ src/components/swap/SwapModalHeader.tsx | 2 ++ src/index.tsx | 1 - src/pages/Earn/Manage.tsx | 18 ++++++++---------- src/pages/Guides/index.tsx | 2 -- src/pages/Swap/index.tsx | 5 ++--- src/state/crosschain/hooks.ts | 2 +- src/state/stake/hooks.ts | 12 ++++++------ src/state/user/hooks.tsx | 1 - src/state/wallet/hooks.ts | 1 + src/theme/components.tsx | 2 +- 16 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/components/CurrencyLogo/index.tsx b/src/components/CurrencyLogo/index.tsx index c575390e53f..e99e787984c 100644 --- a/src/components/CurrencyLogo/index.tsx +++ b/src/components/CurrencyLogo/index.tsx @@ -55,11 +55,9 @@ export default function CurrencyLogo({ // find logos on ETH address for non-ETH assets let logoAddress = currency.address; let allConfigTokens: any = []; - crosschainConfig.chains.map(chain => { - chain.tokens.map(token => { - allConfigTokens.push(token); - }) - }) + crosschainConfig.chains.map(chain => + chain.tokens.map(token => allConfigTokens.push(token)) + ) let chosenToken = allConfigTokens.find((token: any) => token.address === currency.address); let ethToken = crosschainConfig.chains[0].tokens.find((token: any) => token?.assetBase === chosenToken?.assetBase); if (ethToken) { diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 93793e0fad9..52e01065a29 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -1,5 +1,5 @@ -import { BarChart, Book, DollarSign, Menu as MenuIcon, RefreshCw } from 'react-feather' -import { ExternalLink, TYPE } from '../../theme' +import { BarChart, Book, DollarSign, RefreshCw } from 'react-feather' +import { ExternalLink } from '../../theme' import Row, { RowFixed } from '../Row' // import AvaxLogo from '../../assets/images/avax-logo.png' diff --git a/src/components/WalletModal/index.tsx b/src/components/WalletModal/index.tsx index 3b3b07b3b8e..a719cc1d299 100644 --- a/src/components/WalletModal/index.tsx +++ b/src/components/WalletModal/index.tsx @@ -163,10 +163,10 @@ export default function WalletModal({ }, [setWalletView, active, error, connector, walletModalOpen, activePrevious, connectorPrevious]) const tryActivation = async (connector: AbstractConnector | undefined) => { - let name = '' + Object.keys(SUPPORTED_WALLETS).map(key => { if (connector === SUPPORTED_WALLETS[key].connector) { - return (name = SUPPORTED_WALLETS[key].name) + return SUPPORTED_WALLETS[key].name } return true }) diff --git a/src/components/earn/PoolCard.tsx b/src/components/earn/PoolCard.tsx index 9484d422abc..b79e6cc808e 100644 --- a/src/components/earn/PoolCard.tsx +++ b/src/components/earn/PoolCard.tsx @@ -2,8 +2,8 @@ import { AVAX, ChainId, ETHER, JSBI, TokenAmount } from '@zeroexchange/sdk' import { Break, CardBGImage, CardNoise } from './styled' import { ButtonPrimary, ButtonWhiteBg } from '../Button' import { ExternalLink, StyledInternalLink, TYPE } from '../../theme' -import React, { useState } from 'react' -import { useTokenBalance, useTokenBalancesWithLoadingIndicator } from '../../state/wallet/hooks' +import React from 'react' +// import { useTokenBalance } from '../../state/wallet/hooks' import { AutoColumn } from '../Column' import { BIG_INT_SECONDS_IN_WEEK } from '../../constants' @@ -76,7 +76,7 @@ const BottomSection = styled.div<{ showBackground: boolean }>` export default function PoolCard({ stakingInfoTop }: { stakingInfoTop: StakingInfo }) { - const { chainId, account } = useActiveWeb3React() + const { chainId } = useActiveWeb3React() const token0 = stakingInfoTop.tokens[0] const token1 = stakingInfoTop.tokens[1] @@ -94,16 +94,16 @@ export default function PoolCard({ stakingInfoTop }: { stakingInfoTop: StakingIn const isStaking = Boolean(stakingInfo?.stakedAmount?.greaterThan('0')) // detect existing unstaked LP position to show add button if none found - const userLiquidityUnstaked = useTokenBalance(account ?? undefined, stakingInfo?.stakedAmount?.token) - const showAddLiquidityButton = Boolean(stakingInfo?.stakedAmount?.equalTo('0') && userLiquidityUnstaked?.equalTo('0')) + // const userLiquidityUnstaked = useTokenBalance(account ?? undefined, stakingInfo?.stakedAmount?.token) + // const showAddLiquidityButton = Boolean(stakingInfo?.stakedAmount?.equalTo('0') && userLiquidityUnstaked?.equalTo('0')) - // toggle for staking modal and unstaking modal - const [showStakingModal, setShowStakingModal] = useState(false) - const [showUnstakingModal, setShowUnstakingModal] = useState(false) - const [showClaimRewardModal, setShowClaimRewardModal] = useState(false) + // // toggle for staking modal and unstaking modal + // const [showStakingModal, setShowStakingModal] = useState(false) + // const [showUnstakingModal, setShowUnstakingModal] = useState(false) + // const [showClaimRewardModal, setShowClaimRewardModal] = useState(false) - // fade cards if nothing staked or nothing earned yet - const disableTop = !stakingInfo?.stakedAmount || stakingInfo.stakedAmount.equalTo(JSBI.BigInt(0)) + // // fade cards if nothing staked or nothing earned yet + // const disableTop = !stakingInfo?.stakedAmount || stakingInfo.stakedAmount.equalTo(JSBI.BigInt(0)) const token = (currencyA === ETHER || currencyA === AVAX) ? tokenB : tokenA const WETH = (currencyA === ETHER || currencyA === AVAX) ? tokenA : tokenB diff --git a/src/components/swap/ConfirmSwapModal.tsx b/src/components/swap/ConfirmSwapModal.tsx index bcc8a8524b2..784cd9e476a 100644 --- a/src/components/swap/ConfirmSwapModal.tsx +++ b/src/components/swap/ConfirmSwapModal.tsx @@ -66,6 +66,7 @@ export default function ConfirmSwapModal({ chainId={chainId} /> ) : null + // eslint-disable-next-line }, [allowedSlippage, onAcceptChanges, recipient, showAcceptChanges, trade]) const modalBottom = useCallback(() => { @@ -79,6 +80,7 @@ export default function ConfirmSwapModal({ chainId={chainId} /> ) : null + // eslint-disable-next-line }, [allowedSlippage, onConfirm, showAcceptChanges, swapErrorMessage, trade]) // text to show while loading diff --git a/src/components/swap/SwapModalFooter.tsx b/src/components/swap/SwapModalFooter.tsx index 2b85339141e..cfb49c38888 100644 --- a/src/components/swap/SwapModalFooter.tsx +++ b/src/components/swap/SwapModalFooter.tsx @@ -40,6 +40,8 @@ export default function SwapModalFooter({ allowedSlippage, trade ]) + + // eslint-disable-next-line const { priceImpactWithoutFee, realizedLPFee } = useMemo(() => computeTradePriceBreakdown(trade, chainId), [trade]) const severity = warningSeverity(priceImpactWithoutFee) diff --git a/src/components/swap/SwapModalHeader.tsx b/src/components/swap/SwapModalHeader.tsx index df45079a118..494b35a262b 100644 --- a/src/components/swap/SwapModalHeader.tsx +++ b/src/components/swap/SwapModalHeader.tsx @@ -33,6 +33,8 @@ export default function SwapModalHeader({ trade, allowedSlippage ]) + + // eslint-disable-next-line const { priceImpactWithoutFee } = useMemo(() => computeTradePriceBreakdown(trade, chainId), [trade]) const priceImpactSeverity = warningSeverity(priceImpactWithoutFee) diff --git a/src/index.tsx b/src/index.tsx index 4ee7c79f5ff..82d7749ca1d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,6 @@ import { createWeb3ReactRoot, Web3ReactProvider } from '@web3-react/core' import 'inter-ui' import React, { StrictMode } from 'react' -import { isMobile } from 'react-device-detect' import ReactDOM from 'react-dom' import { Provider } from 'react-redux' import { HashRouter } from 'react-router-dom' diff --git a/src/pages/Earn/Manage.tsx b/src/pages/Earn/Manage.tsx index a48781df401..000cc59b61d 100644 --- a/src/pages/Earn/Manage.tsx +++ b/src/pages/Earn/Manage.tsx @@ -1,4 +1,4 @@ -import { AVAX, ChainId, ETHER, JSBI, Pair, TokenAmount } from '@zeroexchange/sdk' +import { AVAX, ETHER, JSBI, Pair, TokenAmount } from '@zeroexchange/sdk' import { BIG_INT_SECONDS_IN_WEEK, BIG_INT_ZERO } from '../../constants' import { CardBGImage, CardNoise, CardSection, DataCard } from '../../components/earn/styled' import React, { useCallback, useContext, useMemo, useState } from 'react' @@ -24,7 +24,6 @@ import { currencyId } from '../../utils/currencyId' import { useActiveWeb3React } from '../../hooks' import { useColor } from '../../hooks/useColor' import { useCurrency } from '../../hooks/Tokens' -import { useHistory } from 'react-router'; import { usePair } from '../../data/Reserves' import { usePairs } from '../../data/Reserves' import usePrevious from '../../hooks/usePrevious' @@ -140,7 +139,6 @@ export default function Manage({ const { account, chainId } = useActiveWeb3React() const theme = useContext(ThemeContext) - let history = useHistory(); // get currencies and pair const [currencyA, currencyB] = [useCurrency(currencyIdA), useCurrency(currencyIdB)] const tokenA = wrappedCurrency(currencyA ?? undefined, chainId) @@ -241,13 +239,13 @@ export default function Manage({ const stakingPairs = usePairs(stakingInfosWithBalance?.map(stakingInfo => stakingInfo.tokens)) // remove any pairs that also are included in pairs with stake in mining pool - const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter(v2Pair => { - return ( - stakingPairs - ?.map(stakingPair => stakingPair[1]) - .filter(stakingPair => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0 - ) - }) + // const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter(v2Pair => { + // return ( + // stakingPairs + // ?.map(stakingPair => stakingPair[1]) + // .filter(stakingPair => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0 + // ) + // }) const showMe = (pair: any) => { return pair?.token0?.symbol === stakingTokenPair?.token0?.symbol && diff --git a/src/pages/Guides/index.tsx b/src/pages/Guides/index.tsx index 391b7f1d43f..0c8f73353c3 100644 --- a/src/pages/Guides/index.tsx +++ b/src/pages/Guides/index.tsx @@ -2,8 +2,6 @@ import AppBody from '../AppBody' import { AutoColumn } from '../../components/Column' import { Book } from 'react-feather' import React from 'react' -import { TYPE } from '../../theme' -import { Wrapper } from '../../components/swap/styleds' import styled from 'styled-components' const GuideItem = styled.div` diff --git a/src/pages/Swap/index.tsx b/src/pages/Swap/index.tsx index 3baf73f9928..d57a171dce3 100644 --- a/src/pages/Swap/index.tsx +++ b/src/pages/Swap/index.tsx @@ -13,7 +13,7 @@ import { setTransferAmount } from '../../state/crosschain/actions' import Column, { AutoColumn } from '../../components/Column' -import { Field, selectCurrency } from '../../state/swap/actions' +import { Field } from '../../state/swap/actions' import { GetTokenByAddress, useCrossChain, useCrosschainHooks, useCrosschainState } from '../../state/crosschain/hooks' import { LinkStyledButton, TYPE } from '../../theme' import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react' @@ -55,7 +55,6 @@ import { Text } from 'rebass' import TokenWarningModal from '../../components/TokenWarningModal' import TradePrice from '../../components/swap/TradePrice' import confirmPriceImpactWithoutFee from '../../components/swap/confirmPriceImpactWithoutFee' -import { getTradeVersion } from '../../data/V1' import { maxAmountSpend } from '../../utils/maxAmountSpend' import { useActiveWeb3React } from '../../hooks' import { useCurrency } from '../../hooks/Tokens' @@ -133,7 +132,6 @@ export default function Swap() { const { currentTxID, availableChains, - availableTokens, currentChain, currentToken, transferAmount, @@ -312,6 +310,7 @@ export default function Swap() { txHash: undefined }) }) + // eslint-disable-next-line }, [tradeToConfirm, account, priceImpactWithoutFee, recipient, recipientAddress, showConfirm, swapCallback, trade]) // errors diff --git a/src/state/crosschain/hooks.ts b/src/state/crosschain/hooks.ts index 2674b5865e3..2d7229cc8b4 100644 --- a/src/state/crosschain/hooks.ts +++ b/src/state/crosschain/hooks.ts @@ -13,7 +13,6 @@ import { setCrosschainSwapDetails, setCrosschainTransferStatus, setCurrentChain, - setCurrentToken, setCurrentTokenBalance, setCurrentTxID, setPendingTransfer, @@ -484,5 +483,6 @@ export function useCrossChain() { dispatch(setCrosschainRecipient({ address: account || '' })) UpdateOwnTokenBalance().catch(console.error) UpdateFee().catch(console.error) + // eslint-disable-next-line }, [account, currentToken]) } diff --git a/src/state/stake/hooks.ts b/src/state/stake/hooks.ts index 79fed00fbd2..047e28cc55e 100644 --- a/src/state/stake/hooks.ts +++ b/src/state/stake/hooks.ts @@ -1,6 +1,6 @@ import { ChainId, CurrencyAmount, JSBI, Token, TokenAmount, WETH, Pair } from '@zeroexchange/sdk' import { useMemo } from 'react' -import { ZERO, MOCK1, UNI, zETH, zUSDC, WAVAX, zZERO} from '../../constants' +import { MOCK1, UNI, zETH, zUSDC, WAVAX, zZERO } from '../../constants' import { STAKING_REWARDS_INTERFACE } from '../../constants/abis/staking-rewards' import { useActiveWeb3React } from '../../hooks' import { NEVER_RELOAD, useMultipleContractSingleData } from '../multicall/hooks' @@ -87,13 +87,13 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] { () => chainId ? STAKING_REWARDS_INFO[chainId]?.filter(stakingRewardInfo => - pairToFilterBy === undefined - ? true - : pairToFilterBy === null + pairToFilterBy === undefined + ? true + : pairToFilterBy === null ? false : pairToFilterBy.involvesToken(stakingRewardInfo.tokens[0]) && - pairToFilterBy.involvesToken(stakingRewardInfo.tokens[1]) - ) ?? [] + pairToFilterBy.involvesToken(stakingRewardInfo.tokens[1]) + ) ?? [] : [], [chainId, pairToFilterBy] ) diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index ae00a4a925a..33c4b21d12e 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -19,7 +19,6 @@ import { useCallback, useMemo } from 'react' import flatMap from 'lodash.flatmap' import { useActiveWeb3React } from '../../hooks' import { useAllTokens } from '../../hooks/Tokens' -import { useHistory } from "react-router-dom"; function serializeToken(token: Token): SerializedToken { return { diff --git a/src/state/wallet/hooks.ts b/src/state/wallet/hooks.ts index 159cfa73738..b8f50193a28 100644 --- a/src/state/wallet/hooks.ts +++ b/src/state/wallet/hooks.ts @@ -45,6 +45,7 @@ export function useETHBalances( if (value) memo[address] = CurrencyAmount.ether(JSBI.BigInt(value.toString()), chainId) return memo }, {}), + // eslint-disable-next-line [addresses, results] ) } diff --git a/src/theme/components.tsx b/src/theme/components.tsx index c0a0807f480..d595d31a9d7 100644 --- a/src/theme/components.tsx +++ b/src/theme/components.tsx @@ -136,7 +136,7 @@ export function ExternalLink({ event.preventDefault() } }, - [href, target] + [target] ) return }