Sha256: 6f813286f7d8c7e8d53ec123e0d2dafcde3a7b62f04b2aab77029dd43e51fef2

Contents?: true

Size: 1.01 KB

Versions: 24

Compression:

Stored size: 1.01 KB

Contents

const stylelint = require('stylelint');
const _ = require('lodash');
const hasEmptyLineBefore = require('./hasEmptyLineBefore');
const removeEmptyLinesBefore = require('./removeEmptyLinesBefore');

module.exports = function checkEmptyLineBeforeFirstProp(propData, sharedInfo) {
	let emptyLineBefore = false;

	if (propData.orderData) {
		// Get an array of just the property groups, remove any solo properties
		let groups = _.reject(sharedInfo.primaryOption, _.isString);

		emptyLineBefore = _.get(groups[propData.orderData.separatedGroup - 2], 'emptyLineBefore');
	} else if (sharedInfo.emptyLineBeforeUnspecified) {
		emptyLineBefore = true;
	}

	if (emptyLineBefore && hasEmptyLineBefore(propData.node)) {
		if (sharedInfo.isFixEnabled) {
			removeEmptyLinesBefore(propData.node, sharedInfo.context.newline);
		} else {
			stylelint.utils.report({
				message: sharedInfo.messages.rejectedEmptyLineBefore(propData.name),
				node: propData.node,
				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/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.7 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.6 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.5 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.4 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.3 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.2 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.1 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3.5 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-5.0.0 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3.4 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3.3 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3.2 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3.1 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.3 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.2.3 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.2.2 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.2.1 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.2 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js
trusty-cms-4.1.9 node_modules/stylelint-order/rules/properties-order/checkEmptyLineBeforeFirstProp.js