@magicspace/tslint-rules
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -7,2 +7,3 @@ "use strict"; | ||
const failure_manager_1 = require("../utils/failure-manager"); | ||
const function_1 = require("../utils/function"); | ||
const ERROR_MESSAGE_EXPLICIT_RETURN_TYPE_REQUIRED = 'This function requires explicit return type.'; | ||
@@ -123,3 +124,3 @@ exports.BASE_TYPE_STRING_SET = new Set([ | ||
// class Foo {bar: Bar = () => {};} | ||
tsutils_1.isPropertyDeclaration(parent)) { | ||
typescript_1.isPropertyDeclaration(parent)) { | ||
return !!parent.type; | ||
@@ -143,5 +144,12 @@ } | ||
// return () => {}; | ||
let block = parent.parent; | ||
let functionLike = block.parent; | ||
return this.checkReturnType(functionLike); | ||
let functionLikeParent = function_1.getFunctionLikeParent(parent); | ||
if (functionLikeParent && | ||
isReturnTypeRelatedFunctionLikeDeclaration(functionLikeParent)) { | ||
return this.checkReturnType(functionLikeParent); | ||
} | ||
else { | ||
// Actually return statement should be invalid here in setter and | ||
// constructor. | ||
return true; | ||
} | ||
} | ||
@@ -151,2 +159,9 @@ return this.checkExpressionType(parent); | ||
} | ||
function isReturnTypeRelatedFunctionLikeDeclaration(node) { | ||
return (typescript_1.isFunctionDeclaration(node) || | ||
typescript_1.isFunctionExpression(node) || | ||
typescript_1.isArrowFunction(node) || | ||
typescript_1.isMethodDeclaration(node) || | ||
typescript_1.isGetAccessorDeclaration(node)); | ||
} | ||
//# sourceMappingURL=explicitReturnTypeRule.js.map |
{ | ||
"name": "@magicspace/tslint-rules", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Custom TSLint rules for MagicSpace.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/makeflow/magicspace.git", |
32788
10
856