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-6.3.1 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.7 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.6 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.5 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.4 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.3 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.2 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.1 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3.5 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-5.0.0 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3.4 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3.3 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3.2 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3.1 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.3 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.2.3 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.2.2 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.2.1 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.2 node_modules/stylelint-order/rules/order/checkNode.js
trusty-cms-4.1.9 node_modules/stylelint-order/rules/order/checkNode.js