当JSDoc在我们的JS文档中缺少某些参数时,我希望我们的皮棉机接起来。例如,我能够使JSDoc抱怨缺少 param 或 returns 标记,但不能针对 public / private / static / classdesc 或函数。有效代码示例:
/**
* A cool function
*
* @param {function} fnCallback Callback to call after something cool
* @public
* @static
* @function beCool
*/
Cool.beCool = function (fnCallback) {
无效代码示例:
/**
* A cool function
*
* @param {function} fnCallback Callback to call after something cool
*
*/
Cool.beCool = function (fnCallback) {
规则如下:
//
// JSDoc
//
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": false,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
}
}],
"valid-jsdoc": ["error", {
"matchDescription": ".+",
"prefer": {
"arg": "param",
"argument": "param",
"class": "class",
"return": "returns",
"virtual": "abstract"
},
"preferType": {
"Boolean": "boolean",
"Number": "number",
"object": "Object",
"String": "string",
"Any": "any",
"Function": "function",
"RegExp": "regexp",
"date": "Date",
"array": "Array",
"promise": "Promise",
"map": "Map"
},
"requireReturn": false,
"requireReturnType": true,
"requireParamDescription": true,
"requireParamType": true
}]
}