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 =
|
15 | declarationValueIndex(decl) + (decl.raws.between || "").length - 1;
|
16 |
|
17 |
|
18 |
|
19 | const propPlusColon = decl.toString().slice(0, endOfPropIndex) + "xxx";
|
20 |
|
21 | for (let i = 0, l = propPlusColon.length; i < l; i++) {
|
22 | if (propPlusColon[i] !== ":") {
|
23 | continue;
|
24 | }
|
25 |
|
26 | opts.locationChecker({
|
27 | source: propPlusColon,
|
28 | index: i,
|
29 | lineCheckStr: decl.value,
|
30 | err: m => {
|
31 | if (opts.fix && opts.fix(decl, i)) {
|
32 | return;
|
33 | }
|
34 |
|
35 | report({
|
36 | message: m,
|
37 | node: decl,
|
38 | index: decl.prop.toString().length + 1,
|
39 | result: opts.result,
|
40 | ruleName: opts.checkedRuleName
|
41 | });
|
42 | }
|
43 | });
|
44 | break;
|
45 | }
|
46 | });
|
47 | };
|