-
Notifications
You must be signed in to change notification settings - Fork 484
/
font-sizes.js
38 lines (32 loc) · 1.08 KB
/
font-sizes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Rule: You shouldn't need more than 9 font-size declarations.
*/
CSSLint.addRule({
// rule information
id: "font-sizes",
name: "Disallow too many font sizes",
desc: "Checks the number of font-size declarations.",
url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
browsers: "All",
// initialization
init: function(parser, reporter) {
"use strict";
var rule = this,
count = 0;
// check for use of "font-size"
parser.addListener("property", function(event) {
if (!reporter.isIgnored(event.property.line)) {
if (event.property.toString() === "font-size") {
count++;
}
}
});
// report the results
parser.addListener("endstylesheet", function() {
reporter.stat("font-sizes", count);
if (count >= 10) {
reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
}
});
}
});