function checkJSDoc(node){var jsdocNode=sourceCode.getJSDocComment(node),functionData=fns.pop(),params=(0,_create4.default)(null);var hasReturns=false,hasConstructor=false,isInterface=false,isOverride=false,isAbstract=false,jsdoc=void 0;// make sure only to validate JSDoc comments
if(jsdocNode){try{jsdoc=doctrine.parse(jsdocNode.value,{strict:true,unwrap:true,sloppy:true});}catch(ex){if(/braces/i.test(ex.message)){context.report({node:jsdocNode,message:"JSDoc type missing brace."});}else{context.report({node:jsdocNode,message:"JSDoc syntax error."});}return;}jsdoc.tags.forEach(function(tag){switch(tag.title.toLowerCase()){case"param":case"arg":case"argument":if(!tag.type){context.report({node:jsdocNode,message:"Missing JSDoc parameter type for '{{name}}'.",data:{name:tag.name}});}if(!tag.description&&requireParamDescription){context.report({node:jsdocNode,message:"Missing JSDoc parameter description for '{{name}}'.",data:{name:tag.name}});}if(params[tag.name]){context.report({node:jsdocNode,message:"Duplicate JSDoc parameter '{{name}}'.",data:{name:tag.name}});}else if(tag.name.indexOf(".")===-1){params[tag.name]=1;}break;case"return":case"returns":hasReturns=true;if(!requireReturn&&!functionData.returnPresent&&(tag.type===null||!isValidReturnType(tag))&&!isAbstract){context.report({node:jsdocNode,message:"Unexpected @{{title}} tag; function has no return statement.",data:{title:tag.title}});}else{if(requireReturnType&&!tag.type){context.report({node:jsdocNode,message:"Missing JSDoc return type."});}if(!isValidReturnType(tag)&&!tag.description&&requireReturnDescription){context.report({node:jsdocNode,message:"Missing JSDoc return description."});}}break;case"constructor":case"class":hasConstructor=true;break;case"override":case"inheritdoc":isOverride=true;break;case"abstract":case"virtual":isAbstract=true;break;case"interface":isInterface=true;break;// no default
}// check tag preferences
if(prefer.hasOwnProperty(tag.title)&&tag.title!==prefer[tag.title]){context.report({node:jsdocNode,message:"Use @{{name}} instead.",data:{name:prefer[tag.title]}});}// validate the types
if(checkPreferType&&tag.type){validateType(jsdocNode,tag.type);}});// check for functions missing @returns
if(!isOverride&&!hasReturns&&!hasConstructor&&!isInterface&&node.parent.kind!=="get"&&node.parent.kind!=="constructor"&&node.parent.kind!=="set"&&!isTypeClass(node)){if(requireReturn||functionData.returnPresent){context.report({node:jsdocNode,message:"Missing JSDoc @{{returns}} for function.",data:{returns:prefer.returns||"returns"}});}}// check the parameters
var jsdocParams=(0,_keys4.default)(params);if(node.params){node.params.forEach(function(param,i){if(param.type==="AssignmentPattern"){param=param.left;}var name=param.name;// TODO(nzakas): Figure out logical things to do with destructured, default, rest params
if(param.type==="Identifier"){if(jsdocParams[i]&&name!==jsdocParams[i]){context.report({node:jsdocNode,message:"Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",data:{name:name,jsdocName:jsdocParams[i]}});}else if(!params[name]&&!isOverride){context.report({node:jsdocNode,message:"Missing JSDoc for parameter '{{name}}'.",data:{name:name}});}}});}if(options.matchDescription){var regex=new RegExp(options.matchDescription);if(!regex.test(jsdoc.description)){context.report({node:jsdocNode,message:"JSDoc description does not satisfy the regex pattern."});}}}}//--------------------------------------------------------------------------
Validate the JSDoc node and output warnings if anything is wrong.
@param {ASTNode} node The AST node to check.
@returns {void}
@private