Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Final fixes for 0.3.0

  • Loading branch information...
commit 83ed025170b2f35c833b682089c9e567ae09615d 1 parent ed86653
Nicholas C. Zakas nzakas authored
5 CHANGELOG
... ... @@ -1,4 +1,7 @@
1 1 Next (not yet released)
  2 +* n/a
  3 +
  4 +June 25, 2011 - v0.3.0
2 5
3 6 * Rhino and Node CLIs both exit with code 1 when there are errors (pull #72)
4 7 * Changed description of adjoining classes to be unsupported in IE6 (fixes #11)
@@ -11,6 +14,8 @@ Next (not yet released)
11 14 * border:none with width/height is okay (fixes #45)
12 15 * Updated web worker to accept JSON-encoded input
13 16 * Allow turning on/off rules in web interface and CLIs (fixes #77)
  17 +* Introduced release directory that will hold official release version
  18 +* Build directory will be removed in next release
14 19
15 20 June 18, 2011 - v0.2.0
16 21
6 README.md
Source Rendered
@@ -36,7 +36,7 @@ Even though you can define any group of properties together in a CSS rule, some
36 36
37 37 Removed the ignored or problematic properties decreases file size and improves performance.
38 38
39   -### Avoid using to many !important declarations
  39 +### Avoid using too many !important declarations
40 40
41 41 Using `!important` overides any cascaded rule and may lead to specificity war. CSSLint checks if you've used `!important`, and if so, displays a warning. If there's at least 10 `!important` declaration in your code CSSLint displays an error.
42 42
@@ -103,6 +103,10 @@ CSS3 adds complex attribute selectors such as `~=` that are slow. When using att
103 103
104 104 Borders and padding add space outside of an element's content. Setting `width` or `height` along with borders and padding is usually a mistake because you won't get the visual result you're looking for. CSSLint warns when a rule uses `width` or `height` in addition to padding and/or border.
105 105
  106 +### Avoid @import
  107 +
  108 +The `@import` command shouldn't be used because it prevent parallel downloads in some browsers (see http://www.stevesouders.com/blog/2009/04/09/dont-use-import/).
  109 +
106 110 ## Contributors
107 111
108 112 ### Creators
10 build.xml
... ... @@ -1,7 +1,7 @@
1 1 <project name="csslint" default="all">
2 2
3 3 <!-- version number -->
4   - <property name="csslint.version" value="0.2.0" />
  4 + <property name="csslint.version" value="0.3.0" />
5 5
6 6 <!-- the directories containing the source files -->
7 7 <property name="src.dir" value="./src" />
@@ -10,6 +10,7 @@
10 10
11 11 <!-- the directories and files to output to -->
12 12 <property name="build.dir" value="./build" />
  13 + <property name="release.dir" value="./release" />
13 14 <property name="build.npm.dir" value="${build.dir}/npm" />
14 15
15 16 <!-- the directory containing library files -->
@@ -34,6 +35,7 @@
34 35 <!-- clean -->
35 36 <target name="clean">
36 37 <delete dir="${build.dir}" />
  38 + <delete dir="${release.dir}" />
37 39 </target>
38 40
39 41 <!-- build the core library -->
@@ -120,8 +122,12 @@
120 122
121 123 <!-- Update version number in files -->
122 124 <target name="release" depends="all">
  125 + <mkdir dir="${release.dir}"/>
  126 + <copy todir="${release.dir}">
  127 + <fileset dir="${build.dir}" includes="**/*" />
  128 + </copy>
123 129 <replaceregexp match="@VERSION@" replace="${csslint.version}" flags="g" byline="true">
124   - <fileset dir="${build.dir}" includes="**/*.js"/>
  130 + <fileset dir="${release.dir}" includes="**/*"/>
125 131 </replaceregexp>
126 132 </target>
127 133
34 build/csslint-node.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 21 THE SOFTWARE.
22 22
23 23 */
24   -/* Build time: 23-June-2011 03:44:41 */
  24 +/* Build time: 25-June-2011 07:20:29 */
25 25 /*!
26 26 Parser-Lib
27 27 Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -10293,6 +10293,38 @@ CSSLint.addRule({
10293 10293
10294 10294 });
10295 10295 /*
  10296 + * Rule: Don't use text-indent for image replacement if you need to support rtl.
  10297 + *
  10298 + */
  10299 +/*
  10300 + * Should we be checking for rtl/ltr?
  10301 + */
  10302 +//Commented out due to lack of tests
  10303 +/*CSSLint.addRule({
  10304 +
  10305 + //rule information
  10306 + id: "text-indent",
  10307 + name: "Text Indent",
  10308 + desc: "Checks for text indent less than -99px",
  10309 + browsers: "All",
  10310 +
  10311 + //initialization
  10312 + init: function(parser, reporter){
  10313 + var rule = this;
  10314 +
  10315 + //check for use of "font-size"
  10316 + parser.addListener("property", function(event){
  10317 + var name = event.property,
  10318 + value = event.value;
  10319 +
  10320 + if (name == "text-indent" && value < -99){
  10321 + reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
  10322 + }
  10323 + });
  10324 + }
  10325 +
  10326 +});*/
  10327 +/*
10296 10328 * Rule: Headings (h1-h6) should be defined only once.
10297 10329 */
10298 10330 CSSLint.addRule({
34 build/csslint-rhino.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 21 THE SOFTWARE.
22 22
23 23 */
24   -/* Build time: 23-June-2011 03:44:41 */
  24 +/* Build time: 25-June-2011 07:20:29 */
25 25 var CSSLint = (function(){
26 26 /*!
27 27 Parser-Lib
@@ -10294,6 +10294,38 @@ CSSLint.addRule({
10294 10294
10295 10295 });
10296 10296 /*
  10297 + * Rule: Don't use text-indent for image replacement if you need to support rtl.
  10298 + *
  10299 + */
  10300 +/*
  10301 + * Should we be checking for rtl/ltr?
  10302 + */
  10303 +//Commented out due to lack of tests
  10304 +/*CSSLint.addRule({
  10305 +
  10306 + //rule information
  10307 + id: "text-indent",
  10308 + name: "Text Indent",
  10309 + desc: "Checks for text indent less than -99px",
  10310 + browsers: "All",
  10311 +
  10312 + //initialization
  10313 + init: function(parser, reporter){
  10314 + var rule = this;
  10315 +
  10316 + //check for use of "font-size"
  10317 + parser.addListener("property", function(event){
  10318 + var name = event.property,
  10319 + value = event.value;
  10320 +
  10321 + if (name == "text-indent" && value < -99){
  10322 + reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
  10323 + }
  10324 + });
  10325 + }
  10326 +
  10327 +});*/
  10328 +/*
10297 10329 * Rule: Headings (h1-h6) should be defined only once.
10298 10330 */
10299 10331 CSSLint.addRule({
34 build/csslint-worker.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 21 THE SOFTWARE.
22 22
23 23 */
24   -/* Build time: 23-June-2011 03:44:41 */
  24 +/* Build time: 25-June-2011 07:20:29 */
25 25 /*!
26 26 Parser-Lib
27 27 Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -10293,6 +10293,38 @@ CSSLint.addRule({
10293 10293
10294 10294 });
10295 10295 /*
  10296 + * Rule: Don't use text-indent for image replacement if you need to support rtl.
  10297 + *
  10298 + */
  10299 +/*
  10300 + * Should we be checking for rtl/ltr?
  10301 + */
  10302 +//Commented out due to lack of tests
  10303 +/*CSSLint.addRule({
  10304 +
  10305 + //rule information
  10306 + id: "text-indent",
  10307 + name: "Text Indent",
  10308 + desc: "Checks for text indent less than -99px",
  10309 + browsers: "All",
  10310 +
  10311 + //initialization
  10312 + init: function(parser, reporter){
  10313 + var rule = this;
  10314 +
  10315 + //check for use of "font-size"
  10316 + parser.addListener("property", function(event){
  10317 + var name = event.property,
  10318 + value = event.value;
  10319 +
  10320 + if (name == "text-indent" && value < -99){
  10321 + reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
  10322 + }
  10323 + });
  10324 + }
  10325 +
  10326 +});*/
  10327 +/*
10296 10328 * Rule: Headings (h1-h6) should be defined only once.
10297 10329 */
10298 10330 CSSLint.addRule({
34 build/csslint.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 21 THE SOFTWARE.
22 22
23 23 */
24   -/* Build time: 23-June-2011 03:44:41 */
  24 +/* Build time: 25-June-2011 07:20:29 */
25 25 var CSSLint = (function(){
26 26 /*!
27 27 Parser-Lib
@@ -10294,6 +10294,38 @@ CSSLint.addRule({
10294 10294
10295 10295 });
10296 10296 /*
  10297 + * Rule: Don't use text-indent for image replacement if you need to support rtl.
  10298 + *
  10299 + */
  10300 +/*
  10301 + * Should we be checking for rtl/ltr?
  10302 + */
  10303 +//Commented out due to lack of tests
  10304 +/*CSSLint.addRule({
  10305 +
  10306 + //rule information
  10307 + id: "text-indent",
  10308 + name: "Text Indent",
  10309 + desc: "Checks for text indent less than -99px",
  10310 + browsers: "All",
  10311 +
  10312 + //initialization
  10313 + init: function(parser, reporter){
  10314 + var rule = this;
  10315 +
  10316 + //check for use of "font-size"
  10317 + parser.addListener("property", function(event){
  10318 + var name = event.property,
  10319 + value = event.value;
  10320 +
  10321 + if (name == "text-indent" && value < -99){
  10322 + reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
  10323 + }
  10324 + });
  10325 + }
  10326 +
  10327 +});*/
  10328 +/*
10297 10329 * Rule: Headings (h1-h6) should be defined only once.
10298 10330 */
10299 10331 CSSLint.addRule({
34 build/npm/lib/csslint-node.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 21 THE SOFTWARE.
22 22
23 23 */
24   -/* Build time: 23-June-2011 03:44:41 */
  24 +/* Build time: 25-June-2011 07:20:29 */
25 25 /*!
26 26 Parser-Lib
27 27 Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -10293,6 +10293,38 @@ CSSLint.addRule({
10293 10293
10294 10294 });
10295 10295 /*
  10296 + * Rule: Don't use text-indent for image replacement if you need to support rtl.
  10297 + *
  10298 + */
  10299 +/*
  10300 + * Should we be checking for rtl/ltr?
  10301 + */
  10302 +//Commented out due to lack of tests
  10303 +/*CSSLint.addRule({
  10304 +
  10305 + //rule information
  10306 + id: "text-indent",
  10307 + name: "Text Indent",
  10308 + desc: "Checks for text indent less than -99px",
  10309 + browsers: "All",
  10310 +
  10311 + //initialization
  10312 + init: function(parser, reporter){
  10313 + var rule = this;
  10314 +
  10315 + //check for use of "font-size"
  10316 + parser.addListener("property", function(event){
  10317 + var name = event.property,
  10318 + value = event.value;
  10319 +
  10320 + if (name == "text-indent" && value < -99){
  10321 + reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
  10322 + }
  10323 + });
  10324 + }
  10325 +
  10326 +});*/
  10327 +/*
10296 10328 * Rule: Headings (h1-h6) should be defined only once.
10297 10329 */
10298 10330 CSSLint.addRule({
10,522 release/csslint-node.js
10,522 additions, 0 deletions not shown
10,708 release/csslint-rhino.js
10,708 additions, 0 deletions not shown
967 release/csslint-tests.js
... ... @@ -0,0 +1,967 @@
  1 +(function(){
  2 +
  3 + /*global YUITest, CSSLint*/
  4 + var Assert = YUITest.Assert;
  5 +
  6 + YUITest.TestRunner.add(new YUITest.TestCase({
  7 +
  8 + name: "Adjoining Selector Rule Errors",
  9 +
  10 + "Adjoining classes should result in a warning": function(){
  11 + var result = CSSLint.verify(".foo.bar { }", { "adjoining-classes": 1 });
  12 + Assert.areEqual(1, result.messages.length);
  13 + Assert.areEqual("warning", result.messages[0].type);
  14 + Assert.areEqual("Don't use adjoining classes.", result.messages[0].message);
  15 + },
  16 +
  17 + "Descendant selector with classes should not result in a warning": function(){
  18 + var result = CSSLint.verify(".foo .bar { }", { "adjoining-classes": 1 });
  19 + Assert.areEqual(0, result.messages.length);
  20 + }
  21 +
  22 + }));
  23 +
  24 +})();
  25 +
  26 +(function(){
  27 +
  28 + /*global YUITest, CSSLint*/
  29 + var Assert = YUITest.Assert;
  30 +
  31 + YUITest.TestRunner.add(new YUITest.TestCase({
  32 +
  33 + name: "Box Model Rule Errors",
  34 +
  35 + "Using width and padding should result in a warning": function(){
  36 + var result = CSSLint.verify(".foo { width: 100px; padding: 10px; }", { "box-model": 1 });
  37 + Assert.areEqual(1, result.messages.length);
  38 + Assert.areEqual("warning", result.messages[0].type);
  39 + Assert.areEqual("Broken box model: using width with padding.", result.messages[0].message);
  40 + },
  41 +
  42 + "Using width when padding is zero should not result in a warning": function(){
  43 + var result = CSSLint.verify(".foo { width: 100px; padding: 0; }", { "box-model": 1 });
  44 + Assert.areEqual(0, result.messages.length);
  45 + },
  46 +
  47 + "Using width and padding-left should result in a warning": function(){
  48 + var result = CSSLint.verify(".foo { width: 100px; padding-left: 10px; }", { "box-model": 1 });
  49 + Assert.areEqual(1, result.messages.length);
  50 + Assert.areEqual("warning", result.messages[0].type);
  51 + Assert.areEqual("Broken box model: using width with padding-left.", result.messages[0].message);
  52 + },
  53 +
  54 + "Using width when padding-left is zero should not result in a warning": function(){
  55 + var result = CSSLint.verify(".foo { width: 100px; padding-left: 0; }", { "box-model": 1 });
  56 + Assert.areEqual(0, result.messages.length);
  57 + },
  58 +
  59 + "Using width and padding-right should result in a warning": function(){
  60 + var result = CSSLint.verify(".foo { width: 100px; padding-right: 10px; }", { "box-model": 1 });
  61 + Assert.areEqual(1, result.messages.length);
  62 + Assert.areEqual("warning", result.messages[0].type);
  63 + Assert.areEqual("Broken box model: using width with padding-right.", result.messages[0].message);
  64 + },
  65 +
  66 + "Using width when padding-right is zero should not result in a warning": function(){
  67 + var result = CSSLint.verify(".foo { width: 100px; padding-right: 0; }", { "box-model": 1 });
  68 + Assert.areEqual(0, result.messages.length);
  69 + },
  70 +
  71 + "Using width and padding-top should not result in a warning": function(){
  72 + var result = CSSLint.verify(".foo { width: 100px; padding-top: 10px; }", { "box-model": 1 });
  73 + Assert.areEqual(0, result.messages.length);
  74 + },
  75 +
  76 + "Using width and padding-bottom should not result in a warning": function(){
  77 + var result = CSSLint.verify(".foo { width: 100px; padding-bottom: 10px; }", { "box-model": 1 });
  78 + Assert.areEqual(0, result.messages.length);
  79 + },
  80 +
  81 + "Using width and border should result in a warning": function(){
  82 + var result = CSSLint.verify(".foo { width: 100px; border: 10px; }", { "box-model": 1 });
  83 + Assert.areEqual(1, result.messages.length);
  84 + Assert.areEqual("warning", result.messages[0].type);
  85 + Assert.areEqual("Broken box model: using width with border.", result.messages[0].message);
  86 + },
  87 +
  88 + "Using width and border-left should result in a warning": function(){
  89 + var result = CSSLint.verify(".foo { width: 100px; border-left: 10px; }", { "box-model": 1 });
  90 + Assert.areEqual(1, result.messages.length);
  91 + Assert.areEqual("warning", result.messages[0].type);
  92 + Assert.areEqual("Broken box model: using width with border-left.", result.messages[0].message);
  93 + },
  94 +
  95 + "Using width when border-left is zero should not result in a warning": function(){
  96 + var result = CSSLint.verify(".foo { width: 100px; border-left: 0; }", { "box-model": 1 });
  97 + Assert.areEqual(0, result.messages.length);
  98 + },
  99 +
  100 + "Using width and border-right should result in a warning": function(){
  101 + var result = CSSLint.verify(".foo { width: 100px; border-right: 10px; }", { "box-model": 1 });
  102 + Assert.areEqual(1, result.messages.length);
  103 + Assert.areEqual("warning", result.messages[0].type);
  104 + Assert.areEqual("Broken box model: using width with border-right.", result.messages[0].message);
  105 + },
  106 +
  107 + "Using width when border-right is zero should not result in a warning": function(){
  108 + var result = CSSLint.verify(".foo { width: 100px; border-right: 0; }", { "box-model": 1 });
  109 + Assert.areEqual(0, result.messages.length);
  110 + },
  111 +
  112 + "Using width and border-top should not result in a warning": function(){
  113 + var result = CSSLint.verify(".foo { width: 100px; border-top: 10px; }", { "box-model": 1 });
  114 + Assert.areEqual(0, result.messages.length);
  115 + },
  116 +
  117 + "Using width and border-bottom should not result in a warning": function(){
  118 + var result = CSSLint.verify(".foo { width: 100px; border-bottom: 10px; }", { "box-model": 1 });
  119 + Assert.areEqual(0, result.messages.length);
  120 + },
  121 +
  122 + "Using height and padding should result in a warning": function(){
  123 + var result = CSSLint.verify(".foo { height: 100px; padding: 10px; }", { "box-model": 1 });
  124 + Assert.areEqual(1, result.messages.length);
  125 + Assert.areEqual("warning", result.messages[0].type);
  126 + Assert.areEqual("Broken box model: using height with padding.", result.messages[0].message);
  127 + },
  128 +
  129 + "Using height when padding is zero should not result in a warning": function(){
  130 + var result = CSSLint.verify(".foo { height: 100px; padding: 0; }", { "box-model": 1 });
  131 + Assert.areEqual(0, result.messages.length);
  132 + },
  133 +
  134 + "Using height and padding-left should not result in a warning": function(){
  135 + var result = CSSLint.verify(".foo { height: 100px; padding-left: 10px; }", { "box-model": 1 });
  136 + Assert.areEqual(0, result.messages.length);
  137 + },
  138 +
  139 + "Using height and padding-right should not result in a warning": function(){
  140 + var result = CSSLint.verify(".foo { height: 100px; padding-right: 10px; }", { "box-model": 1 });
  141 + Assert.areEqual(0, result.messages.length);
  142 + },
  143 +
  144 + "Using height and padding-top should result in a warning": function(){
  145 + var result = CSSLint.verify(".foo { height: 100px; padding-top: 10px; }", { "box-model": 1 });
  146 + Assert.areEqual(1, result.messages.length);
  147 + Assert.areEqual("warning", result.messages[0].type);
  148 + Assert.areEqual("Broken box model: using height with padding-top.", result.messages[0].message);
  149 + },
  150 +
  151 + "Using height when padding-top is zero should not result in a warning": function(){
  152 + var result = CSSLint.verify(".foo { height: 100px; padding-top: 0; }", { "box-model": 1 });
  153 + Assert.areEqual(0, result.messages.length);
  154 + },
  155 +
  156 + "Using height and padding-bottom should result in a warning": function(){
  157 + var result = CSSLint.verify(".foo { height: 100px; padding-bottom: 10px; }", { "box-model": 1 });
  158 + Assert.areEqual(1, result.messages.length);
  159 + Assert.areEqual("warning", result.messages[0].type);
  160 + Assert.areEqual("Broken box model: using height with padding-bottom.", result.messages[0].message);
  161 + },
  162 +
  163 + "Using height when padding-bottom is zero should not result in a warning": function(){
  164 + var result = CSSLint.verify(".foo { height: 100px; padding-bottom: 0; }", { "box-model": 1 });
  165 + Assert.areEqual(0, result.messages.length);
  166 + },
  167 +
  168 + "Using height and border should result in a warning": function(){
  169 + var result = CSSLint.verify(".foo { height: 100px; border: 10px; }", { "box-model": 1 });
  170 + Assert.areEqual(1, result.messages.length);
  171 + Assert.areEqual("warning", result.messages[0].type);
  172 + Assert.areEqual("Broken box model: using height with border.", result.messages[0].message);
  173 + },
  174 +
  175 + "Using height and border: none should not result in a warning": function(){
  176 + var result = CSSLint.verify(".foo { height: 100px; border: none; }", { "box-model": 1 });
  177 + Assert.areEqual(0, result.messages.length);
  178 + },
  179 +
  180 + "Using height and border: 0 should not result in a warning": function(){
  181 + var result = CSSLint.verify(".foo { height: 100px; border: 0; }", { "box-model": 1 });
  182 + Assert.areEqual(0, result.messages.length);
  183 + },
  184 +
  185 + "Using height and border-left should not result in a warning": function(){
  186 + var result = CSSLint.verify(".foo { height: 100px; border-left: 10px; }", { "box-model": 1 });
  187 + Assert.areEqual(0, result.messages.length);
  188 + },
  189 +
  190 + "Using height and border-right should not result in a warning": function(){
  191 + var result = CSSLint.verify(".foo { height: 100px; border-right: 10px; }", { "box-model": 1 });
  192 + Assert.areEqual(0, result.messages.length);
  193 + },
  194 +
  195 + "Using height and border-top should result in a warning": function(){
  196 + var result = CSSLint.verify(".foo { height: 100px; border-top: 10px; }", { "box-model": 1 });
  197 + Assert.areEqual(1, result.messages.length);
  198 + Assert.areEqual("warning", result.messages[0].type);
  199 + Assert.areEqual("Broken box model: using height with border-top.", result.messages[0].message);
  200 + },
  201 +
  202 + "Using height when border-top is zero should not result in a warning": function(){
  203 + var result = CSSLint.verify(".foo { height: 100px; border-top: 0; }", { "box-model": 1 });
  204 + Assert.areEqual(0, result.messages.length);
  205 + },
  206 +
  207 + "Using height and border-bottom should result in a warning": function(){
  208 + var result = CSSLint.verify(".foo { height: 100px; border-bottom: 10px; }", { "box-model": 1 });
  209 + Assert.areEqual(1, result.messages.length);
  210 + Assert.areEqual("warning", result.messages[0].type);
  211 + Assert.areEqual("Broken box model: using height with border-bottom.", result.messages[0].message);
  212 + },
  213 +
  214 + "Using height when border-bottom is zero should not result in a warning": function(){
  215 + var result = CSSLint.verify(".foo { height: 100px; border-bottom: 0px; }", { "box-model": 1 });
  216 + Assert.areEqual(0, result.messages.length);
  217 + },
  218 +
  219 + "Using height when border-bottom is zero should not result in a warning": function(){
  220 + var result = CSSLint.verify(".foo { height: 100px; border-bottom: 0; }", { "box-model": 1 });
  221 + Assert.areEqual(0, result.messages.length);
  222 + }
  223 +
  224 + }));
  225 +
  226 +})();
  227 +
  228 +(function(){
  229 +
  230 + /*global YUITest, CSSLint*/
  231 + var Assert = YUITest.Assert;
  232 +
  233 + YUITest.TestRunner.add(new YUITest.TestCase({
  234 +
  235 + name: "Display Property Grouping Rule Errors",
  236 +
  237 +/*
  238 + * - float should not be used with inline-block
  239 + * - height, width, margin-top, margin-bottom, float should not be used with inline
  240 + * - vertical-align should not be used with block
  241 + * - margin, float should not be used with table-*
  242 +*/
  243 + "Float with inline-block should result in a warning": function(){
  244 + var result = CSSLint.verify(".foo { float: left; display: inline-block; }", { "display-property-grouping": 1 });
  245 + Assert.areEqual(1, result.messages.length);
  246 + Assert.areEqual("warning", result.messages[0].type);
  247 + Assert.areEqual("float can't be used with display: inline-block.", result.messages[0].message);
  248 + },
  249 +
  250 + "Float with inline should result in a warning": function(){
  251 + var result = CSSLint.verify(".foo { float: left; display: inline; }", { "display-property-grouping": 1 });
  252 + Assert.areEqual(1, result.messages.length);
  253 + Assert.areEqual("warning", result.messages[0].type);
  254 + Assert.areEqual("float can't be used with display: inline.", result.messages[0].message);
  255 + },
  256 +
  257 + "Float:none with inline-block should not result in a warning": function(){
  258 + var result = CSSLint.verify(".foo { float: none; display: inline-block; }", { "display-property-grouping": 1 });
  259 + Assert.areEqual(0, result.messages.length);
  260 + },
  261 +
  262 + "Float:none with inline should result not in a warning": function(){
  263 + var result = CSSLint.verify(".foo { float: none; display: inline; }", { "display-property-grouping": 1 });
  264 + Assert.areEqual(0, result.messages.length);
  265 + },
  266 +
  267 + "Height with inline should result in a warning": function(){
  268 + var result = CSSLint.verify(".foo { height: 100px; display: inline; }", { "display-property-grouping": 1 });
  269 + Assert.areEqual(1, result.messages.length);
  270 + Assert.areEqual("warning", result.messages[0].type);
  271 + Assert.areEqual("height can't be used with display: inline.", result.messages[0].message);
  272 + },
  273 +
  274 + "Width with inline should result in a warning": function(){
  275 + var result = CSSLint.verify(".foo { width: 100px; display: inline; }", { "display-property-grouping": 1 });
  276 + Assert.areEqual(1, result.messages.length);
  277 + Assert.areEqual("warning", result.messages[0].type);
  278 + Assert.areEqual("width can't be used with display: inline.", result.messages[0].message);
  279 + },
  280 +
  281 + "Margin with inline should result in a warning": function(){
  282 + var result = CSSLint.verify(".foo { margin: 100px; display: inline; }", { "display-property-grouping": 1 });
  283 + Assert.areEqual(1, result.messages.length);
  284 + Assert.areEqual("warning", result.messages[0].type);
  285 + Assert.areEqual("margin can't be used with display: inline.", result.messages[0].message);
  286 + },
  287 +
  288 + "Margin-left with inline should not result in a warning": function(){
  289 + var result = CSSLint.verify(".foo { margin-left: 100px; display: inline; }", { "display-property-grouping": 1 });
  290 + Assert.areEqual(0, result.messages.length);
  291 + },
  292 +
  293 + "Margin-right with inline should not result in a warning": function(){
  294 + var result = CSSLint.verify(".foo { margin-right: 100px; display: inline; }", { "display-property-grouping": 1 });
  295 + Assert.areEqual(0, result.messages.length);
  296 + },
  297 +
  298 + "Margin-top with inline should result in a warning": function(){
  299 + var result = CSSLint.verify(".foo { margin-top: 100px; display: inline; }", { "display-property-grouping": 1 });
  300 + Assert.areEqual(1, result.messages.length);
  301 + Assert.areEqual("warning", result.messages[0].type);
  302 + Assert.areEqual("margin-top can't be used with display: inline.", result.messages[0].message);
  303 + },
  304 +
  305 + "Margin-bottom with inline should result in a warning": function(){
  306 + var result = CSSLint.verify(".foo { margin-bottom: 100px; display: inline; }", { "display-property-grouping": 1 });
  307 + Assert.areEqual(1, result.messages.length);
  308 + Assert.areEqual("warning", result.messages[0].type);
  309 + Assert.areEqual("margin-bottom can't be used with display: inline.", result.messages[0].message);
  310 + },
  311 +
  312 + "Padding with inline should not result in a warning": function(){
  313 + var result = CSSLint.verify(".foo { padding: 100px; display: inline; }", { "display-property-grouping": 1 });
  314 + Assert.areEqual(0, result.messages.length);
  315 + },
  316 +
  317 + "Padding-left with inline should not result in a warning": function(){
  318 + var result = CSSLint.verify(".foo { padding-left: 100px; display: inline; }", { "display-property-grouping": 1 });
  319 + Assert.areEqual(0, result.messages.length);
  320 + },
  321 +
  322 + "Padding-right with inline should not result in a warning": function(){
  323 + var result = CSSLint.verify(".foo { padding-right: 100px; display: inline; }", { "display-property-grouping": 1 });
  324 + Assert.areEqual(0, result.messages.length);
  325 + },
  326 +
  327 + "Padding-top with inline should not result in a warning": function(){
  328 + var result = CSSLint.verify(".foo { padding-top: 100px; display: inline; }", { "display-property-grouping": 1 });
  329 + Assert.areEqual(0, result.messages.length);
  330 + },
  331 +
  332 + "Padding-bottom with inline should result in a warning": function(){
  333 + var result = CSSLint.verify(".foo { padding-bottom: 100px; display: inline; }", { "display-property-grouping": 1 });
  334 + Assert.areEqual(0, result.messages.length);
  335 + },
  336 +
  337 + "Vertical-align with block should result in a warning": function(){
  338 + var result = CSSLint.verify(".foo { vertical-align: bottom; display: block; }", { "display-property-grouping": 1 });
  339 + Assert.areEqual(1, result.messages.length);
  340 + Assert.areEqual("warning", result.messages[0].type);
  341 + Assert.areEqual("vertical-align can't be used with display: block.", result.messages[0].message);
  342 + },
  343 +
  344 + "Margin with table-cell should result in a warning": function(){
  345 + var result = CSSLint.verify(".foo { margin: 100px; display: table-cell; }", { "display-property-grouping": 1 });
  346 + Assert.areEqual(1, result.messages.length);
  347 + Assert.areEqual("warning", result.messages[0].type);
  348 + Assert.areEqual("margin can't be used with display: table-cell.", result.messages[0].message);
  349 + },
  350 +
  351 + "Margin-left with table-cell should result in a warning": function(){
  352 + var result = CSSLint.verify(".foo { margin-left: 100px; display: table-cell; }", { "display-property-grouping": 1 });
  353 + Assert.areEqual(1, result.messages.length);
  354 + Assert.areEqual("warning", result.messages[0].type);
  355 + Assert.areEqual("margin-left can't be used with display: table-cell.", result.messages[0].message);
  356 + },
  357 +
  358 + "Margin-right with table-cell should result in a warning": function(){
  359 + var result = CSSLint.verify(".foo { margin-right: 100px; display: table-cell; }", { "display-property-grouping": 1 });
  360 + Assert.areEqual(1, result.messages.length);
  361 + Assert.areEqual("warning", result.messages[0].type);
  362 + Assert.areEqual("margin-right can't be used with display: table-cell.", result.messages[0].message);
  363 + },
  364 +
  365 + "Margin-top with table-cell should result in a warning": function(){
  366 + var result = CSSLint.verify(".foo { margin-top: 100px; display: table-cell; }", { "display-property-grouping": 1 });
  367 + Assert.areEqual(1, result.messages.length);
  368 + Assert.areEqual("warning", result.messages[0].type);
  369 + Assert.areEqual("margin-top can't be used with display: table-cell.", result.messages[0].message);
  370 + },
  371 +
  372 + "Margin-bottom with table-cell should result in a warning": function(){
  373 + var result = CSSLint.verify(".foo { margin-bottom: 100px; display: table-cell; }", { "display-property-grouping": 1 });
  374 + Assert.areEqual(1, result.messages.length);
  375 + Assert.areEqual("warning", result.messages[0].type);
  376 + Assert.areEqual("margin-bottom can't be used with display: table-cell.", result.messages[0].message);
  377 + },
  378 +
  379 + "Margin with table-row should result in a warning": function(){
  380 + var result = CSSLint.verify(".foo { margin: 100px; display: table-row; }", { "display-property-grouping": 1 });
  381 + Assert.areEqual(1, result.messages.length);
  382 + Assert.areEqual("warning", result.messages[0].type);
  383 + Assert.areEqual("margin can't be used with display: table-row.", result.messages[0].message);
  384 + },
  385 +
  386 + "Margin-left with table-row should result in a warning": function(){
  387 + var result = CSSLint.verify(".foo { margin-left: 100px; display: table-row; }", { "display-property-grouping": 1 });
  388 + Assert.areEqual(1, result.messages.length);
  389 + Assert.areEqual("warning", result.messages[0].type);
  390 + Assert.areEqual("margin-left can't be used with display: table-row.", result.messages[0].message);
  391 + },
  392 +
  393 + "Margin-right with table-row should result in a warning": function(){
  394 + var result = CSSLint.verify(".foo { margin-right: 100px; display: table-row; }", { "display-property-grouping": 1 });
  395 + Assert.areEqual(1, result.messages.length);
  396 + Assert.areEqual("warning", result.messages[0].type);
  397 + Assert.areEqual("margin-right can't be used with display: table-row.", result.messages[0].message);
  398 + },
  399 +
  400 + "Margin-top with table-row should result in a warning": function(){
  401 + var result = CSSLint.verify(".foo { margin-top: 100px; display: table-row; }", { "display-property-grouping": 1 });
  402 + Assert.areEqual(1, result.messages.length);
  403 + Assert.areEqual("warning", result.messages[0].type);
  404 + Assert.areEqual("margin-top can't be used with display: table-row.", result.messages[0].message);
  405 + },
  406 +
  407 + "Margin-bottom with table-row should result in a warning": function(){
  408 + var result = CSSLint.verify(".foo { margin-bottom: 100px; display: table-row; }", { "display-property-grouping": 1 });
  409 + Assert.areEqual(1, result.messages.length);
  410 + Assert.areEqual("warning", result.messages[0].type);
  411 + Assert.areEqual("margin-bottom can't be used with display: table-row.", result.messages[0].message);
  412 + },
  413 +
  414 + "Float with table-row should result in a warning": function(){
  415 + var result = CSSLint.verify(".foo { float: left; display: table-row; }", { "display-property-grouping": 1 });
  416 + Assert.areEqual(1, result.messages.length);
  417 + Assert.areEqual("warning", result.messages[0].type);
  418 + Assert.areEqual("float can't be used with display: table-row.", result.messages[0].message);
  419 + },
  420 +
  421 + "Float with table-cell should result in a warning": function(){
  422 + var result = CSSLint.verify(".foo { float: left; display: table-cell; }", { "display-property-grouping": 1 });
  423 + Assert.areEqual(1, result.messages.length);
  424 + Assert.areEqual("warning", result.messages[0].type);
  425 + Assert.areEqual("float can't be used with display: table-cell.", result.messages[0].message);
  426 + },
  427 +
  428 + "Float:none with table-row should not result in a warning": function(){
  429 + var result = CSSLint.verify(".foo { float: none; display: table-row; }", { "display-property-grouping": 1 });
  430 + Assert.areEqual(0, result.messages.length);
  431 + },
  432 +
  433 + "Float:none with table-cell should not result in a warning": function(){
  434 + var result = CSSLint.verify(".foo { float: none; display: table-cell; }", { "display-property-grouping": 1 });
  435 + Assert.areEqual(0, result.messages.length);
  436 + }
  437 +
  438 + }));
  439 +
  440 +})();
  441 +
  442 +(function(){
  443 +
  444 + /*global YUITest, CSSLint*/
  445 + var Assert = YUITest.Assert;
  446 +
  447 + YUITest.TestRunner.add(new YUITest.TestCase({
  448 +
  449 + name: "Empty Rule Errors",
  450 +
  451 + "Empty rule should result in a warning": function(){
  452 + var result = CSSLint.verify("li { }", { "empty-rules": 1 });
  453 + Assert.areEqual(1, result.messages.length);
  454 + Assert.areEqual("warning", result.messages[0].type);
  455 + Assert.areEqual("Rule is empty.", result.messages[0].message);
  456 + }
  457 + }));
  458 +
  459 +})();
  460 +
  461 +(function(){
  462 +
  463 + /*global YUITest, CSSLint*/
  464 + var Assert = YUITest.Assert;
  465 +
  466 + YUITest.TestRunner.add(new YUITest.TestCase({
  467 +
  468 + name: "Parsing Errors",
  469 +
  470 + "Parsing error should result in one parsing error message": function(){
  471 + var result = CSSLint.verify("li { float left;}", { errors: 1 });
  472 + Assert.areEqual(1, result.messages.length);
  473 + Assert.areEqual("error", result.messages[0].type);
  474 + }
  475 + }));
  476 +
  477 +})();
  478 +
  479 +(function(){
  480 +
  481 + /*global YUITest, CSSLint*/
  482 + var Assert = YUITest.Assert;
  483 +
  484 + YUITest.TestRunner.add(new YUITest.TestCase({
  485 +
  486 + name: "Floats Rule Errors",
  487 +
  488 + "10 floats should result in a warning": function(){
  489 + var result = CSSLint.verify(".foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; }", { "floats": 1 });
  490 + Assert.areEqual(1, result.messages.length);
  491 + Assert.areEqual("warning", result.messages[0].type);
  492 + Assert.areEqual("Too many floats (10), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
  493 + },
  494 +
  495 + "9 floats should not result in a warning": function(){
  496 + var result = CSSLint.verify(".foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; }", { "floats": 1 });
  497 + Assert.areEqual(0, result.messages.length);
  498 + },
  499 +
  500 + "11 floats should result in a warning": function(){
  501 + var result = CSSLint.verify(".foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; }", { "floats": 1 });
  502 + Assert.areEqual(1, result.messages.length);
  503 + Assert.areEqual("warning", result.messages[0].type);
  504 + Assert.areEqual("Too many floats (11), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
  505 + },
  506 +
  507 + "float: none should not count and therefore should not result in a warning": function(){
  508 + var result = CSSLint.verify(".foo { float: none; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; } .foo { float: left; }", { "floats": 1 });
  509 + Assert.areEqual(0, result.messages.length);
  510 + }
  511 + }));
  512 +
  513 +})();
  514 +
  515 +(function(){
  516 +
  517 + /*global YUITest, CSSLint*/
  518 + var Assert = YUITest.Assert;
  519 +
  520 + YUITest.TestRunner.add(new YUITest.TestCase({
  521 +
  522 + name: "font-faces Rule Errors",
  523 +
  524 + "5 font-faces should result in a warning": function(){
  525 + var result = CSSLint.verify("@font-face{ } @font-face{ } @font-face{ } @font-face{ } @font-face{ }", { "font-faces": 1 });
  526 + Assert.areEqual(0, result.messages.length);
  527 + },
  528 +
  529 + "4 font-faces should not result in a warning": function(){
  530 + var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
  531 + Assert.areEqual(0, result.messages.length);
  532 + },
  533 +
  534 + "6 font-faces should result in a warning": function(){
  535 + var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
  536 + Assert.areEqual(1, result.messages.length);
  537 + Assert.areEqual("warning", result.messages[0].type);
  538 + Assert.areEqual("Too many @font-face declarations (6).", result.messages[0].message);
  539 + }
  540 + }));
  541 +
  542 +})();
  543 +
  544 +(function(){
  545 +
  546 + /*global YUITest, CSSLint*/
  547 + var Assert = YUITest.Assert;
  548 +
  549 + YUITest.TestRunner.add(new YUITest.TestCase({
  550 +
  551 + name: "font-size Rule Errors",
  552 +
  553 + "10 font-sizes should result in a warning": function(){
  554 + var result = CSSLint.verify(".foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } ", {"font-sizes": 1 });
  555 + Assert.areEqual(1, result.messages.length);
  556 + Assert.areEqual("warning", result.messages[0].type);
  557 + Assert.areEqual("Too many font-size declarations (10), abstraction needed.", result.messages[0].message);
  558 + },
  559 +
  560 + "9 font-sizes should not result in a warning": function(){
  561 + var result = CSSLint.verify(" .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } ", {"font-sizes": 1 });
  562 + Assert.areEqual(0, result.messages.length);
  563 + },
  564 +
  565 + "11 font-sizes should result in a warning": function(){
  566 + var result = CSSLint.verify(".foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } .foo { font-size: 10px; } ", {"font-sizes": 1 });
  567 + Assert.areEqual(1, result.messages.length);
  568 + Assert.areEqual("warning", result.messages[0].type);
  569 + Assert.areEqual("Too many font-size declarations (11), abstraction needed.", result.messages[0].message);
  570 + }
  571 + }));
  572 +
  573 +})();
  574 +
  575 +(function(){
  576 +
  577 + /*global YUITest, CSSLint*/
  578 + var Assert = YUITest.Assert;
  579 +
  580 + YUITest.TestRunner.add(new YUITest.TestCase({
  581 +
  582 +/*
  583 +background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
  584 +background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
  585 +background: -webkit-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
  586 +background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
  587 +background: -ms-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
  588 +
  589 +*/
  590 +
  591 + name: "Gradients Rule Errors",
  592 +
  593 + "Only using Mozilla gradients should result in a warning": function(){
  594 + var result = CSSLint.verify(".foo { background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
  595 + Assert.areEqual(1, result.messages.length);
  596 + Assert.areEqual("warning", result.messages[0].type);
  597 + },
  598 +
  599 + "Only using Opera gradients should result in a warning": function(){
  600 + var result = CSSLint.verify(".foo { background: -o-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
  601 + Assert.areEqual(1, result.messages.length);
  602 + Assert.areEqual("warning", result.messages[0].type);
  603 + },
  604 +
  605 + "Only using IE gradients should result in a warning": function(){
  606 + var result = CSSLint.verify(".foo { background: -ms-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
  607 + Assert.areEqual(1, result.messages.length);
  608 + Assert.areEqual("warning", result.messages[0].type);
  609 + },
  610 +
  611 + "Only using WebKit gradients should result in a warning": function(){
  612 + var result = CSSLint.verify(".foo { background: -webkit-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
  613 + Assert.areEqual(1, result.messages.length);
  614 + Assert.areEqual("warning", result.messages[0].type);
  615 + }
  616 +
  617 + //parser barfs
  618 + /*"Only using old WebKit gradients should result in a warning": function(){
  619 + var result = CSSLint.verify(".foo { background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8)); }", {"gradients": 1 });
  620 + Assert.areEqual(1, result.messages.length);
  621 + Assert.areEqual("warning", result.messages[0].type);
  622 + } */
  623 + }));
  624 +
  625 +})();
  626 +
  627 +(function(){
  628 +
  629 + /*global YUITest, CSSLint*/
  630 + var Assert = YUITest.Assert;
  631 +
  632 + YUITest.TestRunner.add(new YUITest.TestCase({
  633 +
  634 + name: "IDs Rule Errors",
  635 +
  636 + "Using an ID should result in one warning": function(){
  637 + var result = CSSLint.verify("#foo { float: left;}", { ids: 1 });
  638 + Assert.areEqual(1, result.messages.length);
  639 + Assert.areEqual("warning", result.messages[0].type);
  640 + Assert.areEqual("Don't use IDs in selectors.", result.messages[0].message);
  641 + },
  642 +
  643 + "Using multiple IDs should result in one warning": function(){
  644 + var result = CSSLint.verify("#foo #bar { float: left;}", { ids: 1 });
  645 + Assert.areEqual(1, result.messages.length);
  646 + Assert.areEqual("warning", result.messages[0].type);
  647 + Assert.areEqual("2 IDs in the selector, really?", result.messages[0].message);
  648 + }
  649 + }));
  650 +
  651 +})();
  652 +
  653 +(function(){
  654 +
  655 + /*global YUITest, CSSLint*/
  656 + var Assert = YUITest.Assert;
  657 +
  658 + YUITest.TestRunner.add(new YUITest.TestCase({
  659 +
  660 + name: "Import Rule Errors",
  661 +
  662 + "Using @import should result in a warning": function(){
  663 + var result = CSSLint.verify("@import url('foo.css');", { "import": 1 });
  664 + Assert.areEqual(1, result.messages.length);
  665 + Assert.areEqual("warning", result.messages[0].type);
  666 + Assert.areEqual("@import prevents parallel downloads, use <link> instead.", result.messages[0].message);
  667 + }
  668 + }));
  669 +
  670 +})();
  671 +
  672 +(function(){
  673 +
  674 + /*global YUITest, CSSLint*/
  675 + var Assert = YUITest.Assert;
  676 +
  677 + YUITest.TestRunner.add(new YUITest.TestCase({
  678 +
  679 + name: "!important; Errors",
  680 +
  681 + "!important declarations should result in a warning": function(){
  682 + var result = CSSLint.verify("h1 { color:#fff !important; }", { "important": 1 });
  683 + Assert.areEqual(1, result.messages.length);
  684 + Assert.areEqual("warning", result.messages[0].type);
  685 + Assert.areEqual("Use of !important", result.messages[0].message);
  686 + },
  687 +
  688 + "Using !important at least 10 times should result in an error": function(){
  689 + var css = "h1 { color:#fff !important; } h2 { color:#fff !important; } h3 { color:#fff !important; } h4 { color:#fff !important; } h5 { color:#fff !important; } h6 { color:#fff !important; } p { color:#fff !important; } ul { color:#fff !important; } ol { color:#fff !important; } li { color:#fff !important; }";
  690 + var result = CSSLint.verify(css, { "important": 1 });
  691 + Assert.areEqual(11, result.messages.length);
  692 + Assert.areEqual("error", result.messages[10].type);
  693 + Assert.areEqual("Too many !important declarations (10), be careful with rule specificity", result.messages[10].message);
  694 + }
  695 +
  696 + }));
  697 +
  698 +})();
  699 +
  700 +(function(){
  701 +
  702 + /*global YUITest, CSSLint*/
  703 + var Assert = YUITest.Assert;
  704 +
  705 + YUITest.TestRunner.add(new YUITest.TestCase({
  706 +
  707 + name: "Overqualified Elements Errors",
  708 +
  709 + "Using an ID with an element should result in one warning": function(){
  710 + var result = CSSLint.verify("li#foo { float: left;}", { "overqualified-elements": 1 });
  711 + Assert.areEqual(1, result.messages.length);
  712 + Assert.areEqual("warning", result.messages[0].type);
  713 + Assert.areEqual("Element (li#foo) is overqualified, just use #foo without element name.", result.messages[0].message);
  714 + },
  715 +
  716 + "Using a class without an element should not result in a warning": function(){
  717 + var result = CSSLint.verify(".foo { float: left;}", { "overqualified-elements": 1 });
  718 + Assert.areEqual(0, result.messages.length);
  719 + },
  720 +
  721 + "Using a class with an element should result in one warning": function(){
  722 + var result = CSSLint.verify("li.foo { float: left;}", { "overqualified-elements": 1 });
  723 + Assert.areEqual(1, result.messages.length);
  724 + Assert.areEqual("warning", result.messages[0].type);
  725 + Assert.areEqual("Element (li.foo) is overqualified, just use .foo without element name.", result.messages[0].message);
  726 + },
  727 +
  728 + "Using a class with two different elements should not result in a warning": function(){
  729 + var result = CSSLint.verify("li.foo { float: left;} p.foo { float: right; }", { "overqualified-elements": 1 });
  730 + Assert.areEqual(0, result.messages.length);
  731 + },
  732 +
  733 + "Using a class with an element and without should not result in a warning": function(){
  734 + var result = CSSLint.verify("li.foo { float: left;} .foo { float: right; }", { "overqualified-elements": 1 });
  735 + Assert.areEqual(0, result.messages.length);
  736 + }
  737 +
  738 + }));
  739 +
  740 +})();
  741 +
  742 +(function(){
  743 +
  744 + /*global YUITest, CSSLint*/
  745 + var Assert = YUITest.Assert;
  746 +
  747 + YUITest.TestRunner.add(new YUITest.TestCase({
  748 +
  749 + name: "Qualified Headings Errors",
  750 +
  751 + "Using a heading as a descendant should result in one warning": function(){
  752 + var result = CSSLint.verify("li h3{ float: left;}", { "qualified-headings": 1 });
  753 + Assert.areEqual(1, result.messages.length);
  754 + Assert.areEqual("warning", result.messages[0].type);
  755 + Assert.areEqual("Heading (h3) should not be qualified.", result.messages[0].message);
  756 + }
  757 +
  758 + }));
  759 +
  760 +})();
  761 +
  762 +(function(){
  763 +
  764 + /*global YUITest, CSSLint*/
  765 + var Assert = YUITest.Assert;
  766 +
  767 + YUITest.TestRunner.add(new YUITest.TestCase({
  768 +
  769 + name: "Regex Selectors Errors",
  770 +
  771 + "Using |= in an attribute selector should result in one warning": function(){
  772 + var result = CSSLint.verify("li[class|=foo]{ color: red; }", { "regex-selectors": 1 });
  773 + Assert.areEqual(1, result.messages.length);
  774 + Assert.areEqual("warning", result.messages[0].type);
  775 + Assert.areEqual("Attribute selectors with |= are slow!", result.messages[0].message);
  776 + },
  777 +
  778 + "Using *= in an attribute selector should result in one warning": function(){
  779 + var result = CSSLint.verify("li[class*=foo]{ color: red; }", { "regex-selectors": 1 });
  780 + Assert.areEqual(1, result.messages.length);
  781 + Assert.areEqual("warning", result.messages[0].type);
  782 + Assert.areEqual("Attribute selectors with *= are slow!", result.messages[0].message);
  783 + },
  784 +
  785 + "Using $= in an attribute selector should result in one warning": function(){
  786 + var result = CSSLint.verify("li[class$=foo]{ color: red; }", { "regex-selectors": 1 });
  787 + Assert.areEqual(1, result.messages.length);
  788 + Assert.areEqual("warning", result.messages[0].type);
  789 + Assert.areEqual("Attribute selectors with $= are slow!", result.messages[0].message);
  790 + },
  791 +
  792 + "Using ~= in an attribute selector should result in one warning": function(){
  793 + var result = CSSLint.verify("li[class~=foo]{ color: red; }", { "regex-selectors": 1 });
  794 + Assert.areEqual(1, result.messages.length);
  795 + Assert.areEqual("warning", result.messages[0].type);
  796 + Assert.areEqual("Attribute selectors with ~= are slow!", result.messages[0].message);
  797 + },
  798 +
  799 + "Using ^= in an attribute selector should result in one warning": function(){
  800 + var result = CSSLint.verify("li[class^=foo]{ color: red; }", { "regex-selectors": 1 });
  801 + Assert.areEqual(1, result.messages.length);
  802 + Assert.areEqual("warning", result.messages[0].type);
  803 + Assert.areEqual("Attribute selectors with ^= are slow!", result.messages[0].message);
  804 + },
  805 +
  806 + "Using = in an attribute selector should not result in a warning": function(){
  807 + var result = CSSLint.verify("li[class=foo]{ color: red; }", { "regex-selectors": 1 });
  808 + Assert.areEqual(0, result.messages.length);
  809 + }
  810 +
  811 + }));
  812 +
  813 +})();
  814 +
  815 +(function(){
  816 +
  817 + /*global YUITest, CSSLint*/
  818 + var Assert = YUITest.Assert;
  819 +
  820 + YUITest.TestRunner.add(new YUITest.TestCase({
  821 +
  822 + name: "Unique Headings Errors",
  823 +
  824 + "Defining two rules for h1 should result in one warning": function(){
  825 + var result = CSSLint.verify("h1 { color: red;} h1 {color: blue;}", { "unique-headings": 1 });
  826 + Assert.areEqual(1, result.messages.length);
  827 + Assert.areEqual("warning", result.messages[0].type);
  828 + Assert.areEqual("Heading (h1) has already been defined.", result.messages[0].message);
  829 + },
  830 +
  831 + "Defining one rule for h1 should not result in a warning": function(){
  832 + var result = CSSLint.verify("h1 { color: red;}", { "unique-headings": 1 });
  833 + Assert.areEqual(0, result.messages.length);
  834 + },
  835 +
  836 + "Defining multiple rules that contain h1 should not result in a warning": function(){
  837 + var result = CSSLint.verify("h2 a, h2 a:active, h2 a:hover, h2 a:visited, h2 a:link { color: red;}", { "unique-headings": 1 });
  838 + Assert.areEqual(0, result.messages.length);
  839 + }
  840 +
  841 + }));