UNPKG

924 BJavaScriptView Raw
1"use strict";
2
3var debug = require("debug")("analyze-css:prefixes"),
4 format = require("util").format;
5
6/**
7 * @param { import("../lib/css-analyzer") } analyzer
8 */
9function rule(analyzer) {
10 var data = require(__dirname + "/prefixes.json"),
11 prefixes = data.prefixes;
12
13 debug("Using data generated on %s", data.generated);
14 analyzer.setMetric("oldPropertyPrefixes");
15
16 analyzer.on("declaration", function (rule, property, value) {
17 var prefixData = prefixes[property];
18
19 // prefix needs to be kept
20 if (prefixData && !prefixData.keep) {
21 analyzer.incrMetric("oldPropertyPrefixes");
22 analyzer.addOffender(
23 "oldPropertyPrefixes",
24 format(
25 "%s { %s: %s } // %s",
26 rule.selectors.join(", "),
27 property,
28 value,
29 prefixData.msg
30 )
31 );
32 }
33 });
34}
35
36rule.description = "Reports outdated vendor prefixes";
37module.exports = rule;