diff options
author | kao <zichongkao@gmail.com> | 2018-12-08 08:35:00 +0800 |
---|---|---|
committer | kao <zichongkao@gmail.com> | 2018-12-08 09:06:52 +0800 |
commit | f14603ca4d91ca72d9e81de53168230d85bc50aa (patch) | |
tree | 69eecd797c8c28f1b51513ffe01e7ab5e2104df1 /packages | |
parent | aa4fcebdc71fa58b12dc12ab03d7697444416c09 (diff) | |
download | dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar.gz dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar.bz2 dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar.lz dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar.xz dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.tar.zst dexon-sol-tools-f14603ca4d91ca72d9e81de53168230d85bc50aa.zip |
Implement prefer-template tslint rule
Diffstat (limited to 'packages')
-rw-r--r-- | packages/monorepo-scripts/src/test_installation.ts | 2 | ||||
-rw-r--r-- | packages/order-utils/test/order_hash_test.ts | 2 | ||||
-rw-r--r-- | packages/pipeline/src/data_sources/bloxy/index.ts | 2 | ||||
-rw-r--r-- | packages/pipeline/src/data_sources/paradex/index.ts | 6 | ||||
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 2 | ||||
-rw-r--r-- | packages/tslint-config/tslint.json | 1 | ||||
-rw-r--r-- | packages/utils/src/abi_utils.ts | 4 | ||||
-rw-r--r-- | packages/utils/test/abi_encoder/evm_data_types_test.ts | 4 |
8 files changed, 12 insertions, 11 deletions
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 96875d0f9..5ae13b198 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -98,7 +98,7 @@ async function testInstallPackageAsync( const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; const packageName = installablePackage.packageJson.name; utils.log(`Testing ${packageName}@${lastChangelogVersion}`); - const packageDirName = path.join(...(packageName + '-test').split('/')); + const packageDirName = path.join(...`${packageName}-test`.split('/')); // NOTE(fabio): The `testDirectory` needs to be somewhere **outside** the monorepo root directory. // Otherwise, it will have access to the hoisted `node_modules` directory and the Typescript missing // type errors will not be caught. diff --git a/packages/order-utils/test/order_hash_test.ts b/packages/order-utils/test/order_hash_test.ts index a85d4c81a..30fb15a37 100644 --- a/packages/order-utils/test/order_hash_test.ts +++ b/packages/order-utils/test/order_hash_test.ts @@ -70,7 +70,7 @@ describe('Order hashing', () => { }); it('returns true if order hash is correct', () => { const orderHashLength = 65; - const isValid = orderHashUtils.isValidOrderHash('0x' + Array(orderHashLength).join('0')); + const isValid = orderHashUtils.isValidOrderHash(`0x${Array(orderHashLength).join('0')}`); expect(isValid).to.be.true(); }); }); diff --git a/packages/pipeline/src/data_sources/bloxy/index.ts b/packages/pipeline/src/data_sources/bloxy/index.ts index 31cd5bfd6..94468d25a 100644 --- a/packages/pipeline/src/data_sources/bloxy/index.ts +++ b/packages/pipeline/src/data_sources/bloxy/index.ts @@ -116,7 +116,7 @@ export class BloxySource { }, }); if (isError(resp.data)) { - throw new Error('Error in Bloxy API response: ' + resp.data.error); + throw new Error(`Error in Bloxy API response: ${resp.data.error}`); } return resp.data; } diff --git a/packages/pipeline/src/data_sources/paradex/index.ts b/packages/pipeline/src/data_sources/paradex/index.ts index 69a03d553..46d448f4b 100644 --- a/packages/pipeline/src/data_sources/paradex/index.ts +++ b/packages/pipeline/src/data_sources/paradex/index.ts @@ -1,9 +1,9 @@ import { fetchAsync, logUtils } from '@0x/utils'; const PARADEX_BASE_URL = 'https://api.paradex.io/consumer/v0'; -const ACTIVE_MARKETS_URL = PARADEX_BASE_URL + '/markets'; -const ORDERBOOK_ENDPOINT = PARADEX_BASE_URL + '/orderbook'; -const TOKEN_INFO_ENDPOINT = PARADEX_BASE_URL + '/tokens'; +const ACTIVE_MARKETS_URL = `${PARADEX_BASE_URL}/markets`; +const ORDERBOOK_ENDPOINT = `${PARADEX_BASE_URL}/orderbook`; +const TOKEN_INFO_ENDPOINT = `${PARADEX_BASE_URL}/tokens`; export const PARADEX_SOURCE = 'paradex'; export type ParadexActiveMarketsResponse = ParadexMarket[]; diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index cba67f292..85df8209e 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -400,7 +400,7 @@ export class Compiler { * while others are absolute ("Token.sol", "@0x/contracts/Wallet.sol") * And we need to append the base path for relative imports. */ - importPath = path.resolve('/' + contractFolder, importPath).replace('/', ''); + importPath = path.resolve(`/${contractFolder}`, importPath).replace('/', ''); } if (_.isUndefined(sourcesToAppendTo[importPath])) { diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json index fd1849dd0..e8de6221e 100644 --- a/packages/tslint-config/tslint.json +++ b/packages/tslint-config/tslint.json @@ -92,6 +92,7 @@ "prefer-function-over-method": true, "prefer-object-spread": true, "prefer-readonly": true, + "prefer-template": true, "promise-function-async": true, "quotemark": [true, "single", "avoid-escape", "jsx-double"], "restrict-plus-operands": true, diff --git a/packages/utils/src/abi_utils.ts b/packages/utils/src/abi_utils.ts index 598ea5fcc..3e6fc9665 100644 --- a/packages/utils/src/abi_utils.ts +++ b/packages/utils/src/abi_utils.ts @@ -26,7 +26,7 @@ function parseEthersParams(params: DataItem[]): { names: ParamName[]; types: str const result = parseEthersParams(param.components); names.push({ name: param.name || null, names: result.names }); - types.push('tuple(' + result.types.join(',') + ')' + suffix); + types.push(`tuple(${result.types.join(',')})${suffix}`); } else { names.push(param.name || null); types.push(param.type); @@ -120,7 +120,7 @@ function splitTupleTypes(type: string): string[] { if (_.endsWith(type, '[]')) { throw new Error('Internal error: array types are not supported'); } else if (!_.startsWith(type, 'tuple(')) { - throw new Error('Internal error: expected tuple type but got non-tuple type: ' + type); + throw new Error(`Internal error: expected tuple type but got non-tuple type: ${type}`); } // Trim the outtermost tuple(). const trimmedType = type.substring('tuple('.length, type.length - 1); diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts index 9ef80a560..7185851a8 100644 --- a/packages/utils/test/abi_encoder/evm_data_types_test.ts +++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts @@ -901,7 +901,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Construct args to be encoded // Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes. const bytesLength = 40; - const args = '0x' + '61'.repeat(bytesLength); + const args = `0x${'61'.repeat(bytesLength)}`; // Encode Args and validate result const encodedArgs = dataType.encode(args, encodingRules); const expectedEncodedArgs = @@ -993,7 +993,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { // Construct args to be encoded // Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes. const strLength = 40; - const args = '0x' + 'a'.repeat(strLength); + const args = `0x${'a'.repeat(strLength)}`; // Encode Args and validate result const encodedArgs = dataType.encode(args, encodingRules); const expectedEncodedArgs = |