From 943c378309a84ed142852c6584b53958df7817c8 Mon Sep 17 00:00:00 2001 From: Xianny <8582774+xianny@users.noreply.github.com> Date: Fri, 11 Jan 2019 10:04:30 -0800 Subject: Implement tslint enum-naming to enforce PascalCase on enum members (#1474) --- .../ts/components/dialogs/ledger_config_dialog.tsx | 18 +++++----- packages/website/ts/components/fill_order.tsx | 8 ++--- .../ts/components/generate_order/asset_picker.tsx | 42 +++++++++++----------- .../generate_order/generate_order_form.tsx | 20 +++++------ .../components/generate_order/new_token_form.tsx | 2 +- .../components/inputs/allowance_state_toggle.tsx | 2 +- packages/website/ts/components/portal/portal.tsx | 4 +-- packages/website/ts/components/token_balances.tsx | 22 ++++++------ packages/website/ts/components/ui/alert.tsx | 2 +- .../ts/components/ui/lifecycle_raised_button.tsx | 24 ++++++------- packages/website/ts/types.ts | 36 +++++++++---------- packages/website/ts/utils/utils.ts | 10 +++--- 12 files changed, 95 insertions(+), 95 deletions(-) (limited to 'packages/website') diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx index e15a2dd94..527353aa0 100644 --- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx +++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx @@ -20,8 +20,8 @@ import { utils } from 'ts/utils/utils'; const VALID_ETHEREUM_DERIVATION_PATH_PREFIX = `44'/60'`; enum LedgerSteps { - CONNECT, - SELECT_ADDRESS, + Connect, + SelectAddress, } interface LedgerConfigDialogProps { @@ -52,7 +52,7 @@ export class LedgerConfigDialog extends React.Component, ]; const dialogTitle = - this.state.stepIndex === LedgerSteps.CONNECT ? 'Connect to your Ledger' : 'Select desired address'; + this.state.stepIndex === LedgerSteps.Connect ? 'Connect to your Ledger' : 'Select desired address'; return (
- {this.state.stepIndex === LedgerSteps.CONNECT && this._renderConnectStep()} - {this.state.stepIndex === LedgerSteps.SELECT_ADDRESS && this._renderSelectAddressStep()} + {this.state.stepIndex === LedgerSteps.Connect && this._renderConnectStep()} + {this.state.stepIndex === LedgerSteps.SelectAddress && this._renderSelectAddressStep()}
); @@ -195,7 +195,7 @@ export class LedgerConfigDialog extends React.Component { )} {!_.isEmpty(this.state.orderJSONErrMsg) && ( - + )} ); @@ -298,7 +298,7 @@ export class FillOrder extends React.Component { onClick={this._onCancelOrderClickFireAndForgetAsync.bind(this)} /> {this.state.didCancelOrderSucceed && ( - + )} ) : ( @@ -310,10 +310,10 @@ export class FillOrder extends React.Component { onClick={this._onFillOrderClick.bind(this)} /> {!_.isEmpty(this.state.globalErrMsg) && ( - + )} {this.state.didFillOrderSucceed && ( - + )} )} diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx index e6ecd2ec8..d3f11f962 100644 --- a/packages/website/ts/components/generate_order/asset_picker.tsx +++ b/packages/website/ts/components/generate_order/asset_picker.tsx @@ -18,9 +18,9 @@ import { utils } from 'ts/utils/utils'; const TOKEN_ICON_DIMENSION = 100; const TILE_DIMENSION = 146; enum AssetViews { - ASSET_PICKER = 'ASSET_PICKER', - NEW_TOKEN_FORM = 'NEW_TOKEN_FORM', - CONFIRM_TRACK_TOKEN = 'CONFIRM_TRACK_TOKEN', + AssetPicker = 'ASSET_PICKER', + NewTokenForm = 'NEW_TOKEN_FORM', + ConfirmTrackToken = 'CONFIRM_TRACK_TOKEN', } interface AssetPickerProps { @@ -44,29 +44,29 @@ interface AssetPickerState { export class AssetPicker extends React.Component { public static defaultProps: Partial = { - tokenVisibility: TokenVisibility.ALL, + tokenVisibility: TokenVisibility.All, }; private readonly _dialogConfigsByAssetView: { [assetView: string]: DialogConfigs }; constructor(props: AssetPickerProps) { super(props); this.state = { - assetView: AssetViews.ASSET_PICKER, + assetView: AssetViews.AssetPicker, hoveredAddress: undefined, chosenTrackTokenAddress: undefined, isAddingTokenToTracked: false, }; this._dialogConfigsByAssetView = { - [AssetViews.ASSET_PICKER]: { + [AssetViews.AssetPicker]: { title: 'Select token', isModal: false, actions: [], }, - [AssetViews.NEW_TOKEN_FORM]: { + [AssetViews.NewTokenForm]: { title: 'Add an ERC20 token', isModal: false, actions: [], }, - [AssetViews.CONFIRM_TRACK_TOKEN]: { + [AssetViews.ConfirmTrackToken]: { title: 'Tracking confirmation', isModal: true, actions: [ @@ -95,15 +95,15 @@ export class AssetPicker extends React.Component - {this.state.assetView === AssetViews.ASSET_PICKER && this._renderAssetPicker()} - {this.state.assetView === AssetViews.NEW_TOKEN_FORM && ( + {this.state.assetView === AssetViews.AssetPicker && this._renderAssetPicker()} + {this.state.assetView === AssetViews.NewTokenForm && ( )} - {this.state.assetView === AssetViews.CONFIRM_TRACK_TOKEN && this._renderConfirmTrackToken()} + {this.state.assetView === AssetViews.ConfirmTrackToken && this._renderConfirmTrackToken()} ); } @@ -138,19 +138,19 @@ export class AssetPicker extends React.Component { return ( token.symbol !== constants.ZRX_TOKEN_SYMBOL && token.symbol !== constants.ETHER_TOKEN_SYMBOL && - ((this.props.tokenVisibility === TokenVisibility.TRACKED && utils.isTokenTracked(token)) || - (this.props.tokenVisibility === TokenVisibility.UNTRACKED && + ((this.props.tokenVisibility === TokenVisibility.Tracked && utils.isTokenTracked(token)) || + (this.props.tokenVisibility === TokenVisibility.Untracked && !utils.isTokenTracked(token))) ); }); // if we are showing tracked tokens, sort by date added, otherwise sort by symbol - const sortKey = this.props.tokenVisibility === TokenVisibility.TRACKED ? 'trackedTimestamp' : 'symbol'; + const sortKey = this.props.tokenVisibility === TokenVisibility.Tracked ? 'trackedTimestamp' : 'symbol'; const sortedTokens = filteredTokens.sort(firstBy(sortKey)); if (_.isEmpty(sortedTokens)) { return
No tokens to remove.
; @@ -188,7 +188,7 @@ export class AssetPicker extends React.Component {this.state.globalErrMsg !== '' && ( - + )} @@ -215,7 +215,7 @@ export class GenerateOrderForm extends React.Component { @@ -305,13 +305,13 @@ export class GenerateOrderForm extends React.Component { this.setState({ - signingState: SigningState.SIGNING, + signingState: SigningState.Signing, }); const exchangeAddress = this.props.blockchain.getExchangeContractAddressIfExists(); if (_.isUndefined(exchangeAddress)) { this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); this.setState({ - signingState: SigningState.UNSIGNED, + signingState: SigningState.Unsigned, }); return undefined; } @@ -371,7 +371,7 @@ export class GenerateOrderForm extends React.Component - {this.state.globalErrMsg !== '' && } + {this.state.globalErrMsg !== '' && } ); } diff --git a/packages/website/ts/components/inputs/allowance_state_toggle.tsx b/packages/website/ts/components/inputs/allowance_state_toggle.tsx index 5396295d2..3a78d32f3 100644 --- a/packages/website/ts/components/inputs/allowance_state_toggle.tsx +++ b/packages/website/ts/components/inputs/allowance_state_toggle.tsx @@ -150,7 +150,7 @@ export class AllowanceStateToggle extends React.Component { const isAssetPickerDialogOpen = this.state.tokenManagementState !== TokenManagementState.None; const tokenVisibility = this.state.tokenManagementState === TokenManagementState.Add - ? TokenVisibility.UNTRACKED - : TokenVisibility.TRACKED; + ? TokenVisibility.Untracked + : TokenVisibility.Tracked; return ( diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index 2ed0229c8..e8f2a6461 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -303,7 +303,7 @@ export class TokenBalances extends React.Component ); @@ -439,7 +439,7 @@ export class TokenBalances extends React.Component Our faucet can only send test Ether to addresses on testnets. Please make sure you are connected @@ -468,7 +468,7 @@ export class TokenBalances extends React.Component ); - case BalanceErrs.faucetRequestFailed: + case BalanceErrs.FaucetRequestFailed: return (
An unexpected error occurred while trying to request test Ether from our faucet. Please refresh @@ -476,13 +476,13 @@ export class TokenBalances extends React.Component ); - case BalanceErrs.faucetQueueIsFull: + case BalanceErrs.FaucetQueueIsFull: return
Our test Ether faucet queue is full. Please try requesting test Ether again later.
; - case BalanceErrs.mintingFailed: + case BalanceErrs.MintingFailed: return
Minting your test tokens failed unexpectedly. Please refresh the page and try again.
; - case BalanceErrs.allowanceSettingFailed: + case BalanceErrs.AllowanceSettingFailed: return (
An unexpected error occurred while trying to set your test token allowance. Please refresh the @@ -521,7 +521,7 @@ export class TokenBalances extends React.Component ${responseBody}`); const errorType = response.status === constants.UNAVAILABLE_STATUS - ? BalanceErrs.faucetQueueIsFull - : BalanceErrs.faucetRequestFailed; + ? BalanceErrs.FaucetQueueIsFull + : BalanceErrs.FaucetRequestFailed; this.setState({ errorType, }); diff --git a/packages/website/ts/components/ui/alert.tsx b/packages/website/ts/components/ui/alert.tsx index 32e0f1be8..c7a5b9030 100644 --- a/packages/website/ts/components/ui/alert.tsx +++ b/packages/website/ts/components/ui/alert.tsx @@ -8,7 +8,7 @@ interface AlertProps { } export const Alert = (props: AlertProps) => { - const isAlert = props.type === AlertTypes.ERROR; + const isAlert = props.type === AlertTypes.Error; const errMsgStyles = { background: isAlert ? colors.red200 : colors.lightestGreen, color: colors.white, diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx index a8daf4102..f004dd47f 100644 --- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx +++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx @@ -6,9 +6,9 @@ import * as React from 'react'; const COMPLETE_STATE_SHOW_LENGTH_MS = 2000; enum ButtonState { - READY, - LOADING, - COMPLETE, + Ready, + Loading, + Complete, } interface LifeCycleRaisedButtonProps { @@ -38,7 +38,7 @@ export class LifeCycleRaisedButton extends React.Component ); } public async onClickAsync(): Promise { this.setState({ - buttonState: ButtonState.LOADING, + buttonState: ButtonState.Loading, }); const didSucceed = await this.props.onClickAsyncFn(); if (this._didUnmount) { @@ -86,16 +86,16 @@ export class LifeCycleRaisedButton extends React.Component { this.setState({ - buttonState: ButtonState.READY, + buttonState: ButtonState.Ready, }); }, COMPLETE_STATE_SHOW_LENGTH_MS); } else { this.setState({ - buttonState: ButtonState.READY, + buttonState: ButtonState.Ready, }); } } diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 50114e2d6..9492da5a5 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -83,12 +83,12 @@ export interface Fill { } export enum BalanceErrs { - incorrectNetworkForFaucet, - faucetRequestFailed, - faucetQueueIsFull, - mintingFailed, - sendFailed, - allowanceSettingFailed, + IncorrectNetworkForFaucet, + FaucetRequestFailed, + FaucetQueueIsFull, + MintingFailed, + SendFailed, + AllowanceSettingFailed, } export enum ActionTypes { @@ -209,8 +209,8 @@ export enum ScreenWidths { } export enum AlertTypes { - ERROR, - SUCCESS, + Error, + Success, } export enum BlockchainErrs { @@ -228,11 +228,11 @@ export enum BlockchainCallErrs { } export enum Environments { - DEVELOPMENT = 'DEVELOPMENT', - DOGFOOD = 'DOGFOOD', - STAGING = 'STAGING', - PRODUCTION = 'PRODUCTION', - UNKNOWN = 'UNKNOWN', + Development = 'DEVELOPMENT', + Dogfood = 'DOGFOOD', + Staging = 'STAGING', + Production = 'PRODUCTION', + Unknown = 'UNKNOWN', } export type ContractInstance = any; // TODO: add type definition for Contract @@ -323,9 +323,9 @@ export interface DialogConfigs { } export enum TokenVisibility { - ALL = 'ALL', - UNTRACKED = 'UNTRACKED', - TRACKED = 'TRACKED', + All = 'ALL', + Untracked = 'UNTRACKED', + Tracked = 'TRACKED', } export interface VersionToFilePath { @@ -350,7 +350,7 @@ export enum WebsitePaths { Docs = '/docs', ZeroExJs = '/docs/0x.js', Home = '/', - FAQ = '/faq', + FAQ = '/faq', // tslint:disable-line:enum-naming About = '/about', AboutMission = '/about/mission', AboutTeam = '/about/team', @@ -629,7 +629,7 @@ export enum BrowserType { export enum OperatingSystemType { Android = 'Android', - iOS = 'iOS', + iOS = 'iOS', // tslint:disable-line:enum-naming Mac = 'Mac', Windows = 'Windows', WindowsPhone = 'WindowsPhone', diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 8cc0061de..890f1553a 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -342,18 +342,18 @@ export const utils = { }, getEnvironment(): Environments { if (utils.isDogfood()) { - return Environments.DOGFOOD; + return Environments.Dogfood; } if (utils.isDevelopment()) { - return Environments.DEVELOPMENT; + return Environments.Development; } if (utils.isStaging()) { - return Environments.STAGING; + return Environments.Staging; } if (utils.isProduction()) { - return Environments.PRODUCTION; + return Environments.Production; } - return Environments.UNKNOWN; + return Environments.Unknown; }, getEthToken(tokenByAddress: TokenByAddress): Token { return utils.getTokenBySymbol(constants.ETHER_TOKEN_SYMBOL, tokenByAddress); -- cgit v1.2.3