.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / declarationColonSpaceChecker.js
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     // Get the raw prop, and only the prop
14     const endOfPropIndex =
15       declarationValueIndex(decl) + (decl.raws.between || "").length - 1;
16
17     // The extra characters tacked onto the end ensure that there is a character to check
18     // after the colon. Otherwise, with `background:pink` the character after the
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       opts.locationChecker({
26         source: propPlusColon,
27         index: i,
28         lineCheckStr: decl.value,
29         err: m => {
30           report({
31             message: m,
32             node: decl,
33             index: decl.prop.toString().length + 1,
34             result: opts.result,
35             ruleName: opts.checkedRuleName
36           });
37         }
38       });
39       break;
40     }
41   });
42 };