Skip to content

Commit

Permalink
chore: add 'import/no-duplicates' ESLint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Oct 31, 2024
1 parent a64091e commit f2aac41
Show file tree
Hide file tree
Showing 83 changed files with 178 additions and 178 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module.exports = {
'newlines-between': 'always',
},
],
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
{
Expand Down
4 changes: 1 addition & 3 deletions packages/blockchain-link/src/workers/baseWebsocket.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import WebSocket from 'ws';
import { createDeferred } from '@trezor/utils';
import { createDeferredManager } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import { createDeferred, createDeferredManager, TypedEmitter } from '@trezor/utils';

import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';

Expand Down
9 changes: 7 additions & 2 deletions packages/coinjoin/src/backend/CoinjoinBackendClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { scheduleAction, arrayShuffle, urlToOnion, getWeakRandomInt } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import {
scheduleAction,
arrayShuffle,
urlToOnion,
getWeakRandomInt,
TypedEmitter,
} from '@trezor/utils';
import type { BlockbookAPI } from '@trezor/blockchain-link/src/workers/blockbook/websocket';

import { RequestOptions, resetIdentityCircuit } from '../utils/http';
Expand Down
3 changes: 1 addition & 2 deletions packages/coinjoin/src/client/CoinjoinRound.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TypedEmitter } from '@trezor/utils';
import { scheduleAction, arrayDistinct, arrayPartition } from '@trezor/utils';
import { TypedEmitter, scheduleAction, arrayDistinct, arrayPartition } from '@trezor/utils';
import { Network } from '@trezor/utxo-lib';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
NewModal as ModalComponent,
NewModalProps,
variables,
intermediaryTheme,
IconCircle,
} from '../../index';
import { newModalVariants, newModalSizes } from './types';
import { ThemeProvider } from 'styled-components';
import { intermediaryTheme, IconCircle } from '../../index';
import { getFramePropsStory } from '../../utils/frameProps';

const Buttons = () => (
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/typography/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { typography, TypographyStyle, typographyStyles } from '@trezor/theme';
import { TransientProps } from '../../utils/transientProps';
import { TransientProps, makePropsTransient } from '../../utils/transientProps';
import { UIHorizontalAlignment, uiHorizontalAlignments } from '../../config/types';
import { css } from 'styled-components';
import { makePropsTransient } from '../../utils/transientProps';

export const textWraps = ['balance', 'break-word'];
export type TextWrap = (typeof textWraps)[number];
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/utils/useScrollShadow.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import styled, { CSSObject } from 'styled-components';
import styled, { CSSObject, DefaultTheme } from 'styled-components';
import { useElevation } from '../components/ElevationContext/ElevationContext';
import { Color, Elevation, mapElevationToBackground } from '@trezor/theme';
import { DefaultTheme } from 'styled-components';
import { UIHorizontalAlignment, UIVerticalAlignment } from '../config/types';

type GradientDirection = Exclude<UIHorizontalAlignment | UIVerticalAlignment, 'center'>;
Expand Down
4 changes: 1 addition & 3 deletions packages/connect-common/src/messageChannel/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* this file is bundled into content script so be careful what you are importing not to bloat the bundle
*/

import { Deferred, createDeferred } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import { scheduleAction } from '@trezor/utils';
import { Deferred, createDeferred, TypedEmitter, scheduleAction } from '@trezor/utils';

// TODO: so logger should be probably moved to connect common, or this file should be moved to connect
// import type { Log } from '@trezor/connect/src/utils/debug';
Expand Down
3 changes: 1 addition & 2 deletions packages/connect-explorer/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useEffect, useState } from 'react';
import { Provider } from 'react-redux';

import { ThemeProvider as NextThemeProvider } from 'next-themes';
import { ThemeProvider as NextThemeProvider, useTheme } from 'next-themes';
import { ThemeProvider } from 'styled-components';
import type { AppProps } from 'next/app';
import { useTheme } from 'next-themes';
import Head from 'next/head';
import { useRouter } from 'next/router';

