analyze-css
Version:
CSS selectors complexity and performance analyzer
24 lines (19 loc) • 575 B
JavaScript
const format = require("util").format;
/**
* @param { import("../lib/css-analyzer") } analyzer
*/
function rule(analyzer) {
analyzer.setMetric("importants");
analyzer.on("declaration", function (rule, property, value) {
if (value.indexOf("!important") > -1) {
analyzer.incrMetric("importants");
analyzer.addOffender(
"importants",
format("%s {%s: %s}", rule.selectors.join(", "), property, value),
);
}
});
}
rule.description = "Number of properties with value forced by !important";
module.exports = rule;
;