Sha256: 59f8cd943fbfdf6296dc3b08af1991eee94171e71d65511dc24436f0474e2258

Contents?: true

Size: 864 Bytes

Versions: 24

Compression:

Stored size: 864 Bytes

Contents

'use strict';

const _ = require('lodash');

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

/**
 * @param {Node} node
 */
function getNodeLine(node) {
	return _.get(node, 'source.start.line');
}

/**
 * @param {import('postcss').Node | void} node
 * @returns {Node | void}
 */
module.exports = function getPreviousNonSharedLineCommentNode(node) {
	if (node === undefined) {
		return undefined;
	}

	const previousNode = node.prev();

	if (!previousNode || _.get(previousNode, 'type') !== 'comment') {
		return previousNode;
	}

	if (getNodeLine(node) === getNodeLine(previousNode)) {
		return getPreviousNonSharedLineCommentNode(previousNode);
	}

	const previousNode2 = previousNode.prev();

	if (previousNode2 && getNodeLine(previousNode) === getNodeLine(previousNode2)) {
		return getPreviousNonSharedLineCommentNode(previousNode);
	}

	return previousNode;
};

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-4.1.8 node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.js
trusty-cms-4.1.7 node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.js
trusty-cms-4.1.6 node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.js
trusty-cms-4.1.5 node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.js