Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

More linter rules #1523

Merged
merged 3 commits into from
Oct 13, 2020
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'eslint:recommended',
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
Expand Down Expand Up @@ -44,4 +45,9 @@ module.exports = {
globals: {
VERSION: true,
},
env: {
browser: true,
node: true,
jest: true,
},
}
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ function createTcrApi(web3: Web3): TcrApi | undefined {
case 'none':
tcrApi = undefined
break
case 'multi-tcr':
case 'multi-tcr': {
const multiTcrApiConfig = CONFIG.tcr
tcrApi = new MultiTcrApiProxy({ web3, ...multiTcrApiConfig.config })
break
}

default:
throw new Error('Unknown implementation for DexPriceEstimatorApi: ' + type)
Expand Down
3 changes: 2 additions & 1 deletion src/components/TokenOptionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const generateMessage = ({
case TokenFromExchange.NOT_ERC20:
return <>Not a valid ERC20 token</>
// registered but not in list --> option to add
case TokenFromExchange.NOT_IN_TOKEN_LIST:
case TokenFromExchange.NOT_IN_TOKEN_LIST: {
if (!token || !('id' in token)) return <>{defaultText}</>

const handleAddToken: React.MouseEventHandler<HTMLButtonElement> = async (e) => {
Expand All @@ -201,6 +201,7 @@ const generateMessage = ({
<button onClick={handleAddToken}>Add Token</button>
</OptionItem>
)
}
default:
return <>{defaultText}</>
}
Expand Down
1 change: 1 addition & 0 deletions src/components/TradesWidget/TradeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const TradeRow: React.FC<TradeRowProps> = (params) => {
return `${fillPercentage} matched out of ${orderAmount} ${displayTokenSymbolOrLink(sellToken)}`
}
}
// falls through
case 'liquidity':
case 'unknown':
default:
Expand Down
3 changes: 2 additions & 1 deletion src/reducers-actions/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ export async function sideEffect(state: OrdersState, action: ReducerActionType):
switch (action.type) {
case 'OVERWRITE_ORDERS':
case 'UPDATE_ORDERS':
case 'APPEND_ORDERS':
case 'APPEND_ORDERS': {
const newTokenIdsFromOrders = new Set<number>()

// orders can contain many duplicated tokenIds
state.orders.forEach(({ sellTokenId, buyTokenId }) => newTokenIdsFromOrders.add(sellTokenId).add(buyTokenId))

addUnlistedTokensToUserTokenListById(Array.from(newTokenIdsFromOrders))
}
}
}
1 change: 1 addition & 0 deletions src/reducers-actions/pendingOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const sideEffect = (state: PendingOrdersState, action: ReducerType): Pend
case 'SAVE_PENDING_ORDERS':
case 'REPLACE_PENDING_ORDERS':
setStorageItem(STORAGE_PENDING_ORDER_KEY, state)
// falls through
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers-actions/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function getPendingTrades(tradesByRevertKey: Map<string, Trade[]>): Map<string,

// Filter out trades in that range (curr ... curr -2).
// The `revertKey` is composed by batchId|orderId, so this regex looks for the batchIds in the keys
const batchesRegex = new RegExp(`^(${currentBatchId}|${currentBatchId - 1}|${currentBatchId - 2})\\\|`)
const batchesRegex = new RegExp(`^(${currentBatchId}|${currentBatchId - 1}|${currentBatchId - 2})\\|`)

const pending = new Map<string, Trade[]>()

Expand Down