Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Commit 66ab079

Browse files
author
Manuel Lopez
committed
Merge branch 'master' into updates
2 parents 5177312 + 6f8ce27 commit 66ab079

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/rules/validJsdocRule.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,11 @@ class ValidJsdocWalker extends Lint.RuleWalker {
267267
}
268268

269269
let comments = node.getFullText();
270-
comments = comments.substring(comments.indexOf('/**'));
270+
let offset = comments.indexOf('/**');
271+
comments = comments.substring(offset);
271272
comments = comments.substring(0, comments.indexOf('*/') + 2);
272273

273-
let start = node.pos;
274+
let start = node.pos + offset;
274275
let width = comments.length;
275276

276277
if (!/^\/\*\*/.test(comments) || !/\*\/$/.test(comments)) {

src/test/rules/validJsdocRuleTests.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,4 +718,28 @@ ruleTester.addTestGroup('param-type', 'should handle requireParamType option', [
718718
}
719719
]);
720720

721+
ruleTester.addTestGroup('error-location', 'error location should span the comment', [
722+
{
723+
code: dedent`
724+
/**
725+
* Class
726+
*/
727+
class Foo {
728+
729+
/**
730+
* Function
731+
*/
732+
public bar(x: any): void {
733+
}
734+
735+
}`,
736+
options: { requireReturn: false },
737+
errors: [{
738+
failure: "missing JSDoc for parameter 'x'",
739+
startPosition: new Position(6, 2),
740+
endPosition: new Position(8, 5)
741+
}]
742+
}
743+
]);
744+
721745
ruleTester.runTests();

0 commit comments

Comments
 (0)