1

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;
};
4

2 回答 2

3

看起来jscs-jsdoc做到了!它作为 JSCS 的插件提供,您可以在 中包含以下内容.jscsrc

"plugins": ["jscs-jsdoc"],
"jsDoc": {
    "enforceExistence": true
}
于 2015-03-19T16:07:57.970 回答
1

使用 grunt 你可以使用grunt reg ex check

这允许您对内容运行基于正则表达式的检查。github repo 上的示例是测试 console.log 的,但可用于查找没有 jsdoc 注释的函数。

不理想,但会完成这项工作,证明正则表达式符合要求

于 2015-03-19T15:11:00.810 回答