Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jscs-jsdoc

> 编程语言
Open source

JsDoc validation rules for jscs

99 stars0 likes1 views
WebsiteGitHub

About

JsDoc validation rules for jscs

jscs-jsdoc

jsdoc plugin for jscs. Twitter | Mailing List

Table of Contents

  • Installation
  • Versioning & Semver
  • Usage
  • Rules

Plugin installation

NB Since jscs v2.0 the plugin jscs-jsdoc is bundled into it.

jscs-jsdoc can be installed using NPM and requires jscs.

Install it globally if you are using globally installed jscs

npm -g install jscs-jsdoc

But better install it into your project

bash
npm install jscs-jsdoc --save-dev

Versioning & Semver

We recommend installing jscs-jsdoc via NPM using ^, or ~ if you want more stable releases.

Semver (http://semver.org/) dictates that breaking changes be major version bumps. In the context of a linting tool, a bug fix that causes more errors to be reported can be interpreted as a breaking change. However, that would require major version bumps to occur more often than can be desirable. Therefore, as a compromise, we will only release bug fixes that cause more errors to be reported in minor versions.

Below you will find our versioning strategy, and what you can expect to come out of a new jscs-jsdoc release.

  • Patch release:
    • A bug fix in a rule that causes jscs-jsdoc to report less errors;
    • Docs, refactoring and other "invisible" changes for user;
  • Minor release:
    • Any preset changes;
    • A bug fix in a rule that causes jscs-jsdoc to report more errors;
    • New rules or new options for existing rules that don't change existing behavior;
    • Modifying rules so they report less errors, and don't cause build failures;
  • Major release:
    • Purposefully modifying existing rules so that they report more errors or change the meaning of a rule;
    • Any architectural changes that could cause builds to fail.

Usage

To use plugin you should add these lines to configuration file .jscsrc:

json
{
    "plugins": [
        "jscs-jsdoc"
    ],
    "jsDoc": {
        "checkAnnotations": "closurecompiler",
        "checkTypes": "strictNativeCase",
        "enforceExistence": {
            "allExcept": ["exports"]
        }
    }
}

Rules

checkAnnotations

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: *

Tag values

extra field should contains tags in keys and there are options for values:

  • false means tag available with no value
  • true means tag available with any value
  • "some" means tag available and requires some value

See also tag presets.

Example

javascript
"checkAnnotations": true
Valid
javascript
/**
 * @chainable
 * @param {string} message
 * @return {string}
 */
function _f() {}
Invalid
javascript
/**
 * @pororo
 * @lalala
 */
function _f() {}

Example 2

javascript
"checkAnnotations": {
    "preset": "jsdoc3",
    "extra": {
        "boomer": false
    }
}
Valid
javascript
/**
 * @boomer
 * @argument {String}
 */
function _f() {}
Invalid
javascript
/** @still-invalid */

checkParamExistence

Checks all parameters are documented.

Type: Boolean

Values: true

Example

javascript
"checkParamExistence": true
Valid
javascript
/**
 * @param {string} message
 * @return {string}
 */
function _f ( message ) {
  return true;
}

/**
 * @inheritdoc
 */
function _f ( message ) {
  return true;
}
Invalid
javascript
/**
 * @return {string}
 */
function _f ( message ) {
  return true;
}

checkParamNames

Checks param names in jsdoc and in function declaration are equal.

Type: Boolean

Values: true

Context: functions

Tags: param, arg, argument

Example

javascript
"checkParamNames": true
Valid
javascript
/**
 * @param {String} message
 * @param {Number|Object} [line]
 */
function method(message, line) {}
Invalid
javascript
/**
 * @param {String} msg
 * @param {Number|Object} [line]
 */
function method(message) {}

requireParamTypes

Checks params in jsdoc contains type.

Type: Boolean

Values: true

Context: functions

Tags: param, arg, argument

Example

javascript
"requireParamTypes": true
Valid
javascript
/**
 * @param {String} message
 */
function method() {}
Invalid
javascript
/**
 * @param message
 */
function method() {}

checkRedundantParams

Reports redundant params in jsdoc.

Type: Boolean

Values: true

Context: functions

Tags: param, arg, argument

Example

javascript
"checkRedundantParams": true
Valid
javascript
/**
 * @param {String} message
 */
function method(message) {}
Invalid
javascript
/**
 * @param {String} message
 */
function method() {}

checkReturnTypes

Checks for differences between the jsdoc and actual return types if both exist.

Type: Boolean

Values: true

Context: functions

Tags: return, returns

Example

javascript
"checkReturnTypes": true
Valid
javascript
/**
 * @returns {String}
 */
function method() {
    return 'foo';
}
Invalid
javascript
/**
 * @returns {String}
 */
function method(f) {
    if (f) {
        return true;
    }
    return 1;
}

checkRedundantReturns

Report statements for functions without return.

Type: Boolean

Values: true

Context: functions

Tags: return, returns

Example

javascript
"checkRedundantReturns": true
Valid
javascript
/**
 * @returns {string}
 */
function f() {
    return 'yes';
}
Invalid
javascript
/**
 * @returns {string}
 */
function f() {
    // no return here
}

requireReturnTypes

Checks returns in jsdoc contains type

Type: Boolean

Values: true

Context: functions

Tags: return, returns

Example

javascript
"requireReturnTypes": true
Valid
javascript
/**
 * @returns {String}
 */
function method() {}

/**
 * no @return
 */
function method() {}
Invalid
javascript
/**
 * @returns
 */
function method() {}

checkTypes

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

Example

javascript
"checkTypes": true
Valid
javascript
/**
 * @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) {}
Invalid
javascript
/** @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) {}
javascript
/** @type {some~number} */
var x = 1;

checkRedundantAccess

Reports redundant access declarations.

Type: Boolean or String

Values: true or "enforceLeadingUnderscore" or "enforceTrailingUnderscore"

Context: functions

Tags: access, private, protected, public

Example

javascript
"checkRedundantAccess": true
"checkRedundantAccess": "enforceLeadingUnderscore"
Valid for true, "enforceLeadingUnderscore"
javascript
/**
 * @access private
 */
function _f() {}

/**
 * @access public
 */
function f() {}
Invalid for true
javascript
/**
 * @private
 * @access private
 */
function _f() {}
Invalid for "enforceLeadingUnderscore"
javascript
/**
 * @private
 */
function _f() {}

leadingUnderscoreAccess

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

Example

javascript
"leadingUnderscoreAccess": "protected"
Valid
javascript
/**
 * @protected
 */
function _f() {}
Invalid
javascript
function _g() {}

/**
 * @private
 */
function _e() {}

enforceExistence

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 skipped

Context: functions

Example

javascript
"enforceExistence": true
Valid
javascript
/**
 * @protected
 */
function _f() {}
Invalid
javascript
function _g() {}

requireHyphenBeforeDescription

Checks a param description has a hyphen before it (checks for - ).

Type: Boolean

Values: true

Context: functions

Tags: param, arg, argument

Example

javascript
"requireHyphenBeforeDescription": true
Valid
javascript
/**
 * @param {String} - message
 */
function method() {}
Invalid
javascript
/**
 * @param {String} message
 */
function method() {}

requireNewlineAfterDescription

Checks a doc comment description has padding newline.

Type: Boolean

Values: true

Context: functions

Tags: *

Example

javascript
"requireNewlineAfterDescription": true
Valid
javascript
/**
 * @param {String} msg - message
 */
function method(msg) {}

/**
 * Description
 */
function method() {}

/**
 * Description
 *
 * @param {String} msg - message
 */
function method(msg) {}
Invalid
javascript
/**
 * Description
 * @param {String} message
 */
function method() {}

disallowNewlineAfterDescription

Checks a doc comment description has no padding newlines.

Type: Boolean

Values: true

Context: functions

Tags: *

Example

javascript
"disallowNewlineAfterDescription": true
Valid
javascript
/**
 * @param {String} msg - message
 */
function method(msg) {}

/**
 * Description
 */
function method() {}

/**
 * Description
 * @param {String} msg - message
 */
function method(msg) {}
Invalid
javascript
/**
 * Description
 *
 * @param {String} message
 */
function method(message) {}

requireDescriptionCompleteSentence

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: *

Example

javascript
"requireDescriptionCompleteSentence": true
Valid
javascript
/**
 * @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) {}
Invalid
javascript
/**
 * Description
 * @param {

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言