Sha256: 3693215cdbe71fc48cb4013692fae9bec996b9b3c8a8a4e098cba897581e5cca

Contents?: true

Size: 961 Bytes

Versions: 24

Compression:

Stored size: 961 Bytes

Contents

'use strict';

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

/**
 * @param {Rule | AtRule} statement
 * @param {{
 * 	noRawBefore?: boolean
 * }} options
 *
 * @returns {string}
 */
module.exports = function (statement, options = {}) {
	let result = '';
	/** @type {Rule | undefined} */
	let rule; /*?: postcss$rule*/
	/** @type {AtRule | undefined} */
	let atRule; /*?: postcss$atRule*/

	if (statement.type === 'rule') {
		rule = statement;
	}

	if (statement.type === 'atrule') {
		atRule = statement;
	}

	if (!rule && !atRule) {
		return result;
	}

	const before = statement.raws.before || '';

	if (!options.noRawBefore) {
		result += before;
	}

	if (rule) {
		result += rule.selector;
	}

	if (atRule) {
		result += `@${atRule.name}${atRule.raws.afterName || ''}${atRule.params}`;
	}

	const between = statement.raws.between;

	if (between !== undefined) {
		result += between;
	}

	return result;
};

Version data entries

24 entries across 24 versions & 1 rubygems

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