Skip to content

Commit

Permalink
feat: consistent import type specifiers lint (#8194)
Browse files Browse the repository at this point in the history
* feat: consistent import type specifiers lint

* feat: revert back caughtErrors none behaviour

* feat: autofix

* feat: disable for legit uses as types

* feat: revert tsconfig changes

* feat: missing packages lint fixes

* feat: manual packages fixes

* feat: more manual fixes

* feat: last manual fixes

* feat: actual last ones

* feat: actually last one this time
  • Loading branch information
gomesalexandre authored Nov 26, 2024
1 parent d79e3b4 commit 120efec
Show file tree
Hide file tree
Showing 201 changed files with 1,359 additions and 687 deletions.
22 changes: 19 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"jest",
"prettier",
"simple-import-sort",
"eslint-plugin-react-memo"
"eslint-plugin-react-memo",
"eslint-plugin-import"
],
"parserOptions": {
"sourceType": "module"
Expand All @@ -29,7 +30,18 @@
"rules": {
"jsx-a11y/alt-text": "error",
"jsx-a11y/no-autofocus": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "none",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"prettier/prettier": [
"error",
{
Expand Down Expand Up @@ -77,7 +89,11 @@
"eqeqeq": "error",
"react-hooks/exhaustive-deps": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-imports": ["error", {
"prefer": "type-imports",
"fixStyle": "separate-type-imports"
}],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"react/jsx-handler-names": "error",
"require-await": "error",
"import/no-duplicates": "error",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"dotenv": "^16.0.1",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react-memo": "^0.0.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
Expand Down Expand Up @@ -312,6 +312,9 @@
"p-queue": "^6.6.2",
"web3": "4.2.1-dev.a0d6730.0",
"react-scripts@^5.0.1": "patch:react-scripts@npm%3A5.0.1#./.yarn/patches/react-scripts-npm-5.0.1-d06bd2d5ad.patch",
"@shapeshiftoss/[email protected]": "patch:@shapeshiftoss/bitcoinjs-lib@npm%3A5.2.0-shapeshift.2#./.yarn/patches/@shapeshiftoss-bitcoinjs-lib-npm-5.2.0-shapeshift.2-e59ff81828.patch"
"@shapeshiftoss/[email protected]": "patch:@shapeshiftoss/bitcoinjs-lib@npm%3A5.2.0-shapeshift.2#./.yarn/patches/@shapeshiftoss-bitcoinjs-lib-npm-5.2.0-shapeshift.2-e59ff81828.patch",
"@typescript-eslint/parser": "^8.16.0",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"eslint-plugin-import": "^2.31.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ import type {
CosmosSdkMsgDelegate,
CosmosSdkMsgSend,
CosmosSdkMsgUndelegate,
CosmosSdkMsgWithdrawDelegationReward,
ValidatorAction,
} from '../types'
import {
CosmosSdkMessageType,
type CosmosSdkMsgWithdrawDelegationReward,
type ValidatorAction,
} from '../types'
import { CosmosSdkMessageType } from '../types'

const SUPPORTED_CHAIN_IDS = [KnownChainIds.CosmosMainnet]
const DEFAULT_CHAIN_ID = KnownChainIds.CosmosMainnet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { bnOrZero } from '../../utils/bignumber'
import { assertAddressNotSanctioned } from '../../utils/validateAddress'
import type { ChainAdapterArgs as BaseChainAdapterArgs } from '../CosmosSdkBaseAdapter'
import { CosmosSdkBaseAdapter } from '../CosmosSdkBaseAdapter'
import type { ThorchainMsgSend } from '../types'
import { ThorchainMessageType, type ThorchainMsgDeposit } from '../types'
import type { ThorchainMsgDeposit, ThorchainMsgSend } from '../types'
import { ThorchainMessageType } from '../types'

// https://dev.thorchain.org/thorchain-dev/interface-guide/fees#thorchain-native-rune
// static automatic outbound fee as defined by: https://daemon.thorchain.shapeshift.com/lcd/thorchain/constants
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Address, erc20Abi } from 'viem'
import type { Address } from 'viem'
import { erc20Abi } from 'viem'

