Skip to content

Commit 231b359

Browse files
author
Alexej Yaroshevich
committed
checkRedundantReturns: skip reporting for abstract declarations
Fixes #93
1 parent 3b1ed48 commit 231b359

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lib/jsdoc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ function DocComment(value, loc) {
6767
return new DocTag(tag, new DocLocation(tag.line, 3, loc.start));
6868
});
6969

70+
// calculate abstract flag
71+
this.abstract = this.tags.some(function(v) {
72+
return v.id === 'abstract' || v.id === 'virtual';
73+
});
74+
7075
/**
7176
* @param {function(this: DocComment, DocTag): DocComment} fn
7277
* @returns {DocComment}

lib/rules/validate-jsdoc/check-redundant-returns.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ function checkReturnTypes(node, tag, err) {
1717
return;
1818
}
1919

20+
// skip abstract methods
21+
if (node.jsdoc.abstract) {
22+
return;
23+
}
24+
2025
// checking redundant: invalid or not return statements in code
2126
var redundant = !Boolean(this._getReturnStatementsForNode(node).length);
2227

test/lib/rules/validate-jsdoc/check-redundant-returns.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ describe('lib/rules/validate-jsdoc/check-redundant-returns', function () {
7979
});
8080
}
8181
}
82+
}, {
83+
it: 'should not report for abstract methods',
84+
code: function () {
85+
/**
86+
* @abstract
87+
* @return {number}
88+
*/
89+
function onEvent () {}
90+
}
8291
}
8392
/* jshint ignore:end */
8493
]);

0 commit comments

Comments
 (0)