Sha256: 976080cfc27af48b0127f2dba17e97a90d55efcca2ccb5dea6315788eb1ffe0e

Contents?: true

Size: 1.19 KB

Versions: 24

Compression:

Stored size: 1.19 KB

Contents

const stylelint = require('stylelint');
const checkOrder = require('./checkOrder');
const getOrderData = require('./getOrderData');

module.exports = function checkNode(node, sharedInfo) {
	let allNodesData = [];

	node.each(function processEveryNode(child) {
		// Skip comments
		if (child.type === 'comment') {
			return;
		}

		// Receive node description and expectedPosition
		let nodeOrderData = getOrderData(sharedInfo.orderInfo, child);

		let nodeData = {
			node: child,
			description: nodeOrderData.description,
			expectedPosition: nodeOrderData.expectedPosition,
		};

		allNodesData.push(nodeData);

		let previousNodeData = allNodesData[allNodesData.length - 2];

		// Skip first node
		if (!previousNodeData) {
			return;
		}

		let isCorrectOrder = checkOrder(previousNodeData, nodeData, allNodesData, sharedInfo);

		if (isCorrectOrder) {
			return;
		}

		if (sharedInfo.isFixEnabled) {
			sharedInfo.shouldFix = true;

			// Don't go further, fix will be applied
			return;
		}

		stylelint.utils.report({
			message: sharedInfo.messages.expected(nodeData.description, previousNodeData.description),
			node: child,
			result: sharedInfo.result,
			ruleName: sharedInfo.ruleName,
		});
	});
};

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-4.1.8 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.1.7 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.1.6 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.1.5 node_modules/stylelint-order/rules/order/checkNode.js