import { EVERGREEN_FARMING_ABI } from './abis/evergreenFarming'
import { FARMING_ABI } from './abis/farming'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Erc20Bridger, EthBridger } from '@arbitrum/sdk'
import { ethAssetId, ethChainId } from '@shapeshiftoss/caip'
import { type EvmChainAdapter } from '@shapeshiftoss/chain-adapters'
import type { EvmChainAdapter } from '@shapeshiftoss/chain-adapters'
import { describe, expect, it, vi } from 'vitest'

import type { GetEvmTradeQuoteInput, SwapperDeps } from '../../../types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethChainId } from '@shapeshiftoss/caip'
import { type HDWallet } from '@shapeshiftoss/hdwallet-core'
import type { HDWallet } from '@shapeshiftoss/hdwallet-core'
import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
import { v4 as uuid } from 'uuid'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type { ChainId } from '@shapeshiftoss/caip'
import { ethAssetId, ethChainId, fromAssetId } from '@shapeshiftoss/caip'
import type { EvmChainAdapter } from '@shapeshiftoss/chain-adapters'
import { getEthersV5Provider } from '@shapeshiftoss/contracts'
import { type Asset, KnownChainIds } from '@shapeshiftoss/types'
import type { Asset } from '@shapeshiftoss/types'
import { KnownChainIds } from '@shapeshiftoss/types'
import { assertUnreachable } from '@shapeshiftoss/utils'
import { BigNumber } from 'ethers5'
import { arbitrum } from 'viem/chains'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { arbitrumAssetId, ethAssetId, ethChainId, fromAssetId } from '@shapeshif
import type { EvmChainAdapter } from '@shapeshiftoss/chain-adapters'
import { evm } from '@shapeshiftoss/chain-adapters'
import { getEthersV5Provider } from '@shapeshiftoss/contracts'
import { type Asset, KnownChainIds } from '@shapeshiftoss/types'
import type { Asset } from '@shapeshiftoss/types'
import { KnownChainIds } from '@shapeshiftoss/types'
import type { Result } from '@sniptt/monads/build'
import { Err, Ok } from '@sniptt/monads/build'
import { getAddress, isAddressEqual } from 'viem'
Expand Down
3 changes: 1 addition & 2 deletions packages/swapper/src/swappers/ChainflipSwapper/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { AssetId, ChainId } from '@shapeshiftoss/caip'
import {
arbitrumAssetId,
type AssetId,
btcAssetId,
type ChainId,
ethAssetId,
flipAssetId,
solAssetId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import { v4 as uuid } from 'uuid'
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants'
import type {
CommonTradeQuoteInput,
GetEvmTradeQuoteInput,
GetUtxoTradeQuoteInput,
ProtocolFee,
SwapErrorRight,
SwapperDeps,
TradeQuote,
} from '../../../types'
import {
type GetEvmTradeQuoteInput,
type ProtocolFee,
SwapperName,
TradeQuoteError,
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { getRate, makeSwapErrorRight } from '../../../utils'
import {
CHAINFLIP_BAAS_COMMISSION,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type AssetId, type ChainId, fromAssetId } from '@shapeshiftoss/caip'
import type { AssetId, ChainId } from '@shapeshiftoss/caip'
import { fromAssetId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import { bn, bnOrZero, fromBaseUnit } from '@shapeshiftoss/utils'
import type { Result } from '@sniptt/monads'
Expand Down
3 changes: 2 additions & 1 deletion packages/swapper/src/swappers/CowSwapper/CowSwapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type AssetId, fromChainId } from '@shapeshiftoss/caip'
import type { AssetId } from '@shapeshiftoss/caip'
import { fromChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import { ethers } from 'ethers'

Expand Down
12 changes: 5 additions & 7 deletions packages/swapper/src/swappers/CowSwapper/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ import {
} from '../../utils'
import { getCowSwapTradeQuote } from './getCowSwapTradeQuote/getCowSwapTradeQuote'
import { getCowSwapTradeRate } from './getCowSwapTradeRate/getCowSwapTradeRate'
import type { CowSwapOrder } from './types'
import {
CoWSwapBuyTokenDestination,
type CowSwapGetTradesResponse,
type CowSwapGetTransactionsResponse,
CoWSwapSellTokenSource,
CoWSwapSigningScheme,
import type {
CowSwapGetTradesResponse,
CowSwapGetTransactionsResponse,
CowSwapOrder,
} from './types'
import { CoWSwapBuyTokenDestination, CoWSwapSellTokenSource, CoWSwapSigningScheme } from './types'
import { cowService } from './utils/cowService'
import {
deductAffiliateFeesFromAmount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import {
WETH,
XDAI,
} from '../../utils/test-data/assets'
import {
CoWSwapBuyTokenDestination,
type CowSwapQuoteResponse,
CoWSwapSellTokenSource,
} from '../types'
import type { CowSwapQuoteResponse } from '../types'
import { CoWSwapBuyTokenDestination, CoWSwapSellTokenSource } from '../types'
import { COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS, DEFAULT_ADDRESS } from '../utils/constants'
import { cowService } from '../utils/cowService'
import type { CowSwapSellQuoteApiInput } from '../utils/helpers/helpers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import type {
import { SwapperName } from '../../../types'
import { createTradeAmountTooSmallErr } from '../../../utils'
import { isNativeEvmAsset } from '../../utils/helpers/helpers'
import { CoWSwapOrderKind, type CowSwapQuoteError, type CowSwapQuoteResponse } from '../types'
import type { CowSwapQuoteError, CowSwapQuoteResponse } from '../types'
import { CoWSwapOrderKind } from '../types'
import {
COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS,
COW_SWAP_VAULT_RELAYER_ADDRESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import type { GetEvmTradeRateInput, SwapErrorRight, SwapperConfig, TradeRate } f
import { SwapperName } from '../../../types'
import { createTradeAmountTooSmallErr } from '../../../utils'
import { isNativeEvmAsset } from '../../utils/helpers/helpers'
import { CoWSwapOrderKind, type CowSwapQuoteError, type CowSwapQuoteResponse } from '../types'
import type { CowSwapQuoteError, CowSwapQuoteResponse } from '../types'
import { CoWSwapOrderKind } from '../types'
import {
COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS,
COW_SWAP_VAULT_RELAYER_ADDRESS,
Expand Down
8 changes: 6 additions & 2 deletions packages/swapper/src/swappers/LifiSwapper/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ChainKey, ExtendedTransactionInfo, GetStatusRequest, Route } from '@lifi/sdk'
import { getStepTransaction } from '@lifi/sdk'
import { type ChainId, fromChainId } from '@shapeshiftoss/caip'
import type { ChainId } from '@shapeshiftoss/caip'
import { fromChainId } from '@shapeshiftoss/caip'
import { evm } from '@shapeshiftoss/chain-adapters'
import { TxStatus } from '@shapeshiftoss/unchained-client'
import { bn } from '@shapeshiftoss/utils'
Expand All @@ -15,10 +16,13 @@ import type {
GetEvmTradeRateInput,
GetTradeRateInput,
GetUnsignedEvmTransactionArgs,
SwapErrorRight,
SwapperApi,
SwapperDeps,
TradeQuote,
TradeRate,
} from '../../types'
import { type SwapErrorRight, type SwapperApi, type TradeQuote, TradeQuoteError } from '../../types'
import { TradeQuoteError } from '../../types'
import {
checkSafeTransactionStatus,
createDefaultStatusResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ import { Err, Ok } from '@sniptt/monads'

import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants'
import type {
GetEvmTradeQuoteInput,
GetEvmTradeQuoteInputBase,
MultiHopTradeQuoteSteps,
SingleHopTradeQuoteSteps,
SwapErrorRight,
SwapperDeps,
SwapSource,
} from '../../../types'
import {
type GetEvmTradeQuoteInput,
type SwapErrorRight,
SwapperName,
TradeQuoteError,
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { makeSwapErrorRight } from '../../../utils'
import { configureLiFi } from '../utils/configureLiFi'
import { LIFI_INTEGRATOR_ID } from '../utils/constants'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
import { zeroAddress } from 'viem'

import type { GetEvmTradeQuoteInputBase, SwapperConfig } from '../../../types'
import {
type SingleHopTradeQuoteSteps,
type SwapErrorRight,
SwapperName,
type TradeQuote,
TradeQuoteError,
import type {
GetEvmTradeQuoteInputBase,
SingleHopTradeQuoteSteps,
SwapErrorRight,
SwapperConfig,
TradeQuote,
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { getRate, makeSwapErrorRight } from '../../../utils'
import { getTreasuryAddressFromChainId, isNativeEvmAsset } from '../../utils/helpers/helpers'
import { chainIdToPortalsNetwork } from '../constants'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { getDefaultSlippageDecimalPercentageForSwapper } from '../../..'
import type {
GetEvmTradeRateInput,
SingleHopTradeRateSteps,
SwapErrorRight,
SwapperConfig,
TradeRate,
} from '../../../types'
import { type SwapErrorRight, SwapperName, TradeQuoteError } from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { getRate, makeSwapErrorRight } from '../../../utils'
import { isNativeEvmAsset } from '../../utils/helpers/helpers'
import { chainIdToPortalsNetwork } from '../constants'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ChainId } from '@shapeshiftoss/caip'
import {
arbitrumChainId,
avalancheChainId,
baseChainId,
binanceChainId,
type ChainId,
ethChainId,
gnosisChainId,
optimismChainId,
Expand Down
3 changes: 2 additions & 1 deletion packages/swapper/src/swappers/ThorchainSwapper/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { bchChainId, type ChainId } from '@shapeshiftoss/caip'
import type { ChainId } from '@shapeshiftoss/caip'
import { bchChainId } from '@shapeshiftoss/caip'
import { KnownChainIds } from '@shapeshiftoss/types'
import { isUtxoChainId } from '@shapeshiftoss/utils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cosmossdk as cosmossdkChainAdapter, evm } from '@shapeshiftoss/chain-ad
import type { BTCSignTx } from '@shapeshiftoss/hdwallet-core'
import { cosmossdk, TxStatus } from '@shapeshiftoss/unchained-client'
import { assertUnreachable, BigNumber, bn, bnOrZero } from '@shapeshiftoss/utils'
import { type Result } from '@sniptt/monads/build'
import type { Result } from '@sniptt/monads/build'
import assert from 'assert'
import axios from 'axios'
import type { InterpolationOptions } from 'node-polyglot'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fromAssetId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import { type Address, getAddress } from 'viem'
import type { Address } from 'viem'
import { getAddress } from 'viem'

import { depositWithExpiry, getInboundAddressDataForChain } from '../../../../thorchain-utils'
import type { SwapperConfig } from '../../../../types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type AssetId, type ChainId } from '@shapeshiftoss/caip'
import type { AssetId, ChainId } from '@shapeshiftoss/caip'
import { bn } from '@shapeshiftoss/chain-adapters'
import { subtractBasisPointAmount } from '@shapeshiftoss/utils'
import assert from 'assert'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import { Err, Ok } from '@sniptt/monads'
import { v4 as uuid } from 'uuid'

import { getDefaultSlippageDecimalPercentageForSwapper } from '../../..'
import type { GetEvmTradeQuoteInput, ProtocolFee, SwapperDeps } from '../../../types'
import {
type GetTradeRateInput,
type SwapErrorRight,
SwapperName,
TradeQuoteError,
import type {
GetEvmTradeQuoteInput,
GetTradeRateInput,
ProtocolFee,
SwapErrorRight,
SwapperDeps,
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { makeSwapErrorRight } from '../../../utils'
import {
THOR_PRECISION,
Expand Down
Loading

0 comments on commit 120efec

Please sign in to comment.