Sha256: cdc0897726f4cf5413fe14a1b22e67a8c874d715019caceb51eb8ab93d8daeab

Contents?: true

Size: 1.19 KB

Versions: 23

Compression:

Stored size: 1.19 KB

Contents

'use strict';

const declarationValueIndex = require('../utils/declarationValueIndex');
const isStandardSyntaxDeclaration = require('../utils/isStandardSyntaxDeclaration');
const report = require('../utils/report');

module.exports = function (opts) {
	opts.root.walkDecls((decl) => {
		if (!isStandardSyntaxDeclaration(decl)) {
			return;
		}

		// Get the raw prop, and only the prop
		const endOfPropIndex = declarationValueIndex(decl) + (decl.raws.between || '').length - 1;

		// The extra characters tacked onto the end ensure that there is a character to check
		// after the colon. Otherwise, with `background:pink` the character after the
		const propPlusColon = `${decl.toString().slice(0, endOfPropIndex)}xxx`;

		for (let i = 0, l = propPlusColon.length; i < l; i++) {
			if (propPlusColon[i] !== ':') {
				continue;
			}

			opts.locationChecker({
				source: propPlusColon,
				index: i,
				lineCheckStr: decl.value,
				err: (m) => {
					if (opts.fix && opts.fix(decl, i)) {
						return;
					}

					report({
						message: m,
						node: decl,
						index: decl.prop.toString().length + 1,
						result: opts.result,
						ruleName: opts.checkedRuleName,
					});
				},
			});
			break;
		}
	});
};

Version data entries

23 entries across 23 versions & 1 rubygems

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