Sha256: 5cdd253d6b869fe258ac845d596b239e7b35b335260b81652b2e6ac42dc69b58

Contents?: true

Size: 1 KB

Versions: 24

Compression:

Stored size: 1 KB

Contents

const postcss = require('postcss');
const _ = require('lodash');

const order = require('./lib/order');
const propertiesOrder = require('./lib/properties-order');
const validateOptions = require('./lib/validateOptions');

module.exports = postcss.plugin('postcss-sorting', function(opts) {
	return function(css) {
		plugin(css, opts);
	};
});

function plugin(css, opts) {
	const validatedOptions = validateOptions(opts);

	if (validatedOptions !== true) {
		const throwValidateErrors = _.get(opts, 'throw-validate-errors', false);

		if (throwValidateErrors) {
			if (_.isString(validatedOptions)) {
				throw new Error(validatedOptions);
			}

			throw new Error(`postcss-sorting: Invalid config.`);
		} else {
			// eslint-disable-next-line no-console
			if (console && console.warn && _.isString(validatedOptions)) {
				console.warn(validatedOptions); // eslint-disable-line no-console
			}

			return;
		}
	}

	if (opts.order) {
		order(css, opts);
	}

	if (opts['properties-order']) {
		propertiesOrder(css, opts);
	}
}

Version data entries

24 entries across 24 versions & 1 rubygems

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