Skip to content

Commit 3cfb1ed

Browse files
committed
Updated the error messages to the requested values and split the two rules into their own files.
1 parent 8182d9d commit 3cfb1ed

File tree

4 files changed

+62
-37
lines changed

4 files changed

+62
-37
lines changed

src/rules/selector-max-approaching.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Rule: Warn people with approaching the IE 4095 limit
3+
*/
4+
/*global CSSLint*/
5+
CSSLint.addRule({
6+
7+
//rule information
8+
id: "selector-max-approaching",
9+
name: "Warn when approaching the 4095 limit for IE",
10+
desc: "Will warn when selector count is >= 3800 rules.",
11+
browsers: "All",
12+
13+
//initialization
14+
init: function(parser, reporter){
15+
var rule = this,
16+
count = 0;
17+
18+
parser.addListener('startrule',function(event){
19+
count++;
20+
21+
});
22+
23+
parser.addListener("endstylesheet", function(){
24+
if(count >= 3800){
25+
reporter.report("You have "+count+" rules. Internet Explorer supports a maximum of 4095 rules. Consider refactoring.",0,0,rule);
26+
}
27+
});
28+
}
29+
30+
});

src/rules/selector-max.js

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
11
/*
2-
* Rule: Warn people with approaching the IE 4095 limit
2+
* Rule: Warn people past the IE 4095 limit
33
*/
44
/*global CSSLint*/
5-
CSSLint.addRule({
6-
7-
//rule information
8-
id: "selector-max-approaching",
9-
name: "Warn when approaching the 4095 limit for IE",
10-
desc: "Will warn when selector count is >= 3800 rules.",
11-
browsers: "All",
12-
13-
//initialization
14-
init: function(parser, reporter){
15-
var rule = this,
16-
count = 0,
17-
notFired = true;
18-
19-
parser.addListener('startrule',function(event){
20-
count++;
21-
if(count >= 3800 && notFired){
22-
notFired=false;
23-
var selectors = event.selectors;
24-
reporter.report("Rule is the number 3800 and approaching the 4095 IE limit.", selectors[0].line, selectors[0].col, rule);
25-
}
26-
});
27-
}
28-
29-
});
30-
31-
32-
335
CSSLint.addRule({
346

357
//rule information
@@ -41,15 +13,15 @@ CSSLint.addRule({
4113
//initialization
4214
init: function(parser, reporter){
4315
var rule = this,
44-
count = 0,
45-
notFired = true;
16+
count = 0;
4617

4718
parser.addListener('startrule',function(event){
4819
count++;
49-
if(count >= 4096 && notFired){
50-
notFired=false;
51-
var selectors = event.selectors;
52-
reporter.report("Rule is the number 4096 and past the 4095 IE limit.", selectors[0].line, selectors[0].col, rule);
20+
});
21+
22+
parser.addListener("endstylesheet", function(){
23+
if(count>4095){
24+
reporter.report("You have "+count+" rules. nternet Explorer supports a maximum of 4095 rules. All additional rules will be ignored by IE. Consider refactoring.",0,0,rule);
5325
}
5426
});
5527
}

tests/rules/selector-max-approaching.js

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/rules/selector-max.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)