stylelint
Version:
A mighty, modern CSS linter.
33 lines (25 loc) • 693 B
JavaScript
/* @flow */
;
const _ = require("lodash");
function getNodeLine(node /*:: ?: postcss$node*/) /*: number | void*/ {
return _.get(node, "source.start.line");
}
module.exports = function getNextNonSharedLineCommentNode(
node /*:: ?: postcss$node*/
) /*: postcss$node | void*/ {
if (node === undefined) {
return undefined;
}
const nextNode = node.next();
if (_.get(nextNode, "type") !== "comment") {
return nextNode;
}
if (
getNodeLine(node) === getNodeLine(nextNode) ||
(nextNode !== undefined &&
getNodeLine(nextNode) === getNodeLine(nextNode.next()))
) {
return getNextNonSharedLineCommentNode(nextNode);
}
return nextNode;
};