4
0

getNextNonSharedLineCommentNode.cjs 889 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. /** @typedef {import('postcss').Node} Node */
  5. /**
  6. * @param {Node | void} node
  7. */
  8. function getNodeLine(node) {
  9. return node && node.source && node.source.start && node.source.start.line;
  10. }
  11. /**
  12. * @param {Node | void} node
  13. * @returns {Node | void}
  14. */
  15. function getNextNonSharedLineCommentNode(node) {
  16. if (node === undefined) {
  17. return undefined;
  18. }
  19. /** @type {Node | void} */
  20. const nextNode = node.next();
  21. if (!nextNode || nextNode.type !== 'comment') {
  22. return nextNode;
  23. }
  24. if (
  25. getNodeLine(node) === getNodeLine(nextNode) ||
  26. getNodeLine(nextNode) === getNodeLine(nextNode.next())
  27. ) {
  28. return getNextNonSharedLineCommentNode(nextNode);
  29. }
  30. return nextNode;
  31. }
  32. module.exports = getNextNonSharedLineCommentNode;