UNPKG

531 BJavaScriptView Raw
1"use strict";
2
3/**
4 * @param { import("../lib/css-analyzer") } analyzer
5 */
6function rule(analyzer) {
7 analyzer.setMetric("emptyRules");
8
9 analyzer.on("rule", function (rule) {
10 var properties = rule.declarations.filter(function (item) {
11 return item.type === "declaration";
12 });
13
14 if (properties.length === 0) {
15 analyzer.incrMetric("emptyRules");
16 analyzer.addOffender("emptyRules", rule.selectors.join(", "));
17 }
18 });
19}
20
21rule.description = "Total number of empty CSS rules";
22module.exports = rule;