Commit ea17c7c1 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

chore: restrict imports from dist (#2443)

* fix: consistent @uniswap/v3-sdk imports

* fix: consistent @redux/toolkit imports

* fix: consistent @web-react imports

* fix: consistent @uniswap/token-lists imports

* chore: restrict dist/ imports
parent 52630aa7
...@@ -39,18 +39,26 @@ ...@@ -39,18 +39,26 @@
"paths": [ "paths": [
{ {
"name": "lodash", "name": "lodash",
"message": "Please import lodash modules directly (lodash/module)." "message": "Please import from 'lodash/module' directly to support tree-shaking."
},
{
"name": "ethers",
"message": "Please import from '@ethersproject/module' directly to support tree-shaking."
}, },
{ {
"name": "styled-components", "name": "styled-components",
"message": "Please import from styled-components/macro." "message": "Please import from styled-components/macro."
}
],
"patterns": [
{
"group": ["**/dist"],
"message": "Do not import from dist/ - this is an implementation detail, and breaks tree-shaking."
}, },
{ {
"name": "ethers", "group": ["!styled-components/macro"]
"message": "Please import from @ethersproject."
} }
], ]
"patterns": ["!styled-components/macro"]
} }
] ]
} }
......
import { Plural, Trans } from '@lingui/macro' import { Plural, Trans } from '@lingui/macro'
import { Currency, Token } from '@uniswap/sdk-core' import { Currency, Token } from '@uniswap/sdk-core'
import { TokenList } from '@uniswap/token-lists/dist/types' import { TokenList } from '@uniswap/token-lists'
import { ButtonPrimary } from 'components/Button' import { ButtonPrimary } from 'components/Button'
import Card from 'components/Card' import Card from 'components/Card'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
......
import { Web3Provider } from '@ethersproject/providers' import { Web3Provider } from '@ethersproject/providers'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { Web3ReactContextInterface } from '@web3-react/core/dist/types'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { gnosisSafe, injected } from '../connectors' import { gnosisSafe, injected } from '../connectors'
import { IS_IN_IFRAME, NetworkContextName } from '../constants/misc' import { IS_IN_IFRAME, NetworkContextName } from '../constants/misc'
import { isMobile } from '../utils/userAgent' import { isMobile } from '../utils/userAgent'
export function useActiveWeb3React(): Web3ReactContextInterface<Web3Provider> { export function useActiveWeb3React() {
const context = useWeb3React<Web3Provider>() const context = useWeb3React<Web3Provider>()
const contextNetwork = useWeb3React<Web3Provider>(NetworkContextName) const contextNetwork = useWeb3React<Web3Provider>(NetworkContextName)
return context.active ? context : contextNetwork return context.active ? context : contextNetwork
......
import { BaseQueryApi, BaseQueryFn } from '@reduxjs/toolkit/dist/query/baseQueryTypes' import { BaseQueryFn } from '@reduxjs/toolkit/query'
import { createApi } from '@reduxjs/toolkit/query/react' import { createApi } from '@reduxjs/toolkit/query/react'
import { SupportedChainId } from 'constants/chains' import { SupportedChainId } from 'constants/chains'
import { DocumentNode } from 'graphql' import { DocumentNode } from 'graphql'
...@@ -82,7 +82,7 @@ function graphqlRequestBaseQuery(): BaseQueryFn< ...@@ -82,7 +82,7 @@ function graphqlRequestBaseQuery(): BaseQueryFn<
Pick<ClientError, 'name' | 'message' | 'stack'>, Pick<ClientError, 'name' | 'message' | 'stack'>,
Partial<Pick<ClientError, 'request' | 'response'>> Partial<Pick<ClientError, 'request' | 'response'>>
> { > {
return async ({ document, variables }, { getState }: BaseQueryApi) => { return async ({ document, variables }, { getState }) => {
try { try {
const chainId = (getState() as AppState).application.chainId const chainId = (getState() as AppState).application.chainId
......
import { createReducer } from '@reduxjs/toolkit' import { createReducer } from '@reduxjs/toolkit'
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists' import { getVersionUpgrade, TokenList, VersionUpgrade } from '@uniswap/token-lists'
import { TokenList } from '@uniswap/token-lists/dist/types'
import { DEFAULT_ACTIVE_LIST_URLS } from '../../constants/lists' import { DEFAULT_ACTIVE_LIST_URLS } from '../../constants/lists'
import { DEFAULT_LIST_OF_LISTS } from '../../constants/lists' import { DEFAULT_LIST_OF_LISTS } from '../../constants/lists'
......
import { Currency, Token } from '@uniswap/sdk-core' import { Currency, Token } from '@uniswap/sdk-core'
import { Tags, TokenInfo } from '@uniswap/token-lists' import { Tags, TokenInfo, TokenList } from '@uniswap/token-lists'
import { TokenList } from '@uniswap/token-lists/dist/types'
import { isAddress } from '../../utils' import { isAddress } from '../../utils'
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
TICK_SPACINGS, TICK_SPACINGS,
TickMath, TickMath,
tickToPrice, tickToPrice,
} from '@uniswap/v3-sdk/dist/' } from '@uniswap/v3-sdk'
import { usePool } from 'hooks/usePools' import { usePool } from 'hooks/usePools'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { useCallback, useMemo } from 'react' import { useCallback, useMemo } from 'react'
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
priceToClosestTick, priceToClosestTick,
TICK_SPACINGS, TICK_SPACINGS,
TickMath, TickMath,
} from '@uniswap/v3-sdk/dist/' } from '@uniswap/v3-sdk'
import JSBI from 'jsbi' import JSBI from 'jsbi'
export function tryParsePrice(baseToken?: Token, quoteToken?: Token, value?: string) { export function tryParsePrice(baseToken?: Token, quoteToken?: Token, value?: string) {
......
...@@ -3,7 +3,7 @@ import { AddressZero } from '@ethersproject/constants' ...@@ -3,7 +3,7 @@ import { AddressZero } from '@ethersproject/constants'
import { Contract } from '@ethersproject/contracts' import { Contract } from '@ethersproject/contracts'
import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers' import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
import { Token } from '@uniswap/sdk-core' import { Token } from '@uniswap/sdk-core'
import { FeeAmount } from '@uniswap/v3-sdk/dist/' import { FeeAmount } from '@uniswap/v3-sdk'
import { TokenAddressMap } from '../state/lists/hooks' import { TokenAddressMap } from '../state/lists/hooks'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment