diff --git a/.eslintrc b/.eslintrc index 7c00e41a..9f709b13 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,6 +12,7 @@ "jest": true }, "rules": { + "import/prefer-default-export": 0, "no-use-before-define": 0, "no-plusplus": 0, "class-methods-use-this": 0, diff --git a/src/utils/ethUtils.js b/src/utils/ethUtils.js index 82d5744a..2d4b553e 100644 --- a/src/utils/ethUtils.js +++ b/src/utils/ethUtils.js @@ -5,14 +5,11 @@ import EthereumjsUtil from 'ethereumjs-util'; export const decimalToHex = (dec: number): string => new BigNumber(dec).toString(16); -export const padLeftEven = (hex: string): string => { - hex = hex.length % 2 != 0 ? `0${hex}` : hex; - return hex; -}; +export const padLeftEven = (hex: string): string => (hex.length % 2 !== 0 ? `0${hex}` : hex); -export const sanitizeHex = (hex: number | string): ?string => { - if (typeof hex !== 'string') return null; - hex = hex.substring(0, 2) === '0x' ? hex.substring(2) : hex; +export const sanitizeHex = ($hex: number | string): ?string => { + if (typeof $hex !== 'string') return null; + const hex = $hex.substring(0, 2) === '0x' ? $hex.substring(2) : $hex; if (hex === '') return ''; return `0x${padLeftEven(hex)}`; }; @@ -35,10 +32,12 @@ export const validateAddress = (address: string): ?string => { const hasUpperCase = new RegExp('^(.*[A-Z].*)$'); if (address.length < 1) { return 'Address is not set'; - } else if (!EthereumjsUtil.isValidAddress(address)) { + } + if (!EthereumjsUtil.isValidAddress(address)) { return 'Address is not valid'; - } else if (address.match(hasUpperCase) && !EthereumjsUtil.isValidChecksumAddress(address)) { + } + if (address.match(hasUpperCase) && !EthereumjsUtil.isValidChecksumAddress(address)) { return 'Address is not a valid checksum'; } return null; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/utils/promiseUtils.js b/src/utils/promiseUtils.js index 48be95a1..6567d30c 100644 --- a/src/utils/promiseUtils.js +++ b/src/utils/promiseUtils.js @@ -1,12 +1,5 @@ /* @flow */ - -// import root from 'window-or-global'; -// import Promise from 'es6-promise'; - -export async function resolveAfter(msec: number, value?: any): Promise { - await new Promise((resolve) => { - //root.setTimeout(resolve, msec, value); - window.setTimeout(resolve, msec, value); - }); -} \ No newline at end of file +export const resolveAfter = (msec: number, value?: any): Promise => new Promise((resolve) => { + window.setTimeout(resolve, msec, value); +});