From 2321d2ab25650d374b3829fce1c4179af047db72 Mon Sep 17 00:00:00 2001 From: Jeremy Ruppel Date: Fri, 20 May 2016 16:19:06 -0700 Subject: [PATCH] Allow whitespace after jsdoc comments. Fixes #6238 --- lib/util/source-code.js | 3 +-- tests/lib/util/source-code.js | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util/source-code.js b/lib/util/source-code.js index adf4df93a6b3..6c37a538cf98 100644 --- a/lib/util/source-code.js +++ b/lib/util/source-code.js @@ -54,8 +54,7 @@ function findJSDocComment(comments, line) { if (comments) { for (var i = comments.length - 1; i >= 0; i--) { if (comments[i].type === "Block" && comments[i].value.charAt(0) === "*") { - - if (line - comments[i].loc.end.line <= 1) { + if (comments[i].loc.end.line <= line) { return comments[i]; } else { break; diff --git a/tests/lib/util/source-code.js b/tests/lib/util/source-code.js index 56552b5fe43e..3dd8bc6a1d89 100644 --- a/tests/lib/util/source-code.js +++ b/tests/lib/util/source-code.js @@ -836,7 +836,7 @@ describe("SourceCode", function() { assert.isTrue(spy.calledOnce, "Event handler should be called."); }); - it("should not get JSDoc comment for function declaration when the function has blank lines on top", function() { + it("should get JSDoc comment for function declaration when the function has blank lines on top", function() { var code = [ "/** Merges two objects together.*/", @@ -857,7 +857,8 @@ describe("SourceCode", function() { var sourceCode = eslint.getSourceCode(); var jsdoc = sourceCode.getJSDocComment(node); - assert.isNull(jsdoc); + assert.equal(jsdoc.type, "Block"); + assert.equal(jsdoc.value, "* Merges two objects together."); } var spy = sandbox.spy(assertJSDoc);