1 | 'use strict';
|
2 |
|
3 | const declarationValueIndex = require('../utils/declarationValueIndex');
|
4 | const isStandardSyntaxDeclaration = require('../utils/isStandardSyntaxDeclaration');
|
5 | const report = require('../utils/report');
|
6 |
|
7 | module.exports = function (opts) {
|
8 | opts.root.walkDecls((decl) => {
|
9 | if (!isStandardSyntaxDeclaration(decl)) {
|
10 | return;
|
11 | }
|
12 |
|
13 |
|
14 | const endOfPropIndex = declarationValueIndex(decl) + (decl.raws.between || '').length - 1;
|
15 |
|
16 |
|
17 |
|
18 | const propPlusColon = `${decl.toString().slice(0, endOfPropIndex)}xxx`;
|
19 |
|
20 | for (let i = 0, l = propPlusColon.length; i < l; i++) {
|
21 | if (propPlusColon[i] !== ':') {
|
22 | continue;
|
23 | }
|
24 |
|
25 | opts.locationChecker({
|
26 | source: propPlusColon,
|
27 | index: i,
|
28 | lineCheckStr: decl.value,
|
29 | err: (m) => {
|
30 | if (opts.fix && opts.fix(decl, i)) {
|
31 | return;
|
32 | }
|
33 |
|
34 | report({
|
35 | message: m,
|
36 | node: decl,
|
37 | index: decl.prop.toString().length + 1,
|
38 | result: opts.result,
|
39 | ruleName: opts.checkedRuleName,
|
40 | });
|
41 | },
|
42 | });
|
43 | break;
|
44 | }
|
45 | });
|
46 | };
|