Fix TSLint issues

This commit is contained in:
Fabio Berger 2018-05-14 21:48:46 +02:00
parent da60008048
commit 5422bf5733
9 changed files with 28 additions and 19 deletions

View File

@ -5,7 +5,7 @@ import * as path from 'path';
import { constants } from './utils/constants';
import { provider } from './utils/web3_wrapper';
before('migrate contracts', async function() {
before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
this.timeout(20000);

View File

@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber');
import * as dirtyChai from 'dirty-chai';
export const chaiSetup = {
configure() {
configure(): void {
chai.config.includeStack = true;
chai.use(ChaiBigNumber());
chai.use(dirtyChai);

View File

@ -6,7 +6,10 @@ import { DoneCallback } from '@0xproject/types';
const expect = chai.expect;
export const callbackErrorReporter = {
reportNoErrorCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) {
reportNoErrorCallbackErrors(
done: DoneCallback,
expectToBeCalledOnce: boolean = true,
): <T>(f?: ((value: T) => void) | undefined) => (value: T) => void {
const callback = <T>(f?: (value: T) => void) => {
const wrapped = (value: T) => {
if (_.isUndefined(f)) {
@ -26,7 +29,10 @@ export const callbackErrorReporter = {
};
return callback;
},
reportNodeCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) {
reportNodeCallbackErrors(
done: DoneCallback,
expectToBeCalledOnce: boolean = true,
): <T>(f?: ((value: T) => void) | undefined) => (error: Error | null, value: T | undefined) => void {
const callback = <T>(f?: (value: T) => void) => {
const wrapped = (error: Error | null, value: T | undefined) => {
if (!_.isNull(error)) {
@ -50,7 +56,10 @@ export const callbackErrorReporter = {
};
return callback;
},
assertNodeCallbackError(done: DoneCallback, errMsg: string) {
assertNodeCallbackError(
done: DoneCallback,
errMsg: string,
): <T>(error: Error | null, value: T | undefined) => void {
const wrapped = <T>(error: Error | null, value: T | undefined) => {
if (_.isNull(error)) {
done(new Error('Expected callback to receive an error'));

View File

@ -74,7 +74,7 @@ export const postpublishUtils = {
utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`);
}
},
async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string) {
async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise<void> {
const configs = this.generateConfig(packageJSON, tsConfigJSON, cwd);
if (_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath)) {
utils.log('config.postpublish.docPublishConfigs.s3StagingBucketPath entry in package.json not found!');
@ -109,7 +109,7 @@ export const postpublishUtils = {
assets,
});
},
getReleaseNotes(packageName: string, version: string) {
getReleaseNotes(packageName: string, version: string): string {
const packageNameWithNamespace = packageName.replace('@0xproject/', '');
const changelogJSONPath = path.join(
constants.monorepoRootPath,
@ -135,14 +135,14 @@ export const postpublishUtils = {
});
return notes;
},
getTag(packageName: string, version: string) {
getTag(packageName: string, version: string): string {
return `${packageName}@${version}`;
},
getReleaseName(subPackageName: string, version: string): string {
const releaseName = `${subPackageName} v${version}`;
return releaseName;
},
adjustAssetPaths(cwd: string, assets: string[]) {
adjustAssetPaths(cwd: string, assets: string[]): string[] {
const finalAssets: string[] = [];
_.each(assets, (asset: string) => {
finalAssets.push(`${cwd}/${asset}`);
@ -164,7 +164,7 @@ export const postpublishUtils = {
});
return fileIncludesAdjusted;
},
async generateAndUploadDocsAsync(cwd: string, fileIncludes: string[], version: string, S3BucketPath: string) {
async generateAndUploadDocsAsync(cwd: string, fileIncludes: string[], version: string, S3BucketPath: string): Promise<void> {
const fileIncludesAdjusted = this.adjustFileIncludePaths(fileIncludes, cwd);
const projectFiles = fileIncludesAdjusted.join(' ');
const jsonFilePath = `${cwd}/${generatedDocsDirectoryName}/index.json`;

View File

@ -72,7 +72,7 @@ const packageNameToWebsitePath: { [name: string]: string } = {
process.exit(1);
});
async function confirmDocPagesRenderAsync(packages: LernaPackage[]) {
async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise<void> {
// push docs to staging
utils.log("Upload all docJson's to S3 staging...");
await execAsync(`yarn lerna:stage_docs`, { cwd: constants.monorepoRootPath });
@ -162,7 +162,7 @@ async function checkPublishRequiredSetupAsync(): Promise<boolean> {
return true;
}
async function pushChangelogsToGithubAsync() {
async function pushChangelogsToGithubAsync(): Promise<void> {
await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath });
await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath });
await execAsync(`git push`, { cwd: constants.monorepoRootPath });
@ -228,7 +228,7 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[])
return packageToVersionChange;
}
async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }) {
async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise<void> {
// HACK: Lerna publish does not provide a way to specify multiple package versions via
// flags so instead we need to interact with their interactive prompt interface.
const child = spawn('lerna', ['publish', '--registry=https://registry.npmjs.org/'], {
@ -269,7 +269,7 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin
});
}
function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string) {
function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string {
if (proposedNextVersion === currentVersion) {
return utils.getNextPatchVersion(currentVersion);
}

View File

@ -17,7 +17,7 @@ export const utils = {
const newPatchVersion = `${versionSegments[0]}.${versionSegments[1]}.${newPatch}`;
return newPatchVersion;
},
async prettifyAsync(filePath: string, cwd: string) {
async prettifyAsync(filePath: string, cwd: string): Promise<void> {
await execAsync(`prettier --write ${filePath} --config .prettierrc`, {
cwd,
});
@ -43,7 +43,7 @@ export const utils = {
}
return updatedPackages;
},
getChangelogJSONIfExists(changelogPath: string) {
getChangelogJSONIfExists(changelogPath: string): string|undefined {
try {
const changelogJSON = fs.readFileSync(changelogPath, 'utf-8');
return changelogJSON;

View File

@ -12,7 +12,7 @@ import { isValidSignature } from '@0xproject/order-utils';
export const assert = {
...sharedAssert,
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string): void {
const isValid = isValidSignature(orderHash, ecSignature, signerAddress);
this.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
},

View File

@ -5,7 +5,7 @@ import * as path from 'path';
import { constants } from './utils/constants';
import { provider } from './utils/web3_wrapper';
before('migrate contracts', async function() {
before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
this.timeout(20000);

View File

@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber');
import * as dirtyChai from 'dirty-chai';
export const chaiSetup = {
configure() {
configure(): void {
chai.config.includeStack = true;
chai.use(ChaiBigNumber());
chai.use(dirtyChai);