Skip to content

Commit 1beefd3

Browse files
Alexej Yaroshevichqfox
authored andcommitted
checkReturnTypes: skip checking 'this.something'
Fixes #115 Closes gh-120
1 parent e8a73cc commit 1beefd3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/jsdoc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,16 @@ function jsDocMatchType (variants, argument) {
519519
result = result || (type === 'array');
520520

521521
} else if (argument.type === 'NewExpression' && type === 'object') {
522-
result = result || true;
522+
result = true;
523523

524524
} else if (argument.type === 'NewExpression') {
525525
var c = argument.callee;
526526
var exam = c.name;
527527
if (!exam && c.type === 'MemberExpression') {
528+
if (c.object.type === 'ThisExpression') {
529+
result = true;
530+
break;
531+
}
528532
var cur = c;
529533
exam = [];
530534
while (cur.object) {

test/lib/rules/validate-jsdoc/check-return-types.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ describe('lib/rules/validate-jsdoc/check-return-types', function () {
291291
};
292292
};
293293
}
294+
}, {
295+
it: 'should not report on `@returns {Class}` for `new this.*`. issue #115',
296+
code: function () {
297+
/**
298+
* @returns {Element}
299+
*/
300+
function foo() {
301+
return new this.something();
302+
}
303+
}
294304
}
295305
/* jshint ignore:end */
296306
]);

0 commit comments

Comments
 (0)