stylelint-sassdoc
Version:
stylelint plugin to check scss files for a valid sassdoc documentation Credits to https://github.com/anneangersbach
28 lines (25 loc) • 880 B
JavaScript
const adjacentLineIsSCSSComment = require('./adjacentLineIsSCSSComment');
const regExCheck = require('./regExCheck');
/**
* Checks the suceeding comment nodes for @group-name
* @param {Node} node - the current node
*/
let results = [];
module.exports = function checkCommentsForGroupName(node, tail = 0) {
const nextNode = node.next();
if (tail === 0) {
results = [];
}
if (adjacentLineIsSCSSComment(node, false)) {
// check for @group-name
if (regExCheck(nextNode, /@group-name .+/)) {
const returnComment = {};
returnComment.returnOnLine = nextNode.source.start.line;
returnComment.node = nextNode;
results.push(returnComment);
}
// continue with any comments preceding this one
return checkCommentsForGroupName(nextNode, tail + 1);
}
return results;
};