UNPKG

687 BJavaScriptView Raw
1/**
2 * Detect whether a comment is a JSDoc comment: it must be a block
3 * comment which starts with two asterisks, not any other number of asterisks.
4 *
5 * The code parser automatically strips out the first asterisk that's
6 * required for the comment to be a comment at all, so we count the remaining
7 * comments.
8 *
9 * @name isJSDocComment
10 * @param {Object} comment an ast path of the comment
11 * @returns {boolean} whether it is valid
12 */
13module.exports = function isJSDocComment(
14 comment /*: {
15 value: string,
16 type: string
17}*/
18) {
19 const asterisks = comment.value.match(/^(\*+)/);
20 return (
21 comment.type === 'CommentBlock' && asterisks && asterisks[1].length === 1
22 );
23};