Welcome to mirror list, hosted at ThFree Co, Russian Federation.

beforeBlockString.js « utils « lib « stylelint « node_modules « assets - github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 02beaa0ddea7af89fd6172c3dee58f2bb6795135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'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;
};