fix: remove requirement of default case in all switch statements

This commit is contained in:
fragosti 2018-11-12 17:30:28 -08:00
parent 711b307e6c
commit 01b36b4949
8 changed files with 12 additions and 22 deletions

View File

@ -51,8 +51,6 @@ export class PaymentMethod extends React.Component<PaymentMethodProps> {
return 'connect your wallet'; return 'connect your wallet';
case AccountState.Ready: case AccountState.Ready:
return 'payment method'; return 'payment method';
default:
return 'payment method';
} }
}; };
private readonly _renderTitleLabel = (): React.ReactNode => { private readonly _renderTitleLabel = (): React.ReactNode => {
@ -104,8 +102,6 @@ export class PaymentMethod extends React.Component<PaymentMethodProps> {
network={network} network={network}
/> />
); );
default:
return null;
} }
}; };
} }

View File

@ -156,8 +156,6 @@ export class ScalingInput extends React.Component<ScalingInputProps, ScalingInpu
return `${width}px`; return `${width}px`;
} }
return `${textLengthThreshold}ch`; return `${textLengthThreshold}ch`;
default:
return '1ch';
} }
}; };
private readonly _calculateFontSize = (phase: ScalingInputPhase): number => { private readonly _calculateFontSize = (phase: ScalingInputPhase): number => {

View File

@ -22,7 +22,7 @@ export class StandardSlidingPanel extends React.Component<StandardSlidingPanelPr
switch (content) { switch (content) {
case StandardSlidingPanelContent.InstallWallet: case StandardSlidingPanelContent.InstallWallet:
return <InstallWalletPanelContent />; return <InstallWalletPanelContent />;
default: case StandardSlidingPanelContent.None:
return null; return null;
} }
}; };

View File

@ -1,4 +1,5 @@
import { AssetProxyId } from '@0x/types'; import { AssetProxyId } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
@ -64,19 +65,13 @@ export const asyncData = {
const activeAddress = availableAddresses[0]; const activeAddress = availableAddresses[0];
dispatch(actions.setAccountStateReady(activeAddress)); dispatch(actions.setAccountStateReady(activeAddress));
// tslint:disable-next-line:no-floating-promises // tslint:disable-next-line:no-floating-promises
asyncData.fetchAccountBalanceAndDispatchToStore(providerState, dispatch); asyncData.fetchAccountBalanceAndDispatchToStore(activeAddress, providerState.web3Wrapper, dispatch);
} else { } else {
dispatch(actions.setAccountStateLocked()); dispatch(actions.setAccountStateLocked());
} }
}, },
fetchAccountBalanceAndDispatchToStore: async (providerState: ProviderState, dispatch: Dispatch) => { fetchAccountBalanceAndDispatchToStore: async (address: string, web3Wrapper: Web3Wrapper, dispatch: Dispatch) => {
const web3Wrapper = providerState.web3Wrapper;
const account = providerState.account;
// if (account.state !== AccountState.Ready) {
// return;
// }
try { try {
const address = account.address;
const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(address); const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(address);
dispatch(actions.updateAccountEthBalance({ address, ethBalanceInWei })); dispatch(actions.updateAccountEthBalance({ address, ethBalanceInWei }));
} catch (e) { } catch (e) {

View File

@ -74,13 +74,16 @@ export const createReducer = (initialState: State) => {
return reduceStateWithAccount(state, LOCKED_ACCOUNT); return reduceStateWithAccount(state, LOCKED_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_READY: { case ActionTypes.SET_ACCOUNT_STATE_READY: {
const address = action.data; const address = action.data;
const newAccount: AccountReady = { let newAccount: AccountReady = {
state: AccountState.Ready, state: AccountState.Ready,
address, address,
}; };
const currentAccount = state.providerState.account; const currentAccount = state.providerState.account;
if (currentAccount.state === AccountState.Ready && currentAccount.address === address) { if (currentAccount.state === AccountState.Ready && currentAccount.address === address) {
newAccount.ethBalanceInWei = currentAccount.ethBalanceInWei; newAccount = {
...newAccount,
ethBalanceInWei: currentAccount.ethBalanceInWei,
};
} }
return reduceStateWithAccount(state, newAccount); return reduceStateWithAccount(state, newAccount);
} }

View File

@ -80,8 +80,6 @@ export const assetUtils = {
return metaData.symbol.toUpperCase(); return metaData.symbol.toUpperCase();
case AssetProxyId.ERC721: case AssetProxyId.ERC721:
return metaData.name; return metaData.name;
default:
return defaultName;
} }
}, },
formattedSymbolForAsset: (asset?: ERC20Asset, defaultName: string = '???'): string => { formattedSymbolForAsset: (asset?: ERC20Asset, defaultName: string = '???'): string => {

View File

@ -8,9 +8,8 @@ const etherscanPrefix = (networkId: number): string | undefined => {
return 'kovan.'; return 'kovan.';
case Network.Mainnet: case Network.Mainnet:
return ''; return '';
default:
return undefined;
} }
return '';
}; };
export const etherscanUtil = { export const etherscanUtil = {

View File

@ -3,6 +3,7 @@
"rules": { "rules": {
"custom-no-magic-numbers": false, "custom-no-magic-numbers": false,
"semicolon": [true, "always", "ignore-bound-class-methods"], "semicolon": [true, "always", "ignore-bound-class-methods"],
"max-classes-per-file": false "max-classes-per-file": false,
"switch-default": false
} }
} }