.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / declarationBangSpaceChecker.js
1 "use strict";
2
3 const declarationValueIndex = require("../utils/declarationValueIndex");
4 const report = require("../utils/report");
5 const styleSearch = require("style-search");
6
7 module.exports = function(opts) {
8   opts.root.walkDecls(function(decl) {
9     const indexOffset = declarationValueIndex(decl);
10     const declString = decl.toString();
11     const valueString = decl.toString().slice(indexOffset);
12     if (valueString.indexOf("!") === -1) {
13       return;
14     }
15
16     styleSearch({ source: valueString, target: "!" }, match => {
17       check(declString, match.startIndex + indexOffset, decl);
18     });
19   });
20
21   function check(source, index, node) {
22     opts.locationChecker({
23       source,
24       index,
25       err: m =>
26         report({
27           message: m,
28           node,
29           index,
30           result: opts.result,
31           ruleName: opts.checkedRuleName
32         })
33     });
34   }
35 };