Update .bashrc
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / rules / block-no-empty / index.js
1 "use strict";
2
3 const beforeBlockString = require("../../utils/beforeBlockString");
4 const hasEmptyBlock = require("../../utils/hasEmptyBlock");
5 const report = require("../../utils/report");
6 const ruleMessages = require("../../utils/ruleMessages");
7 const validateOptions = require("../../utils/validateOptions");
8
9 const ruleName = "block-no-empty";
10
11 const messages = ruleMessages(ruleName, {
12   rejected: "Unexpected empty block"
13 });
14
15 const rule = function(actual) {
16   return (root, result) => {
17     const validOptions = validateOptions(result, ruleName, { actual });
18     if (!validOptions) {
19       return;
20     }
21
22     // Check both kinds of statements: rules and at-rules
23     root.walkRules(check);
24     root.walkAtRules(check);
25
26     function check(statement) {
27       if (!hasEmptyBlock(statement)) {
28         return;
29       }
30
31       let index = beforeBlockString(statement, { noRawBefore: true }).length;
32
33       // For empty blocks when using SugarSS parser
34       if (statement.raws.between === undefined) {
35         index--;
36       }
37
38       report({
39         message: messages.rejected,
40         node: statement,
41         index,
42         result,
43         ruleName
44       });
45     }
46   };
47 };
48
49 rule.ruleName = ruleName;
50 rule.messages = messages;
51 module.exports = rule;