From 86e9463c423894232ec16bd7e3a9b650de005fec Mon Sep 17 00:00:00 2001 From: Mark Sinclair <14054343+mmsinclair@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:17:15 +0000 Subject: [PATCH] Typescript: fix eslint errors and add GitHub Action for linting (#2886) * Fix eslint errors * GitHub Actions: add Typescript project linting * Fix dependency * Revert changes and exclude rule Co-authored-by: Mark Sinclair --- .github/workflows/typescript-lint.yml | 49 +++++++++++++++++++ lerna.json | 4 +- nym-connect/package.json | 2 + nym-connect/src/components/AppVersion.tsx | 2 +- .../src/components/ConnectionButton.tsx | 9 +--- .../src/components/ConnectionStatus.tsx | 2 +- .../Growth/TestAndEarnButtonArea.tsx | 1 + .../Growth/TestAndEarnDraws.stories.tsx | 1 + .../components/Growth/TestAndEarnDraws.tsx | 3 +- .../Growth/TestAndEarnEnterWalletAddress.tsx | 4 +- .../Growth/TestAndEarnPopup.stories.tsx | 5 -- .../components/Growth/TestAndEarnTakePart.tsx | 2 +- .../Growth/TestAndEarnWinner.stories.tsx | 1 + .../components/Growth/TestAndEarnWinner.tsx | 2 +- .../Growth/TestAndEarnWinnerWalletAddress.tsx | 4 +- .../src/components/Growth/context/types.ts | 2 - .../src/components/ServiceProviderPopup.tsx | 4 +- .../components/ServiceProviderSelector.tsx | 4 +- nym-connect/src/context/main.tsx | 6 +-- nym-connect/src/context/mocks/main.tsx | 9 ++-- nym-connect/src/stories/AppFlow.stories.tsx | 5 +- .../src/stories/ConnectedLayout.stories.tsx | 4 +- nym-connect/src/theme/index.tsx | 1 + nym-connect/src/theme/theme.tsx | 1 + .../Accounts/modals/MnemonicModal.tsx | 6 +-- .../src/components/Bonding/BondedMixnode.tsx | 6 +-- .../Bonding/forms/BondMixnodeForm.tsx | 2 +- .../Bonding/forms/gatewayValidationSchema.ts | 1 + .../Bonding/forms/mixnodeValidationSchema.ts | 1 + .../Bonding/modals/BondMoreModal.tsx | 2 +- .../Bonding/modals/NodeSettingsModal.tsx | 4 +- .../components/Bonding/modals/UnbondModal.tsx | 2 +- nym-wallet/src/components/Buy/Tutorial.tsx | 7 +-- nym-wallet/src/components/ClientAddress.tsx | 2 + .../Delegation/DelegationActions.tsx | 1 - .../components/Delegation/DelegationItem.tsx | 9 ++-- .../components/Delegation/UndelegateModal.tsx | 1 - nym-wallet/src/components/LogViewer/index.tsx | 1 + nym-wallet/src/components/Modals/ModalFee.tsx | 14 +++--- .../RewardsPlayground/NodeDetail.tsx | 2 +- .../src/components/Send/SendSuccessModal.tsx | 2 +- nym-wallet/src/context/bonding.tsx | 1 + nym-wallet/src/context/delegations.tsx | 8 +-- nym-wallet/src/context/main.tsx | 2 +- nym-wallet/src/context/mocks/bonding.tsx | 4 +- nym-wallet/src/context/mocks/delegations.tsx | 35 +++++++------ nym-wallet/src/context/mocks/main.tsx | 2 +- nym-wallet/src/context/mocks/rewards.tsx | 2 +- nym-wallet/src/context/rewards.tsx | 2 +- nym-wallet/src/pages/balance/index.tsx | 2 +- nym-wallet/src/pages/balance/vesting.tsx | 3 +- nym-wallet/src/pages/bonding/Bonding.tsx | 14 +++--- .../bonding/node-settings/NodeSettings.tsx | 4 +- .../node-settings/apy-playground/index.tsx | 16 +++--- .../node-settings/apy-playground/utils.tsx | 2 +- .../settings-pages/NodeUnbondPage.tsx | 3 +- .../general-settings/InfoSettings.tsx | 6 +-- .../general-settings/ParametersSettings.tsx | 16 ++---- .../settings-pages/general-settings/index.tsx | 4 +- nym-wallet/src/pages/delegation/index.tsx | 12 ++--- nym-wallet/src/requests/actions.ts | 3 +- nym-wallet/src/requests/queries.ts | 13 +++-- nym-wallet/src/requests/simulate.ts | 3 +- nym-wallet/src/requests/vesting.ts | 15 ++---- nym-wallet/src/svg-icons/poweredByBity.tsx | 2 +- nym-wallet/src/types/global.ts | 11 +---- nym-wallet/src/types/rust/Epoch.ts | 7 ++- nym-wallet/src/types/rust/StateParams.ts | 2 +- nym-wallet/src/utils/index.ts | 4 +- nym-wallet/src/utils/nextEpoch.ts | 23 --------- .../src/App.tsx | 3 +- .../packages/sdk/src/mixnet/wasm/types.ts | 1 + .../packages/sdk/src/mixnet/wasm/worker.ts | 3 ++ .../mui-theme/src/theme/network-explorer.ts | 9 ++-- ts-packages/mui-theme/src/theme/theme.ts | 36 +++----------- ts-packages/mui-theme/src/theme/utils.ts | 31 ++++++++++++ .../components/banners/MaintenanceBanner.tsx | 1 + .../coins/CoinMarkTestnet.stories.tsx | 1 - .../src/components/currency/Currency.tsx | 2 +- .../components/tooltip/Tooltip.stories.tsx | 24 +++++---- .../src/components/tooltip/Tooltip.tsx | 18 +++++-- .../types/src/types/rust/PendingEpochEvent.ts | 8 +-- .../src/types/rust/PendingIntervalEvent.ts | 8 +-- ts-packages/webpack/webpack.common.js | 17 +++---- 84 files changed, 299 insertions(+), 274 deletions(-) create mode 100644 .github/workflows/typescript-lint.yml delete mode 100644 nym-wallet/src/utils/nextEpoch.ts create mode 100644 ts-packages/mui-theme/src/theme/utils.ts diff --git a/.github/workflows/typescript-lint.yml b/.github/workflows/typescript-lint.yml new file mode 100644 index 0000000000..c8234e0e44 --- /dev/null +++ b/.github/workflows/typescript-lint.yml @@ -0,0 +1,49 @@ +name: CI for linting Typescript + +on: + push: + paths: + - 'ts-packages/**' + - 'sdk/typescript/**' + - nym-connect + - nym-wallet + +jobs: + build: + runs-on: custom-runner-linux + steps: + - uses: actions/checkout@v2 + - name: Install rsync + run: sudo apt-get install rsync + - uses: rlespinasse/github-slug-action@v3.x + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Setup yarn + run: npm install -g yarn + - name: Lint + run: yarn && yarn lint + - name: Keybase - Node Install + run: npm install + working-directory: .github/workflows/support-files + - name: Keybase - Send Notification + env: + NYM_NOTIFICATION_KIND: ts-packages + NYM_PROJECT_NAME: "ts-packages" + NYM_CI_WWW_BASE: "${{ secrets.NYM_CI_WWW_BASE }}" + NYM_CI_WWW_LOCATION: "ts-${{ env.GITHUB_REF_SLUG }}" + GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" + GIT_BRANCH: "${GITHUB_REF##*/}" + KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" + KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" + KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" + KEYBASE_NYM_CHANNEL: "ci-ts-packages" + IS_SUCCESS: "${{ job.status == 'success' }}" + MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" + MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" + MATRIX_USER_ID: "${{ secrets.MATRIX_USER_ID }}" + MATRIX_TOKEN: "${{ secrets.MATRIX_TOKEN }}" + MATRIX_DEVICE_ID: "${{ secrets.MATRIX_DEVICE_ID }}" + uses: docker://keybaseio/client:stable-node + with: + args: .github/workflows/support-files/notifications/entry_point.sh diff --git a/lerna.json b/lerna.json index cc6884af07..a2393382ed 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,9 @@ { "packages": [ "ts-packages/*", - "nym-wallet" + "nym-wallet", + "nym-connect", + "sdk/typescript/**" ], "version": "0.0.0" } diff --git a/nym-connect/package.json b/nym-connect/package.json index c2de26db48..9214e54a1b 100644 --- a/nym-connect/package.json +++ b/nym-connect/package.json @@ -30,6 +30,8 @@ "@mui/icons-material": "^5.2.0", "@mui/material": "^5.2.2", "@mui/styles": "^5.2.2", + "@mui/system": ">= 5", + "@mui/lab": "^5.0.0-alpha.72", "@nymproject/react": "^1.0.0", "@tauri-apps/api": "^1.2.0", "@tauri-apps/tauri-forage": "^1.0.0-beta.2", diff --git a/nym-connect/src/components/AppVersion.tsx b/nym-connect/src/components/AppVersion.tsx index f82f99b5a2..2a0250e86b 100644 --- a/nym-connect/src/components/AppVersion.tsx +++ b/nym-connect/src/components/AppVersion.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Typography, Box } from '@mui/material'; +import { Box } from '@mui/material'; import { useClientContext } from 'src/context/main'; export const AppVersion = () => { diff --git a/nym-connect/src/components/ConnectionButton.tsx b/nym-connect/src/components/ConnectionButton.tsx index 74f4846519..29fb90c1db 100644 --- a/nym-connect/src/components/ConnectionButton.tsx +++ b/nym-connect/src/components/ConnectionButton.tsx @@ -1,13 +1,6 @@ import React from 'react'; import { ConnectionStatusKind } from '../types'; -const getBusyFillColor = (color: string): string => { - if (color === '#F4B02D') { - return '#21D072'; - } - return '#F4B02D'; -}; - const getStatusFillColor = (status: ConnectionStatusKind, hover: boolean, isError: boolean): string => { if (isError && hover) { return '#21D072'; @@ -57,7 +50,7 @@ export const ConnectionButton: FCWithChildren<{ busy?: boolean; isError?: boolean; onClick?: (status: ConnectionStatusKind) => void; -}> = ({ status, disabled, isError, onClick, busy }) => { +}> = ({ status, disabled, isError, onClick }) => { const [hover, setHover] = React.useState(false); const handleClick = React.useCallback(() => { diff --git a/nym-connect/src/components/ConnectionStatus.tsx b/nym-connect/src/components/ConnectionStatus.tsx index 8ad2c9932c..c8dadd2e67 100644 --- a/nym-connect/src/components/ConnectionStatus.tsx +++ b/nym-connect/src/components/ConnectionStatus.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Box, CircularProgress, Divider, Stack, Tooltip, Typography } from '@mui/material'; +import { Box, CircularProgress, Tooltip, Typography } from '@mui/material'; import { DateTime } from 'luxon'; import { ConnectionStatusKind, GatewayPerformance } from '../types'; import { ServiceProvider } from '../types/directory'; diff --git a/nym-connect/src/components/Growth/TestAndEarnButtonArea.tsx b/nym-connect/src/components/Growth/TestAndEarnButtonArea.tsx index e3f8372c60..92c88ec321 100644 --- a/nym-connect/src/components/Growth/TestAndEarnButtonArea.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnButtonArea.tsx @@ -18,6 +18,7 @@ export const Wrapper: FCWithChildren<{ disabled: boolean }> = ({ disabled, child ); } + // eslint-disable-next-line react/jsx-no-useless-fragment return <>{children}; }; diff --git a/nym-connect/src/components/Growth/TestAndEarnDraws.stories.tsx b/nym-connect/src/components/Growth/TestAndEarnDraws.stories.tsx index 83776d8e20..c70f223420 100644 --- a/nym-connect/src/components/Growth/TestAndEarnDraws.stories.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnDraws.stories.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-pascal-case */ import * as React from 'react'; import { ComponentMeta } from '@storybook/react'; import { NymShipyardTheme } from 'src/theme'; diff --git a/nym-connect/src/components/Growth/TestAndEarnDraws.tsx b/nym-connect/src/components/Growth/TestAndEarnDraws.tsx index 929313982e..24d97b7439 100644 --- a/nym-connect/src/components/Growth/TestAndEarnDraws.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnDraws.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-no-useless-fragment */ import React from 'react'; import LoadingButton from '@mui/lab/LoadingButton'; import { @@ -134,7 +135,7 @@ const StatusText: FCWithChildren<{ entry: DrawEntry }> = ({ entry }) => { export const TestAndEarnDraws: FCWithChildren<{ sx?: SxProps; -}> = ({ sx }) => { +}> = () => { const context = useTestAndEarnContext(); const draws = React.useMemo( diff --git a/nym-connect/src/components/Growth/TestAndEarnEnterWalletAddress.tsx b/nym-connect/src/components/Growth/TestAndEarnEnterWalletAddress.tsx index efafc67d50..60aea1d51b 100644 --- a/nym-connect/src/components/Growth/TestAndEarnEnterWalletAddress.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnEnterWalletAddress.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { WalletAddressFormField } from '@nymproject/react/account/WalletAddressFormField'; import { SxProps } from '@mui/system'; -import { Paper, Stack, Button, Box } from '@mui/material'; +import { Box, Button, Paper, Stack } from '@mui/material'; import ArrowCircleRightIcon from '@mui/icons-material/ArrowCircleRight'; import { useTestAndEarnContext } from './context/TestAndEarnContext'; @@ -10,7 +10,7 @@ export const TestAndEarnEnterWalletAddress: FCWithChildren<{ placeholder?: string; onSubmit?: () => Promise | void; sx?: SxProps; -}> = ({ initialValue, placeholder, onSubmit, sx }) => { +}> = ({ initialValue, placeholder, onSubmit }) => { const context = useTestAndEarnContext(); const [isAddressValid, setAddressIsValid] = React.useState(false); return ( diff --git a/nym-connect/src/components/Growth/TestAndEarnPopup.stories.tsx b/nym-connect/src/components/Growth/TestAndEarnPopup.stories.tsx index ec5da3282a..7e000ca093 100644 --- a/nym-connect/src/components/Growth/TestAndEarnPopup.stories.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnPopup.stories.tsx @@ -7,13 +7,8 @@ import { TestAndEarnPopup, TestAndEarnPopupContent } from './TestAndEarnPopup'; import { TestAndEarnContextProvider } from './context/TestAndEarnContext'; import { MockProvider } from '../../context/mocks/main'; import { ConnectionStatusKind } from '../../types'; -import { TestAndEarnCurrentDraw } from './TestAndEarnCurrentDraw'; -import { TestAndEarnWinner } from './TestAndEarnWinner'; -import { TestAndEarnDraws } from './TestAndEarnDraws'; -import { TestAndEarnWinnerWalletAddress } from './TestAndEarnWinnerWalletAddress'; import { MockTestAndEarnProvider_NotRegistered, - MockTestAndEarnProvider_Registered, MockTestAndEarnProvider_RegisteredAndError, MockTestAndEarnProvider_RegisteredWithDraws, MockTestAndEarnProvider_RegisteredWithDrawsAndEntry, diff --git a/nym-connect/src/components/Growth/TestAndEarnTakePart.tsx b/nym-connect/src/components/Growth/TestAndEarnTakePart.tsx index b447c9c735..9238c8ce75 100644 --- a/nym-connect/src/components/Growth/TestAndEarnTakePart.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnTakePart.tsx @@ -5,7 +5,7 @@ import { SxProps } from '@mui/system'; import ArrowCircleRightIcon from '@mui/icons-material/ArrowCircleRight'; import { invoke } from '@tauri-apps/api'; import { useTestAndEarnContext } from './context/TestAndEarnContext'; -import { ClientId, Registration } from './context/types'; +import { Registration } from './context/types'; export const TestAndEarnTakePart: FCWithChildren<{ websiteLinkUrl: string; diff --git a/nym-connect/src/components/Growth/TestAndEarnWinner.stories.tsx b/nym-connect/src/components/Growth/TestAndEarnWinner.stories.tsx index ed12362122..03ed77aa53 100644 --- a/nym-connect/src/components/Growth/TestAndEarnWinner.stories.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnWinner.stories.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-pascal-case */ import * as React from 'react'; import { ComponentMeta } from '@storybook/react'; import { NymShipyardTheme } from 'src/theme'; diff --git a/nym-connect/src/components/Growth/TestAndEarnWinner.tsx b/nym-connect/src/components/Growth/TestAndEarnWinner.tsx index 980e285a99..41db329a2a 100644 --- a/nym-connect/src/components/Growth/TestAndEarnWinner.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnWinner.tsx @@ -11,7 +11,7 @@ import Content from './content/en.yaml'; export const TestAndEarnWinner: FCWithChildren<{ sx?: SxProps; entry?: DrawEntry; -}> = ({ sx, entry }) => { +}> = ({ entry }) => { const context = useTestAndEarnContext(); const [busy, setBusy] = React.useState(false); const [error, setError] = React.useState(); diff --git a/nym-connect/src/components/Growth/TestAndEarnWinnerWalletAddress.tsx b/nym-connect/src/components/Growth/TestAndEarnWinnerWalletAddress.tsx index f07593b828..deea1049e7 100644 --- a/nym-connect/src/components/Growth/TestAndEarnWinnerWalletAddress.tsx +++ b/nym-connect/src/components/Growth/TestAndEarnWinnerWalletAddress.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import { Box, Button, Card, CardContent, CardMedia, Typography } from '@mui/material'; +import { Box } from '@mui/material'; import { SxProps } from '@mui/system'; import Content from './content/TestAndEarn/WinnerEntersWalletAddress.mdx'; export const TestAndEarnWinnerWalletAddress: FCWithChildren<{ sx?: SxProps; -}> = ({ sx }) => ( +}> = () => ( diff --git a/nym-connect/src/components/Growth/context/types.ts b/nym-connect/src/components/Growth/context/types.ts index ebedf20d91..c7574b282f 100644 --- a/nym-connect/src/components/Growth/context/types.ts +++ b/nym-connect/src/components/Growth/context/types.ts @@ -1,5 +1,3 @@ -import { DateTime } from 'luxon'; - export interface ClientId { client_id: string; client_id_signature: string; diff --git a/nym-connect/src/components/ServiceProviderPopup.tsx b/nym-connect/src/components/ServiceProviderPopup.tsx index 79a47c375a..660fee4134 100644 --- a/nym-connect/src/components/ServiceProviderPopup.tsx +++ b/nym-connect/src/components/ServiceProviderPopup.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Autocomplete, Box, Chip, Dialog, DialogProps, TextField, Typography } from '@mui/material'; -import { ServiceProvider, Service, Services } from '../types/directory'; +import { Autocomplete, Box, Dialog, DialogProps, TextField, Typography } from '@mui/material'; +import { Service, ServiceProvider, Services } from '../types/directory'; export const ServiceProviderPopup: FCWithChildren< DialogProps & { services: Services; onServiceProviderChanged: (sp?: ServiceProvider, s?: Service) => void } diff --git a/nym-connect/src/components/ServiceProviderSelector.tsx b/nym-connect/src/components/ServiceProviderSelector.tsx index 52bdfece50..741465dac4 100644 --- a/nym-connect/src/components/ServiceProviderSelector.tsx +++ b/nym-connect/src/components/ServiceProviderSelector.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo } from 'react'; -import { Box, CircularProgress, Stack, TextField, Tooltip, Typography, MenuItem, ListItemIcon } from '@mui/material'; -import { ServiceProvider, Service, Services } from '../types/directory'; +import { Box, CircularProgress, MenuItem, Stack, TextField, Tooltip, Typography } from '@mui/material'; +import { Service, ServiceProvider, Services } from '../types/directory'; import { useTauriEvents } from '../utils'; type ServiceWithRandomSp = { diff --git a/nym-connect/src/context/main.tsx b/nym-connect/src/context/main.tsx index d4cbd9cf99..bba01764e7 100644 --- a/nym-connect/src/context/main.tsx +++ b/nym-connect/src/context/main.tsx @@ -4,12 +4,12 @@ import { invoke } from '@tauri-apps/api'; import type { UnlistenFn } from '@tauri-apps/api/event'; import { listen } from '@tauri-apps/api/event'; import { forage } from '@tauri-apps/tauri-forage'; -import { ConnectionStatusKind, GatewayPerformance } from '../types'; -import { ConnectionStatsItem } from '../components/ConnectionStats'; -import { ServiceProvider, Services } from '../types/directory'; import { Error } from 'src/types/error'; import { TauriEvent } from 'src/types/event'; import { getVersion } from '@tauri-apps/api/app'; +import { ConnectionStatusKind, GatewayPerformance } from '../types'; +import { ConnectionStatsItem } from '../components/ConnectionStats'; +import { ServiceProvider, Services } from '../types/directory'; const TAURI_EVENT_STATUS_CHANGED = 'app:connection-status-changed'; diff --git a/nym-connect/src/context/mocks/main.tsx b/nym-connect/src/context/mocks/main.tsx index 0845aa49be..9b4341cc23 100644 --- a/nym-connect/src/context/mocks/main.tsx +++ b/nym-connect/src/context/mocks/main.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { ConnectionStatusKind } from 'src/types'; import { ClientContext, TClientContext } from '../main'; @@ -24,6 +24,7 @@ const mockValues: TClientContext = { export const MockProvider: FCWithChildren<{ children?: React.ReactNode; connectionStatus?: ConnectionStatusKind; -}> = ({ connectionStatus = ConnectionStatusKind.disconnected, children }) => ( - {children} -); +}> = ({ connectionStatus = ConnectionStatusKind.disconnected, children }) => { + const value = useMemo(() => ({ ...mockValues, connectionStatus }), [connectionStatus]); + return {children}; +}; diff --git a/nym-connect/src/stories/AppFlow.stories.tsx b/nym-connect/src/stories/AppFlow.stories.tsx index 248334d0c8..f0c8428058 100644 --- a/nym-connect/src/stories/AppFlow.stories.tsx +++ b/nym-connect/src/stories/AppFlow.stories.tsx @@ -8,7 +8,6 @@ import { ConnectionStatusKind } from '../types'; import { DefaultLayout } from '../layouts/DefaultLayout'; import { ConnectedLayout } from '../layouts/ConnectedLayout'; import { Services } from '../types/directory'; -import { TestAndEarnButtonArea } from '../components/Growth/TestAndEarnButtonArea'; export default { title: 'App/Flow', @@ -90,9 +89,7 @@ export const Mock: ComponentStory = () => { { - return undefined; - }} + handleCloseInfoModal={() => undefined} status={context.connectionStatus} busy={busy} onConnectClick={handleConnectClick} diff --git a/nym-connect/src/stories/ConnectedLayout.stories.tsx b/nym-connect/src/stories/ConnectedLayout.stories.tsx index 4d79900340..216e9c38db 100644 --- a/nym-connect/src/stories/ConnectedLayout.stories.tsx +++ b/nym-connect/src/stories/ConnectedLayout.stories.tsx @@ -15,9 +15,7 @@ export const Default: ComponentStory = () => ( { - return undefined; - }} + handleCloseInfoModal={() => undefined} status={ConnectionStatusKind.connected} connectedSince={DateTime.now()} ipAddress="127.0.0.1" diff --git a/nym-connect/src/theme/index.tsx b/nym-connect/src/theme/index.tsx index 7eb23af5df..ad2350053d 100644 --- a/nym-connect/src/theme/index.tsx +++ b/nym-connect/src/theme/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { createTheme, ThemeProvider } from '@mui/material/styles'; import { CssBaseline } from '@mui/material'; import { getDesignTokens } from './theme'; +// eslint-disable-next-line import/no-relative-packages import '../../../assets/fonts/non-variable/fonts.css'; /** diff --git a/nym-connect/src/theme/theme.tsx b/nym-connect/src/theme/theme.tsx index a580ae0b4e..abda87ef72 100644 --- a/nym-connect/src/theme/theme.tsx +++ b/nym-connect/src/theme/theme.tsx @@ -73,6 +73,7 @@ const lightMode: NymPaletteVariant = { * IMPORTANT: do not export this constant, always use the MUI `useTheme` hook to get the correct * colours for dark/light mode. */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars const nymMixnetPalette = (variant: NymPaletteVariant): NymMixnetPalette => ({ nymMixnet: {}, }); diff --git a/nym-wallet/src/components/Accounts/modals/MnemonicModal.tsx b/nym-wallet/src/components/Accounts/modals/MnemonicModal.tsx index bede36211b..c9ea2202a3 100644 --- a/nym-wallet/src/components/Accounts/modals/MnemonicModal.tsx +++ b/nym-wallet/src/components/Accounts/modals/MnemonicModal.tsx @@ -3,18 +3,16 @@ import { Box, Button, CircularProgress, - Paper, Dialog, DialogActions, DialogContent, DialogTitle, - IconButton, + Paper, Typography, } from '@mui/material'; -import { ArrowBackSharp } from '@mui/icons-material'; import { AccountsContext } from 'src/context'; import { useClipboard } from 'use-clipboard-copy'; -import { PasswordInput, Mnemonic } from 'src/components'; +import { Mnemonic, PasswordInput } from 'src/components'; import { StyledBackButton } from 'src/components/StyledBackButton'; export const MnemonicModal = () => { diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index ae32fdefba..199c8f5653 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -7,11 +7,11 @@ import { TBondedMixnode, urls } from 'src/context'; import { NymCard } from 'src/components'; import { IdentityKey } from 'src/components/IdentityKey'; import { NodeStatus } from 'src/components/NodeStatus'; +import { getIntervalAsDate } from 'src/utils'; import { Node as NodeIcon } from '../../svg-icons/node'; import { Cell, Header, NodeTable } from './NodeTable'; import { BondedMixnodeActions, TBondedMixnodeActions } from './BondedMixnodeActions'; import { NodeStats } from './NodeStats'; -import { getIntervalAsDate } from 'src/utils'; const textWhenNotName = 'This node has not yet set a name'; @@ -85,8 +85,8 @@ export const BondedMixnode = ({ const getNextInterval = async () => { try { - const { nextEpoch } = await getIntervalAsDate(); - setNextEpoch(nextEpoch); + const { nextEpoch: newNextEpoch } = await getIntervalAsDate(); + setNextEpoch(newNextEpoch); } catch { setNextEpoch(Error()); } diff --git a/nym-wallet/src/components/Bonding/forms/BondMixnodeForm.tsx b/nym-wallet/src/components/Bonding/forms/BondMixnodeForm.tsx index 6f229a403d..2f8864a017 100644 --- a/nym-wallet/src/components/Bonding/forms/BondMixnodeForm.tsx +++ b/nym-wallet/src/components/Bonding/forms/BondMixnodeForm.tsx @@ -9,8 +9,8 @@ import { checkHasEnoughFunds, checkHasEnoughLockedTokens } from 'src/utils'; import { NodeTypeSelector, TokenPoolSelector } from 'src/components'; import { MixnodeAmount, MixnodeData } from 'src/pages/bonding/types'; import { ModalListItem } from 'src/components/Modals/ModalListItem'; -import { amountSchema, mixnodeValidationSchema } from './mixnodeValidationSchema'; import { AppContext } from 'src/context'; +import { amountSchema, mixnodeValidationSchema } from './mixnodeValidationSchema'; const NodeFormData = ({ mixnodeData, onNext }: { mixnodeData: MixnodeData; onNext: (data: any) => void }) => { const [showAdvancedOptions, setShowAdvancedOptions] = useState(false); diff --git a/nym-wallet/src/components/Bonding/forms/gatewayValidationSchema.ts b/nym-wallet/src/components/Bonding/forms/gatewayValidationSchema.ts index c126d6c309..82de5cd3a2 100644 --- a/nym-wallet/src/components/Bonding/forms/gatewayValidationSchema.ts +++ b/nym-wallet/src/components/Bonding/forms/gatewayValidationSchema.ts @@ -60,6 +60,7 @@ export const amountSchema = Yup.object().shape({ operatorCost: Yup.object().shape({ amount: Yup.string() .required('An operating cost is required') + // eslint-disable-next-line .test('valid-operating-cost', 'A valid amount is required (min 40)', async function isValidAmount(this, value) { if (value && (!Number(value) || isLessThan(+value, 40))) { return false; diff --git a/nym-wallet/src/components/Bonding/forms/mixnodeValidationSchema.ts b/nym-wallet/src/components/Bonding/forms/mixnodeValidationSchema.ts index aa5752f4aa..2289760520 100644 --- a/nym-wallet/src/components/Bonding/forms/mixnodeValidationSchema.ts +++ b/nym-wallet/src/components/Bonding/forms/mixnodeValidationSchema.ts @@ -40,6 +40,7 @@ const operatingCostAndPmValidation = { operatorCost: Yup.object().shape({ amount: Yup.string() .required('An operating cost is required') + // eslint-disable-next-line prefer-arrow-callback .test('valid-operating-cost', 'A valid amount is required (min 40)', async function isValidAmount(this, value) { if (value && (!Number(value) || isLessThan(+value, 40))) { return false; diff --git a/nym-wallet/src/components/Bonding/modals/BondMoreModal.tsx b/nym-wallet/src/components/Bonding/modals/BondMoreModal.tsx index e2145e431e..e99315b467 100644 --- a/nym-wallet/src/components/Bonding/modals/BondMoreModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/BondMoreModal.tsx @@ -4,7 +4,7 @@ import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField' import { ModalListItem } from 'src/components/Modals/ModalListItem'; import { SimpleModal } from 'src/components/Modals/SimpleModal'; import { DecCoin } from '@nymproject/types'; -import { TokenPoolSelector, TPoolOption } from 'src/components/TokenPoolSelector'; +import { TPoolOption } from 'src/components/TokenPoolSelector'; import { ConfirmTx } from 'src/components/ConfirmTX'; import { useGetFee } from 'src/hooks/useGetFee'; import { validateAmount } from 'src/utils'; diff --git a/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx b/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx index 3a8dca5576..0aa53e7368 100644 --- a/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/NodeSettingsModal.tsx @@ -12,7 +12,7 @@ import { simulateUpdateMixnodeCostParams, simulateVestingUpdateMixnodeCostParams import { LoadingModal } from 'src/components/Modals/LoadingModal'; import { FeeDetails } from '@nymproject/types'; -//Now we are using the node setting page instead of this modal +// Now we are using the node setting page instead of this modal export const NodeSettings = ({ currentPm, isVesting, @@ -108,7 +108,7 @@ export const NodeSettings = ({ okLabel="Next" onClose={onClose} > - + Set profit margin diff --git a/nym-wallet/src/components/Bonding/modals/UnbondModal.tsx b/nym-wallet/src/components/Bonding/modals/UnbondModal.tsx index 15b46b517b..41eeb45211 100644 --- a/nym-wallet/src/components/Bonding/modals/UnbondModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/UnbondModal.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; +import { useEffect } from 'react'; import { Typography } from '@mui/material'; -import { useEffect, useState } from 'react'; import { TBondedGateway, TBondedMixnode } from 'src/context'; import { useGetFee } from 'src/hooks/useGetFee'; import { isGateway, isMixnode } from 'src/types'; diff --git a/nym-wallet/src/components/Buy/Tutorial.tsx b/nym-wallet/src/components/Buy/Tutorial.tsx index 8d403cb2e6..be669a38a5 100644 --- a/nym-wallet/src/components/Buy/Tutorial.tsx +++ b/nym-wallet/src/components/Buy/Tutorial.tsx @@ -2,10 +2,10 @@ import React, { useContext, useState } from 'react'; import { Button, Stack, Typography, Grid, useMediaQuery, useTheme } from '@mui/material'; import { Tune as TuneIcon, BorderColor as BorderColorIcon } from '@mui/icons-material'; import { CoinMark } from '@nymproject/react/coins/CoinMark'; -import { NymCard, ClientAddress } from '../../components'; -import { SignMessageModal } from './SignMessageModal'; import { PoweredByBity } from 'src/svg-icons'; import { AppContext } from 'src/context'; +import { NymCard, ClientAddress } from '..'; +import { SignMessageModal } from './SignMessageModal'; // TODO retrieve this value from env const EXCHANGE_URL = 'https://buy.nymtech.net'; @@ -114,7 +114,8 @@ export const Tutorial = () => { icon={} text={ t.palette.nym.text.muted }}> - {`Send the defined BTC amount to Bity's address that's given to you. As soon as your BTC tx has 4 confirmations, Bity will send the purchased NYM tokens to your wallet.`} + {`Send the defined BTC amount to Bity's address that's given to you. As soon as your BTC tx has 4 + confirmations, Bity will send the purchased NYM tokens to your wallet.`} } /> diff --git a/nym-wallet/src/components/ClientAddress.tsx b/nym-wallet/src/components/ClientAddress.tsx index a7039ca8d4..7ab858306e 100644 --- a/nym-wallet/src/components/ClientAddress.tsx +++ b/nym-wallet/src/components/ClientAddress.tsx @@ -6,11 +6,13 @@ import { splice } from '../utils'; const AddressTooltip: FCWithChildren<{ visible?: boolean; address?: string }> = ({ visible, address, children }) => { if (!visible || !address) { + // eslint-disable-next-line react/jsx-no-useless-fragment return <>{children}; } return ( + {/* eslint-disable-next-line react/jsx-no-useless-fragment */} <>{children} ); diff --git a/nym-wallet/src/components/Delegation/DelegationActions.tsx b/nym-wallet/src/components/Delegation/DelegationActions.tsx index 628a893443..2b9001de7c 100644 --- a/nym-wallet/src/components/Delegation/DelegationActions.tsx +++ b/nym-wallet/src/components/Delegation/DelegationActions.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { Box, Button, Stack, Tooltip, Typography } from '@mui/material'; -import { DelegationEventKind } from '@nymproject/types'; import { Delegate, Undelegate } from '../../svg-icons'; import { ActionsMenu, ActionsMenuItem } from '../ActionsMenu'; import { DelegateListItemPending } from './types'; diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 1b4327621c..188901902f 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -12,6 +12,7 @@ const getStakeSaturation = (item: DelegationWithEverything) => !item.stake_saturation ? '-' : `${decimalToPercentage(item.stake_saturation)}%`; const getRewardValue = (item: DelegationWithEverything) => { + // eslint-disable-next-line @typescript-eslint/naming-convention const { unclaimed_rewards } = item; return !unclaimed_rewards ? '-' : `${unclaimed_rewards.amount} ${unclaimed_rewards.denom}`; }; @@ -32,11 +33,11 @@ export const DelegationItem = ({ const tooltipText = () => { if (nodeIsUnbonded) { return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; - } else if (item.uses_vesting_contract_tokens) { - return 'Delegation made with locked tockens'; - } else { - return ''; } + if (item.uses_vesting_contract_tokens) { + return 'Delegation made with locked tockens'; + } + return ''; }; return ( diff --git a/nym-wallet/src/components/Delegation/UndelegateModal.tsx b/nym-wallet/src/components/Delegation/UndelegateModal.tsx index 368b9d6fce..fe518d37ff 100644 --- a/nym-wallet/src/components/Delegation/UndelegateModal.tsx +++ b/nym-wallet/src/components/Delegation/UndelegateModal.tsx @@ -1,5 +1,4 @@ import { Box, SxProps } from '@mui/material'; -import { IdentityKeyFormField } from '@nymproject/react/mixnodes/IdentityKeyFormField'; import React, { useEffect } from 'react'; import { FeeDetails } from '@nymproject/types'; import { useGetFee } from 'src/hooks/useGetFee'; diff --git a/nym-wallet/src/components/LogViewer/index.tsx b/nym-wallet/src/components/LogViewer/index.tsx index f2a9d2e6d0..c7d4e69911 100644 --- a/nym-wallet/src/components/LogViewer/index.tsx +++ b/nym-wallet/src/components/LogViewer/index.tsx @@ -42,6 +42,7 @@ export const LogViewer: FC = () => { useEffect(() => { listen('log://log', (event) => { + // eslint-disable-next-line no-console console.log(event.payload); const payload = event.payload as RecordPayload; messages.current.unshift(payload); diff --git a/nym-wallet/src/components/Modals/ModalFee.tsx b/nym-wallet/src/components/Modals/ModalFee.tsx index 752be087a7..835b73e689 100644 --- a/nym-wallet/src/components/Modals/ModalFee.tsx +++ b/nym-wallet/src/components/Modals/ModalFee.tsx @@ -27,11 +27,9 @@ export const ModalFee = ({ fee, isLoading, error, divider }: TFeeProps) => ( ); -export const ModalTotalAmount = ({ fee, amount, isLoading, error, divider }: TTotalAmountProps) => { - return ( - <> - - {divider && } - - ); -}; +export const ModalTotalAmount = ({ fee, amount, isLoading, error, divider }: TTotalAmountProps) => ( + <> + + {divider && } + +); diff --git a/nym-wallet/src/components/RewardsPlayground/NodeDetail.tsx b/nym-wallet/src/components/RewardsPlayground/NodeDetail.tsx index fb8a239be0..d067dc3e5b 100644 --- a/nym-wallet/src/components/RewardsPlayground/NodeDetail.tsx +++ b/nym-wallet/src/components/RewardsPlayground/NodeDetail.tsx @@ -24,7 +24,7 @@ export const NodeDetails = ({ saturation }: { saturation?: string }) => { Selection probability - + diff --git a/nym-wallet/src/components/Send/SendSuccessModal.tsx b/nym-wallet/src/components/Send/SendSuccessModal.tsx index cee7c2fdff..ffee6dd2e2 100644 --- a/nym-wallet/src/components/Send/SendSuccessModal.tsx +++ b/nym-wallet/src/components/Send/SendSuccessModal.tsx @@ -1,9 +1,9 @@ import React, { useContext } from 'react'; import { Stack, Typography, SxProps } from '@mui/material'; import { Link } from '@nymproject/react/link/Link'; +import { AppContext } from 'src/context'; import { TTransactionDetails } from './types'; import { ConfirmationModal } from '../Modals/ConfirmationModal'; -import { AppContext } from 'src/context'; export const SendSuccessModal = ({ txDetails, diff --git a/nym-wallet/src/context/bonding.tsx b/nym-wallet/src/context/bonding.tsx index c8a64b98b5..48d8d8409d 100644 --- a/nym-wallet/src/context/bonding.tsx +++ b/nym-wallet/src/context/bonding.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { FeeDetails, DecCoin, diff --git a/nym-wallet/src/context/delegations.tsx b/nym-wallet/src/context/delegations.tsx index 2324b141da..79ee6380f7 100644 --- a/nym-wallet/src/context/delegations.tsx +++ b/nym-wallet/src/context/delegations.tsx @@ -1,12 +1,12 @@ import React, { createContext, FC, useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import { getDelegationSummary, undelegateAllFromMixnode, undelegateFromMixnode } from 'src/requests/delegation'; +import { getDelegationSummary, undelegateFromMixnode } from 'src/requests/delegation'; import { - DelegationWithEverything, - FeeDetails, DecCoin, + DelegationWithEverything, + Fee, + FeeDetails, TransactionExecuteResult, WrappedDelegationEvent, - Fee, } from '@nymproject/types'; import type { Network } from 'src/types'; import { diff --git a/nym-wallet/src/context/main.tsx b/nym-wallet/src/context/main.tsx index ae82bff958..a638a7568d 100644 --- a/nym-wallet/src/context/main.tsx +++ b/nym-wallet/src/context/main.tsx @@ -2,7 +2,7 @@ import React, { createContext, useEffect, useMemo, useState } from 'react'; import { forage } from '@tauri-apps/tauri-forage'; import { useNavigate } from 'react-router-dom'; import { useSnackbar } from 'notistack'; -import { Account, AccountEntry, MixNodeBond, MixNodeDetails } from '@nymproject/types'; +import { Account, AccountEntry, MixNodeDetails } from '@nymproject/types'; import { getVersion } from '@tauri-apps/api/app'; import { AppEnv, Network } from '../types'; import { TUseuserBalance, useGetBalance } from '../hooks/useGetBalance'; diff --git a/nym-wallet/src/context/mocks/bonding.tsx b/nym-wallet/src/context/mocks/bonding.tsx index f38168ee28..610b9ee299 100644 --- a/nym-wallet/src/context/mocks/bonding.tsx +++ b/nym-wallet/src/context/mocks/bonding.tsx @@ -1,7 +1,7 @@ -import { FeeDetails, DecCoin, TransactionExecuteResult } from '@nymproject/types'; +import { FeeDetails, TransactionExecuteResult } from '@nymproject/types'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import type { Network } from 'src/types'; -import { TBondedGateway, TBondedMixnode, BondingContext } from '../bonding'; +import { BondingContext, TBondedGateway, TBondedMixnode } from '../bonding'; import { mockSleep } from './utils'; const SLEEP_MS = 1000; diff --git a/nym-wallet/src/context/mocks/delegations.tsx b/nym-wallet/src/context/mocks/delegations.tsx index 58c5ea61cb..0c42a2b2e4 100644 --- a/nym-wallet/src/context/mocks/delegations.tsx +++ b/nym-wallet/src/context/mocks/delegations.tsx @@ -1,11 +1,11 @@ -import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { - DelegationWithEverything, - DecCoin, - TransactionExecuteResult, - FeeDetails, - Fee, CurrencyDenom, + DecCoin, + DelegationWithEverything, + Fee, + FeeDetails, + TransactionExecuteResult, } from '@nymproject/types'; import { DelegationContext, TDelegationTransaction } from '../delegations'; @@ -190,18 +190,17 @@ export const MockDelegationContextProvider: FCWithChildren = ({ children }) => { }; }; - const undelegateVesting = async (mix_id: number, _fee?: FeeDetails) => { - return { - logs_json: '', - data_json: '', - transaction_hash: '', - gas_info: { - gas_wanted: { gas_units: BigInt(1) }, - gas_used: { gas_units: BigInt(1) }, - }, - fee: { amount: '1', denom: 'nym' as CurrencyDenom }, - }; - }; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const undelegateVesting = async (mix_id: number, _fee?: FeeDetails) => ({ + logs_json: '', + data_json: '', + transaction_hash: '', + gas_info: { + gas_wanted: { gas_units: BigInt(1) }, + gas_used: { gas_units: BigInt(1) }, + }, + fee: { amount: '1', denom: 'nym' as CurrencyDenom }, + }); const resetState = () => { setIsLoading(true); diff --git a/nym-wallet/src/context/mocks/main.tsx b/nym-wallet/src/context/mocks/main.tsx index 0a073c47d8..ff49784f7b 100644 --- a/nym-wallet/src/context/mocks/main.tsx +++ b/nym-wallet/src/context/mocks/main.tsx @@ -1,4 +1,4 @@ -import React, { FC, useMemo } from 'react'; +import React, { useMemo } from 'react'; import type { TAppContext } from '../main'; import { AppContext } from '../main'; diff --git a/nym-wallet/src/context/mocks/rewards.tsx b/nym-wallet/src/context/mocks/rewards.tsx index fff2cbb21e..c89fdb00b3 100644 --- a/nym-wallet/src/context/mocks/rewards.tsx +++ b/nym-wallet/src/context/mocks/rewards.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { DelegationWithEverything, TransactionExecuteResult } from '@nymproject/types'; import { RewardsContext, TRewardsTransaction } from '../rewards'; import { useDelegationContext } from '../delegations'; diff --git a/nym-wallet/src/context/rewards.tsx b/nym-wallet/src/context/rewards.tsx index b65e2c6768..dc6b72a44f 100644 --- a/nym-wallet/src/context/rewards.tsx +++ b/nym-wallet/src/context/rewards.tsx @@ -1,4 +1,4 @@ -import React, { createContext, FC, useContext, useEffect, useMemo, useState } from 'react'; +import React, { createContext, useContext, useEffect, useMemo, useState } from 'react'; import { FeeDetails, TransactionExecuteResult } from '@nymproject/types'; import { useDelegationContext } from './delegations'; import { claimDelegatorRewards } from '../requests'; diff --git a/nym-wallet/src/pages/balance/index.tsx b/nym-wallet/src/pages/balance/index.tsx index a788a1c460..e214d1bddf 100644 --- a/nym-wallet/src/pages/balance/index.tsx +++ b/nym-wallet/src/pages/balance/index.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useState } from 'react'; +import React, { useContext, useState } from 'react'; import { Box } from '@mui/material'; import { AppContext } from '../../context/main'; diff --git a/nym-wallet/src/pages/balance/vesting.tsx b/nym-wallet/src/pages/balance/vesting.tsx index 1ef8e0f30e..d84accf898 100644 --- a/nym-wallet/src/pages/balance/vesting.tsx +++ b/nym-wallet/src/pages/balance/vesting.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { Refresh } from '@mui/icons-material'; import { Box, @@ -14,7 +14,6 @@ import { Typography, } from '@mui/material'; import { useSnackbar } from 'notistack'; -import { useContext, useEffect, useState } from 'react'; import { NymCard } from 'src/components'; import { AppContext } from 'src/context/main'; import { Period } from 'src/types'; diff --git a/nym-wallet/src/pages/bonding/Bonding.tsx b/nym-wallet/src/pages/bonding/Bonding.tsx index 1aa6bd5ef2..1eae1d3924 100644 --- a/nym-wallet/src/pages/bonding/Bonding.tsx +++ b/nym-wallet/src/pages/bonding/Bonding.tsx @@ -99,8 +99,8 @@ const Bonding = () => { (await getMixnodeStakeSaturation(newMixId)).uncapped_saturation, ); if (newSaturation && newSaturation > 1) { - const saturationPercentage = Math.round(newSaturation * 100); - return { isOverSaturated: true, saturationPercentage }; + const newSaturationPercentage = Math.round(newSaturation * 100); + return { isOverSaturated: true, saturationPercentage: newSaturationPercentage }; } return { isOverSaturated: false, saturationPercentage: undefined }; } catch (e) { @@ -113,10 +113,12 @@ const Bonding = () => { switch (action) { case 'bondMore': { if (bondedNode && isMixnode(bondedNode)) { - const { isOverSaturated, saturationPercentage } = await handleCheckStakeSaturation(bondedNode.mixId); - if (isOverSaturated && saturationPercentage) { + const { isOverSaturated, saturationPercentage: newSaturationPercentage } = await handleCheckStakeSaturation( + bondedNode.mixId, + ); + if (isOverSaturated && newSaturationPercentage) { setShowModal('bond-more-oversaturated'); - setSaturationPercentage(saturationPercentage.toString()); + setSaturationPercentage(newSaturationPercentage.toString()); break; } } @@ -178,7 +180,7 @@ const Bonding = () => { {showModal === 'bond-more-oversaturated' && saturationPercentage && ( setShowModal(undefined)} onContinue={() => setShowModal('bond-more')} saturationPercentage={saturationPercentage} diff --git a/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx index 2a9ef67f13..a390c0e7c0 100644 --- a/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx @@ -13,12 +13,12 @@ import { Tabs } from 'src/components/Tabs'; import { useBondingContext, BondingContextProvider, TBondedMixnode } from 'src/context'; import { AppContext, urls } from 'src/context/main'; +import { isMixnode } from 'src/types'; +import { getIntervalAsDate } from 'src/utils'; import { NodeGeneralSettings } from './settings-pages/general-settings'; import { NodeUnbondPage } from './settings-pages/NodeUnbondPage'; import { createNavItems } from './node-settings.constant'; -import { isMixnode } from 'src/types'; import { ApyPlayground } from './apy-playground'; -import { getIntervalAsDate } from 'src/utils'; export const NodeSettings = () => { const theme = useTheme(); diff --git a/nym-wallet/src/pages/bonding/node-settings/apy-playground/index.tsx b/nym-wallet/src/pages/bonding/node-settings/apy-playground/index.tsx index 5a3b5f4c6b..efac9050cb 100644 --- a/nym-wallet/src/pages/bonding/node-settings/apy-playground/index.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/apy-playground/index.tsx @@ -1,14 +1,13 @@ -import React, { useState, useEffect, useContext } from 'react'; +import React, { useEffect, useState } from 'react'; import { Box, Card, CardContent, CardHeader, Grid, Typography } from '@mui/material'; -import { decimalToPercentage, percentToDecimal } from '@nymproject/types'; import { ResultsTable } from 'src/components/RewardsPlayground/ResultsTable'; import { getDelegationSummary } from 'src/requests'; import { NodeDetails } from 'src/components/RewardsPlayground/NodeDetail'; -import { Inputs, CalculateArgs } from 'src/components/RewardsPlayground/Inputs'; -import { AppContext, TBondedMixnode } from 'src/context'; -import { computeEstimate, computeStakeSaturation, handleCalculatePeriodRewards } from './utils'; +import { CalculateArgs, Inputs } from 'src/components/RewardsPlayground/Inputs'; +import { TBondedMixnode } from 'src/context'; import { useSnackbar } from 'notistack'; import { LoadingModal } from 'src/components/Modals/LoadingModal'; +import { computeEstimate, computeStakeSaturation, handleCalculatePeriodRewards } from './utils'; export type DefaultInputValues = { profitMargin: string; @@ -76,11 +75,12 @@ export const ApyPlayground = ({ bondedNode }: { bondedNode: TBondedMixnode }) => const handleCalculateEstimate = async ({ bond, delegations, uptime, profitMargin, operatorCost }: CalculateArgs) => { try { + // eslint-disable-next-line @typescript-eslint/naming-convention const { estimation, reward_params } = await computeEstimate({ mixId: bondedNode.mixId, - uptime: uptime, - profitMargin: profitMargin, - operatorCost: operatorCost, + uptime, + profitMargin, + operatorCost, totalDelegation: delegations, pledgeAmount: bond, }); diff --git a/nym-wallet/src/pages/bonding/node-settings/apy-playground/utils.tsx b/nym-wallet/src/pages/bonding/node-settings/apy-playground/utils.tsx index bc99898b45..c86be7b22d 100644 --- a/nym-wallet/src/pages/bonding/node-settings/apy-playground/utils.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/apy-playground/utils.tsx @@ -24,7 +24,7 @@ export const computeEstimate = async ({ operatorCost: string; }) => { const computedEstimate = await computeMixnodeRewardEstimation({ - mixId: mixId, + mixId, performance: percentToDecimal(uptime), pledgeAmount: Math.round(+pledgeAmount * SCALE_FACTOR), totalDelegation: Math.round(+totalDelegation * SCALE_FACTOR), diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/NodeUnbondPage.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/NodeUnbondPage.tsx index 347ed2467a..7cccb8d3f7 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/NodeUnbondPage.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/NodeUnbondPage.tsx @@ -4,6 +4,7 @@ import { TBondedMixnode, TBondedGateway } from 'src/context/bonding'; import { Error } from 'src/components/Error'; import { UnbondModal } from 'src/components/Bonding/modals/UnbondModal'; import { isMixnode } from 'src/types'; + interface Props { bondedNode: TBondedMixnode | TBondedGateway; @@ -13,7 +14,7 @@ interface Props { export const NodeUnbondPage = ({ bondedNode, onConfirm, onError }: Props) => { const [confirmField, setConfirmField] = useState(''); const [isConfirmed, setIsConfirmed] = useState(false); - //TODO: Check what happens with a gateway + // TODO: Check what happens with a gateway return ( diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/InfoSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/InfoSettings.tsx index 31e88a0f31..00a409dab2 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/InfoSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/InfoSettings.tsx @@ -1,11 +1,11 @@ -import { useState } from 'react'; +import React, { useState } from 'react'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { Button, Divider, Typography, TextField, Grid, CircularProgress, Box } from '@mui/material'; +import { Box, Button, Divider, Grid, TextField, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import { isMixnode } from 'src/types'; import { simulateUpdateMixnodeConfig, simulateVestingUpdateMixnodeConfig, updateMixnodeConfig } from 'src/requests'; -import { TBondedMixnode, TBondedGateway } from 'src/context/bonding'; +import { TBondedGateway, TBondedMixnode } from 'src/context/bonding'; import { SimpleModal } from 'src/components/Modals/SimpleModal'; import { bondedInfoParametersValidationSchema } from 'src/components/Bonding/forms/mixnodeValidationSchema'; import { Console } from 'src/utils/console'; diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index b342f32d15..a4e2bac152 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -1,7 +1,7 @@ import React, { useContext, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { Button, Divider, Typography, TextField, InputAdornment, Grid, Box, FormHelperText } from '@mui/material'; +import { Box, Button, Divider, FormHelperText, Grid, InputAdornment, TextField, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import { CurrencyDenom, MixNodeCostParams } from '@nymproject/types'; import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField'; @@ -88,7 +88,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode const onSubmit = async (data: { operatorCost: { amount: string; denom: CurrencyDenom }; profitMargin: string }) => { resetFeeState(); if (data.operatorCost && data.profitMargin) { - const MixNodeCostParams = { + const mixNodeCostParams = { profit_margin_percent: (+data.profitMargin / 100).toString(), interval_operating_cost: { amount: data.operatorCost.amount, @@ -97,9 +97,9 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; try { if (bondedNode.proxy) { - await vestingUpdateMixnodeCostParams(MixNodeCostParams); + await vestingUpdateMixnodeCostParams(mixNodeCostParams); } else { - await updateMixnodeCostParams(MixNodeCostParams); + await updateMixnodeCostParams(mixNodeCostParams); } await getPendingEvents(); reset(); @@ -132,13 +132,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode /> )} {isSubmitting && } - - {`Next interval: ${intervalTime}`} - - } - /> + {`Next interval: ${intervalTime}`}} /> diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/index.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/index.tsx index 6597c096f7..edc8ac0f45 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/index.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/index.tsx @@ -1,15 +1,15 @@ import React, { useState } from 'react'; import { Box, Button, Divider, Grid } from '@mui/material'; +import { isMixnode } from 'src/types'; import { TBondedMixnode, TBondedGateway } from '../../../../../context/bonding'; import { InfoSettings } from './InfoSettings'; import { ParametersSettings } from './ParametersSettings'; -import { isMixnode } from 'src/types'; const nodeGeneralNav = ['Info', 'Parameters']; export const NodeGeneralSettings = ({ bondedNode }: { bondedNode: TBondedMixnode | TBondedGateway }) => { const [settingsCard, setSettingsCard] = useState(nodeGeneralNav[0]); - //TODO: Check what happens with a gateway + // TODO: Check what happens with a gateway return ( diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 50ac86b354..05914742eb 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -1,6 +1,6 @@ import React, { FC, useContext, useEffect, useState } from 'react'; -import { Box, Button, Paper, Stack, Typography, CircularProgress } from '@mui/material'; -import { useTheme, Theme } from '@mui/material/styles'; +import { Box, Button, CircularProgress, Paper, Stack, Typography } from '@mui/material'; +import { Theme, useTheme } from '@mui/material/styles'; import { DecCoin, decimalToFloatApproximation, DelegationWithEverything, FeeDetails } from '@nymproject/types'; import { Link } from '@nymproject/react/link/Link'; import { AppContext, urls } from 'src/context/main'; @@ -9,8 +9,9 @@ import { TPoolOption } from 'src/components'; import { Console } from 'src/utils/console'; import { OverSaturatedBlockerModal } from 'src/components/Delegation/DelegateBlocker'; import { getSpendableCoins, userBalance } from 'src/requests'; +import { getIntervalAsDate, toPercentIntegerString } from 'src/utils'; import { RewardsSummary } from '../../components/Rewards/RewardsSummary'; -import { DelegationContextProvider, useDelegationContext, TDelegations } from '../../context/delegations'; +import { DelegationContextProvider, TDelegations, useDelegationContext } from '../../context/delegations'; import { RewardsContextProvider, useRewardsContext } from '../../context/rewards'; import { DelegateModal } from '../../components/Delegation/DelegateModal'; import { UndelegateModal } from '../../components/Delegation/UndelegateModal'; @@ -18,7 +19,6 @@ import { DelegationListItemActions } from '../../components/Delegation/Delegatio import { RedeemModal } from '../../components/Rewards/RedeemModal'; import { DelegationModal, DelegationModalProps } from '../../components/Delegation/DelegationModal'; import { backDropStyles, modalStyles } from '../../../.storybook/storiesStyles'; -import { toPercentIntegerString, getIntervalAsDate } from 'src/utils'; const storybookStyles = (theme: Theme, isStorybook?: boolean, backdropProps?: object) => isStorybook @@ -77,8 +77,8 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { const getNextInterval = async () => { try { - const { nextEpoch } = await getIntervalAsDate(); - setNextEpoch(nextEpoch); + const { nextEpoch: newNextEpoch } = await getIntervalAsDate(); + setNextEpoch(newNextEpoch); } catch { setNextEpoch(Error()); } diff --git a/nym-wallet/src/requests/actions.ts b/nym-wallet/src/requests/actions.ts index b4aaa144c0..db4e715fb4 100644 --- a/nym-wallet/src/requests/actions.ts +++ b/nym-wallet/src/requests/actions.ts @@ -33,5 +33,4 @@ export const unbond = async (type: EnumNodeType) => { return unbondGateway(); }; -export const bondMore = async (args: TBondMoreArgs) => - invokeWrapper('pledge_more', args); +export const bondMore = async (args: TBondMoreArgs) => invokeWrapper('pledge_more', args); diff --git a/nym-wallet/src/requests/queries.ts b/nym-wallet/src/requests/queries.ts index 640fc79abb..e80fd313fa 100644 --- a/nym-wallet/src/requests/queries.ts +++ b/nym-wallet/src/requests/queries.ts @@ -1,14 +1,13 @@ import { - StakeSaturationResponse, - MixnodeStatusResponse, - InclusionProbabilityResponse, DecCoin, - MixNodeDetails, GatewayBond, - RewardEstimationResponse, - WrappedDelegationEvent, + InclusionProbabilityResponse, + MixNodeDetails, + MixnodeStatusResponse, PendingIntervalEvent, - Coin, + RewardEstimationResponse, + StakeSaturationResponse, + WrappedDelegationEvent, } from '@nymproject/types'; import { Interval, TGatewayReport, TNodeDescription } from 'src/types'; import { invokeWrapper } from './wrapper'; diff --git a/nym-wallet/src/requests/simulate.ts b/nym-wallet/src/requests/simulate.ts index 4a1b82f0d4..bee1644298 100644 --- a/nym-wallet/src/requests/simulate.ts +++ b/nym-wallet/src/requests/simulate.ts @@ -64,8 +64,7 @@ export const simulateClaimOperatorReward = async () => invokeWrapper export const simulateVestingClaimOperatorReward = async () => invokeWrapper('simulate_vesting_claim_operator_reward'); -export const simulateBondMore = async (args: any) => - invokeWrapper('simulate_pledge_more', args); +export const simulateBondMore = async (args: any) => invokeWrapper('simulate_pledge_more', args); export const simulateVestingBondMore = async (args: any) => invokeWrapper('simulate_vesting_pledge_more', args); diff --git a/nym-wallet/src/requests/vesting.ts b/nym-wallet/src/requests/vesting.ts index bad2f7febf..993910dd14 100644 --- a/nym-wallet/src/requests/vesting.ts +++ b/nym-wallet/src/requests/vesting.ts @@ -106,13 +106,8 @@ export const vestingClaimOperatorReward = async (fee?: Fee) => export const vestingClaimDelegatorRewards = async (mixId: number) => invokeWrapper('vesting_claim_delegator_reward', { mixId }); -export const vestingBondMore = async ({ - fee, - additionalPledge, -}: { - fee?: Fee; - additionalPledge: DecCoin; -}) => invokeWrapper('vesting_pledge_more', { - fee, - additionalPledge, -}); +export const vestingBondMore = async ({ fee, additionalPledge }: { fee?: Fee; additionalPledge: DecCoin }) => + invokeWrapper('vesting_pledge_more', { + fee, + additionalPledge, + }); diff --git a/nym-wallet/src/svg-icons/poweredByBity.tsx b/nym-wallet/src/svg-icons/poweredByBity.tsx index 3b061ae7d3..458a77369f 100644 --- a/nym-wallet/src/svg-icons/poweredByBity.tsx +++ b/nym-wallet/src/svg-icons/poweredByBity.tsx @@ -5,7 +5,7 @@ export const PoweredByBity = (props: SvgIconProps) => ( - + diff --git a/nym-wallet/src/types/global.ts b/nym-wallet/src/types/global.ts index 2c16901cfe..c5f0fc3a95 100644 --- a/nym-wallet/src/types/global.ts +++ b/nym-wallet/src/types/global.ts @@ -1,12 +1,4 @@ -import { - Gateway, - DecCoin, - MixNode, - PledgeData, - MixNodeCostParams, - PendingIntervalEventData, - PendingEpochEventData, -} from '@nymproject/types'; +import { DecCoin, Gateway, MixNode, MixNodeCostParams, PledgeData } from '@nymproject/types'; import { Fee } from '@nymproject/types/dist/types/rust/Fee'; import { TBondedGateway, TBondedMixnode } from 'src/context'; @@ -52,7 +44,6 @@ export type TBondMixNodeArgs = { export type TBondMoreArgs = { additionalPledge: DecCoin; fee?: Fee; - }; export type TNodeDescription = { diff --git a/nym-wallet/src/types/rust/Epoch.ts b/nym-wallet/src/types/rust/Epoch.ts index b9529dc336..21ec4ac2df 100644 --- a/nym-wallet/src/types/rust/Epoch.ts +++ b/nym-wallet/src/types/rust/Epoch.ts @@ -1,3 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface Epoch { id: number, start: bigint, end: bigint, duration_seconds: bigint, } \ No newline at end of file +export interface Epoch { + id: number; + start: bigint; + end: bigint; + duration_seconds: bigint; +} diff --git a/nym-wallet/src/types/rust/StateParams.ts b/nym-wallet/src/types/rust/StateParams.ts index c9420f50dc..a394fb0d42 100644 --- a/nym-wallet/src/types/rust/StateParams.ts +++ b/nym-wallet/src/types/rust/StateParams.ts @@ -1,4 +1,4 @@ -import type { DecCoin } from '../../../../ts-packages/types/src/types/rust/DecCoin'; +import type { DecCoin } from '@nymproject/types'; export interface TauriContractStateParams { minimum_mixnode_pledge: DecCoin; diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index 936a89e57d..704fe9b80b 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -3,7 +3,7 @@ import bs58 from 'bs58'; import Big from 'big.js'; import { valid } from 'semver'; import { add, format, fromUnixTime } from 'date-fns'; -import { isValidRawCoin, DecCoin, MixNodeCostParams } from '@nymproject/types'; +import { DecCoin, isValidRawCoin, MixNodeCostParams } from '@nymproject/types'; import { TPoolOption } from 'src/components'; import { getCurrentInterval, @@ -14,8 +14,6 @@ import { } from '../requests'; import { Console } from './console'; -export * from './nextEpoch'; - export const validateKey = (key: string, bytesLength: number): boolean => { // it must be a valid base58 key try { diff --git a/nym-wallet/src/utils/nextEpoch.ts b/nym-wallet/src/utils/nextEpoch.ts deleted file mode 100644 index db80a22280..0000000000 --- a/nym-wallet/src/utils/nextEpoch.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { getCurrentInterval } from 'src/requests'; -import { add, format, fromUnixTime } from 'date-fns'; - -export const getIntervalAsDate = async () => { - const interval = await getCurrentInterval(); - const secondsToNextInterval = - Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); - - const intervalTime = format( - add(new Date(), { - seconds: secondsToNextInterval, - }), - 'dd/MM/yyyy, HH:mm', - ); - const nextEpoch = format( - add(fromUnixTime(Number(interval.current_epoch_start_unix)), { - seconds: Number(interval.epoch_length_seconds), - }), - 'HH:mm', - ); - - return { intervalTime, nextEpoch }; -}; \ No newline at end of file diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx b/sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx index 034754d017..0fa57567cd 100644 --- a/sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx +++ b/sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx @@ -69,7 +69,8 @@ export const Content: FCWithChildren = () => { }; const log = React.useRef([]); - const [_logTrigger, setLogTrigger] = React.useState(Date.now()); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [logTrigger, setLogTrigger] = React.useState(Date.now()); const [uploadState, setUploadState] = React.useState({ dialogOpen: false, diff --git a/sdk/typescript/packages/sdk/src/mixnet/wasm/types.ts b/sdk/typescript/packages/sdk/src/mixnet/wasm/types.ts index e3b9673d30..8d59de9859 100644 --- a/sdk/typescript/packages/sdk/src/mixnet/wasm/types.ts +++ b/sdk/typescript/packages/sdk/src/mixnet/wasm/types.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line import/no-extraneous-dependencies import { Debug } from '@nymproject/nym-client-wasm'; /** diff --git a/sdk/typescript/packages/sdk/src/mixnet/wasm/worker.ts b/sdk/typescript/packages/sdk/src/mixnet/wasm/worker.ts index 063b59894b..f30d82e1dd 100644 --- a/sdk/typescript/packages/sdk/src/mixnet/wasm/worker.ts +++ b/sdk/typescript/packages/sdk/src/mixnet/wasm/worker.ts @@ -11,8 +11,10 @@ import * as Comlink from 'comlink'; // Doing it this way, saves having to support a large variety of bundlers and their quirks. // // @ts-ignore +// eslint-disable-next-line import/no-extraneous-dependencies import wasmBytes from '@nymproject/nym-client-wasm/nym_client_wasm_bg.wasm'; +// eslint-disable-next-line import/no-extraneous-dependencies import init, { NymClient, NymClientBuilder, @@ -46,6 +48,7 @@ console.log('[Nym WASM client] Starting Nym WASM web worker...'); * Helper method to send typed messages. * @param event The strongly typed message to send back to the calling thread. */ +// eslint-disable-next-line no-restricted-globals const postMessageWithType = (event: E) => self.postMessage(event); /** diff --git a/ts-packages/mui-theme/src/theme/network-explorer.ts b/ts-packages/mui-theme/src/theme/network-explorer.ts index 776a07290e..2078a6d0ef 100644 --- a/ts-packages/mui-theme/src/theme/network-explorer.ts +++ b/ts-packages/mui-theme/src/theme/network-explorer.ts @@ -1,7 +1,8 @@ -import { Color, PaletteMode } from '@mui/material'; +import { PaletteMode } from '@mui/material'; import { createTheme, ThemeOptions } from '@mui/material/styles'; import { darkMode, nymPalette, NymPaletteVariant } from './common'; -import { createDarkModePalette, createLightModePalette } from './theme'; +// eslint-disable-next-line import/no-cycle +import { createDarkModePalette, createLightModePalette } from './utils'; /** * A palette definition only for the Network Explorer that extends the Nym palette @@ -53,7 +54,7 @@ export interface NetworkExplorerPalette { backgroud: string; color: string; border: string; - } + }; }; } @@ -111,7 +112,7 @@ export const networkExplorerPalette = (variant: NymPaletteVariant): NetworkExplo backgroud: variant.mode === 'light' ? '#FAFAFA' : '#C7C9CD', color: variant.mode === 'light' ? '#7D7D7D' : '#636466', border: variant.mode === 'light' ? '#DFDEDE' : '#DDDDDD', - } + }, }, }); diff --git a/ts-packages/mui-theme/src/theme/theme.ts b/ts-packages/mui-theme/src/theme/theme.ts index bb4dcae533..2ea995b313 100644 --- a/ts-packages/mui-theme/src/theme/theme.ts +++ b/ts-packages/mui-theme/src/theme/theme.ts @@ -1,8 +1,12 @@ -import { createTheme, Palette, PaletteOptions, ThemeOptions } from '@mui/material/styles'; +import { createTheme, Palette, ThemeOptions } from '@mui/material/styles'; import { PaletteMode } from '@mui/material'; -import { darkMode, lightMode, nymPalette, NymPalette, variantToMUIPalette } from './common'; -import { NymWalletPalette, nymWalletPallete } from './wallet'; -import { networkExplorerPalette, NetworkExplorerPalette } from './network-explorer'; +import { nymPalette, NymPalette } from './common'; +// eslint-disable-next-line import/no-cycle +import { NymWalletPalette } from './wallet'; +// eslint-disable-next-line import/no-cycle +import { NetworkExplorerPalette } from './network-explorer'; +// eslint-disable-next-line import/no-cycle +import { createDarkModePalette, createLightModePalette } from './utils'; /** * To use the theme, copy the file in `../../template/mui-theme.d.ts` into `src/typings/mui-theme.d.ts` in your project. @@ -30,30 +34,6 @@ export interface NymTheme { */ export type NymPaletteWithExtensionsOptions = Partial; -/** - * Returns the Nym palette for light mode. - */ -export const createLightModePalette = (): PaletteOptions & NymPaletteWithExtensionsOptions => ({ - nym: { - ...nymPalette, - ...nymWalletPallete(lightMode), - ...networkExplorerPalette(lightMode), - }, - ...variantToMUIPalette(lightMode), -}); - -/** - * Returns the Nym palette for dark mode. - */ -export const createDarkModePalette = (): PaletteOptions & NymPaletteWithExtensionsOptions => ({ - nym: { - ...nymPalette, - ...nymWalletPallete(darkMode), - ...networkExplorerPalette(darkMode), - }, - ...variantToMUIPalette(darkMode), -}); - /** * Gets the theme options to be passed to `createTheme`. * diff --git a/ts-packages/mui-theme/src/theme/utils.ts b/ts-packages/mui-theme/src/theme/utils.ts new file mode 100644 index 0000000000..a6d74daa7a --- /dev/null +++ b/ts-packages/mui-theme/src/theme/utils.ts @@ -0,0 +1,31 @@ +import { PaletteOptions } from '@mui/material/styles'; +import { darkMode, lightMode, nymPalette, variantToMUIPalette } from './common'; +import { nymWalletPallete } from './wallet'; +// eslint-disable-next-line import/no-cycle +import { networkExplorerPalette } from './network-explorer'; +// eslint-disable-next-line import/no-cycle +import { NymPaletteWithExtensionsOptions } from './theme'; + +/** + * Returns the Nym palette for light mode. + */ +export const createLightModePalette = (): PaletteOptions & NymPaletteWithExtensionsOptions => ({ + nym: { + ...nymPalette, + ...nymWalletPallete(lightMode), + ...networkExplorerPalette(lightMode), + }, + ...variantToMUIPalette(lightMode), +}); + +/** + * Returns the Nym palette for dark mode. + */ +export const createDarkModePalette = (): PaletteOptions & NymPaletteWithExtensionsOptions => ({ + nym: { + ...nymPalette, + ...nymWalletPallete(darkMode), + ...networkExplorerPalette(darkMode), + }, + ...variantToMUIPalette(darkMode), +}); diff --git a/ts-packages/react-components/src/components/banners/MaintenanceBanner.tsx b/ts-packages/react-components/src/components/banners/MaintenanceBanner.tsx index 86e7cd4f2e..6400203708 100644 --- a/ts-packages/react-components/src/components/banners/MaintenanceBanner.tsx +++ b/ts-packages/react-components/src/components/banners/MaintenanceBanner.tsx @@ -1,3 +1,4 @@ +import * as React from 'react'; import { Box, Collapse, Alert, IconButton, Typography, Divider } from '@mui/material'; import CloseIcon from '@mui/icons-material/Close'; import { SxProps } from '@mui/system'; diff --git a/ts-packages/react-components/src/components/coins/CoinMarkTestnet.stories.tsx b/ts-packages/react-components/src/components/coins/CoinMarkTestnet.stories.tsx index ba45395b4c..bbe7389732 100644 --- a/ts-packages/react-components/src/components/coins/CoinMarkTestnet.stories.tsx +++ b/ts-packages/react-components/src/components/coins/CoinMarkTestnet.stories.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { ComponentMeta } from '@storybook/react'; import { Stack, Typography } from '@mui/material'; -import { CoinMark } from './CoinMark'; import { CoinMarkTestnet } from './CoinMarkTestnet'; export default { diff --git a/ts-packages/react-components/src/components/currency/Currency.tsx b/ts-packages/react-components/src/components/currency/Currency.tsx index 6c2f394dc0..56f201bc74 100644 --- a/ts-packages/react-components/src/components/currency/Currency.tsx +++ b/ts-packages/react-components/src/components/currency/Currency.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import type { DecCoin } from '@nymproject/types'; -import { Stack, SxProps, Typography } from '@mui/material'; +import { Stack, SxProps } from '@mui/material'; import { CurrencyWithCoinMark } from './CurrencyWithCoinMark'; import { CURRENCY_AMOUNT_SPACING, CurrencyAmount } from './CurrencyAmount'; diff --git a/ts-packages/react-components/src/components/tooltip/Tooltip.stories.tsx b/ts-packages/react-components/src/components/tooltip/Tooltip.stories.tsx index a8960a5986..873295874b 100644 --- a/ts-packages/react-components/src/components/tooltip/Tooltip.stories.tsx +++ b/ts-packages/react-components/src/components/tooltip/Tooltip.stories.tsx @@ -9,16 +9,14 @@ export default { export const Default = () => ; -export const NEStyle = () => { - return ( - - ); -}; +export const NEStyle = () => ( + +); diff --git a/ts-packages/react-components/src/components/tooltip/Tooltip.tsx b/ts-packages/react-components/src/components/tooltip/Tooltip.tsx index 68375649a3..57956dd3ed 100644 --- a/ts-packages/react-components/src/components/tooltip/Tooltip.tsx +++ b/ts-packages/react-components/src/components/tooltip/Tooltip.tsx @@ -1,12 +1,24 @@ import * as React from 'react'; -import { Tooltip as MUITooltip, TooltipProps, IconButton } from '@mui/material'; +import { IconButton, Tooltip as MUITooltip } from '@mui/material'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; export interface CustomTooltipProps { title: string; arrow?: boolean; id: string; - placement?: "bottom" | "left" | "right" | "top" | "bottom-end" | "bottom-start" | "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start"; + placement?: + | 'bottom' + | 'left' + | 'right' + | 'top' + | 'bottom-end' + | 'bottom-start' + | 'left-end' + | 'left-start' + | 'right-end' + | 'right-start' + | 'top-end' + | 'top-start'; textColor?: string; bgColor?: string; maxWidth?: number; @@ -42,7 +54,7 @@ export const Tooltip = (props: CustomTooltipProps) => { componentsProps={{ tooltip: { sx: { - maxWidth: maxWidth, + maxWidth, background: bgColor, color: textColor, '& .MuiTooltip-arrow': { diff --git a/ts-packages/types/src/types/rust/PendingEpochEvent.ts b/ts-packages/types/src/types/rust/PendingEpochEvent.ts index e775e935c0..3788781f07 100644 --- a/ts-packages/types/src/types/rust/PendingEpochEvent.ts +++ b/ts-packages/types/src/types/rust/PendingEpochEvent.ts @@ -1,7 +1,7 @@ -import type {PendingEpochEventData} from "./PendingEpochEventData"; +import type { PendingEpochEventData } from './PendingEpochEventData'; export interface PendingEpochEvent { - id: number, - created_at: bigint, - event: PendingEpochEventData, + id: number; + created_at: bigint; + event: PendingEpochEventData; } diff --git a/ts-packages/types/src/types/rust/PendingIntervalEvent.ts b/ts-packages/types/src/types/rust/PendingIntervalEvent.ts index 1c72712ef5..29c7e9249a 100644 --- a/ts-packages/types/src/types/rust/PendingIntervalEvent.ts +++ b/ts-packages/types/src/types/rust/PendingIntervalEvent.ts @@ -1,7 +1,7 @@ -import type {PendingIntervalEventData} from "./PendingIntervalEventData"; +import type { PendingIntervalEventData } from './PendingIntervalEventData'; export interface PendingIntervalEvent { - id: number, - created_at: bigint, - event: PendingIntervalEventData, + id: number; + created_at: bigint; + event: PendingIntervalEventData; } diff --git a/ts-packages/webpack/webpack.common.js b/ts-packages/webpack/webpack.common.js index 6c74ed3a13..64c0b8d168 100644 --- a/ts-packages/webpack/webpack.common.js +++ b/ts-packages/webpack/webpack.common.js @@ -61,17 +61,14 @@ module.exports = (baseDir, htmlPath) => ({ plugins: [ // new CleanWebpackPlugin(), - ... Array.isArray(htmlPath) - ? htmlPath.map( - (item) => - new HtmlWebpackPlugin(item), - ) + ...(Array.isArray(htmlPath) + ? htmlPath.map((item) => new HtmlWebpackPlugin(item)) : [ - new HtmlWebpackPlugin({ - filename: 'index.html', - template: path.resolve(baseDir, htmlPath || 'src/index.html'), - }) - ], + new HtmlWebpackPlugin({ + filename: 'index.html', + template: path.resolve(baseDir, htmlPath || 'src/index.html'), + }), + ]), new ForkTsCheckerWebpackPlugin({ typescript: {