Implement prefer-template tslint rule
This commit is contained in:
parent
aa4fcebdc7
commit
f14603ca4d
@ -135,7 +135,7 @@ describe('MixinSignatureValidator', () => {
|
|||||||
|
|
||||||
it('should revert when signature type is unsupported', async () => {
|
it('should revert when signature type is unsupported', async () => {
|
||||||
const unsupportedSignatureType = SignatureType.NSignatureTypes;
|
const unsupportedSignatureType = SignatureType.NSignatureTypes;
|
||||||
const unsupportedSignatureHex = '0x' + Buffer.from([unsupportedSignatureType]).toString('hex');
|
const unsupportedSignatureHex = `0x${Buffer.from([unsupportedSignatureType]).toString('hex')}`;
|
||||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||||
return expectContractCallFailedAsync(
|
return expectContractCallFailedAsync(
|
||||||
signatureValidator.publicIsValidSignature.callAsync(
|
signatureValidator.publicIsValidSignature.callAsync(
|
||||||
@ -148,7 +148,7 @@ describe('MixinSignatureValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should revert when SignatureType=Illegal', async () => {
|
it('should revert when SignatureType=Illegal', async () => {
|
||||||
const unsupportedSignatureHex = '0x' + Buffer.from([SignatureType.Illegal]).toString('hex');
|
const unsupportedSignatureHex = `0x${Buffer.from([SignatureType.Illegal]).toString('hex')}`;
|
||||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||||
return expectContractCallFailedAsync(
|
return expectContractCallFailedAsync(
|
||||||
signatureValidator.publicIsValidSignature.callAsync(
|
signatureValidator.publicIsValidSignature.callAsync(
|
||||||
@ -161,7 +161,7 @@ describe('MixinSignatureValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return false when SignatureType=Invalid and signature has a length of zero', async () => {
|
it('should return false when SignatureType=Invalid and signature has a length of zero', async () => {
|
||||||
const signatureHex = '0x' + Buffer.from([SignatureType.Invalid]).toString('hex');
|
const signatureHex = `0x${Buffer.from([SignatureType.Invalid]).toString('hex')}`;
|
||||||
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
|
||||||
const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
|
const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
|
||||||
orderHashHex,
|
orderHashHex,
|
||||||
|
@ -228,7 +228,7 @@ export class ExchangeWrapper {
|
|||||||
return orderEpoch;
|
return orderEpoch;
|
||||||
}
|
}
|
||||||
public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> {
|
public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> {
|
||||||
const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo;
|
const orderInfo = await this._exchange.getOrderInfo.callAsync(signedOrder);
|
||||||
return orderInfo;
|
return orderInfo;
|
||||||
}
|
}
|
||||||
public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise<OrderInfo[]> {
|
public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise<OrderInfo[]> {
|
||||||
|
@ -137,7 +137,7 @@ export async function expectTransactionFailedWithoutReasonAsync(p: sendTransacti
|
|||||||
// directly.
|
// directly.
|
||||||
txReceiptStatus = result.status;
|
txReceiptStatus = result.status;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unexpected result type: ' + typeof result);
|
throw new Error(`Unexpected result type: ${typeof result}`);
|
||||||
}
|
}
|
||||||
expect(_.toString(txReceiptStatus)).to.equal(
|
expect(_.toString(txReceiptStatus)).to.equal(
|
||||||
'0',
|
'0',
|
||||||
|
@ -25,7 +25,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|||||||
|
|
||||||
// BUG: Ideally we would use Buffer.from(memory).toString('hex')
|
// BUG: Ideally we would use Buffer.from(memory).toString('hex')
|
||||||
// https://github.com/Microsoft/TypeScript/issues/23155
|
// https://github.com/Microsoft/TypeScript/issues/23155
|
||||||
const toHex = (buf: Uint8Array): string => buf.reduce((a, v) => a + ('00' + v.toString(16)).slice(-2), '0x');
|
const toHex = (buf: Uint8Array): string => buf.reduce((a, v) => a + `00${v.toString(16)}`.slice(-2), '0x');
|
||||||
|
|
||||||
const fromHex = (str: string): Uint8Array => Uint8Array.from(Buffer.from(str.slice(2), 'hex'));
|
const fromHex = (str: string): Uint8Array => Uint8Array.from(Buffer.from(str.slice(2), 'hex'));
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ async function testInstallPackageAsync(
|
|||||||
const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version;
|
const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version;
|
||||||
const packageName = installablePackage.packageJson.name;
|
const packageName = installablePackage.packageJson.name;
|
||||||
utils.log(`Testing ${packageName}@${lastChangelogVersion}`);
|
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.
|
// 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
|
// Otherwise, it will have access to the hoisted `node_modules` directory and the Typescript missing
|
||||||
// type errors will not be caught.
|
// type errors will not be caught.
|
||||||
|
@ -70,7 +70,7 @@ describe('Order hashing', () => {
|
|||||||
});
|
});
|
||||||
it('returns true if order hash is correct', () => {
|
it('returns true if order hash is correct', () => {
|
||||||
const orderHashLength = 65;
|
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();
|
expect(isValid).to.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -116,7 +116,7 @@ export class BloxySource {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (isError(resp.data)) {
|
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;
|
return resp.data;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { fetchAsync, logUtils } from '@0x/utils';
|
import { fetchAsync, logUtils } from '@0x/utils';
|
||||||
|
|
||||||
const PARADEX_BASE_URL = 'https://api.paradex.io/consumer/v0';
|
const PARADEX_BASE_URL = 'https://api.paradex.io/consumer/v0';
|
||||||
const ACTIVE_MARKETS_URL = PARADEX_BASE_URL + '/markets';
|
const ACTIVE_MARKETS_URL = `${PARADEX_BASE_URL}/markets`;
|
||||||
const ORDERBOOK_ENDPOINT = PARADEX_BASE_URL + '/orderbook';
|
const ORDERBOOK_ENDPOINT = `${PARADEX_BASE_URL}/orderbook`;
|
||||||
const TOKEN_INFO_ENDPOINT = PARADEX_BASE_URL + '/tokens';
|
const TOKEN_INFO_ENDPOINT = `${PARADEX_BASE_URL}/tokens`;
|
||||||
export const PARADEX_SOURCE = 'paradex';
|
export const PARADEX_SOURCE = 'paradex';
|
||||||
|
|
||||||
export type ParadexActiveMarketsResponse = ParadexMarket[];
|
export type ParadexActiveMarketsResponse = ParadexMarket[];
|
||||||
|
@ -400,7 +400,7 @@ export class Compiler {
|
|||||||
* while others are absolute ("Token.sol", "@0x/contracts/Wallet.sol")
|
* while others are absolute ("Token.sol", "@0x/contracts/Wallet.sol")
|
||||||
* And we need to append the base path for relative imports.
|
* 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])) {
|
if (_.isUndefined(sourcesToAppendTo[importPath])) {
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
"prefer-function-over-method": true,
|
"prefer-function-over-method": true,
|
||||||
"prefer-object-spread": true,
|
"prefer-object-spread": true,
|
||||||
"prefer-readonly": true,
|
"prefer-readonly": true,
|
||||||
|
"prefer-template": true,
|
||||||
"promise-function-async": true,
|
"promise-function-async": true,
|
||||||
"quotemark": [true, "single", "avoid-escape", "jsx-double"],
|
"quotemark": [true, "single", "avoid-escape", "jsx-double"],
|
||||||
"restrict-plus-operands": true,
|
"restrict-plus-operands": true,
|
||||||
|
@ -26,7 +26,7 @@ function parseEthersParams(params: DataItem[]): { names: ParamName[]; types: str
|
|||||||
|
|
||||||
const result = parseEthersParams(param.components);
|
const result = parseEthersParams(param.components);
|
||||||
names.push({ name: param.name || null, names: result.names });
|
names.push({ name: param.name || null, names: result.names });
|
||||||
types.push('tuple(' + result.types.join(',') + ')' + suffix);
|
types.push(`tuple(${result.types.join(',')})${suffix}`);
|
||||||
} else {
|
} else {
|
||||||
names.push(param.name || null);
|
names.push(param.name || null);
|
||||||
types.push(param.type);
|
types.push(param.type);
|
||||||
@ -120,7 +120,7 @@ function splitTupleTypes(type: string): string[] {
|
|||||||
if (_.endsWith(type, '[]')) {
|
if (_.endsWith(type, '[]')) {
|
||||||
throw new Error('Internal error: array types are not supported');
|
throw new Error('Internal error: array types are not supported');
|
||||||
} else if (!_.startsWith(type, 'tuple(')) {
|
} 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().
|
// Trim the outtermost tuple().
|
||||||
const trimmedType = type.substring('tuple('.length, type.length - 1);
|
const trimmedType = type.substring('tuple('.length, type.length - 1);
|
||||||
|
@ -901,7 +901,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
|
|||||||
// Construct args to be encoded
|
// Construct args to be encoded
|
||||||
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
|
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
|
||||||
const bytesLength = 40;
|
const bytesLength = 40;
|
||||||
const args = '0x' + '61'.repeat(bytesLength);
|
const args = `0x${'61'.repeat(bytesLength)}`;
|
||||||
// Encode Args and validate result
|
// Encode Args and validate result
|
||||||
const encodedArgs = dataType.encode(args, encodingRules);
|
const encodedArgs = dataType.encode(args, encodingRules);
|
||||||
const expectedEncodedArgs =
|
const expectedEncodedArgs =
|
||||||
@ -993,7 +993,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
|
|||||||
// Construct args to be encoded
|
// Construct args to be encoded
|
||||||
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
|
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
|
||||||
const strLength = 40;
|
const strLength = 40;
|
||||||
const args = '0x' + 'a'.repeat(strLength);
|
const args = `0x${'a'.repeat(strLength)}`;
|
||||||
// Encode Args and validate result
|
// Encode Args and validate result
|
||||||
const encodedArgs = dataType.encode(args, encodingRules);
|
const encodedArgs = dataType.encode(args, encodingRules);
|
||||||
const expectedEncodedArgs =
|
const expectedEncodedArgs =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user