Search code examples
javascriptjsdocjscs

Require JSDoc on all functions with JSCS


I'm using JSCS to enforce a consistent code style in one of my projects.

Is there a way to use JSCS to check that every function has some JSDoc?

Something that would say this is invalid:

var add = function(x, y) {
    return x + y;
};

But this is valid:

/**
 * Adds two numbers together
 * @param {number} x
 * @param {number} y
 * @returns The sum of x and y
 */
var add = function(x, y) {
    return x + y;
};

Solution

  • It looks like jscs-jsdoc does it! It comes as a plugin for JSCS, and you can include the following in your .jscsrc:

    "plugins": ["jscs-jsdoc"],
    "jsDoc": {
        "enforceExistence": true
    }