From 84def6aedc34653fdd13ace6ad03ed859377f44b Mon Sep 17 00:00:00 2001 From: Sergey Zarouski Date: Tue, 20 Oct 2015 15:37:10 -0400 Subject: [PATCH] Fix: scope for arrow functions Closes gh-173 --- lib/esprima-helpers.js | 3 ++- test/lib/rules/validate-jsdoc/check-redundant-returns.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/esprima-helpers.js b/lib/esprima-helpers.js index d36dff6..5e874d6 100644 --- a/lib/esprima-helpers.js +++ b/lib/esprima-helpers.js @@ -5,7 +5,8 @@ module.exports = { var scopeNodeTypes = [ 'Program', 'FunctionDeclaration', - 'FunctionExpression' + 'FunctionExpression', + 'ArrowFunctionExpression' ]; /** diff --git a/test/lib/rules/validate-jsdoc/check-redundant-returns.js b/test/lib/rules/validate-jsdoc/check-redundant-returns.js index 6f9c103..fe8d58a 100644 --- a/test/lib/rules/validate-jsdoc/check-redundant-returns.js +++ b/test/lib/rules/validate-jsdoc/check-redundant-returns.js @@ -66,6 +66,15 @@ describe('lib/rules/validate-jsdoc/check-redundant-returns', function () { if (true) { return x; } } } + }, { + it: 'should not report redundant @returns for arrow function', + code: [ + '/** @returns {String}*/', + 'var funcName = () => {', + ' var x = function () { return 1; }', + ' if (true) { return x; }', + '}' + ].join('\n') }, { it: 'should not report expression return for inner call result', code: function () {