eslint-plugin-flowtype
Advanced tools
Comparing version 2.29.2 to 2.30.0
@@ -5,4 +5,4 @@ # Change Log | ||
<a name="2.29.2"></a> | ||
## [2.29.2](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.29.1...v2.29.2) (2016-12-29) | ||
<a name="2.30.0"></a> | ||
# [2.30.0](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.29.1...v2.30.0) (2017-01-15) | ||
@@ -14,4 +14,8 @@ | ||
### Features | ||
* `require-return-type` include / exclude filter support ([3f4b947](https://github.com/gajus/eslint-plugin-flowtype/commit/3f4b947)) | ||
<a name="2.29.1"></a> | ||
@@ -18,0 +22,0 @@ ## [2.29.1](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.29.0...v2.29.1) (2016-12-01) |
@@ -18,2 +18,9 @@ 'use strict'; | ||
var makeRegExp = function makeRegExp(str) { | ||
return new RegExp(str); | ||
}; | ||
var excludeMatching = _lodash2.default.get(context, 'options[1].excludeMatching', []).map(makeRegExp); | ||
var includeOnlyMatching = _lodash2.default.get(context, 'options[1].includeOnlyMatching', []).map(makeRegExp); | ||
var targetNodes = []; | ||
@@ -38,2 +45,21 @@ | ||
var shouldFilterNode = function shouldFilterNode(functionNode) { | ||
var isArrow = functionNode.type === 'ArrowFunctionExpression'; | ||
var identiferName = _lodash2.default.get(functionNode, isArrow ? 'parent.id.name' : 'id.name'); | ||
var checkRegExp = function checkRegExp(regex) { | ||
return regex.test(identiferName); | ||
}; | ||
if (excludeMatching.length && _lodash2.default.some(excludeMatching, checkRegExp)) { | ||
return true; | ||
} | ||
if (includeOnlyMatching.length && !_lodash2.default.some(includeOnlyMatching, checkRegExp)) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var evaluateFunction = function evaluateFunction(functionNode) { | ||
@@ -61,3 +87,3 @@ var targetNode = targetNodes.pop(); | ||
} else if (!isFunctionReturnUndefined && !isReturnTypeAnnotationUndefined) { | ||
if (annotateReturn && !functionNode.returnType) { | ||
if (annotateReturn && !functionNode.returnType && !shouldFilterNode(functionNode)) { | ||
context.report(functionNode, 'Missing return type annotation.'); | ||
@@ -64,0 +90,0 @@ } |
{ | ||
"name": "eslint-plugin-flowtype", | ||
"description": "Flowtype linting rules for ESLint.", | ||
"version": "2.29.2", | ||
"version": "2.30.0", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174441
1714
3616