Skip to content

Commit c35a88e

Browse files
chore: fix fast-refresh & add new linting rule (v2) (#6778)
* chore: new linting rule for fast-refresh * chore: migrate NoImpactWarning * chore: downgrade react-refresh lint rule to warning * chore: fix most important react-refresh lint errors * fix: migrate OrderProgressEventsUpdater because of tests dependency
1 parent e94a3d9 commit c35a88e

File tree

80 files changed

+453
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+453
-398
lines changed

apps/cowswap-frontend/src/common/hooks/useBlockNumber.tsx renamed to apps/cowswap-frontend/src/common/hooks/useBlockNumber/BlockNumberProvider.tsx

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
1-
import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react'
1+
import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
22

33
import { useIsWindowVisible } from '@cowprotocol/common-hooks'
44
import { useWalletChainId, useWalletProvider } from '@cowprotocol/wallet-provider'
55

6-
import { useLingui } from '@lingui/react/macro'
7-
8-
const MISSING_PROVIDER = Symbol()
9-
const BlockNumberContext = createContext<
10-
| {
11-
value?: number
12-
}
13-
| typeof MISSING_PROVIDER
14-
>(MISSING_PROVIDER)
15-
16-
// TODO: Add proper return type annotation
17-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
18-
function useBlockNumberContext() {
19-
const blockNumber = useContext(BlockNumberContext)
20-
const { t } = useLingui()
21-
22-
if (blockNumber === MISSING_PROVIDER) {
23-
throw new Error(t`BlockNumber hooks must be wrapped in a` + ` <BlockNumberProvider>`)
24-
}
25-
return blockNumber
26-
}
27-
28-
/** Requires that BlockUpdater be installed in the DOM tree. */
29-
export function useBlockNumber(): number | undefined {
30-
return useBlockNumberContext().value
31-
}
6+
import { BlockNumberContext } from './context'
327

338
// TODO: Add proper return type annotation
349
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createContext } from 'react'
2+
3+
export const MISSING_PROVIDER = Symbol('MISSING_PROVIDER')
4+
5+
export const BlockNumberContext = createContext<
6+
| {
7+
value?: number
8+
}
9+
| typeof MISSING_PROVIDER
10+
>(MISSING_PROVIDER)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { useBlockNumber } from './useBlockNumber'
2+
export { BlockNumberProvider } from './BlockNumberProvider'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useContext } from 'react'
2+
3+
import { useLingui } from '@lingui/react/macro'
4+
5+
import { BlockNumberContext, MISSING_PROVIDER } from './context'
6+
7+
// TODO: Add proper return type annotation
8+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
9+
function useBlockNumberContext() {
10+
const blockNumber = useContext(BlockNumberContext)
11+
const { t } = useLingui()
12+
13+
if (blockNumber === MISSING_PROVIDER) {
14+
throw new Error(t`BlockNumber hooks must be wrapped in a` + ` <BlockNumberProvider>`)
15+
}
16+
return blockNumber
17+
}
18+
19+
/** Requires that BlockUpdater be installed in the DOM tree. */
20+
export function useBlockNumber(): number | undefined {
21+
return useBlockNumberContext().value
22+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { HelpCircle } from '.'
22

3-
const fixtures = {
3+
const Fixtures = {
44
default: () => <HelpCircle />,
55
size16: <HelpCircle size={16} />,
66
}
77

8-
export default fixtures
8+
export default Fixtures

apps/cowswap-frontend/src/common/pure/Modal/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { ContentWrapper, HeaderRow, HoverText, StyledDialogContent, StyledDialog
1414

1515
import { openModalState } from '../../state/openModalState'
1616

17-
export * from './styled'
17+
export { ContentWrapper, HeaderRow, HoverText, StyledDialogContent, StyledDialogOverlay, CloseIcon } from './styled'
18+
1819
interface ModalProps {
1920
isOpen: boolean
2021
onDismiss: Command

apps/cowswap-frontend/src/common/pure/TransactionErrorContent/index.cosmos.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ const Wrapper = styled.div`
1010
background: var(${UI.COLOR_PAPER});
1111
`
1212

13-
const fixtures = {
13+
const Fixtures = {
1414
default: () => (
1515
<Wrapper>
1616
<TransactionErrorContent modalMode message={'User rejected transaction'} onDismiss={console.log} />
1717
</Wrapper>
1818
),
1919
}
2020

21-
export default fixtures
21+
export default Fixtures

apps/cowswap-frontend/src/common/updaters/LpBalancesAndAllowancesUpdater.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { atom, useSetAtom } from 'jotai'
1+
import { useSetAtom } from 'jotai'
22
import { ReactNode, useEffect, useMemo, useState } from 'react'
33

44
import { BalancesRpcCallUpdater } from '@cowprotocol/balances-and-allowances'
@@ -8,6 +8,8 @@ import { LP_TOKEN_LIST_CATEGORIES, useAllLpTokens } from '@cowprotocol/tokens'
88

99
import ms from 'ms.macro'
1010

11+
import { areLpBalancesLoadedAtom } from './lpBalancesState'
12+
1113
// A small gap between balances and allowances refresh intervals is needed to avoid high load to the node at the same time
1214
const LP_BALANCES_SWR_CONFIG = { refreshInterval: ms`32s`, revalidateIfStale: false }
1315
const LP_MULTICALL_OPTIONS = { consequentExecution: true }
@@ -16,8 +18,6 @@ const LP_MULTICALL_OPTIONS = { consequentExecution: true }
1618
// We start the updater with a delay
1719
const LP_UPDATER_START_DELAY = ms`3s`
1820

19-
export const areLpBalancesLoadedAtom = atom(false)
20-
2121
export interface BalancesAndAllowancesUpdaterProps {
2222
account: string | undefined
2323
chainId: SupportedChainId
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { atom } from 'jotai'
2+
3+
export const areLpBalancesLoadedAtom = atom(false)

apps/cowswap-frontend/src/cow-react/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (window.ethereum) {
4141
window.ethereum.autoRefreshOnNetworkChange = false
4242
}
4343

44-
function Main(): ReactNode {
44+
export function Main(): ReactNode {
4545
return (
4646
<StrictMode>
4747
<SvgCacheProvider>

0 commit comments

Comments
 (0)