Permalink
Browse files

Merge pull request #304 from beckje01/tooManyRules

Rules and test for the IE max selector count warning.
  • Loading branch information...
stubbornella committed Sep 25, 2012
2 parents c6d79d2 + c669f6f commit 43cee88800187611c48e9d43a81e8da260636479
@@ -0,0 +1,30 @@
+/*
+ * Rule: Warn people with approaching the IE 4095 limit
+ */
+/*global CSSLint*/
+CSSLint.addRule({
+
+ //rule information
+ id: "selector-max-approaching",
+ name: "Warn when approaching the 4095 limit for IE",
+ desc: "Will warn when selector count is >= 3800 rules.",
+ browsers: "IE",
+
+ //initialization
+ init: function(parser, reporter){
+ var rule = this,
+ count = 0;
+
+ parser.addListener('startrule',function(event){
+ count++;
+
+ });
+
+ parser.addListener("endstylesheet", function(){
+ if(count >= 3800){
+ reporter.report("You have "+count+" rules. Internet Explorer supports a maximum of 4095 rules. Consider refactoring.",0,0,rule);
+ }
+ });
+ }
+
+});
View
@@ -0,0 +1,29 @@
+/*
+ * Rule: Warn people past the IE 4095 limit
+ */
+/*global CSSLint*/
+CSSLint.addRule({
+
+ //rule information
+ id: "selector-max",
+ name: "Error when past the 4095 limit for IE",
+ desc: "Will error when selector count is > 4095.",
+ browsers: "IE",
+
+ //initialization
+ init: function(parser, reporter){
+ var rule = this,
+ count = 0;
+
+ parser.addListener('startrule',function(event){
+ count++;
+ });
+
+ parser.addListener("endstylesheet", function(){
+ if(count>4095){
+ reporter.report("You have "+count+" rules. Internet Explorer supports a maximum of 4095 rules. All additional rules will be ignored by IE. Consider refactoring.",0,0,rule);
+ }
+ });
+ }
+
+});

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit 43cee88

Please sign in to comment.