Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback } from 'react'

import { useCowAnalytics } from '@cowprotocol/analytics'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { LpToken } from '@cowprotocol/common-const'
import { LpTokenProvider } from '@cowprotocol/types'
import { BigNumber } from '@ethersproject/bignumber'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useState } from 'react'

import { CowHookDetails, HookToDappMatch } from '@cowprotocol/hook-dapp-lib'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { ReactElement, useEffect, useMemo, useState } from 'react'

import { cowAppDataLatestScheme } from '@cowprotocol/cow-sdk'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { GPv2Settlement, CoWSwapEthFlow } from '@cowprotocol/abis'
import { calculateGasMargin } from '@cowprotocol/common-utils'
import { BigNumber } from '@ethersproject/bignumber'
Expand Down Expand Up @@ -25,7 +26,7 @@ export interface OnChainCancellation {

export async function getEthFlowCancellation(
ethFlowContract: CoWSwapEthFlow,
order: Order
order: Order,
): Promise<OnChainCancellation> {
const cancelOrderParams = {
buyToken: order.buyToken,
Expand All @@ -43,7 +44,7 @@ export async function getEthFlowCancellation(
logTradeFlowError(
LOG_LABEL,
`Error estimating invalidateOrder gas. Using default ${CANCELLATION_GAS_LIMIT_DEFAULT}`,
error
error,
)
return CANCELLATION_GAS_LIMIT_DEFAULT
})
Expand Down Expand Up @@ -72,7 +73,7 @@ export async function getOnChainCancellation(contract: GPv2Settlement, order: Or
logTradeFlowError(
LOG_LABEL,
`Error estimating invalidateOrder gas. Using default ${CANCELLATION_GAS_LIMIT_DEFAULT}`,
error
error,
)
return CANCELLATION_GAS_LIMIT_DEFAULT
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback } from 'react'

import { getIsNativeToken } from '@cowprotocol/common-utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback } from 'react'

import { getIsNativeToken } from '@cowprotocol/common-utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { USDC } from '@cowprotocol/common-const'
import { getWrappedToken, tryParseCurrencyAmount } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { SupportedChainId } from '@cowprotocol/cow-sdk'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { useTokenByAddress } from '@cowprotocol/tokens'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { useTradeTypeInfo } from 'modules/trade'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { MIN_FIAT_SURPLUS_VALUE, MIN_FIAT_SURPLUS_VALUE_MODAL, MIN_SURPLUS_UNITS } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback } from 'react'

import { getChainInfo } from '@cowprotocol/common-const'
Expand Down
7 changes: 4 additions & 3 deletions apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback } from 'react'

import { tryParseCurrencyAmount } from '@cowprotocol/common-utils'
Expand All @@ -14,7 +15,7 @@ import { RateInfoParams } from 'common/pure/RateInfo'

export function useRateInfoParams(
inputCurrencyAmount: Nullish<CurrencyAmount<Currency>>,
outputCurrencyAmount: Nullish<CurrencyAmount<Currency>>
outputCurrencyAmount: Nullish<CurrencyAmount<Currency>>,
): RateInfoParams {
const { chainId } = useWalletInfo()

Expand All @@ -26,15 +27,15 @@ export function useRateInfoParams(

return (invert ? activeRate.invert() : activeRate).toSignificant(18)
},
[activeRate]
[activeRate],
)

const {
inputAmount: { value: invertedActiveRateFiatAmount },
outputAmount: { value: activeRateFiatAmount },
} = useTradeUsdAmounts(
tryParseCurrencyAmount(parseRate(true), inputCurrencyAmount?.currency || undefined),
tryParseCurrencyAmount(parseRate(false), outputCurrencyAmount?.currency || undefined)
tryParseCurrencyAmount(parseRate(false), outputCurrencyAmount?.currency || undefined),
)

return useSafeMemoObject({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { getChainInfo, TokenWithLogo } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { getChainInfo, TokenWithLogo } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useMemo } from 'react'

import { TokenWithLogo } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import React, { useCallback, useMemo, useRef } from 'react'

import { isTruthy } from '@cowprotocol/common-utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import React, { ReactNode } from 'react'

import { Command } from '@cowprotocol/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'

import { NATIVE_CURRENCIES } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { ReactNode } from 'react'

import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { rawToTokenAmount } from '@cowprotocol/common-utils'
import { Currency, CurrencyAmount, Price } from '@uniswap/sdk-core'

Expand All @@ -8,13 +9,13 @@ function getPriceQuoteAmount(price: Price<Currency, Currency>, isInverted: boole

return CurrencyAmount.fromRawAmount(
executionPrice.baseCurrency,
rawToTokenAmount(1, executionPrice.baseCurrency.decimals)
rawToTokenAmount(1, executionPrice.baseCurrency.decimals),
)
}

export function useExecutionPriceFiat(
executionPrice: Price<Currency, Currency> | null,
isInverted: boolean
isInverted: boolean,
): CurrencyAmount<Currency> | null {
const amount = executionPrice ? getPriceQuoteAmount(executionPrice, isInverted) : undefined

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { ReactNode } from 'react'

import { TokenAmount } from '@cowprotocol/ui'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import React, { ReactNode } from 'react'

import { isFractionFalsy } from '@cowprotocol/common-utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useEffect } from 'react'

import { useSetIsBridgingEnabled } from '@cowprotocol/common-hooks'
Expand Down
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/common/updaters/SentryUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useEffect } from 'react'

import { useIsWindowVisible } from '@cowprotocol/common-hooks'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { ReactNode } from 'react'

import { useCowAnalytics } from '@cowprotocol/analytics'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useCallback, useEffect, useRef } from 'react'

import { CANCELLED_ORDERS_PENDING_TIME } from '@cowprotocol/common-const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useSetAtom } from 'jotai'
import { useCallback, useEffect, useMemo, useRef } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useSetAtom } from 'jotai'
import { useCallback, useEffect, useMemo, useRef } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useSetAtom } from 'jotai'
import { useEffect, useMemo } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useSetAtom } from 'jotai'
import { useCallback } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { useAtom, useSetAtom } from 'jotai'
import { useRef } from 'react'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
import { doesHookHavePermit } from '@cowprotocol/hook-dapp-lib'

import { getAppDataHooks } from 'modules/appData'
Expand Down
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ module.exports = [
],
},
},
/**
* Restrict modules/** imports inside common/** dir
* @see CONTRIBUTING.md
*/
{
files: ['apps/cowswap-frontend/src/common/**/*.{ts,tsx,js,jsx}'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'cowswap-frontend/modules',
message: 'Do not import from modules inside common dir.',
},
],
patterns: ['modules/*'],
},
],
},
},

// Tests
{
files: ['**/*.test.{ts,tsx,js,jsx}'],
Expand Down
2 changes: 1 addition & 1 deletion libs/wallet-provider/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["../../.eslintrc.json"],
"extends": ["../../eslint.config.js"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
Expand Down
Loading