Sha256: dd10fd9a6fa875e1598a01ceed2b6421dc47b502f8b8cf2b459c822f2510cf5a

Contents?: true

Size: 1.33 KB

Versions: 24

Compression:

Stored size: 1.33 KB

Contents

let stylelint = require('stylelint');
let _ = require('lodash');
let postcss = require('postcss');
let checkAlphabeticalOrder = require('../checkAlphabeticalOrder');
let { isStandardSyntaxProperty, isCustomProperty } = require('../../utils');

module.exports = function checkNode(node, result, ruleName, messages) {
	let allPropData = [];

	node.each(function processEveryNode(child) {
		if (child.type !== 'decl') {
			return;
		}

		let { prop } = child;

		if (!isStandardSyntaxProperty(prop)) {
			return;
		}

		if (isCustomProperty(prop)) {
			return;
		}

		let unprefixedPropName = postcss.vendor.unprefixed(prop);

		// Hack to allow -moz-osx-font-smoothing to be understood
		// just like -webkit-font-smoothing
		if (unprefixedPropName.startsWith('osx-')) {
			unprefixedPropName = unprefixedPropName.slice(4);
		}

		let propData = {
			name: prop,
			unprefixedName: unprefixedPropName,
			index: allPropData.length,
			node: child,
		};

		let previousPropData = _.last(allPropData);

		allPropData.push(propData);

		// Skip first decl
		if (!previousPropData) {
			return;
		}

		let isCorrectOrder = checkAlphabeticalOrder(previousPropData, propData);

		if (isCorrectOrder) {
			return;
		}

		stylelint.utils.report({
			message: messages.expected(propData.name, previousPropData.name),
			node: child,
			result,
			ruleName,
		});
	});
};

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.7 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.6 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.5 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.4 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.3 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.2 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.1 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3.5 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-5.0.0 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3.4 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3.3 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3.2 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3.1 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.3 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.2.3 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.2.2 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.2.1 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.2 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js
trusty-cms-4.1.9 node_modules/stylelint-order/rules/properties-alphabetical-order/checkNode.js