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");
9 const ruleName = "block-no-empty";
11 const messages = ruleMessages(ruleName, {
12 rejected: "Unexpected empty block"
15 const rule = function(actual) {
16 return (root, result) => {
17 const validOptions = validateOptions(result, ruleName, { actual });
22 // Check both kinds of statements: rules and at-rules
23 root.walkRules(check);
24 root.walkAtRules(check);
26 function check(statement) {
27 if (!hasEmptyBlock(statement)) {
31 let index = beforeBlockString(statement, { noRawBefore: true }).length;
33 // For empty blocks when using SugarSS parser
34 if (statement.raws.between === undefined) {
39 message: messages.rejected,
49 rule.ruleName = ruleName;
50 rule.messages = messages;
51 module.exports = rule;