Skip to content
Permalink
Browse files

Fix: do not require a @return tag for @interface (fixes #4860)

  • Loading branch information...
tschaub committed Jan 5, 2016
1 parent 009a949 commit 5b7586bb2ea107d4097043d6b3362a24a0158483
Showing with 15 additions and 1 deletion.
  1. +6 −1 lib/rules/valid-jsdoc.js
  2. +9 −0 tests/lib/rules/valid-jsdoc.js
@@ -92,6 +92,7 @@ module.exports = function(context) {
functionData = fns.pop(),
hasReturns = false,
hasConstructor = false,
isInterface = false,
isOverride = false,
params = Object.create(null),
jsdoc;
@@ -166,6 +167,10 @@ module.exports = function(context) {
isOverride = true;
break;

case "interface":
isInterface = true;
break;

// no default
}

@@ -177,7 +182,7 @@ module.exports = function(context) {
});

// check for functions missing @returns
if (!isOverride && !hasReturns && !hasConstructor && node.parent.kind !== "get" && !isTypeClass(node)) {
if (!isOverride && !hasReturns && !hasConstructor && !isInterface && node.parent.kind !== "get" && !isTypeClass(node)) {
if (requireReturn || functionData.returnPresent) {
context.report(jsdocNode, "Missing JSDoc @" + (prefer.returns || "returns") + " for function.");
}
@@ -126,6 +126,15 @@ ruleTester.run("valid-jsdoc", rule, {
code: "/** Foo \n@return Foo\n */\nfunction foo(){}",
options: [{ requireReturnType: false }]
},
{
code:
"/**\n" +
" * A thing interface. \n" +
" * @interface\n" +
" */\n" +
"function Thing() {}",
options: [{ requireReturn: true }]
},

// classes
{

0 comments on commit 5b7586b

Please sign in to comment.
You can’t perform that action at this time.