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