UNPKG

574 BJavaScriptView Raw
1"use strict";
2
3const format = require("util").format;
4
5/**
6 * @param { import("../lib/css-analyzer") } analyzer
7 */
8function rule(analyzer) {
9 analyzer.setMetric("importants");
10
11 analyzer.on("declaration", function (rule, property, value) {
12 if (value.indexOf("!important") > -1) {
13 analyzer.incrMetric("importants");
14 analyzer.addOffender(
15 "importants",
16 format("%s {%s: %s}", rule.selectors.join(", "), property, value)
17 );
18 }
19 });
20}
21
22rule.description = "Number of properties with value forced by !important";
23module.exports = rule;