mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
* style(prettier): Use prettier for code formatting This saves us style issues. Also adds husky and lint-staged for pre-commit testing Refs https://github.com/documentationjs/documentation/issues/709
28 lines
783 B
JavaScript
28 lines
783 B
JavaScript
'use strict';
|
|
/* @flow */
|
|
|
|
/**
|
|
* Detect whether a comment is a JSDoc comment: it must be a block
|
|
* comment which starts with two asterisks, not any other number of asterisks.
|
|
*
|
|
* The code parser automatically strips out the first asterisk that's
|
|
* required for the comment to be a comment at all, so we count the remaining
|
|
* comments.
|
|
*
|
|
* @name isJSDocComment
|
|
* @param {Object} comment an ast path of the comment
|
|
* @return {boolean} whether it is valid
|
|
*/
|
|
module.exports = function isJSDocComment(
|
|
comment /*: {
|
|
value: string,
|
|
type: string
|
|
}*/
|
|
) {
|
|
var asterisks = comment.value.match(/^(\*+)/);
|
|
return (comment.type === 'CommentBlock' || // estree
|
|
comment.type === 'Block') && // get-comments / traditional
|
|
asterisks &&
|
|
asterisks[1].length === 1;
|
|
};
|