diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 07:58:34 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 07:58:34 +0800 |
commit | 8c5ff663a9521b3dcefbfd1bc9ef3fa2f4cfe023 (patch) | |
tree | 608b52c60fb24777274de78174e69b88a75362e0 /packages/tslint-config | |
parent | 67422db4bd0b194296a1a584af7ead089e281715 (diff) | |
parent | 6d45beccad44e86ddd692d0cf54c09c29c5d9daf (diff) | |
download | dexon-sol-tools-8c5ff663a9521b3dcefbfd1bc9ef3fa2f4cfe023.tar.gz dexon-sol-tools-8c5ff663a9521b3dcefbfd1bc9ef3fa2f4cfe023.tar.zst dexon-sol-tools-8c5ff663a9521b3dcefbfd1bc9ef3fa2f4cfe023.zip |
Merge branch 'development' into feature/instant/usd-eth-toggle
Diffstat (limited to 'packages/tslint-config')
-rw-r--r-- | packages/tslint-config/CHANGELOG.json | 10 | ||||
-rw-r--r-- | packages/tslint-config/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/tslint-config/package.json | 2 | ||||
-rw-r--r-- | packages/tslint-config/rules/walkers/async_suffix.ts | 39 |
4 files changed, 39 insertions, 16 deletions
diff --git a/packages/tslint-config/CHANGELOG.json b/packages/tslint-config/CHANGELOG.json index 9f504216c..0070a5b81 100644 --- a/packages/tslint-config/CHANGELOG.json +++ b/packages/tslint-config/CHANGELOG.json @@ -1,5 +1,15 @@ [ { + "version": "2.0.0", + "changes": [ + { + "note": "Improve async-suffix rule to check functions too, not just methods", + "pr": 1425 + } + ], + "timestamp": 1544739608 + }, + { "version": "1.0.10", "changes": [ { diff --git a/packages/tslint-config/CHANGELOG.md b/packages/tslint-config/CHANGELOG.md index f5cacb5d1..3cebb1e95 100644 --- a/packages/tslint-config/CHANGELOG.md +++ b/packages/tslint-config/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.0 - _December 13, 2018_ + + * Improve async-suffix rule to check functions too, not just methods (#1425) + ## v1.0.10 - _November 9, 2018_ * Dependencies updated diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index 2914f31e2..64ec1e967 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@0x/tslint-config", - "version": "1.0.10", + "version": "2.0.0", "engines": { "node": ">=6.12" }, diff --git a/packages/tslint-config/rules/walkers/async_suffix.ts b/packages/tslint-config/rules/walkers/async_suffix.ts index eaec9c5f6..4e12152e8 100644 --- a/packages/tslint-config/rules/walkers/async_suffix.ts +++ b/packages/tslint-config/rules/walkers/async_suffix.ts @@ -3,24 +3,33 @@ import * as Lint from 'tslint'; import * as ts from 'typescript'; export class AsyncSuffixWalker extends Lint.RuleWalker { - public static FAILURE_STRING = 'async functions must have an Async suffix'; + public static FAILURE_STRING = 'async functions/methods must have an Async suffix'; + public visitFunctionDeclaration(node: ts.FunctionDeclaration): void { + this._visitFunctionOrMethodDeclaration(node); + super.visitFunctionDeclaration(node); + } public visitMethodDeclaration(node: ts.MethodDeclaration): void { - const methodNameNode = node.name; - const methodName = methodNameNode.getText(); - if (!_.isUndefined(node.type)) { - if (node.type.kind === ts.SyntaxKind.TypeReference) { - // tslint:disable-next-line:no-unnecessary-type-assertion - const returnTypeName = (node.type as ts.TypeReferenceNode).typeName.getText(); - if (returnTypeName === 'Promise' && !methodName.endsWith('Async')) { - const failure = this.createFailure( - methodNameNode.getStart(), - methodNameNode.getWidth(), - AsyncSuffixWalker.FAILURE_STRING, - ); - this.addFailure(failure); + this._visitFunctionOrMethodDeclaration(node); + super.visitMethodDeclaration(node); + } + private _visitFunctionOrMethodDeclaration(node: ts.MethodDeclaration | ts.FunctionDeclaration): void { + const nameNode = node.name; + if (!_.isUndefined(nameNode)) { + const name = nameNode.getText(); + if (!_.isUndefined(node.type)) { + if (node.type.kind === ts.SyntaxKind.TypeReference) { + // tslint:disable-next-line:no-unnecessary-type-assertion + const returnTypeName = (node.type as ts.TypeReferenceNode).typeName.getText(); + if (returnTypeName === 'Promise' && !name.endsWith('Async')) { + const failure = this.createFailure( + nameNode.getStart(), + nameNode.getWidth(), + AsyncSuffixWalker.FAILURE_STRING, + ); + this.addFailure(failure); + } } } } - super.visitMethodDeclaration(node); } } |