123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 'use strict';
- const declarationValueIndex = require('../utils/declarationValueIndex');
- const isStandardSyntaxDeclaration = require('../utils/isStandardSyntaxDeclaration');
- const report = require('../utils/report');
- module.exports = function declarationColonSpaceChecker(opts) {
- opts.root.walkDecls((decl) => {
- if (!isStandardSyntaxDeclaration(decl)) {
- return;
- }
-
- const endOfPropIndex = declarationValueIndex(decl) + (decl.raws.between || '').length - 1;
-
-
- 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: (message) => {
- if (opts.fix && opts.fix(decl, i)) {
- return;
- }
- report({
- message,
- node: decl,
- index: decl.prop.toString().length + 1,
- result: opts.result,
- ruleName: opts.checkedRuleName,
- });
- },
- });
- break;
- }
- });
- };
|