Fix many linter errors that showed up upon upgrading tsutil

This commit is contained in:
Fabio Berger
2018-08-22 18:52:17 +01:00
parent 3c2af2067f
commit b7c119b2aa
24 changed files with 83 additions and 94 deletions

View File

@@ -1,9 +1,9 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
// tslint:disable:no-unused-variable
// tslint:disable:no-unbound-method
import { BaseContract } from '@0xproject/base-contract';
import { ContractArtifact } from 'ethereum-types';
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
import { BigNumber, classUtils, logUtils, promisify } from '@0xproject/utils';
import { BlockParam, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethers from 'ethers';
import * as _ from 'lodash';
@@ -85,3 +85,4 @@ export class {{contractName}}Contract extends BaseContract {
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
}
} // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method

View File

@@ -1,5 +1,5 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { signatureUtils, assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
import { assetDataUtils, orderHashUtils, signatureUtils } from '@0xproject/order-utils';
import { RevertReason, SignatureType, SignedOrder, SignerType } from '@0xproject/types';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';

View File

@@ -23,8 +23,8 @@ export class ERC20Wrapper {
/**
* Instanitates an ERC20Wrapper
* @param provider Web3 provider to use for all JSON RPC requests
* @param tokenOwnerAddresses
* @param contractOwnerAddress
* @param tokenOwnerAddresses Addresses that we want to endow as owners for dummy ERC20 tokens
* @param contractOwnerAddress Desired owner of the contract
* Instance of ERC20Wrapper
*/
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {

View File

@@ -1,8 +1,8 @@
import { ContractArtifact } from 'ethereum-types';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import {
AbiDefinition,
ContractArtifact,
DecodedLogArgs,
LogEntry,
LogWithDecodedArgs,

View File

@@ -1,8 +1,7 @@
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { ContractArtifact } from 'ethereum-types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import { ContractArtifact, LogWithDecodedArgs } from 'ethereum-types';
import * as MetacoinArtifact from '../artifacts/Metacoin.json';
import { MetacoinContract, MetacoinTransferEventArgs } from '../src/contract_wrappers/metacoin';

View File

@@ -38,6 +38,7 @@
"@types/opn": "^5.1.0",
"@types/rimraf": "^2.0.2",
"@types/semver": "5.5.0",
"@types/yargs": "^10.0.0",
"depcheck": "^0.6.9",
"make-promises-safe": "^1.1.0",
"npm-run-all": "^4.1.2",
@@ -64,7 +65,8 @@
"semver": "5.5.0",
"semver-diff": "^2.1.0",
"semver-sort": "0.0.4",
"typedoc": "0xProject/typedoc"
"typedoc": "0xProject/typedoc",
"yargs": "^10.0.3"
},
"publishConfig": {
"access": "public"

View File

@@ -1,6 +1,7 @@
import * as yargs from 'yargs';
import { DocGenerateAndUploadUtils } from './utils/doc_generate_and_upload_utils';
import { utils } from './utils/utils';
const args = yargs
.option('package', {
@@ -31,6 +32,6 @@ const args = yargs
process.exit(0);
})().catch(err => {
console.log(err);
utils.log(err);
process.exit(1);
});

View File

@@ -1,9 +1,7 @@
import * as promisify from 'es6-promisify';
import * as publishRelease from 'publish-release';
import { utils } from './utils/utils';
import { publishReleaseNotesAsync } from './utils/github_release_utils';
import { utils } from './utils/utils';
// tslint:disable-next-line:no-floating-promises
(async () => {
const shouldIncludePrivate = false;
const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);

View File

@@ -11,15 +11,15 @@ import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems, Packag
import { utils } from './utils';
export class DocGenerateAndUploadUtils {
private _isStaging: boolean;
private _shouldUploadDocs: boolean;
private _packageName: string;
private _omitExports: string[];
private _packagePath: string;
private _exportPathToExportedItems: ExportPathToExportedItems;
private _exportPathOrder: string[];
private _monoRepoPkgNameToPath: { [name: string]: string };
private _packageJson: PackageJSON;
private readonly _isStaging: boolean;
private readonly _shouldUploadDocs: boolean;
private readonly _packageName: string;
private readonly _omitExports: string[];
private readonly _packagePath: string;
private readonly _exportPathToExportedItems: ExportPathToExportedItems;
private readonly _exportPathOrder: string[];
private readonly _monoRepoPkgNameToPath: { [name: string]: string };
private readonly _packageJson: PackageJSON;
/**
* Recursively iterate over the TypeDoc JSON object and find all type names
*/
@@ -278,7 +278,7 @@ export class DocGenerateAndUploadUtils {
}
utils.log(`GENERATE_UPLOAD_DOCS: Doc generation done for ${this._packageName}`);
}
private async _uploadDocsAsync(jsonFilePath: string, cwd: string) {
private async _uploadDocsAsync(jsonFilePath: string, cwd: string): Promise<void> {
const fileName = `v${this._packageJson.version}.json`;
utils.log(`GENERATE_UPLOAD_DOCS: Doc generation successful, uploading docs... as ${fileName}`);

View File

@@ -1,27 +1,29 @@
import * as _ from 'lodash';
import * as promisify from 'es6-promisify';
import { readFileSync } from 'fs';
import * as _ from 'lodash';
import * as path from 'path';
import { exec as execAsync } from 'promisify-child-process';
import * as publishRelease from 'publish-release';
import { constants } from '../constants';
import { Package } from '../types';
import { utils } from './utils';
import { readFileSync } from 'fs';
import * as path from 'path';
import { exec as execAsync } from 'promisify-child-process';
const publishReleaseAsync = promisify(publishRelease);
// tslint:disable-next-line:completed-docs
export async function publishReleaseNotesAsync(updatedPublishPackages: Package[]): Promise<void> {
// Git push a tag representing this publish (publish-{commit-hash}) (truncate hash)
const result = await execAsync('git log -n 1 --pretty=format:"%H"', { cwd: constants.monorepoRootPath });
const latestGitCommit = result.stdout;
const shortenedGitCommit = latestGitCommit.slice(0, 7);
const prefixLength = 7;
const shortenedGitCommit = latestGitCommit.slice(0, prefixLength);
const tagName = `monorepo@${shortenedGitCommit}`;
await execAsync(`git rev-parse ${tagName}`);
await execAsync('git tag ${tagName}');
await execAsync(`git tag ${tagName}`);
await execAsync('git push origin ${tagName}');
await execAsync(`git push origin ${tagName}`);
const releaseName = `0x monorepo - ${shortenedGitCommit}`;
let assets: string[] = [];

View File

@@ -1,6 +1,6 @@
import { BigNumber } from '@0xproject/utils';
/**l
/**
* An abstract class to be implemented in order to use OrderStateUtils. The class that
* implements this interface must be capable of fetching the balance and proxyAllowance
* for an Ethereum address and assetData

View File

@@ -1,6 +1,6 @@
import { BigNumber } from '@0xproject/utils';
/**l
/**
* An abstract class to be implemented in order to use OrderStateUtils. The class that
* implements this interface must be capable of fetching the amount filled of an order
* and whether it's been cancelled.

View File

@@ -6,9 +6,9 @@ import * as _ from 'lodash';
import { assert } from './assert';
import { constants } from './constants';
import {
FeeOrdersAndRemainingFeeAmount,
FindFeeOrdersThatCoverFeesForTargetOrdersOpts,
FindOrdersThatCoverMakerAssetFillAmountOpts,
FeeOrdersAndRemainingFeeAmount,
OrdersAndRemainingFillAmount,
} from './types';

View File

@@ -26,12 +26,12 @@ import {
import { constants } from './constants';
export class TypeDocUtils {
private _typeDocNameOrder: string[];
private _externalTypeToLink: ExternalTypeToLink;
private _externalExportToLink: ExternalExportToLink;
private _docsInfo: DocsInfo;
private _typeDocJson: TypeDocNode;
private _classNames: string[];
private readonly _typeDocNameOrder: string[];
private readonly _externalTypeToLink: ExternalTypeToLink;
private readonly _externalExportToLink: ExternalExportToLink;
private readonly _docsInfo: DocsInfo;
private readonly _typeDocJson: TypeDocNode;
private readonly _classNames: string[];
constructor(generatedDocJson: GeneratedDocJson, docsInfo: DocsInfo) {
this._docsInfo = docsInfo;
const exportPathOrder = generatedDocJson.metadata.exportPathOrder;
@@ -191,7 +191,7 @@ export class TypeDocUtils {
case KindString.Function:
if (entity.flags.isExported) {
const funcName = (entity as TypeDocNode).signatures[0].name;
const funcName = entity.signatures[0].name;
if (!this.isUnderscorePrefixed(funcName)) {
const func = this._convertFunction(entity, sectionName, isClassOrObjectLiteral);
docSection.functions.push(func);
@@ -262,7 +262,7 @@ export class TypeDocUtils {
? this._convertMethod(entity.declaration, isConstructor, sectionName)
: undefined;
const doesIndexSignatureExist = !_.isUndefined(entity.indexSignature);
const indexSignature = entity.indexSignature as TypeDocNode;
const indexSignature = entity.indexSignature;
const indexSignatureIfExists = doesIndexSignatureExist
? this._convertIndexSignature(indexSignature, sectionName)
: undefined;
@@ -379,7 +379,7 @@ export class TypeDocUtils {
}
return callPath;
}
private _getLowercaseSectionName(sectionName: string) {
private _getLowercaseSectionName(sectionName: string): string {
if (_.startsWith(sectionName, 'ERC')) {
return `${sectionName.slice(0, 3).toLowerCase()}${sectionName.slice(3)}`;
}
@@ -461,7 +461,7 @@ export class TypeDocUtils {
const doesIndexSignatureExist =
!_.isUndefined(entity.declaration) && !_.isUndefined(entity.declaration.indexSignature);
if (doesIndexSignatureExist) {
const indexSignature = entity.declaration.indexSignature as TypeDocNode;
const indexSignature = entity.declaration.indexSignature;
indexSignatureIfExists = this._convertIndexSignature(indexSignature, sectionName);
} else if (!_.isUndefined(entity.declaration)) {
const isConstructor = false;

View File

@@ -37,7 +37,7 @@ export const utils = {
const charArray = _.map(text, (char, i) => {
const isNumber = !_.eq(_.parseInt(char), NaN);
const isPrevNumber = i !== 0 && !_.eq(_.parseInt(text[i - 1]), NaN);
if (isNumber && (i == 0 || isPrevNumber)) {
if (isNumber && (i === 0 || isPrevNumber)) {
return char;
}
if (char === char.toUpperCase() && i !== 0) {

View File

@@ -80,7 +80,7 @@ describe('#Compiler', function(): void {
it('recompilation should update artifact when source has changed', async () => {
// append some meaningless data to the contract, so that its hash
// will change, so that the compiler will decide to recompile it.
fsWrapper.appendFileAsync(join(contractsDir, `${contract}.sol`), ' ');
await fsWrapper.appendFileAsync(join(contractsDir, `${contract}.sol`), ' ');
await new Compiler(compilerOpts).compileAsync();

View File

@@ -107,4 +107,5 @@ const mainAsync = async () => {
};
await utils.newmanRunAsync(newmanRunOptions);
};
mainAsync().catch(logUtils.log);
mainAsync().catch(logUtils.log.bind(logUtils));

View File

@@ -53,6 +53,8 @@ export abstract class Subprovider {
*/
public async emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload> {
const finalPayload = Subprovider._createFinalPayload(payload);
// Promisify does the binding internally and `this` is supplied as a second argument
// tslint:disable-next-line:no-unbound-method
const response = await promisify<JSONRPCResponsePayload>(this.engine.sendAsync, this.engine)(finalPayload);
return response;
}

View File

@@ -42,9 +42,9 @@
"dependencies": {
"lodash": "^4.17.5",
"tslint": "5.11.0",
"tslint-eslint-rules": "^4.1.1",
"tslint-eslint-rules": "5.4.0",
"tslint-react": "^3.2.0",
"tsutils": "2.22.2"
"tsutils": "3.0.0"
},
"publishConfig": {
"access": "public"

View File

@@ -77,7 +77,6 @@
"no-unnecessary-class": true,
"no-unnecessary-type-assertion": true,
"no-unsafe-finally": true,
"no-unused-variable": [true, "check-parameters"],
"number-literal-format": true,
"object-literal-key-quotes": false,
"object-literal-sort-keys": false,
@@ -124,5 +123,5 @@
"check-preblock"
]
},
"rulesDirectory": "lib/rules"
"rulesDirectory": "lib"
}

View File

@@ -152,15 +152,6 @@ export enum SignerType {
Trezor = 'TREZOR',
}
/**
* Elliptic Curve signature
*/
export interface ECSignature {
v: number;
r: string;
s: string;
}
export enum AssetProxyId {
ERC20 = '0xf47261b0',
ERC721 = '0x02571792',

View File

@@ -1,10 +1,10 @@
import { DocsInfo, DocsMenu } from '@0xproject/react-docs';
import {
colors,
constants as sharedConstants,
MenuSubsectionsBySection,
NestedSidebarMenu,
Styles,
constants as sharedConstants,
} from '@0xproject/react-shared';
import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer';
@@ -378,13 +378,16 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</Link>
{_.map(DOC_WEBSITE_PATHS_TO_KEY, (key, websitePath) => {
if (!this._doesUrlInclude(websitePath)) {
<Link to={websitePath} className="text-decoration-none">
<MenuItem className="py2">
{this.props.translate.get(key, Deco.Cap)}{' '}
{this.props.translate.get(Key.Docs, Deco.Cap)}
</MenuItem>
</Link>;
return (
<Link to={websitePath} className="text-decoration-none">
<MenuItem className="py2">
{this.props.translate.get(key, Deco.Cap)}{' '}
{this.props.translate.get(Key.Docs, Deco.Cap)}
</MenuItem>
</Link>
);
}
return null;
})}
{!this._isViewingPortal() && (
<Link to={`${WebsitePaths.Portal}`} className="text-decoration-none">

View File

@@ -14,9 +14,9 @@ import {
SideToAssetToken,
TokenByAddress,
} from 'ts/types';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
import { utils } from 'ts/utils/utils';
import { constants } from 'ts/utils/constants';
// Instead of defaulting the docs version to an empty string, we pre-populate it with
// a valid version value. This does not need to be updated however, since onLoad, it

View File

@@ -4475,7 +4475,7 @@ dns-txt@^2.0.2:
dependencies:
buffer-indexof "^1.0.0"
doctrine@^0.7.2:
doctrine@0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523"
dependencies:
@@ -13414,7 +13414,7 @@ ts-node@^7.0.0:
source-map-support "^0.5.6"
yn "^2.0.0"
tslib@^1.0.0, tslib@^1.8.0, tslib@^1.8.1:
tslib@1.9.0, tslib@^1.8.0, tslib@^1.8.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
@@ -13428,13 +13428,13 @@ tslint-config-0xproject@^0.0.2:
dependencies:
tslint-react "^3.0.0"
tslint-eslint-rules@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-4.1.1.tgz#7c30e7882f26bc276bff91d2384975c69daf88ba"
tslint-eslint-rules@5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz#e488cc9181bf193fe5cd7bfca213a7695f1737b5"
dependencies:
doctrine "^0.7.2"
tslib "^1.0.0"
tsutils "^1.4.0"
doctrine "0.7.2"
tslib "1.9.0"
tsutils "^3.0.0"
tslint-react@^3.0.0, tslint-react@^3.2.0:
version "3.5.1"
@@ -13476,25 +13476,15 @@ tslint@^5.9.1:
tslib "^1.8.0"
tsutils "^2.12.1"
tsutils@2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.22.2.tgz#0b9f3d87aa3eb95bd32d26ce2b88aa329a657951"
tsutils@3.0.0, tsutils@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.0.0.tgz#0c5070a17a0503e056da038c48b5a1870a50a9ad"
dependencies:
tslib "^1.8.1"
tsutils@^1.4.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0"
tsutils@^2.12.1, tsutils@^2.13.1:
version "2.26.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.26.1.tgz#9e4a0cb9ff173863f34c22a961969081270d1878"
dependencies:
tslib "^1.8.1"
tsutils@^2.27.2:
version "2.27.2"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7"
tsutils@^2.12.1, tsutils@^2.13.1, tsutils@^2.27.2:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
dependencies:
tslib "^1.8.1"