Expand Down
8 changes: 6 additions & 2 deletions packages/connect-mobile/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import * as ERRORS from '@trezor/connect/src/constants/errors';
import { parseConnectSettings } from '@trezor/connect/src/data/connectSettings';
import type { CallMethodPayload } from '@trezor/connect/src/events/call';
import { ConnectFactoryDependencies, factory } from '@trezor/connect/src/factory';
import type { ConnectSettingsMobile } from '@trezor/connect/src/types';
import type { ConnectSettings, Manifest, Response } from '@trezor/connect/src/types';
import type {
ConnectSettingsMobile,
ConnectSettings,
Manifest,
Response,
} from '@trezor/connect/src/types';
import { Login } from '@trezor/connect/src/types/api/requestLogin';
import { Deferred, createDeferred } from '@trezor/utils';
import { InitFullSettings } from '@trezor/connect/src/types/api/init';
Expand Down
3 changes: 1 addition & 2 deletions packages/connect/src/api/ethereum/ethereumDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fetch from 'cross-fetch';

import { MessagesSchema } from '@trezor/protobuf';
import { MessagesSchema, parseConfigure, decode as decodeProtobuf } from '@trezor/protobuf';
import { trzd } from '@trezor/protocol';
import { parseConfigure, decode as decodeProtobuf } from '@trezor/protobuf';
import { DataManager } from '../../data/DataManager';
import { EthereumNetworkInfo } from '../../types';
import { ethereumNetworkInfoBase } from '../../data/coinInfo';
Expand Down
3 changes: 1 addition & 2 deletions packages/connect/src/core/AbstractMethod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { storage } from '@trezor/connect-common';
import { versionUtils } from '@trezor/utils';
import { DataManager } from '../data/DataManager';
import { NETWORK } from '../constants';
import { NETWORK, ERRORS } from '../constants';
import {
UI,
DEVICE,
Expand All @@ -16,7 +16,6 @@ import {
import { getHost } from '../utils/urlUtils';
import type { Device } from '../device/Device';
import type { FirmwareRange, DeviceState, StaticSessionId, DeviceUniquePath } from '../types';
import { ERRORS } from '../constants';

export type Payload<M> = Extract<CallMethodPayload, { method: M }> & { override?: boolean };
export type MethodReturnType<M extends CallMethodPayload['method']> = CallMethodResponse<M>;
Expand Down
3 changes: 1 addition & 2 deletions packages/connect/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import EventEmitter from 'events';

import { TRANSPORT, TRANSPORT_ERROR } from '@trezor/transport';
import { createLazy, createDeferred, throwError } from '@trezor/utils';
import { getSynchronize } from '@trezor/utils';
import { createLazy, createDeferred, throwError, getSynchronize } from '@trezor/utils';
import { storage } from '@trezor/connect-common';

import { DataManager } from '../data/DataManager';
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/types/api/composeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
ComposeResultError as ComposeResultErrorBase,
ComposeResultFinal as ComposeResultFinalBase,
ComposeResultNonFinal as ComposeResultNonFinalBase,
TransactionInputOutputSortingStrategy,
} from '@trezor/utxo-lib';
import type { PROTO } from '../../constants';
import type { Params, Response } from '../params';
import type { TransactionInputOutputSortingStrategy } from '@trezor/utxo-lib';

// for convenience ComposeOutput `type: "payment"` field is not required by @trezor/connect api
export type ComposeOutputPayment = Omit<Extract<ComposeOutputBase, { type: 'payment' }>, 'type'> & {
Expand Down
3 changes: 1 addition & 2 deletions packages/node-utils/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import * as net from 'net';
import * as url from 'url';

import type { RequiredKey } from '@trezor/type-utils';
import { Log, TypedEmitter } from '@trezor/utils';
import { arrayPartition } from '@trezor/utils';
import { Log, TypedEmitter, arrayPartition } from '@trezor/utils';

import { getFreePort } from './getFreePort';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';
import styled, { css, useTheme } from 'styled-components';
import { Icon } from '@trezor/components';
import { Icon, useElevation } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import {
Elevation,
Expand All @@ -9,7 +9,6 @@ import {
spacingsPx,
typography,
} from '@trezor/theme';
import { useElevation } from '@trezor/components';
import { RotateDeviceImage } from '../RotateDeviceImage/RotateDeviceImage';

const Column = styled.div`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { DeviceAnimation } from '@trezor/components';
import { DeviceAnimation, Image } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { Image } from '@trezor/components';
import styled from 'styled-components';

export type RotateDeviceImageProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AssetLogo, useElevation } from '@trezor/components';
import { getCoingeckoId } from '@suite-common/wallet-config';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { getCoingeckoId, NetworkSymbol } from '@suite-common/wallet-config';
import { TokenInfo } from '@trezor/connect';
import { getContractAddressForNetwork } from '@suite-common/wallet-utils';

Expand Down
3 changes: 1 addition & 2 deletions packages/suite-desktop-core/src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from 'path';

import { isNotUndefined } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import { isNotUndefined, TypedEmitter } from '@trezor/utils';
import { InterceptedEvent } from '@trezor/request-manager';
import { isDevEnv } from '@suite-common/suite-utils';
import type { HandshakeClient, TorStatus } from '@trezor/suite-desktop-api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
transactionsActions,
createDiscoveryThunk,
deviceActions,
prepareSendFormReducer,
} from '@suite-common/wallet-core';
import * as discoveryActions from '@suite-common/wallet-core';
import { getAccountTransactions, getAccountIdentifier } from '@suite-common/wallet-utils';
Expand All @@ -18,7 +19,6 @@ import * as walletSettingsActions from 'src/actions/settings/walletSettingsActio
import { accountsReducer, fiatRatesReducer, transactionsReducer } from 'src/reducers/wallet';
import walletSettingsReducer from 'src/reducers/wallet/settingsReducer';
import suiteReducer from 'src/reducers/suite/suiteReducer';
import { prepareSendFormReducer } from '@suite-common/wallet-core';
import graphReducer from 'src/reducers/wallet/graphReducer';
import storageMiddleware from 'src/middlewares/wallet/storageMiddleware';
import { coinjoinReducer } from 'src/reducers/wallet/coinjoinReducer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
preloadFeeInfoThunk,
setCustomBackendThunk,
updateFeeInfoThunk,
feesReducer,
} from '@suite-common/wallet-core';

import { configureStore, filterThunkActionTypes } from 'src/support/tests/configureStore';
import { accountsReducer, transactionsReducer, blockchainReducer } from 'src/reducers/wallet';
import { feesReducer } from '@suite-common/wallet-core';

import * as fixtures from '../__fixtures__/blockchainActions';

Expand Down
3 changes: 1 addition & 2 deletions packages/suite/src/actions/wallet/coinjoinClientActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { arrayDistinct, arrayToDictionary, promiseAllSequence } from '@trezor/ut
import { getOsName } from '@trezor/env-utils';
import { selectAccountByKey, selectDevices } from '@suite-common/wallet-core';
import { getUtxoOutpoint } from '@suite-common/wallet-utils';
import { Account } from '@suite-common/wallet-types';
import { Account, AddressDisplayOptions } from '@suite-common/wallet-types';
import { notificationsActions } from '@suite-common/toast-notifications';
import { getDeviceInstances } from '@suite-common/suite-utils';

Expand All @@ -35,7 +35,6 @@ import {
} from 'src/reducers/wallet/coinjoinReducer';

import * as COINJOIN from './constants/coinjoinConstants';
import { AddressDisplayOptions } from '@suite-common/wallet-types';

import { selectAddressDisplayType } from 'src/reducers/suite/suiteReducer';
import { Feature, selectIsFeatureDisabled } from '@suite-common/message-system';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
hasNetworkFeatures,
parseFormDraftKey,
} from '@suite-common/wallet-utils';
import { Output } from '@suite-common/wallet-types/src';
import { Output, AddressDisplayOptions } from '@suite-common/wallet-types/src';
import {
confirmAddressOnDeviceThunk,
selectDevice,
Expand All @@ -24,7 +24,6 @@ import {
} from 'src/reducers/wallet/coinmarketReducer';
import { submitRequestForm as envSubmitRequestForm } from 'src/utils/suite/env';
import * as formDraftActions from 'src/actions/wallet/formDraftActions';
import { AddressDisplayOptions } from '@suite-common/wallet-types';
import { selectAddressDisplayType } from 'src/reducers/suite/suiteReducer';
import { CryptoId } from 'invity-api';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
PrecomposedTransaction,
PrecomposedTransactionFinal,
ExternalOutput,
AddressDisplayOptions,
} from '@suite-common/wallet-types';
import { selectDevice } from '@suite-common/wallet-core';
import { selectDevice, ComposeActionContext } from '@suite-common/wallet-core';

import { Dispatch, GetState } from 'src/types/suite';
import { selectAddressDisplayType } from 'src/reducers/suite/suiteReducer';
import { AddressDisplayOptions } from '@suite-common/wallet-types';

import {
getStakeTxGasLimit,
Expand All @@ -37,7 +37,6 @@ import {
MIN_ETH_FOR_WITHDRAWALS,
} from 'src/constants/suite/ethStaking';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { ComposeActionContext } from '@suite-common/wallet-core';

const calculate = (
availableBalance: string,
Expand Down
3 changes: 1 addition & 2 deletions packages/suite/src/components/suite/AccountLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import styled from 'styled-components';
import { BadgeSize, Row, TOOLTIP_DELAY_LONG, TruncateWithTooltip } from '@trezor/components';
import { spacings } from '@trezor/theme';
import { AccountType, NetworkSymbol } from '@suite-common/wallet-config';
import { AccountType, NetworkSymbol, Bip43Path, NetworkType } from '@suite-common/wallet-config';
import { AccountTypeBadge } from './AccountTypeBadge';
import { Bip43Path, NetworkType } from '@suite-common/wallet-config';
import { useDefaultAccountLabel } from 'src/hooks/suite';

const TabularNums = styled.span`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ReactNode } from 'react';
import { DropdownMenuItemProps } from '@trezor/components';
import { MetadataAddPayload } from 'src/types/suite/metadata';
import { AccountType, Bip43Path } from '@suite-common/wallet-config';
import { NetworkType } from '@suite-common/wallet-config';
import { AccountType, Bip43Path, NetworkType } from '@suite-common/wallet-config';

export interface Props {
accountType?: AccountType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useState, useEffect } from 'react';
import styled, { keyframes } from 'styled-components';
import { Account } from '@suite-common/wallet-types';
import { spacingsPx, zIndices } from '@trezor/theme';
import { spacingsPx, zIndices, typography } from '@trezor/theme';
import { H2 } from '@trezor/components';
import { typography } from '@trezor/theme';
import {
MetadataLabeling,
AccountLabel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { UserContextPayload } from '@suite-common/suite-types';
import { selectStake } from '@suite-common/wallet-core';
import { selectStake, cancelSignSendFormTransactionThunk } from '@suite-common/wallet-core';
import { cancelSignTx as cancelSignStakingTx } from 'src/actions/wallet/stakeActions';
import { TransactionReviewModalContent } from './TransactionReviewModalContent';
import { useDispatch, useSelector } from 'src/hooks/suite';

import { cancelSignSendFormTransactionThunk } from '@suite-common/wallet-core';

// This modal is opened either in Device (button request) or User (push tx) context
// contexts are distinguished by `type` prop
type TransactionReviewModalProps =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
selectSendFormReviewButtonRequestsCount,
selectStakePrecomposedForm,
StakeState,
SendState,
} from '@suite-common/wallet-core';
import { FormState, StakeFormState } from '@suite-common/wallet-types';
import { constructTransactionReviewOutputs, isRbfTransaction } from '@suite-common/wallet-utils';
import { SendState } from '@suite-common/wallet-core';
import { useSelector } from 'src/hooks/suite';
import { selectIsActionAbortable } from 'src/reducers/suite/suiteReducer';
import { getTransactionReviewModalActionText } from 'src/utils/suite/transactionReview';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Translation } from 'src/components/suite';
import { formatNetworkAmount, formatAmount, isTestnet } from '@suite-common/wallet-utils';
import { BTC_LOCKTIME_VALUE } from '@suite-common/wallet-constants';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { ReviewOutput } from '@suite-common/wallet-types';
import { ReviewOutput, StakeType } from '@suite-common/wallet-types';
import {
TransactionReviewStepIndicator,
TransactionReviewStepIndicatorProps,
Expand All @@ -14,7 +14,6 @@ import {
OutputElementLine,
} from './TransactionReviewOutputElement';
import type { Account } from 'src/types/wallet';
import { StakeType } from '@suite-common/wallet-types';
import { useDisplayMode, useTranslation } from 'src/hooks/suite';
import { TranslationKey } from '@suite-common/intl-types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import type { Account } from 'src/types/wallet';
import type { FormState, GeneralPrecomposedTransactionFinal } from '@suite-common/wallet-types';
import { getTransactionReviewOutputState } from '@suite-common/wallet-utils';
import { TransactionReviewTotalOutput } from './TransactionReviewTotalOutput';
import { ReviewOutput } from '@suite-common/wallet-types';
import { ReviewOutput, StakeFormState, StakeType } from '@suite-common/wallet-types';
import { spacingsPx } from '@trezor/theme';
import { StakeFormState, StakeType } from '@suite-common/wallet-types';

const Content = styled.div`
display: flex;
Expand Down
Loading

0 comments on commit f2aac41

Please sign in to comment.