diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js index 36239c5b8..7af04a45b 100644 --- a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js +++ b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js @@ -84,14 +84,11 @@ function walk(ctx) { } /** Generator functions and functions using `this` are allowed. */ function functionIsExempt(node) { - return node.asteriskToken !== undefined || hasThisParameter(node) || node.body !== undefined && usesThisInBody(node.body) === true; + return node.asteriskToken !== undefined || + node.parameters.length !== 0 && utils.isThisParameter(node.parameters[0]) || + node.body !== undefined && ts.forEachChild(node, usesThis) === true; } -function hasThisParameter(node) { - var first = node.parameters[0]; - return first !== undefined && first.name.kind === ts.SyntaxKind.Identifier && - first.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword; -} -function usesThisInBody(node) { - return node.kind === ts.SyntaxKind.ThisKeyword || !utils.hasOwnThisReference(node) && ts.forEachChild(node, usesThisInBody); +function usesThis(node) { + return node.kind === ts.SyntaxKind.ThisKeyword || !utils.hasOwnThisReference(node) && ts.forEachChild(node, usesThis); } var _a; |