Sha256: d267d33ae24f246dcaa2841bfa6112a3e4cedafeabdc59712956d8da7b042ec4

Contents?: true

Size: 566 Bytes

Versions: 24

Compression:

Stored size: 566 Bytes

Contents

'use strict';

/** @typedef {import('postcss').ChildNode} ChildNode */

/**
 * Add an empty line before a node. Mutates the node.
 *
 * @param {ChildNode} node
 * @param {'\n' | '\r\n'} newline
 * @returns {ChildNode}
 */
function addEmptyLineBefore(node, newline) {
	if (node.raws.before === undefined) {
		return node;
	}

	if (!/\r?\n/.test(node.raws.before)) {
		node.raws.before = newline.repeat(2) + node.raws.before;
	} else {
		node.raws.before = node.raws.before.replace(/(\r?\n)/, `${newline}$1`);
	}

	return node;
}

module.exports = addEmptyLineBefore;

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.7 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.6 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.5 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.4 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.3 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.2 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.1 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3.5 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-5.0.0 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3.4 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3.3 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3.2 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3.1 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.3 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.2.3 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.2.2 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.2.1 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.2 node_modules/stylelint/lib/utils/addEmptyLineBefore.js
trusty-cms-4.1.9 node_modules/stylelint/lib/utils/addEmptyLineBefore.js