Sha256: a0c9f71b14d62784ba24c56cf7e4ee82615f95e780fbd6f870a3900dbb110496

Contents?: true

Size: 1 KB

Versions: 24

Compression:

Stored size: 1 KB

Contents

const postcss = require('postcss');
const shorthandData = require('./shorthandData');

function isShorthand(a, b) {
	const longhands = shorthandData[a] || [];

	return longhands.includes(b);
}

module.exports = function checkAlphabeticalOrder(firstPropData, secondPropData) {
	// OK if the first is shorthand for the second:
	if (isShorthand(firstPropData.unprefixedName, secondPropData.unprefixedName)) {
		return true;
	}

	// Not OK if the second is shorthand for the first:
	if (isShorthand(secondPropData.unprefixedName, firstPropData.unprefixedName)) {
		return false;
	}

	// If unprefixed prop names are the same, compare the prefixed versions
	if (firstPropData.unprefixedName === secondPropData.unprefixedName) {
		// If first property has no prefix and second property has prefix
		if (
			!postcss.vendor.prefix(firstPropData.name).length &&
			postcss.vendor.prefix(secondPropData.name).length
		) {
			return false;
		}

		return true;
	}

	return firstPropData.unprefixedName < secondPropData.unprefixedName;
};

Version data entries

24 entries across 24 versions & 1 rubygems

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