Validate jsdoc comments
{
"jsDoc": {
"checkAnnotations": "closurecompiler",
"checkTypes": "strictNativeCase",
"enforceExistence": "exceptExports"
...
}
}
Checks tag names are valid.
There are 3 presets for Closure Compiler
, JSDoc3
and JSDuck5
.
By default it allows any tag from any preset. You can pass Object
to select preset with preset
field and add custom tags with extra
field.
Type: Boolean
or String
or {"preset": String, "extra": Object}
(see tag values).
Values: true
, "closurecompiler"
, "jsdoc3"
, "jsduck5"
, Object
Context: file
Tags: *
extra
field should contains tags in keys and there are options for values:
false
means tag available with no valuetrue
means tag available with any value"some"
means tag available and requires some valueSee also tag presets.
"checkAnnotations": true
/**
* @chainable
* @param {string} message
* @return {string}
*/
function _f() {}
/**
* @pororo
* @lalala
*/
function _f() {}
"checkAnnotations": {
"preset": "jsdoc3",
"extra": {
"boomer": false
}
}
/**
* @boomer
* @argument {String}
*/
function _f() {}
/** @still-invalid */
Checks all parameters are documented.
Type: Boolean
Values: true
"checkParamExistence": true
/**
* @param {string} message
* @return {string}
*/
function _f ( message ) {
return true;
}
/**
* @inheritdoc
*/
function _f ( message ) {
return true;
}
/**
* @return {string}
*/
function _f ( message ) {
return true;
}
Checks param names in jsdoc and in function declaration are equal.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"checkParamNames": true
/**
* @param {String} message
* @param {Number|Object} [line]
*/
function method(message, line) {}
/**
* @param {String} msg
* @param {Number|Object} [line]
*/
function method(message) {}
Checks params in jsdoc contains type.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireParamTypes": true
/**
* @param {String} message
*/
function method() {}
/**
* @param message
*/
function method() {}
Reports redundant params in jsdoc.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"checkRedundantParams": true
/**
* @param {String} message
*/
function method(message) {}
/**
* @param {String} message
*/
function method() {}
Checks for differences between the jsdoc and actual return types if both exist.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"checkReturnTypes": true
/**
* @returns {String}
*/
function method() {
return 'foo';
}
/**
* @returns {String}
*/
function method(f) {
if (f) {
return true;
}
return 1;
}
Report statements for functions without return.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"checkRedundantReturns": true
/**
* @returns {string}
*/
function f() {
return 'yes';
}
/**
* @returns {string}
*/
function f() {
// no return here
}
Checks returns in jsdoc contains type
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"requireReturnTypes": true
/**
* @returns {String}
*/
function method() {}
/**
* no @return
*/
function method() {}
/**
* @returns
*/
function method() {}
Reports invalid types for bunch of tags.
The strictNativeCase
mode checks that case of natives is the same as in this
list: boolean
, number
, string
, Object
, Array
, Date
, RegExp
.
The capitalizedNativeCase
mode checks that the first letter in all native
types and primitives is uppercased except the case with function
in google
closure format: {function(...)}
Type: Boolean
or String
Values: true
or "strictNativeCase"
or "capitalizedNativeCase"
Context: *
Tags: typedef
, type
, param
, return
, returns
, enum
, var
, prop
,
property
, arg
, argument
, cfg
, lends
, extends
, implements
, define
"checkTypes": true
/**
* @typedef {Object} ObjectLike
* @property {boolean} hasFlag
* @property {string} name
*/
/** @type {number} */
var bar = 1;
/** @const {number} */
var FOO = 2;
/**
* @const
* @type {number}
*/
var BAZ = 3;
/**
* @param {SomeX} x
* @returns {string}
*/
function method(x) {}
/** @type {some~number} */
var x = 1;
/**
* @param {function(redundantName: Number)} x
*/
function method(x) {}
/**
* @param {Number|Boolean|object|array} x invalid for strictNativeCase
*/
function method(x) {}
/** @type {some~number} */
var x = 1;
Reports redundant access declarations.
Type: Boolean
or String
Values: true
or "enforceLeadingUnderscore"
or "enforceTrailingUnderscore"
Context: functions
Tags: access
, private
, protected
, public
"checkRedundantAccess": true
"checkRedundantAccess": "enforceLeadingUnderscore"
/**
* @access private
*/
function _f() {}
/**
* @access public
*/
function f() {}
/**
* @private
* @access private
*/
function _f() {}
/**
* @private
*/
function _f() {}
Checks access declaration is set for _underscored
function names
Ignores a bunch of popular identifiers:
__filename
, __dirname
, __proto__
, __defineGetter__
, super_
,
__constructor
, etc.
Type: Boolean
or String
Values: true
(means not public), "private"
, "protected"
Context: functions
Tags: access
, private
, protected
, public
"leadingUnderscoreAccess": "protected"
/**
* @protected
*/
function _f() {}
function _g() {}
/**
* @private
*/
function _e() {}
Checks jsdoc block exists.
Type: Boolean
, String
or Object
Values:
true
"exceptExports"
(deprecated use "allExcept": ["exports"]
)Object
:"allExcept"
array of exceptions:"expressions"
skip expression functions"exports"
skip module.exports = function () {};
"paramless-procedures"
functions without parameters and with empty
return statements will be skippedContext: functions
"enforceExistence": true
/**
* @protected
*/
function _f() {}
function _g() {}
Checks a param description has a hyphen before it (checks for -
).
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireHyphenBeforeDescription": true
/**
* @param {String} - message
*/
function method() {}
/**
* @param {String} message
*/
function method() {}
Checks a doc comment description has padding newline.
Type: Boolean
Values: true
Context: functions
Tags: *
"requireNewlineAfterDescription": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*/
function method() {}
/**
* Description
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* @param {String} message
*/
function method() {}
Checks a doc comment description has no padding newlines.
Type: Boolean
Values: true
Context: functions
Tags: *
"disallowNewlineAfterDescription": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*/
function method() {}
/**
* Description
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*
* @param {String} message
*/
function method(message) {}
Checks a doc comment description is a complete sentence.
A complete sentence is defined as starting with an upper case letter and ending with a period.
Type: Boolean
Values: true
Context: functions
Tags: *
"requireDescriptionCompleteSentence": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description.
*/
function method() {}
/**
* (Description).
*/
function method() {}
/**
* Description.
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* on multiple lines are allowed.
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* @param {String} message
*/
function method() {}
/**
* Description
* On multiple lines should not start with an upper case.
*
* @param {String} - message
*/
function method() {}
/**
* description starting with a lower case letter.
* @param {String} message
*/
function method() {}
/**
* Description period is offset .
* @param {String} message
*/
function method() {}
/**
* Description!
* @param {String} message
*/
function method() {}
Checks a param description exists.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireParamDescription": true
/**
* @param {String} arg message
*/
function method(arg) {}
/**
* @param arg message
*/
function method(arg) {}
/**
* @param {String} arg
*/
function method(arg) {}
/**
* @param arg
*/
function method(arg) {}
Checks a return description exists.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"requireReturnDescription": true
/**
* @returns {Boolean} Method result.
*/
function method() {
return false;
}
/**
* @returns {String} method result
*/
function method() {
return 'Hello!';
}
/**
* @returns {Boolean}
*/
function method() {
return false;
}