Sha256: fa1282c23b0aa22ad76e4c3c1fa9c1aa9cc77579a8d999140563832538ab259a

Contents?: true

Size: 1.33 KB

Versions: 24

Compression:

Stored size: 1.33 KB

Contents

const _ = require('lodash');

module.exports = function validatePrimaryOption(actualOptions) {
	// Begin checking array options
	if (!Array.isArray(actualOptions)) {
		return false;
	}

	// Every item in the array must be a string or an object
	// with a "properties" property
	if (
		!actualOptions.every(item => {
			if (_.isString(item)) {
				return true;
			}

			return _.isPlainObject(item) && !_.isUndefined(item.properties);
		})
	) {
		return false;
	}

	const objectItems = actualOptions.filter(_.isPlainObject);

	// Every object-item's "properties" should be an array with no items, or with strings
	if (
		!objectItems.every(item => {
			if (!Array.isArray(item.properties)) {
				return false;
			}

			return item.properties.every(property => _.isString(property));
		})
	) {
		return false;
	}

	// Every object-item's "emptyLineBefore" must be "always" or "never"
	if (
		!objectItems.every(item => {
			if (_.isUndefined(item.emptyLineBefore)) {
				return true;
			}

			return ['always', 'never', 'threshold'].includes(item.emptyLineBefore);
		})
	) {
		return false;
	}

	// Every object-item's "noEmptyLineBetween" must be a boolean
	if (
		!objectItems.every(item => {
			if (_.isUndefined(item.noEmptyLineBetween)) {
				return true;
			}

			return _.isBoolean(item.noEmptyLineBetween);
		})
	) {
		return false;
	}

	return true;
};

Version data entries

24 entries across 24 versions & 1 rubygems

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