removeEmptyLinesBefore.js 364 B

123456789101112131415
  1. 'use strict';
  2. /**
  3. * Remove empty lines before a node. Mutates the node.
  4. *
  5. * @template {import('postcss').Node} T
  6. * @param {T} node
  7. * @param {string} newline
  8. * @returns {T}
  9. */
  10. module.exports = function removeEmptyLinesBefore(node, newline) {
  11. node.raws.before = node.raws.before ? node.raws.before.replace(/(\r?\n\s*\n)+/g, newline) : '';
  12. return node;
  13. };