removeEmptyLinesAfter.js 387 B

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