JSPM

eslint-plugin-jsdoc

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2795845
  • Score
    100M100P100Q200280F
  • License BSD-3-Clause

JSDoc specific linting rules for ESLint.

Package Exports

  • eslint-plugin-jsdoc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-jsdoc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

eslint-plugin-jsdoc

Travis build status NPM version

JSDoc specific linting rules for ESLint.

Attribution

Unusual, but I want to start the documentation with attribution to JSCS: JavaScript Code Style checker. This ESLint plugin is a wrapper around JSCS and the jscs-jsdoc plugin.

The reason for writing this plugin is to have all the linting rules in a consistent, plugin driven setup, that ESLint provides.

Thank you @zxqfox and others.

Installation

Install ESLint either locally or globally.

$ npm install eslint

If you have installed ESLint globally, you have to install JSDoc plugin globally too. Otherwise, install it locally.

$ npm install eslint-plugin-jsdoc

Configuration

Add plugins section and specify eslint-plugin-jsdoc as a plugin.

{
    "plugins": [
        "jsdoc"
    ]
}

Finally, enable all of the rules that you would like to use.

{
    "rules": {
        "jsdoc/check-param-names": 1,
        "jsdoc/check-redundant-params": 1,
        "jsdoc/check-redundant-returns": 1,
        "jsdoc/require-return-types": 1,
        "jsdoc/newline-after-description": 1,
        "jsdoc/require-description-complete-sentence": 1,
        "jsdoc/require-param-description": 1,
        "jsdoc/require-param-types": 1,
        "jsdoc/require-return-types": 1
    }
}

Rules

check-param-names

Ensures param names in JSDoc and in function declaration are equal.

The following patterns are considered problems:

/**
 * @param foo
 * @param bar
 */
function quux (bar, foo) {

}

/**
 * @param foo
 */
function quux (bar) {

}

The following patterns are not considered problems:

/**
 * @param foo
 * @param bar
 */
function quux (foo, bar) {

}

/**
 * @param foo
 */
function quux (foo) {

}

check-redundant-params

Reports redundant params in JSDoc.

The following patterns are considered problems:

/**
 * @param {String} foo
 */
function quux () {

}

The following patterns are not considered problems:

/**
 * @param {String} foo
 */
function quux (foo) {

}

check-redundant-returns

Report statements for functions with no return.

The following patterns are considered problems:

/**
 * @returns {String}
 */
function quux () {

}

The following patterns are not considered problems:

/**
 * @returns {String}
 */
function quux () {
    return 'corge';
}

require-return-types

Ensures returns in JSDoc contains type.

The following patterns are considered problems:

/**
 * @returns
 */
function quux () {

}

The following patterns are not considered problems:

/**
 * @returns {String}
 */
function quux () {

}

/**
 * no @return
 */
function quux () {

}

newline-after-description

Enforces consistent padding of doc comment description.

This rule takes one argument. If it is "always" then a problem is raised when there is a newline after description. If it is "never" then a problem is raised when there is no newline after the description. The default value is "always".

The following patterns are considered problems when configured "never":

/**
 * Description
 *
 * @param {String} foo
 */
function quux (foo) {

}

The following patterns are not considered problems when configured "never":

/**
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description
 */
function quux () {

}

/**
 * Description
 * @param {String} foo
 */
function quux (foo) {

}

The following patterns are considered problems when configured "always":

/**
 * Description
 * @param {String} foo
 */
function quux (foo) {

}

The following patterns are not considered problems when configured "always":

/**
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description
 */
function quux () {

}

/**
 * Description
 *
 * @param {String} foo
 */
function quux (foo) {

}

require-description-complete-sentence

Ensures 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.

The following patterns are considered problems:

/**
 * Description
 * On multiple lines.
 *
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * description starting with a lower case letter.
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description period is offset .
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description!
 * @param {String} foo
 */
function quux (foo) {

}

The following patterns are not considered problems:

/**
 * @param {String} foo
 */
function quux (foo) {

}

/**
 * Description.
 */
function quux () {

}

/**
 * (Description).
 */
function quux () {

}

/**
 * Description.
 *
 * @param {String} foo
 */
function quux (foo) {

}

require-param-description

Ensures a param description exists.

The following patterns are considered problems:

/**
 * @param {String} foo
 */
function quux (foo) {}

/**
 * @param foo
 */
function quux (foo) {

}

The following patterns are not considered problems:

/**
 * @param {String} foo Foo.
 */
function quux (foo) {

}

/**
 * @param foo Foo.
 */
function quux (foo) {

}

require-param-types

The following patterns are considered problems:

/**
 * @param foo
 */
function quux () {

}

The following patterns are not considered problems:

/**
 * @param {String} foo
 */
function quux () {

}

check-return-types

Reports discrepancies between the claimed in JSDoc and actual type if both exist (code scan).

The following patterns are considered problems:

/**
 * @returns {String}
 */
function quux () {
    return true;
}

The following patterns are not considered problems:

/**
 * @returns {String}
 */
function quux () {
    return 'corge';
}