UNPKG

stylelint-sassdoc

Version:

stylelint plugin to check scss files for a valid sassdoc documentation Credits to https://github.com/anneangersbach

28 lines (25 loc) 865 B
const adjacentLineIsSCSSComment = require('./adjacentLineIsSCSSComment'); const regExCheck = require('./regExCheck'); /** * Checks the preceding comment nodes for @type * @param {Node} node - the current node */ let results = []; module.exports = function checkCommentsForType(node, tail = 0) { const previousNode = node.prev(); if (tail === 0) { results = []; } if (adjacentLineIsSCSSComment(node)) { // check for @type if (regExCheck(previousNode, /@type .+/)) { const returnComment = {}; returnComment.returnOnLine = previousNode.source.start.line; returnComment.node = previousNode; results.push(returnComment); } // continue with any comments preceding this one return checkCommentsForType(previousNode, tail + 1); } return results; };