diff --git a/dapp/.eslintrc b/dapp/.eslintrc index 4317c87a7..637e91d05 100644 --- a/dapp/.eslintrc +++ b/dapp/.eslintrc @@ -16,5 +16,15 @@ { "allowRequiredDefaults": true } ], "react/require-default-props": [0] + }, + "settings": { + "import/resolver": { + "alias": { + "map": [ + ["#", "./src"] + ], + "extensions": [".js", ".jsx",".ts", ".tsx"] + } + } } } diff --git a/dapp/package.json b/dapp/package.json index c3b061d02..98a2673bf 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -34,6 +34,8 @@ "@typescript-eslint/parser": "^6.12.0", "@vitejs/plugin-react": "^4.2.0", "eslint": "^8.54.0", + "eslint-import-resolver-alias": "^1.1.2", + "eslint-plugin-import": "^2.29.1", "prettier": "^3.1.0", "typescript": "^5.3.2", "vite": "^5.0.2", diff --git a/dapp/src/components/DocsDrawer/index.tsx b/dapp/src/components/DocsDrawer/index.tsx index 5082af57b..060c6e731 100644 --- a/dapp/src/components/DocsDrawer/index.tsx +++ b/dapp/src/components/DocsDrawer/index.tsx @@ -5,8 +5,8 @@ import { DrawerContent, DrawerOverlay, } from "@chakra-ui/react" -import { useDocsDrawer } from "../../hooks" -import { TextMd } from "../shared/Typography" +import { useDocsDrawer } from "#/hooks" +import { TextMd } from "#/components/shared/Typography" export default function DocsDrawer() { const { isOpen, onClose } = useDocsDrawer() diff --git a/dapp/src/components/GlobalStyles/index.tsx b/dapp/src/components/GlobalStyles/index.tsx index 80b36e6e8..352fe7af0 100644 --- a/dapp/src/components/GlobalStyles/index.tsx +++ b/dapp/src/components/GlobalStyles/index.tsx @@ -1,11 +1,11 @@ import React from "react" import { Global } from "@emotion/react" -import SegmentRegular from "../../fonts/Segment-Regular.otf" -import SegmentMedium from "../../fonts/Segment-Medium.otf" -import SegmentSemiBold from "../../fonts/Segment-SemiBold.otf" -import SegmentBold from "../../fonts/Segment-Bold.otf" -import SegmentBlack from "../../fonts/Segment-Black.otf" +import SegmentRegular from "#/fonts/Segment-Regular.otf" +import SegmentMedium from "#/fonts/Segment-Medium.otf" +import SegmentSemiBold from "#/fonts/Segment-SemiBold.otf" +import SegmentBold from "#/fonts/Segment-Bold.otf" +import SegmentBlack from "#/fonts/Segment-Black.otf" export default function GlobalStyles() { return ( diff --git a/dapp/src/components/Header/ConnectWallet.tsx b/dapp/src/components/Header/ConnectWallet.tsx index 90069b4e7..5319a04ca 100644 --- a/dapp/src/components/Header/ConnectWallet.tsx +++ b/dapp/src/components/Header/ConnectWallet.tsx @@ -1,15 +1,15 @@ import React from "react" import { Button, HStack, Icon } from "@chakra-ui/react" import { Account } from "@ledgerhq/wallet-api-client" -import { Bitcoin, Ethereum } from "../../static/icons" import { useRequestBitcoinAccount, useRequestEthereumAccount, useWalletContext, -} from "../../hooks" -import { truncateAddress } from "../../utils" -import { CurrencyBalance } from "../shared/CurrencyBalance" -import { TextMd } from "../shared/Typography" +} from "#/hooks" +import { CurrencyBalance } from "#/components/shared/CurrencyBalance" +import { TextMd } from "#/components/shared/Typography" +import { Bitcoin, Ethereum } from "#/static/icons" +import { truncateAddress } from "#/utils" export type ConnectButtonsProps = { leftIcon: typeof Icon diff --git a/dapp/src/components/Header/index.tsx b/dapp/src/components/Header/index.tsx index 544fbdee9..480cb502e 100644 --- a/dapp/src/components/Header/index.tsx +++ b/dapp/src/components/Header/index.tsx @@ -1,7 +1,7 @@ import React from "react" import { Flex, HStack, Icon } from "@chakra-ui/react" +import { AcreLogo } from "#/static/icons" import ConnectWallet from "./ConnectWallet" -import { AcreLogo } from "../../static/icons" export default function Header() { return ( diff --git a/dapp/src/components/Modals/ActionForm/index.tsx b/dapp/src/components/Modals/ActionForm/index.tsx index 0eae3fe5b..eabb156bb 100644 --- a/dapp/src/components/Modals/ActionForm/index.tsx +++ b/dapp/src/components/Modals/ActionForm/index.tsx @@ -7,8 +7,8 @@ import { TabPanels, TabPanel, } from "@chakra-ui/react" +import { useModalFlowContext } from "#/hooks" import StakeForm from "../Staking/StakeForm" -import { useModalFlowContext } from "../../../hooks" const TABS = ["stake", "unstake"] as const diff --git a/dapp/src/components/Modals/Staking/DepositBTC.tsx b/dapp/src/components/Modals/Staking/DepositBTC.tsx index 853159262..924a0ee24 100644 --- a/dapp/src/components/Modals/Staking/DepositBTC.tsx +++ b/dapp/src/components/Modals/Staking/DepositBTC.tsx @@ -1,7 +1,7 @@ import React from "react" -import Alert from "../../shared/Alert" -import { useDepositBTCTransaction, useModalFlowContext } from "../../../hooks" -import { TextMd } from "../../shared/Typography" +import { useDepositBTCTransaction, useModalFlowContext } from "#/hooks" +import Alert from "#/components/shared/Alert" +import { TextMd } from "#/components/shared/Typography" import StakingSteps from "./components/StakingSteps" export default function DepositBTC() { diff --git a/dapp/src/components/Modals/Staking/Overview/index.tsx b/dapp/src/components/Modals/Staking/Overview/index.tsx index ecb2c310a..af2485db6 100644 --- a/dapp/src/components/Modals/Staking/Overview/index.tsx +++ b/dapp/src/components/Modals/Staking/Overview/index.tsx @@ -6,8 +6,8 @@ import { ModalHeader, StepNumber, } from "@chakra-ui/react" -import { useModalFlowContext } from "../../../../hooks" -import StepperBase from "../../../shared/StepperBase" +import StepperBase from "#/components/shared/StepperBase" +import { useModalFlowContext } from "#/hooks" import { STEPS } from "./steps" export default function Overview() { diff --git a/dapp/src/components/Modals/Staking/Overview/steps.tsx b/dapp/src/components/Modals/Staking/Overview/steps.tsx index 257c671fa..7a6c3ce7a 100644 --- a/dapp/src/components/Modals/Staking/Overview/steps.tsx +++ b/dapp/src/components/Modals/Staking/Overview/steps.tsx @@ -1,5 +1,5 @@ import React from "react" -import { StepBase } from "../../../shared/StepperBase" +import { StepBase } from "#/components/shared/StepperBase" import { Description, Title } from "../components/StakingSteps" export const STEPS: StepBase[] = [ diff --git a/dapp/src/components/Modals/Staking/SignMessage.tsx b/dapp/src/components/Modals/Staking/SignMessage.tsx index 3c6442676..e3cda7886 100644 --- a/dapp/src/components/Modals/Staking/SignMessage.tsx +++ b/dapp/src/components/Modals/Staking/SignMessage.tsx @@ -1,8 +1,8 @@ import React from "react" import { Highlight } from "@chakra-ui/react" -import Alert from "../../shared/Alert" -import { useModalFlowContext, useSignMessage } from "../../../hooks" -import { TextMd } from "../../shared/Typography" +import { useModalFlowContext, useSignMessage } from "#/hooks" +import Alert from "#/components/shared/Alert" +import { TextMd } from "#/components/shared/Typography" import StakingSteps from "./components/StakingSteps" export default function SignMessage() { diff --git a/dapp/src/components/Modals/Staking/StakeForm/Details.tsx b/dapp/src/components/Modals/Staking/StakeForm/Details.tsx index efa0f70a3..698e6da54 100644 --- a/dapp/src/components/Modals/Staking/StakeForm/Details.tsx +++ b/dapp/src/components/Modals/Staking/StakeForm/Details.tsx @@ -1,9 +1,9 @@ import React from "react" import { List } from "@chakra-ui/react" -import { useTransactionDetails } from "../../../../hooks" -import TransactionDetailsAmountItem from "../../../shared/TransactionDetails/AmountItem" -import { CurrencyType } from "../../../../types" -import { useTokenAmountFormValue } from "../../../shared/TokenAmountForm/TokenAmountFormBase" +import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/AmountItem" +import { useTokenAmountFormValue } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" +import { useTransactionDetails } from "#/hooks" +import { CurrencyType } from "#/types" function Details({ currency }: { currency: CurrencyType }) { const value = useTokenAmountFormValue() diff --git a/dapp/src/components/Modals/Staking/StakeForm/index.tsx b/dapp/src/components/Modals/Staking/StakeForm/index.tsx index 635e17e23..e5d5a0754 100644 --- a/dapp/src/components/Modals/Staking/StakeForm/index.tsx +++ b/dapp/src/components/Modals/Staking/StakeForm/index.tsx @@ -1,10 +1,10 @@ import React, { useCallback } from "react" import { Button } from "@chakra-ui/react" -import { BITCOIN_MIN_AMOUNT } from "../../../../constants" -import { ModalStep } from "../../../../contexts" -import { useWalletContext, useTransactionContext } from "../../../../hooks" -import TokenAmountForm from "../../../shared/TokenAmountForm" -import { TokenAmountFormValues } from "../../../shared/TokenAmountForm/TokenAmountFormBase" +import { BITCOIN_MIN_AMOUNT } from "#/constants" +import { ModalStep } from "#/contexts" +import TokenAmountForm from "#/components/shared/TokenAmountForm" +import { TokenAmountFormValues } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" +import { useWalletContext, useTransactionContext } from "#/hooks" import Details from "./Details" function StakeForm({ goNext }: ModalStep) { diff --git a/dapp/src/components/Modals/Staking/components/StakingSteps.tsx b/dapp/src/components/Modals/Staking/components/StakingSteps.tsx index a0ebfd4cb..f092ad079 100644 --- a/dapp/src/components/Modals/Staking/components/StakingSteps.tsx +++ b/dapp/src/components/Modals/Staking/components/StakingSteps.tsx @@ -6,9 +6,9 @@ import { ModalFooter, ModalHeader, } from "@chakra-ui/react" -import { TextLg, TextMd } from "../../../shared/Typography" -import StepperBase, { StepBase } from "../../../shared/StepperBase" -import Spinner from "../../../shared/Spinner" +import { TextLg, TextMd } from "#/components/shared/Typography" +import StepperBase, { StepBase } from "#/components/shared/StepperBase" +import Spinner from "#/components/shared/Spinner" export function Title({ children }: { children: React.ReactNode }) { return {children} diff --git a/dapp/src/components/Modals/Staking/index.tsx b/dapp/src/components/Modals/Staking/index.tsx index 78d04706c..e74dd57ea 100644 --- a/dapp/src/components/Modals/Staking/index.tsx +++ b/dapp/src/components/Modals/Staking/index.tsx @@ -1,7 +1,7 @@ import React from "react" -import { useModalFlowContext } from "../../../hooks" +import { useModalFlowContext } from "#/hooks" +import ModalBase from "#/components/shared/ModalBase" import Overview from "./Overview" -import ModalBase from "../../shared/ModalBase" import ActionForm from "../ActionForm" import SignMessage from "./SignMessage" import DepositBTC from "./DepositBTC" diff --git a/dapp/src/components/Modals/Support/MissingAccount.tsx b/dapp/src/components/Modals/Support/MissingAccount.tsx index 2c32b354e..89ca3effd 100644 --- a/dapp/src/components/Modals/Support/MissingAccount.tsx +++ b/dapp/src/components/Modals/Support/MissingAccount.tsx @@ -7,10 +7,10 @@ import { ModalFooter, ModalHeader, } from "@chakra-ui/react" -import { CurrencyType, RequestAccountParams } from "../../../types" -import { TextMd } from "../../shared/Typography" -import Alert from "../../shared/Alert" -import { getCurrencyByType } from "../../../utils" +import { TextMd } from "#/components/shared/Typography" +import Alert from "#/components/shared/Alert" +import { getCurrencyByType } from "#/utils" +import { CurrencyType, RequestAccountParams } from "#/types" type MissingAccountProps = { currency: CurrencyType diff --git a/dapp/src/components/Modals/Support/index.tsx b/dapp/src/components/Modals/Support/index.tsx index c6784fff4..ae5aa98eb 100644 --- a/dapp/src/components/Modals/Support/index.tsx +++ b/dapp/src/components/Modals/Support/index.tsx @@ -3,9 +3,9 @@ import { useRequestBitcoinAccount, useRequestEthereumAccount, useWalletContext, -} from "../../../hooks" +} from "#/hooks" +import { ConnectBTCAccount, ConnectETHAccount } from "#/static/icons" import MissingAccount from "./MissingAccount" -import { ConnectBTCAccount, ConnectETHAccount } from "../../../static/icons" export default function SupportWrapper({ children, diff --git a/dapp/src/components/Overview/PositionDetails.tsx b/dapp/src/components/Overview/PositionDetails.tsx index c1de13f71..0555c3ddf 100644 --- a/dapp/src/components/Overview/PositionDetails.tsx +++ b/dapp/src/components/Overview/PositionDetails.tsx @@ -10,10 +10,10 @@ import { CardProps, useBoolean, } from "@chakra-ui/react" -import { Info } from "../../static/icons" +import { CurrencyBalanceWithConversion } from "#/components/shared/CurrencyBalanceWithConversion" +import { TextMd } from "#/components/shared/Typography" +import { Info } from "#/static/icons" import StakingModal from "../Modals/Staking" -import { CurrencyBalanceWithConversion } from "../shared/CurrencyBalanceWithConversion" -import { TextMd } from "../shared/Typography" export default function PositionDetails(props: CardProps) { const [isOpenStakingModal, stakingModal] = useBoolean() diff --git a/dapp/src/components/Overview/Statistics.tsx b/dapp/src/components/Overview/Statistics.tsx index 8b9c5979e..b8681ac3e 100644 --- a/dapp/src/components/Overview/Statistics.tsx +++ b/dapp/src/components/Overview/Statistics.tsx @@ -1,6 +1,6 @@ import React from "react" import { CardBody, Card, CardProps } from "@chakra-ui/react" -import { TextMd } from "../shared/Typography" +import { TextMd } from "#/components/shared/Typography" export default function Statistics(props: CardProps) { return ( diff --git a/dapp/src/components/Overview/TransactionHistory.tsx b/dapp/src/components/Overview/TransactionHistory.tsx index e0ff1fb26..a151804df 100644 --- a/dapp/src/components/Overview/TransactionHistory.tsx +++ b/dapp/src/components/Overview/TransactionHistory.tsx @@ -1,6 +1,6 @@ import React from "react" import { CardBody, Card, CardProps } from "@chakra-ui/react" -import { TextMd } from "../shared/Typography" +import { TextMd } from "#/components/shared/Typography" export default function TransactionHistory(props: CardProps) { return ( diff --git a/dapp/src/components/Overview/index.tsx b/dapp/src/components/Overview/index.tsx index 0ac2b4041..d67bed7a8 100644 --- a/dapp/src/components/Overview/index.tsx +++ b/dapp/src/components/Overview/index.tsx @@ -1,12 +1,12 @@ import React from "react" import { Button, Flex, Grid, HStack, Icon, Switch } from "@chakra-ui/react" +import { useDocsDrawer } from "#/hooks" +import { TextSm } from "#/components/shared/Typography" +import { ArrowUpRight } from "#/static/icons" +import { USD } from "#/constants" import PositionDetails from "./PositionDetails" import Statistics from "./Statistics" import TransactionHistory from "./TransactionHistory" -import { USD } from "../../constants" -import { ArrowUpRight } from "../../static/icons" -import { TextSm } from "../shared/Typography" -import { useDocsDrawer } from "../../hooks" export default function Overview() { const { onOpen } = useDocsDrawer() diff --git a/dapp/src/components/Sidebar/index.tsx b/dapp/src/components/Sidebar/index.tsx index a7625698f..faebd8be0 100644 --- a/dapp/src/components/Sidebar/index.tsx +++ b/dapp/src/components/Sidebar/index.tsx @@ -1,6 +1,6 @@ import React from "react" import { Box, Button, useMultiStyleConfig } from "@chakra-ui/react" -import { useDocsDrawer, useSidebar } from "../../hooks" +import { useDocsDrawer, useSidebar } from "#/hooks" export default function Sidebar() { const { isOpen } = useSidebar() diff --git a/dapp/src/components/shared/Alert/index.tsx b/dapp/src/components/shared/Alert/index.tsx index 2ab05a8f2..687e0599b 100644 --- a/dapp/src/components/shared/Alert/index.tsx +++ b/dapp/src/components/shared/Alert/index.tsx @@ -7,7 +7,7 @@ import { Icon, useMultiStyleConfig, } from "@chakra-ui/react" -import { AlertInfo, ArrowUpRight } from "../../../static/icons" +import { AlertInfo, ArrowUpRight } from "#/static/icons" const ICONS = { info: AlertInfo, diff --git a/dapp/src/components/shared/CurrencyBalance/index.tsx b/dapp/src/components/shared/CurrencyBalance/index.tsx index f44f7505e..fdf136420 100644 --- a/dapp/src/components/shared/CurrencyBalance/index.tsx +++ b/dapp/src/components/shared/CurrencyBalance/index.tsx @@ -4,8 +4,8 @@ import { formatTokenAmount, getCurrencyByType, numberToLocaleString, -} from "../../../utils" -import { CurrencyType } from "../../../types" +} from "#/utils" +import { CurrencyType } from "#/types" export type CurrencyBalanceProps = { currency: CurrencyType diff --git a/dapp/src/components/shared/ModalBase/index.tsx b/dapp/src/components/shared/ModalBase/index.tsx index cfeb34472..6b253e89d 100644 --- a/dapp/src/components/shared/ModalBase/index.tsx +++ b/dapp/src/components/shared/ModalBase/index.tsx @@ -5,13 +5,13 @@ import { ModalContent, ModalOverlay, } from "@chakra-ui/react" +import { useSidebar } from "#/hooks" import { ModalFlowContext, ModalFlowContextValue, TransactionContextProvider, -} from "../../../contexts" -import { useSidebar } from "../../../hooks" -import SupportWrapper from "../../Modals/Support" +} from "#/contexts" +import SupportWrapper from "#/components/Modals/Support" export default function ModalBase({ isOpen, diff --git a/dapp/src/components/shared/TokenAmountForm/TokenAmountFormBase.tsx b/dapp/src/components/shared/TokenAmountForm/TokenAmountFormBase.tsx index 7324f2251..18e4bd712 100644 --- a/dapp/src/components/shared/TokenAmountForm/TokenAmountFormBase.tsx +++ b/dapp/src/components/shared/TokenAmountForm/TokenAmountFormBase.tsx @@ -1,7 +1,7 @@ import React from "react" import { FormikProps, useField } from "formik" +import { CurrencyType } from "#/types" import { Form, FormTokenBalanceInput } from "../Form" -import { CurrencyType } from "../../../types" const TOKEN_AMOUNT_FIELD_NAME = "amount" diff --git a/dapp/src/components/shared/TokenAmountForm/index.tsx b/dapp/src/components/shared/TokenAmountForm/index.tsx index d6d0716c1..c4b8dfec7 100644 --- a/dapp/src/components/shared/TokenAmountForm/index.tsx +++ b/dapp/src/components/shared/TokenAmountForm/index.tsx @@ -1,5 +1,5 @@ import { FormikErrors, withFormik } from "formik" -import { getErrorsObj, validateTokenAmount } from "../../../utils" +import { getErrorsObj, validateTokenAmount } from "#/utils" import TokenAmountFormBase, { TokenAmountFormBaseProps, TokenAmountFormValues, diff --git a/dapp/src/components/shared/TokenBalanceInput/index.tsx b/dapp/src/components/shared/TokenBalanceInput/index.tsx index 82aa75fee..68975da92 100644 --- a/dapp/src/components/shared/TokenBalanceInput/index.tsx +++ b/dapp/src/components/shared/TokenBalanceInput/index.tsx @@ -16,13 +16,13 @@ import { fixedPointNumberToString, getCurrencyByType, userAmountToBigInt, -} from "../../../utils" -import { CurrencyType } from "../../../types" +} from "#/utils" +import { AlertInfo } from "#/static/icons" +import { CurrencyType } from "#/types" import NumberFormatInput, { NumberFormatInputValues, } from "../NumberFormatInput" import { CurrencyBalance } from "../CurrencyBalance" -import { AlertInfo } from "../../../static/icons" const VARIANT = "balance" diff --git a/dapp/src/constants/currency.ts b/dapp/src/constants/currency.ts index 420adb8b6..6f747bb1a 100644 --- a/dapp/src/constants/currency.ts +++ b/dapp/src/constants/currency.ts @@ -1,4 +1,4 @@ -import { Currency, CurrencyType } from "../types" +import { Currency, CurrencyType } from "#/types" export const BITCOIN: Currency = { name: "Bitcoin", diff --git a/dapp/src/contexts/TransactionContext.tsx b/dapp/src/contexts/TransactionContext.tsx index 384bfb2e5..3064bd530 100644 --- a/dapp/src/contexts/TransactionContext.tsx +++ b/dapp/src/contexts/TransactionContext.tsx @@ -1,5 +1,5 @@ import React, { createContext, useMemo, useState } from "react" -import { TokenAmount } from "../types" +import { TokenAmount } from "#/types" type TransactionContextValue = { tokenAmount?: TokenAmount diff --git a/dapp/src/hooks/useDepositBTCTransaction.ts b/dapp/src/hooks/useDepositBTCTransaction.ts index a629e6485..0bef0c4be 100644 --- a/dapp/src/hooks/useDepositBTCTransaction.ts +++ b/dapp/src/hooks/useDepositBTCTransaction.ts @@ -1,5 +1,5 @@ import { useCallback } from "react" -import { OnSuccessCallback } from "../types" +import { OnSuccessCallback } from "#/types" export function useDepositBTCTransaction(onSuccess?: OnSuccessCallback) { // TODO: sending transactions using the SDK diff --git a/dapp/src/hooks/useDocsDrawer.ts b/dapp/src/hooks/useDocsDrawer.ts index 4ce8bba3e..3536dba2a 100644 --- a/dapp/src/hooks/useDocsDrawer.ts +++ b/dapp/src/hooks/useDocsDrawer.ts @@ -1,5 +1,5 @@ import { useContext } from "react" -import { DocsDrawerContext } from "../contexts" +import { DocsDrawerContext } from "#/contexts" export function useDocsDrawer() { const context = useContext(DocsDrawerContext) diff --git a/dapp/src/hooks/useModalFlowContext.ts b/dapp/src/hooks/useModalFlowContext.ts index 48882c561..fda6eb681 100644 --- a/dapp/src/hooks/useModalFlowContext.ts +++ b/dapp/src/hooks/useModalFlowContext.ts @@ -1,5 +1,5 @@ import { useContext } from "react" -import { ModalFlowContext } from "../contexts" +import { ModalFlowContext } from "#/contexts" export function useModalFlowContext() { const context = useContext(ModalFlowContext) diff --git a/dapp/src/hooks/useRequestBitcoinAccount.ts b/dapp/src/hooks/useRequestBitcoinAccount.ts index 036db196d..051467dcf 100644 --- a/dapp/src/hooks/useRequestBitcoinAccount.ts +++ b/dapp/src/hooks/useRequestBitcoinAccount.ts @@ -1,8 +1,8 @@ import { useRequestAccount } from "@ledgerhq/wallet-api-client-react" import { useCallback, useContext, useEffect } from "react" -import { CURRENCY_ID_BITCOIN } from "../constants" -import { UseRequestAccountReturn } from "../types" -import { WalletContext } from "../contexts" +import { WalletContext } from "#/contexts" +import { UseRequestAccountReturn } from "#/types" +import { CURRENCY_ID_BITCOIN } from "#/constants" export function useRequestBitcoinAccount(): UseRequestAccountReturn { const { setBtcAccount } = useContext(WalletContext) diff --git a/dapp/src/hooks/useRequestEthereumAccount.ts b/dapp/src/hooks/useRequestEthereumAccount.ts index 5c3cad1f1..fcf18c6ff 100644 --- a/dapp/src/hooks/useRequestEthereumAccount.ts +++ b/dapp/src/hooks/useRequestEthereumAccount.ts @@ -1,8 +1,8 @@ import { useRequestAccount } from "@ledgerhq/wallet-api-client-react" import { useCallback, useContext, useEffect } from "react" -import { CURRENCY_ID_ETHEREUM } from "../constants" -import { UseRequestAccountReturn } from "../types" -import { WalletContext } from "../contexts" +import { WalletContext } from "#/contexts" +import { UseRequestAccountReturn } from "#/types" +import { CURRENCY_ID_ETHEREUM } from "#/constants" export function useRequestEthereumAccount(): UseRequestAccountReturn { const { setEthAccount } = useContext(WalletContext) diff --git a/dapp/src/hooks/useSidebar.ts b/dapp/src/hooks/useSidebar.ts index 986143a89..944364076 100644 --- a/dapp/src/hooks/useSidebar.ts +++ b/dapp/src/hooks/useSidebar.ts @@ -1,5 +1,5 @@ import { useContext } from "react" -import { SidebarContext } from "../contexts" +import { SidebarContext } from "#/contexts" export function useSidebar() { const context = useContext(SidebarContext) diff --git a/dapp/src/hooks/useSignMessage.ts b/dapp/src/hooks/useSignMessage.ts index cc3cadc3e..cd38d1001 100644 --- a/dapp/src/hooks/useSignMessage.ts +++ b/dapp/src/hooks/useSignMessage.ts @@ -1,7 +1,7 @@ import { useSignMessage as useSignMessageLedgerLive } from "@ledgerhq/wallet-api-client-react" import { useCallback, useEffect } from "react" +import { OnSuccessCallback } from "#/types" import { useWalletContext } from "./useWalletContext" -import { OnSuccessCallback } from "../types" const SIGN_MESSAGE = "Test message" diff --git a/dapp/src/hooks/useTransactionContext.ts b/dapp/src/hooks/useTransactionContext.ts index d28c8bf1b..41a8a8359 100644 --- a/dapp/src/hooks/useTransactionContext.ts +++ b/dapp/src/hooks/useTransactionContext.ts @@ -1,5 +1,5 @@ import { useContext } from "react" -import { TransactionContext } from "../contexts" +import { TransactionContext } from "#/contexts" export function useTransactionContext() { const context = useContext(TransactionContext) diff --git a/dapp/src/hooks/useWalletContext.ts b/dapp/src/hooks/useWalletContext.ts index 0da19204b..afca84aff 100644 --- a/dapp/src/hooks/useWalletContext.ts +++ b/dapp/src/hooks/useWalletContext.ts @@ -1,5 +1,5 @@ import { useContext } from "react" -import { WalletContext } from "../contexts" +import { WalletContext } from "#/contexts" export function useWalletContext() { const context = useContext(WalletContext) diff --git a/dapp/src/utils/currency.ts b/dapp/src/utils/currency.ts index 39eda0651..4d8b02a78 100644 --- a/dapp/src/utils/currency.ts +++ b/dapp/src/utils/currency.ts @@ -1,5 +1,5 @@ -import { CURRENCIES_BY_TYPE } from "../constants" -import { Currency, CurrencyType } from "../types" +import { Currency, CurrencyType } from "#/types" +import { CURRENCIES_BY_TYPE } from "#/constants" export const getCurrencyByType = (currency: CurrencyType): Currency => CURRENCIES_BY_TYPE[currency] diff --git a/dapp/src/utils/forms.ts b/dapp/src/utils/forms.ts index 9f7f34759..97872a8f4 100644 --- a/dapp/src/utils/forms.ts +++ b/dapp/src/utils/forms.ts @@ -1,4 +1,4 @@ -import { CurrencyType } from "../types" +import { CurrencyType } from "#/types" import { getCurrencyByType } from "./currency" import { formatTokenAmount } from "./numbers" diff --git a/dapp/tsconfig.json b/dapp/tsconfig.json index 2e31274ea..03b8b2fe1 100644 --- a/dapp/tsconfig.json +++ b/dapp/tsconfig.json @@ -11,8 +11,11 @@ "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", - "strict": true + "strict": true, + "baseUrl": ".", + "paths": { + "#/*": ["./src/*"] + } }, - "include": ["src"], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/dapp/vite.config.ts b/dapp/vite.config.ts index cef82d65c..b60415bd0 100644 --- a/dapp/vite.config.ts +++ b/dapp/vite.config.ts @@ -2,6 +2,13 @@ import { defineConfig } from "vite" import react from "@vitejs/plugin-react" import { nodePolyfills } from "vite-plugin-node-polyfills" +import { resolve } from "path" + export default defineConfig({ + resolve: { + alias: { + "#": resolve(__dirname, "./src"), + }, + }, plugins: [nodePolyfills(), react()], }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbe06e8d4..ef9c6254c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -166,6 +166,12 @@ importers: eslint: specifier: ^8.54.0 version: 8.54.0 + eslint-import-resolver-alias: + specifier: ^1.1.2 + version: 1.1.2(eslint-plugin-import@2.29.1) + eslint-plugin-import: + specifier: ^2.29.1 + version: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) prettier: specifier: ^3.1.0 version: 3.1.0 @@ -373,7 +379,7 @@ packages: '@babel/traverse': 7.23.4 '@babel/types': 7.23.4 convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -1617,7 +1623,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.4 '@babel/types': 7.23.4 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -3170,7 +3176,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 espree: 9.6.1 globals: 13.23.0 ignore: 5.3.0 @@ -3775,7 +3781,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -5390,11 +5396,11 @@ packages: '@typescript-eslint/eslint-plugin': 6.12.0(@typescript-eslint/parser@6.12.0)(eslint@8.54.0)(typescript@5.3.2) '@typescript-eslint/parser': 6.12.0(eslint@8.54.0)(typescript@5.3.2) eslint: 8.54.0 - eslint-config-airbnb: 19.0.4(eslint-plugin-import@2.29.0)(eslint-plugin-jsx-a11y@6.8.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.54.0) - eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.0)(eslint@8.54.0) - eslint-config-airbnb-typescript: 17.1.0(@typescript-eslint/eslint-plugin@6.12.0)(@typescript-eslint/parser@6.12.0)(eslint-plugin-import@2.29.0)(eslint@8.54.0) + eslint-config-airbnb: 19.0.4(eslint-plugin-import@2.29.1)(eslint-plugin-jsx-a11y@6.8.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.54.0) + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.1)(eslint@8.54.0) + eslint-config-airbnb-typescript: 17.1.0(@typescript-eslint/eslint-plugin@6.12.0)(@typescript-eslint/parser@6.12.0)(eslint-plugin-import@2.29.1)(eslint@8.54.0) eslint-config-prettier: 9.0.0(eslint@8.54.0) - eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.54.0) eslint-plugin-no-only-tests: 3.1.0 eslint-plugin-prettier: 5.0.1(eslint-config-prettier@9.0.0)(eslint@8.54.0)(prettier@3.1.0) @@ -5793,7 +5799,7 @@ packages: '@typescript-eslint/type-utils': 6.12.0(eslint@8.54.0)(typescript@5.3.2) '@typescript-eslint/utils': 6.12.0(eslint@8.54.0)(typescript@5.3.2) '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.54.0 graphemer: 1.4.0 ignore: 5.3.0 @@ -5838,7 +5844,7 @@ packages: '@typescript-eslint/types': 6.12.0 '@typescript-eslint/typescript-estree': 6.12.0(typescript@5.3.2) '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.54.0 typescript: 5.3.2 transitivePeerDependencies: @@ -5889,7 +5895,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.12.0(typescript@5.3.2) '@typescript-eslint/utils': 6.12.0(eslint@8.54.0)(typescript@5.3.2) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.54.0 ts-api-utils: 1.0.3(typescript@5.3.2) typescript: 5.3.2 @@ -5936,7 +5942,7 @@ packages: dependencies: '@typescript-eslint/types': 6.12.0 '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -7966,6 +7972,17 @@ packages: dependencies: ms: 2.1.3 + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -8577,6 +8594,21 @@ packages: semver: 6.3.1 dev: true + /eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.29.1)(eslint@8.54.0): + resolution: {integrity: sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==} + engines: {node: ^10.12.0 || >=12.0.0} + peerDependencies: + eslint: ^7.32.0 || ^8.2.0 + eslint-plugin-import: ^2.25.2 + dependencies: + confusing-browser-globals: 1.0.11 + eslint: 8.54.0 + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) + object.assign: 4.1.4 + object.entries: 1.1.7 + semver: 6.3.1 + dev: true + /eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@6.12.0)(@typescript-eslint/parser@6.12.0)(eslint-plugin-import@2.29.0)(eslint@8.54.0): resolution: {integrity: sha512-GPxI5URre6dDpJ0CtcthSZVBAfI+Uw7un5OYNVxP2EYi3H81Jw701yFP7AU+/vCE7xBtFmjge7kfhhk4+RAiig==} peerDependencies: @@ -8592,6 +8624,21 @@ packages: eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) dev: true + /eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@6.12.0)(@typescript-eslint/parser@6.12.0)(eslint-plugin-import@2.29.1)(eslint@8.54.0): + resolution: {integrity: sha512-GPxI5URre6dDpJ0CtcthSZVBAfI+Uw7un5OYNVxP2EYi3H81Jw701yFP7AU+/vCE7xBtFmjge7kfhhk4+RAiig==} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^5.13.0 || ^6.0.0 + '@typescript-eslint/parser': ^5.0.0 || ^6.0.0 + eslint: ^7.32.0 || ^8.2.0 + eslint-plugin-import: ^2.25.3 + dependencies: + '@typescript-eslint/eslint-plugin': 6.12.0(@typescript-eslint/parser@6.12.0)(eslint@8.54.0)(typescript@5.3.2) + '@typescript-eslint/parser': 6.12.0(eslint@8.54.0)(typescript@5.3.2) + eslint: 8.54.0 + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.1)(eslint@8.54.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) + dev: true + /eslint-config-airbnb@19.0.4(eslint-plugin-import@2.29.0)(eslint-plugin-jsx-a11y@6.8.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.54.0): resolution: {integrity: sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==} engines: {node: ^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -8612,6 +8659,26 @@ packages: object.entries: 1.1.7 dev: true + /eslint-config-airbnb@19.0.4(eslint-plugin-import@2.29.1)(eslint-plugin-jsx-a11y@6.8.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.54.0): + resolution: {integrity: sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==} + engines: {node: ^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^7.32.0 || ^8.2.0 + eslint-plugin-import: ^2.25.3 + eslint-plugin-jsx-a11y: ^6.5.1 + eslint-plugin-react: ^7.28.0 + eslint-plugin-react-hooks: ^4.3.0 + dependencies: + eslint: 8.54.0 + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.1)(eslint@8.54.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) + eslint-plugin-jsx-a11y: 6.8.0(eslint@8.54.0) + eslint-plugin-react: 7.33.2(eslint@8.54.0) + eslint-plugin-react-hooks: 4.6.0(eslint@8.54.0) + object.assign: 4.1.4 + object.entries: 1.1.7 + dev: true + /eslint-config-prettier@9.0.0(eslint@8.54.0): resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} hasBin: true @@ -8657,6 +8724,15 @@ packages: eslint-plugin-react-hooks: 4.6.0(eslint@8.54.0) typescript: 5.3.2 + /eslint-import-resolver-alias@1.1.2(eslint-plugin-import@2.29.1): + resolution: {integrity: sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w==} + engines: {node: '>= 4'} + peerDependencies: + eslint-plugin-import: '>=1.4.0' + dependencies: + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0) + dev: true + /eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} dependencies: @@ -8738,6 +8814,41 @@ packages: - eslint-import-resolver-webpack - supports-color + /eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.12.0)(eslint@8.54.0): + resolution: {integrity: sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + dependencies: + '@typescript-eslint/parser': 6.12.0(eslint@8.54.0)(typescript@5.3.2) + array-includes: 3.1.7 + array.prototype.findlastindex: 1.2.3 + array.prototype.flat: 1.3.2 + array.prototype.flatmap: 1.3.2 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 8.54.0 + eslint-import-resolver-node: 0.3.9 + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.12.0)(eslint-import-resolver-node@0.3.9)(eslint@8.54.0) + hasown: 2.0.0 + is-core-module: 2.13.1 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.fromentries: 2.0.7 + object.groupby: 1.0.1 + object.values: 1.1.7 + semver: 6.3.1 + tsconfig-paths: 3.15.0 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + dev: true + /eslint-plugin-jsx-a11y@6.8.0(eslint@8.54.0): resolution: {integrity: sha512-Hdh937BS3KdwwbBaKd5+PLCOmYY6U4f2h9Z2ktwtNKvIdIEu137rjYbcb9ApSbVJfWxANNuiKTD/9tOKjK9qOA==} engines: {node: '>=4.0'} @@ -8932,7 +9043,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -15024,6 +15135,15 @@ packages: minimist: 1.2.8 strip-bom: 3.0.0 + /tsconfig-paths@3.15.0: + resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} + dependencies: + '@types/json5': 0.0.29 + json5: 1.0.2 + minimist: 1.2.8 + strip-bom: 3.0.0 + dev: true + /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}