diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-23 01:52:17 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-23 01:52:17 +0800 |
commit | b7c119b2aaaa2f3579ca4aeef198eca7f38f1216 (patch) | |
tree | 16956eb295a2b0a21fcab07b4e2377c2cd59d3c9 /packages | |
parent | 3c2af2067f768bd3ffe233d9a7c2d0232db6868e (diff) | |
download | dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar.gz dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar.bz2 dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar.lz dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar.xz dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.tar.zst dexon-sol-tools-b7c119b2aaaa2f3579ca4aeef198eca7f38f1216.zip |
Fix many linter errors that showed up upon upgrading tsutil
Diffstat (limited to 'packages')
23 files changed, 69 insertions, 70 deletions
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars index 7fd96f4e0..5c36a765d 100644 --- a/packages/contract_templates/contract.handlebars +++ b/packages/contract_templates/contract.handlebars @@ -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 diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts index e95b70b62..cd4f3d6f3 100644 --- a/packages/contracts/test/exchange/signature_validator.ts +++ b/packages/contracts/test/exchange/signature_validator.ts @@ -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'; diff --git a/packages/contracts/test/utils/erc20_wrapper.ts b/packages/contracts/test/utils/erc20_wrapper.ts index ec9e20a9b..526ffe9f8 100644 --- a/packages/contracts/test/utils/erc20_wrapper.ts +++ b/packages/contracts/test/utils/erc20_wrapper.ts @@ -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) { diff --git a/packages/contracts/test/utils/log_decoder.ts b/packages/contracts/test/utils/log_decoder.ts index 77211d357..144a18dd1 100644 --- a/packages/contracts/test/utils/log_decoder.ts +++ b/packages/contracts/test/utils/log_decoder.ts @@ -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, diff --git a/packages/metacoin/test/metacoin_test.ts b/packages/metacoin/test/metacoin_test.ts index f112ac060..6c16a2d39 100644 --- a/packages/metacoin/test/metacoin_test.ts +++ b/packages/metacoin/test/metacoin_test.ts @@ -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'; diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 41a6e7c91..74be99550 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -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" diff --git a/packages/monorepo-scripts/src/doc_generate_and_upload.ts b/packages/monorepo-scripts/src/doc_generate_and_upload.ts index c70ea5ba7..4c4a72701 100644 --- a/packages/monorepo-scripts/src/doc_generate_and_upload.ts +++ b/packages/monorepo-scripts/src/doc_generate_and_upload.ts @@ -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); }); diff --git a/packages/monorepo-scripts/src/publish_release_notes.ts b/packages/monorepo-scripts/src/publish_release_notes.ts index 964f5b0bb..5afcc8775 100644 --- a/packages/monorepo-scripts/src/publish_release_notes.ts +++ b/packages/monorepo-scripts/src/publish_release_notes.ts @@ -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); diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index bbc763a6b..1645ba0d6 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -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}`); diff --git a/packages/monorepo-scripts/src/utils/github_release_utils.ts b/packages/monorepo-scripts/src/utils/github_release_utils.ts index 1f4c4f1e9..28dce70ac 100644 --- a/packages/monorepo-scripts/src/utils/github_release_utils.ts +++ b/packages/monorepo-scripts/src/utils/github_release_utils.ts @@ -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'; +import { utils } from './utils'; 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[] = []; diff --git a/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts index 7cb859ca7..c7f06abad 100644 --- a/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts +++ b/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts @@ -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 diff --git a/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts b/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts index d2b01c359..fbc1c4718 100644 --- a/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts +++ b/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts @@ -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. diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index b3f302dd2..441c50e5c 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -6,9 +6,9 @@ import * as _ from 'lodash'; import { assert } from './assert'; import { constants } from './constants'; import { + FeeOrdersAndRemainingFeeAmount, FindFeeOrdersThatCoverFeesForTargetOrdersOpts, FindOrdersThatCoverMakerAssetFillAmountOpts, - FeeOrdersAndRemainingFeeAmount, OrdersAndRemainingFillAmount, } from './types'; diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 0eaf5fd6e..76443ad81 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -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; diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts index 0c0e7722c..d6b2a5cf5 100644 --- a/packages/react-shared/src/utils/utils.ts +++ b/packages/react-shared/src/utils/utils.ts @@ -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) { diff --git a/packages/sol-compiler/test/compiler_test.ts b/packages/sol-compiler/test/compiler_test.ts index e41a268f2..464aa8bb6 100644 --- a/packages/sol-compiler/test/compiler_test.ts +++ b/packages/sol-compiler/test/compiler_test.ts @@ -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(); diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index faa904441..b23b6c8d2 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -107,4 +107,5 @@ const mainAsync = async () => { }; await utils.newmanRunAsync(newmanRunOptions); }; -mainAsync().catch(logUtils.log); + +mainAsync().catch(logUtils.log.bind(logUtils)); diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts index 53a3d07ea..dcf880c79 100644 --- a/packages/subproviders/src/subproviders/subprovider.ts +++ b/packages/subproviders/src/subproviders/subprovider.ts @@ -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; } diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index a20cf5621..f6b18cde3 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -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" diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json index 93403d36b..f207d0709 100644 --- a/packages/tslint-config/tslint.json +++ b/packages/tslint-config/tslint.json @@ -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" } diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index f080fba21..298fa77d4 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -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', diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 41b01c57b..e27a1fae2 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -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"> diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index 15f118813..1bc4611e0 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -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 |