diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-23 04:07:53 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:13:37 +0800 |
commit | 87d34f9c7f3ccf22e01798c27c4a4d5d4f943816 (patch) | |
tree | e92510af5e9f1504acbfda424a59bf4facd0249d | |
parent | d20926e150beed4785b31451a415bbf545f850be (diff) | |
download | dexon-0x-contracts-87d34f9c7f3ccf22e01798c27c4a4d5d4f943816.tar.gz dexon-0x-contracts-87d34f9c7f3ccf22e01798c27c4a4d5d4f943816.tar.zst dexon-0x-contracts-87d34f9c7f3ccf22e01798c27c4a4d5d4f943816.zip |
Auto-fix linter errors
28 files changed, 196 insertions, 148 deletions
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index 93912c3d9..2b99cfe4c 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -1,24 +1,25 @@ +import {Block, BlockAndLogStreamer} from 'ethereumjs-blockstream'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import {BlockAndLogStreamer, Block} from 'ethereumjs-blockstream'; -import {Web3Wrapper} from '../web3_wrapper'; -import {AbiDecoder} from '../utils/abi_decoder'; + import { - ZeroExError, - InternalZeroExError, Artifact, + BlockParamLiteral, + ContractEventArgs, + ContractEvents, + EventCallback, + IndexedFilterValues, + InternalZeroExError, LogWithDecodedArgs, RawLog, - ContractEvents, SubscriptionOpts, - IndexedFilterValues, - EventCallback, - BlockParamLiteral, - ContractEventArgs, + ZeroExError, } from '../types'; +import {AbiDecoder} from '../utils/abi_decoder'; import {constants} from '../utils/constants'; -import {intervalUtils} from '../utils/interval_utils'; import {filterUtils} from '../utils/filter_utils'; +import {intervalUtils} from '../utils/interval_utils'; +import {Web3Wrapper} from '../web3_wrapper'; export class ContractWrapper { protected _web3Wrapper: Web3Wrapper; diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts index 9867e9a23..0ac21cb78 100644 --- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts @@ -1,11 +1,13 @@ -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; + +import {artifacts} from '../artifacts'; +import {EtherTokenContract, ZeroExError} from '../types'; +import {assert} from '../utils/assert'; import {Web3Wrapper} from '../web3_wrapper'; + import {ContractWrapper} from './contract_wrapper'; import {TokenWrapper} from './token_wrapper'; -import {EtherTokenContract, ZeroExError} from '../types'; -import {assert} from '../utils/assert'; -import {artifacts} from '../artifacts'; /** * This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract. @@ -89,7 +91,7 @@ export class EtherTokenWrapper extends ContractWrapper { const contractInstance = await this._instantiateContractIfExistsAsync<EtherTokenContract>( artifacts.EtherTokenArtifact, this._contractAddressIfExists, ); - this._etherTokenContractIfExists = contractInstance as EtherTokenContract; + this._etherTokenContractIfExists = contractInstance; return this._etherTokenContractIfExists; } } diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 604c53e3a..97ea54362 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -1,44 +1,46 @@ +import {schemas} from '@0xproject/json-schemas'; +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import BigNumber from 'bignumber.js'; -import {schemas} from '@0xproject/json-schemas'; -import {Web3Wrapper} from '../web3_wrapper'; + +import {artifacts} from '../artifacts'; import { + DecodedLogArgs, ECSignature, + EventCallback, ExchangeContract, ExchangeContractErrCodes, ExchangeContractErrs, - ZeroExError, - OrderValues, - OrderAddresses, - Order, - SignedOrder, + ExchangeContractEventArgs, ExchangeEvents, - SubscriptionOpts, IndexedFilterValues, - OrderCancellationRequest, - OrderFillRequest, + LogCancelContractEventArgs, LogErrorContractEventArgs, LogFillContractEventArgs, - LogCancelContractEventArgs, LogWithDecodedArgs, MethodOpts, - ValidateOrderFillableOpts, + Order, + OrderAddresses, + OrderCancellationRequest, + OrderFillRequest, OrderTransactionOpts, + OrderValues, RawLog, - EventCallback, - ExchangeContractEventArgs, - DecodedLogArgs, + SignedOrder, + SubscriptionOpts, + ValidateOrderFillableOpts, + ZeroExError, } from '../types'; +import {AbiDecoder} from '../utils/abi_decoder'; import {assert} from '../utils/assert'; -import {utils} from '../utils/utils'; +import {decorators} from '../utils/decorators'; +import {ExchangeTransferSimulator} from '../utils/exchange_transfer_simulator'; import {OrderValidationUtils} from '../utils/order_validation_utils'; +import {utils} from '../utils/utils'; +import {Web3Wrapper} from '../web3_wrapper'; + import {ContractWrapper} from './contract_wrapper'; import {TokenWrapper} from './token_wrapper'; -import {decorators} from '../utils/decorators'; -import {AbiDecoder} from '../utils/abi_decoder'; -import {ExchangeTransferSimulator} from '../utils/exchange_transfer_simulator'; -import {artifacts} from '../artifacts'; const SHOULD_VALIDATE_BY_DEFAULT = true; @@ -873,7 +875,7 @@ export class ExchangeWrapper extends ContractWrapper { const contractInstance = await this._instantiateContractIfExistsAsync<ExchangeContract>( artifacts.ExchangeArtifact, this._contractAddressIfExists, ); - this._exchangeContractIfExists = contractInstance as ExchangeContract; + this._exchangeContractIfExists = contractInstance; return this._exchangeContractIfExists; } private async _getTokenTransferProxyAddressAsync(): Promise<string> { diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index 50871d3f2..60fe7f33a 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -1,10 +1,12 @@ import * as _ from 'lodash'; -import {Web3Wrapper} from '../web3_wrapper'; + +import {artifacts} from '../artifacts'; +import {Token, TokenMetadata, TokenRegistryContract, ZeroExError} from '../types'; import {assert} from '../utils/assert'; -import {Token, TokenRegistryContract, TokenMetadata, ZeroExError} from '../types'; import {constants} from '../utils/constants'; +import {Web3Wrapper} from '../web3_wrapper'; + import {ContractWrapper} from './contract_wrapper'; -import {artifacts} from '../artifacts'; /** * This class includes all the functionality related to interacting with the 0x Token Registry smart contract. @@ -123,7 +125,7 @@ export class TokenRegistryWrapper extends ContractWrapper { const contractInstance = await this._instantiateContractIfExistsAsync<TokenRegistryContract>( artifacts.TokenRegistryArtifact, this._contractAddressIfExists, ); - this._tokenRegistryContractIfExists = contractInstance as TokenRegistryContract; + this._tokenRegistryContractIfExists = contractInstance; return this._tokenRegistryContractIfExists; } } diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts index 6970d5433..33adc0a9b 100644 --- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -1,8 +1,10 @@ import * as _ from 'lodash'; -import {Web3Wrapper} from '../web3_wrapper'; -import {ContractWrapper} from './contract_wrapper'; + import {artifacts} from '../artifacts'; import {TokenTransferProxyContract, ZeroExError} from '../types'; +import {Web3Wrapper} from '../web3_wrapper'; + +import {ContractWrapper} from './contract_wrapper'; /** * This class includes the functionality related to interacting with the TokenTransferProxy contract. @@ -60,7 +62,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper { const contractInstance = await this._instantiateContractIfExistsAsync<TokenTransferProxyContract>( artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists, ); - this._tokenTransferProxyContractIfExists = contractInstance as TokenTransferProxyContract; + this._tokenTransferProxyContractIfExists = contractInstance; return this._tokenTransferProxyContractIfExists; } } diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index 5fd3a2a5d..4b359d069 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -1,23 +1,25 @@ -import * as _ from 'lodash'; -import BigNumber from 'bignumber.js'; import {schemas} from '@0xproject/json-schemas'; -import {Web3Wrapper} from '../web3_wrapper'; -import {assert} from '../utils/assert'; -import {constants} from '../utils/constants'; -import {ContractWrapper} from './contract_wrapper'; -import {AbiDecoder} from '../utils/abi_decoder'; +import BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; + import {artifacts} from '../artifacts'; import { - TokenContract, - ZeroExError, - TokenEvents, + EventCallback, IndexedFilterValues, - SubscriptionOpts, - MethodOpts, LogWithDecodedArgs, - EventCallback, + MethodOpts, + SubscriptionOpts, + TokenContract, TokenContractEventArgs, + TokenEvents, + ZeroExError, } from '../types'; +import {AbiDecoder} from '../utils/abi_decoder'; +import {assert} from '../utils/assert'; +import {constants} from '../utils/constants'; +import {Web3Wrapper} from '../web3_wrapper'; + +import {ContractWrapper} from './contract_wrapper'; const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47275; @@ -302,7 +304,7 @@ export class TokenWrapper extends ContractWrapper { const contractInstance = await this._instantiateContractIfExistsAsync<TokenContract>( artifacts.TokenArtifact, tokenAddress, ); - tokenContract = contractInstance as TokenContract; + tokenContract = contractInstance; this._tokenContractsByAddress[tokenAddress] = tokenContract; return tokenContract; } diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index ecbab0cd5..831f19da5 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ -import * as Web3 from 'web3'; import * as _ from 'lodash'; -import {Web3Wrapper} from '../web3_wrapper'; +import * as Web3 from 'web3'; + import { BlockParamLiteral, EventCallback, @@ -8,9 +8,10 @@ import { ZeroExError, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; -import {intervalUtils} from '../utils/interval_utils'; import {assert} from '../utils/assert'; +import {intervalUtils} from '../utils/interval_utils'; import {utils} from '../utils/utils'; +import {Web3Wrapper} from '../web3_wrapper'; const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200; diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index 2ea7835d9..9a1bb1ca4 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -1,10 +1,11 @@ -import * as _ from 'lodash'; import {BigNumber} from 'bignumber.js'; import {RBTree} from 'bintrees'; -import {utils} from '../utils/utils'; -import {intervalUtils} from '../utils/interval_utils'; -import {SignedOrder, ZeroExError} from '../types'; +import * as _ from 'lodash'; + import {ZeroEx} from '../0x'; +import {SignedOrder, ZeroExError} from '../types'; +import {intervalUtils} from '../utils/interval_utils'; +import {utils} from '../utils/utils'; const DEFAULT_EXPIRATION_MARGIN_MS = 0; const DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS = 50; diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 287172ff1..4d57935a1 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -1,37 +1,39 @@ -import * as _ from 'lodash'; import {schemas} from '@0xproject/json-schemas'; +import * as _ from 'lodash'; + import {ZeroEx} from '../0x'; -import {EventWatcher} from './event_watcher'; -import {assert} from '../utils/assert'; -import {utils} from '../utils/utils'; import {artifacts} from '../artifacts'; -import {AbiDecoder} from '../utils/abi_decoder'; -import {intervalUtils} from '../utils/interval_utils'; -import {OrderStateUtils} from '../utils/order_state_utils'; +import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; +import {TokenWrapper} from '../contract_wrappers/token_wrapper'; +import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; +import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store'; import { - LogEvent, - OrderState, - SignedOrder, - Web3Provider, + ApprovalContractEventArgs, BlockParamLiteral, - LogWithDecodedArgs, ContractEventArgs, + ExchangeContractErrs, + ExchangeEvents, + LogCancelContractEventArgs, + LogEvent, + LogFillContractEventArgs, + LogWithDecodedArgs, OnOrderStateChangeCallback, + OrderState, OrderStateWatcherConfig, - ApprovalContractEventArgs, - TransferContractEventArgs, - LogFillContractEventArgs, - LogCancelContractEventArgs, - ExchangeEvents, + SignedOrder, TokenEvents, + TransferContractEventArgs, + Web3Provider, ZeroExError, - ExchangeContractErrs, } from '../types'; +import {AbiDecoder} from '../utils/abi_decoder'; +import {assert} from '../utils/assert'; +import {intervalUtils} from '../utils/interval_utils'; +import {OrderStateUtils} from '../utils/order_state_utils'; +import {utils} from '../utils/utils'; import {Web3Wrapper} from '../web3_wrapper'; -import {TokenWrapper} from '../contract_wrappers/token_wrapper'; -import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; -import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store'; -import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; + +import {EventWatcher} from './event_watcher'; import {ExpirationWatcher} from './expiration_watcher'; interface DependentOrderHashes { @@ -238,7 +240,7 @@ export class OrderStateWatcher { } private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> { for (const orderHash of orderHashes) { - const signedOrder = this._orderByOrderHash[orderHash] as SignedOrder; + const signedOrder = this._orderByOrderHash[orderHash]; // Most of these calls will never reach the network because the data is fetched from stores // and only updated when cache is invalidated const orderState = await this._orderStateUtils.getOrderStateAsync(signedOrder); diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts index c83e61606..293f75db9 100644 --- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts +++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts @@ -1,6 +1,7 @@ +import {BigNumber} from 'bignumber.js'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import {BigNumber} from 'bignumber.js'; + import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {BlockParamLiteral} from '../types'; diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts index 666d8363c..59c1bb7a7 100644 --- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts +++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts @@ -1,6 +1,7 @@ +import {BigNumber} from 'bignumber.js'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import {BigNumber} from 'bignumber.js'; + import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; import {BlockParamLiteral} from '../types'; diff --git a/packages/0x.js/src/utils/abi_decoder.ts b/packages/0x.js/src/utils/abi_decoder.ts index df0fb2d6f..f027026da 100644 --- a/packages/0x.js/src/utils/abi_decoder.ts +++ b/packages/0x.js/src/utils/abi_decoder.ts @@ -1,9 +1,10 @@ -import * as Web3 from 'web3'; -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; -import {AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes, ContractEventArgs} from '../types'; +import * as _ from 'lodash'; +import * as Web3 from 'web3'; import * as SolidityCoder from 'web3/lib/solidity/coder'; +import {AbiType, ContractEventArgs, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes} from '../types'; + export class AbiDecoder { private savedABIs: Web3.AbiDefinition[] = []; private methodIds: {[signatureHash: string]: Web3.EventAbi} = {}; diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts index 55912525c..3cff9d2cf 100644 --- a/packages/0x.js/src/utils/assert.ts +++ b/packages/0x.js/src/utils/assert.ts @@ -1,11 +1,12 @@ +import {assert as sharedAssert} from '@0xproject/assert'; +import {Schema, SchemaValidator} from '@0xproject/json-schemas'; +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import BigNumber from 'bignumber.js'; -import {SchemaValidator, Schema} from '@0xproject/json-schemas'; -import {assert as sharedAssert} from '@0xproject/assert'; -import {Web3Wrapper} from '../web3_wrapper'; -import {signatureUtils} from '../utils/signature_utils'; + import {ECSignature} from '../types'; +import {signatureUtils} from '../utils/signature_utils'; +import {Web3Wrapper} from '../web3_wrapper'; const HEX_REGEX = /^0x[0-9A-F]*$/i; diff --git a/packages/0x.js/src/utils/decorators.ts b/packages/0x.js/src/utils/decorators.ts index ec750b891..1760d8872 100644 --- a/packages/0x.js/src/utils/decorators.ts +++ b/packages/0x.js/src/utils/decorators.ts @@ -1,7 +1,9 @@ import * as _ from 'lodash'; -import {constants} from './constants'; + import {AsyncMethod, ZeroExError} from '../types'; +import {constants} from './constants'; + export const decorators = { /** * Source: https://stackoverflow.com/a/29837695/3546986 diff --git a/packages/0x.js/src/utils/exchange_transfer_simulator.ts b/packages/0x.js/src/utils/exchange_transfer_simulator.ts index cadded224..c3a2d1585 100644 --- a/packages/0x.js/src/utils/exchange_transfer_simulator.ts +++ b/packages/0x.js/src/utils/exchange_transfer_simulator.ts @@ -1,8 +1,9 @@ -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; -import {ExchangeContractErrs, TradeSide, TransferType, BlockParamLiteral} from '../types'; +import * as _ from 'lodash'; + import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; +import {BlockParamLiteral, ExchangeContractErrs, TradeSide, TransferType} from '../types'; enum FailureReason { Balance = 'balance', diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts index e09a95a6e..57c3ee71c 100644 --- a/packages/0x.js/src/utils/filter_utils.ts +++ b/packages/0x.js/src/utils/filter_utils.ts @@ -1,8 +1,9 @@ -import * as _ from 'lodash'; -import * as Web3 from 'web3'; -import * as uuid from 'uuid/v4'; import * as ethUtil from 'ethereumjs-util'; import * as jsSHA3 from 'js-sha3'; +import * as _ from 'lodash'; +import * as uuid from 'uuid/v4'; +import * as Web3 from 'web3'; + import {ContractEvents, IndexedFilterValues, SubscriptionOpts} from '../types'; const TOPIC_LENGTH = 32; diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts index 891849424..6654b9ae1 100644 --- a/packages/0x.js/src/utils/order_state_utils.ts +++ b/packages/0x.js/src/utils/order_state_utils.ts @@ -1,23 +1,24 @@ +import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import * as Web3 from 'web3'; -import BigNumber from 'bignumber.js'; + +import {ZeroEx} from '../0x'; +import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; +import {TokenWrapper} from '../contract_wrappers/token_wrapper'; +import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator'; +import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; +import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store'; import { ExchangeContractErrs, - SignedOrder, - OrderRelevantState, MethodOpts, + OrderRelevantState, OrderState, - OrderStateValid, OrderStateInvalid, + OrderStateValid, + SignedOrder, } from '../types'; -import {ZeroEx} from '../0x'; -import {TokenWrapper} from '../contract_wrappers/token_wrapper'; -import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; -import {utils} from '../utils/utils'; import {constants} from '../utils/constants'; -import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store'; -import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; -import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator'; +import {utils} from '../utils/utils'; const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001; diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts index 4822f66e2..06cfca7bd 100644 --- a/packages/0x.js/src/utils/order_validation_utils.ts +++ b/packages/0x.js/src/utils/order_validation_utils.ts @@ -1,11 +1,13 @@ -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; -import {ExchangeContractErrs, SignedOrder, Order, ZeroExError, TradeSide, TransferType} from '../types'; +import * as _ from 'lodash'; + import {ZeroEx} from '../0x'; -import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; -import {utils} from '../utils/utils'; +import {TokenWrapper} from '../contract_wrappers/token_wrapper'; +import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types'; import {constants} from '../utils/constants'; +import {utils} from '../utils/utils'; + import {ExchangeTransferSimulator} from './exchange_transfer_simulator'; export class OrderValidationUtils { diff --git a/packages/0x.js/src/utils/signature_utils.ts b/packages/0x.js/src/utils/signature_utils.ts index d066f8bf0..aaf04e7b0 100644 --- a/packages/0x.js/src/utils/signature_utils.ts +++ b/packages/0x.js/src/utils/signature_utils.ts @@ -1,4 +1,5 @@ import * as ethUtil from 'ethereumjs-util'; + import {ECSignature} from '../types'; export const signatureUtils = { diff --git a/packages/0x.js/src/utils/utils.ts b/packages/0x.js/src/utils/utils.ts index 5370c3b4b..04ae34aac 100644 --- a/packages/0x.js/src/utils/utils.ts +++ b/packages/0x.js/src/utils/utils.ts @@ -1,9 +1,10 @@ -import * as _ from 'lodash'; +import BigNumber from 'bignumber.js'; +import BN = require('bn.js'); import * as ethABI from 'ethereumjs-abi'; import * as ethUtil from 'ethereumjs-util'; +import * as _ from 'lodash'; + import {Order, SignedOrder, SolidityTypes} from '../types'; -import BigNumber from 'bignumber.js'; -import BN = require('bn.js'); export const utils = { /** diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts index 2c7c2a971..616d8fda0 100644 --- a/packages/0x.js/test/order_state_watcher_test.ts +++ b/packages/0x.js/test/order_state_watcher_test.ts @@ -1,31 +1,33 @@ -import 'mocha'; +import BigNumber from 'bignumber.js'; import * as chai from 'chai'; import * as _ from 'lodash'; +import 'mocha'; import * as Web3 from 'web3'; -import BigNumber from 'bignumber.js'; -import {chaiSetup} from './utils/chai_setup'; -import {web3Factory} from './utils/web3_factory'; -import {Web3Wrapper} from '../src/web3_wrapper'; -import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher'; + import { - Token, - ZeroEx, - LogEvent, DecodedLogEvent, - ZeroExConfig, + ExchangeContractErrs, + LogEvent, OrderState, + OrderStateInvalid, + OrderStateValid, SignedOrder, + Token, + ZeroEx, + ZeroExConfig, ZeroExError, - OrderStateValid, - OrderStateInvalid, - ExchangeContractErrs, } from '../src'; -import {constants} from './utils/constants'; -import {TokenUtils} from './utils/token_utils'; -import {FillScenarios} from './utils/fill_scenarios'; +import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher'; import {DoneCallback} from '../src/types'; +import {Web3Wrapper} from '../src/web3_wrapper'; + import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; +import {chaiSetup} from './utils/chai_setup'; +import {constants} from './utils/constants'; +import {FillScenarios} from './utils/fill_scenarios'; import {reportCallbackErrors} from './utils/report_callback_errors'; +import {TokenUtils} from './utils/token_utils'; +import {web3Factory} from './utils/web3_factory'; const TIMEOUT_MS = 150; diff --git a/packages/0x.js/test/utils/chai_setup.ts b/packages/0x.js/test/utils/chai_setup.ts index c18988106..078edd309 100644 --- a/packages/0x.js/test/utils/chai_setup.ts +++ b/packages/0x.js/test/utils/chai_setup.ts @@ -1,7 +1,7 @@ import * as chai from 'chai'; -import * as dirtyChai from 'dirty-chai'; -import ChaiBigNumber = require('chai-bignumber'); import chaiAsPromised = require('chai-as-promised'); +import ChaiBigNumber = require('chai-bignumber'); +import * as dirtyChai from 'dirty-chai'; export const chaiSetup = { configure() { diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts index a0632b12c..090493935 100644 --- a/packages/0x.js/test/utils/fill_scenarios.ts +++ b/packages/0x.js/test/utils/fill_scenarios.ts @@ -1,6 +1,8 @@ import BigNumber from 'bignumber.js'; -import {ZeroEx, Token, SignedOrder} from '../../src'; + +import {SignedOrder, Token, ZeroEx} from '../../src'; import {orderFactory} from '../utils/order_factory'; + import {constants} from './constants'; export class FillScenarios { diff --git a/packages/0x.js/test/utils/order_factory.ts b/packages/0x.js/test/utils/order_factory.ts index e3161e262..41d93e340 100644 --- a/packages/0x.js/test/utils/order_factory.ts +++ b/packages/0x.js/test/utils/order_factory.ts @@ -1,6 +1,7 @@ -import * as _ from 'lodash'; import BigNumber from 'bignumber.js'; -import {ZeroEx, SignedOrder} from '../../src'; +import * as _ from 'lodash'; + +import {SignedOrder, ZeroEx} from '../../src'; export const orderFactory = { async createSignedOrderAsync( diff --git a/packages/0x.js/test/utils/rpc.ts b/packages/0x.js/test/utils/rpc.ts index 299e72e79..309a96d5e 100644 --- a/packages/0x.js/test/utils/rpc.ts +++ b/packages/0x.js/test/utils/rpc.ts @@ -1,5 +1,6 @@ import * as ethUtil from 'ethereumjs-util'; import * as request from 'request-promise-native'; + import {constants} from './constants'; export class RPC { diff --git a/packages/0x.js/test/utils/token_utils.ts b/packages/0x.js/test/utils/token_utils.ts index 51cb9411c..9c20f52a1 100644 --- a/packages/0x.js/test/utils/token_utils.ts +++ b/packages/0x.js/test/utils/token_utils.ts @@ -1,5 +1,6 @@ import * as _ from 'lodash'; -import {Token, InternalZeroExError} from '../../src/types'; + +import {InternalZeroExError, Token} from '../../src/types'; const PROTOCOL_TOKEN_SYMBOL = 'ZRX'; diff --git a/packages/0x.js/test/utils/web3_factory.ts b/packages/0x.js/test/utils/web3_factory.ts index b20070c74..b4bf1acd3 100644 --- a/packages/0x.js/test/utils/web3_factory.ts +++ b/packages/0x.js/test/utils/web3_factory.ts @@ -3,12 +3,14 @@ // we are not running in a browser env. // Filed issue: https://github.com/ethereum/web3.js/issues/844 (global as any).XMLHttpRequest = undefined; +import * as Web3 from 'web3'; import ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); -import * as Web3 from 'web3'; -import {constants} from './constants'; + import {EmptyWalletSubProvider} from '../../src/subproviders/empty_wallet_subprovider'; +import {constants} from './constants'; + export const web3Factory = { create(hasAddresses: boolean = true): Web3 { const provider = this.getRpcProvider(hasAddresses); diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json index a53f1b10e..4c2c7adf4 100644 --- a/packages/tslint-config/tslint.json +++ b/packages/tslint-config/tslint.json @@ -5,8 +5,14 @@ ], "rules": { "arrow-parens": [true, "ban-single-arg-parens"], + "arrow-return-shorthand": true, "await-promise": true, - "ordered-imports": false, + "ordered-imports": [ + true, + { + "grouped-imports": true + } + ], "quotemark": [true, "single", "avoid-escape", "jsx-double"], "callable-types": true, "interface-name": false, @@ -14,6 +20,7 @@ "object-literal-sort-keys": false, "max-classes-per-file": false, "max-line-length": [true, 120], + "member-access": true, "member-ordering": [true, "public-before-private", "static-before-instance", @@ -23,8 +30,12 @@ "no-default-export": true, "no-empty-interface": false, "no-floating-promises": true, + "no-non-null-assertion": true, + "no-parameter-reassignment": true, + "no-return-await": true, "no-string-throw": true, "no-submodule-imports": false, + "no-unnecessary-type-assertion": true, "no-implicit-dependencies": [true, "dev"], "prefer-const": true, "promise-function-async": true, |