ruby_css_lint 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +19 -0
  5. data/Rakefile +71 -0
  6. data/VERSION +1 -0
  7. data/csslint/CHANGELOG +286 -0
  8. data/csslint/LICENSE +20 -0
  9. data/csslint/README.md +25 -0
  10. data/csslint/build.xml +242 -0
  11. data/csslint/demos/CSSLintDemo.htm +105 -0
  12. data/csslint/demos/demo.css +43 -0
  13. data/csslint/lib/js.jar +0 -0
  14. data/csslint/lib/jshint.js +3963 -0
  15. data/csslint/lib/parserlib.js +6295 -0
  16. data/csslint/lib/yuitest-rhino-cli.js +3955 -0
  17. data/csslint/lib/yuitest.js +4561 -0
  18. data/csslint/npm/package.json +30 -0
  19. data/csslint/release/csslint-node.js +9125 -0
  20. data/csslint/release/csslint-rhino.js +9390 -0
  21. data/csslint/release/csslint-tests.js +1921 -0
  22. data/csslint/release/csslint-worker.js +9148 -0
  23. data/csslint/release/csslint-wsh.js +9477 -0
  24. data/csslint/release/csslint.js +9127 -0
  25. data/csslint/release/npm/cli.js +307 -0
  26. data/csslint/release/npm/lib/csslint-node.js +9125 -0
  27. data/csslint/release/npm/package.json +30 -0
  28. data/csslint/src/cli/common.js +215 -0
  29. data/csslint/src/cli/node.js +87 -0
  30. data/csslint/src/cli/rhino.js +47 -0
  31. data/csslint/src/cli/wsh.js +134 -0
  32. data/csslint/src/core/CSSLint.js +181 -0
  33. data/csslint/src/core/Reporter.js +161 -0
  34. data/csslint/src/core/Util.js +62 -0
  35. data/csslint/src/formatters/checkstyle-xml.js +109 -0
  36. data/csslint/src/formatters/compact.js +59 -0
  37. data/csslint/src/formatters/csslint-xml.js +68 -0
  38. data/csslint/src/formatters/lint-xml.js +69 -0
  39. data/csslint/src/formatters/text.js +64 -0
  40. data/csslint/src/rules/adjoining-classes.js +45 -0
  41. data/csslint/src/rules/box-model.js +93 -0
  42. data/csslint/src/rules/box-sizing.js +28 -0
  43. data/csslint/src/rules/compatible-vendor-prefixes.js +171 -0
  44. data/csslint/src/rules/display-property-grouping.js +117 -0
  45. data/csslint/src/rules/duplicate-background-images.js +37 -0
  46. data/csslint/src/rules/duplicate-properties.js +46 -0
  47. data/csslint/src/rules/empty-rules.js +34 -0
  48. data/csslint/src/rules/errors.js +23 -0
  49. data/csslint/src/rules/fallback-colors.js +67 -0
  50. data/csslint/src/rules/floats.js +36 -0
  51. data/csslint/src/rules/font-faces.js +30 -0
  52. data/csslint/src/rules/font-sizes.js +35 -0
  53. data/csslint/src/rules/gradients.js +69 -0
  54. data/csslint/src/rules/ids.js +50 -0
  55. data/csslint/src/rules/import.js +23 -0
  56. data/csslint/src/rules/important.js +37 -0
  57. data/csslint/src/rules/known-properties.js +29 -0
  58. data/csslint/src/rules/outline-none.js +73 -0
  59. data/csslint/src/rules/overqualified-elements.js +63 -0
  60. data/csslint/src/rules/qualified-headings.js +38 -0
  61. data/csslint/src/rules/regex-selectors.js +44 -0
  62. data/csslint/src/rules/rules-count.js +28 -0
  63. data/csslint/src/rules/shorthand.js +87 -0
  64. data/csslint/src/rules/star-property-hack.js +27 -0
  65. data/csslint/src/rules/text-indent.js +53 -0
  66. data/csslint/src/rules/underscore-property-hack.js +27 -0
  67. data/csslint/src/rules/unique-headings.js +74 -0
  68. data/csslint/src/rules/universal-selector.js +35 -0
  69. data/csslint/src/rules/unqualified-attributes.js +42 -0
  70. data/csslint/src/rules/vendor-prefix.js +143 -0
  71. data/csslint/src/rules/zero-units.js +34 -0
  72. data/csslint/src/worker/Worker.js +26 -0
  73. data/csslint/tests/all-rules.js +64 -0
  74. data/csslint/tests/core/CSSLint.js +22 -0
  75. data/csslint/tests/core/Reporter.js +36 -0
  76. data/csslint/tests/css/width-100.html +76 -0
  77. data/csslint/tests/formatters/checkstyle-xml.js +44 -0
  78. data/csslint/tests/formatters/compact.js +47 -0
  79. data/csslint/tests/formatters/csslint-xml.js +42 -0
  80. data/csslint/tests/formatters/lint-xml.js +43 -0
  81. data/csslint/tests/formatters/text.js +36 -0
  82. data/csslint/tests/rules/adjoining-classes.js +31 -0
  83. data/csslint/tests/rules/box-model.js +211 -0
  84. data/csslint/tests/rules/box-sizing.js +23 -0
  85. data/csslint/tests/rules/compatible-vendor-prefixes.js +56 -0
  86. data/csslint/tests/rules/display-property-grouping.js +213 -0
  87. data/csslint/tests/rules/duplicate-background-images.js +25 -0
  88. data/csslint/tests/rules/duplicate-properties.js +54 -0
  89. data/csslint/tests/rules/empty-rules.js +18 -0
  90. data/csslint/tests/rules/errors.js +17 -0
  91. data/csslint/tests/rules/fallback-colors.js +162 -0
  92. data/csslint/tests/rules/floats.js +35 -0
  93. data/csslint/tests/rules/font-faces.js +28 -0
  94. data/csslint/tests/rules/font-sizes.js +30 -0
  95. data/csslint/tests/rules/gradients.js +60 -0
  96. data/csslint/tests/rules/ids.js +25 -0
  97. data/csslint/tests/rules/import.js +18 -0
  98. data/csslint/tests/rules/important.js +27 -0
  99. data/csslint/tests/rules/known-properties.js +44 -0
  100. data/csslint/tests/rules/outline-none.js +50 -0
  101. data/csslint/tests/rules/overqualified-elements.js +41 -0
  102. data/csslint/tests/rules/qualified-headings.js +19 -0
  103. data/csslint/tests/rules/regex-selectors.js +52 -0
  104. data/csslint/tests/rules/shorthand.js +36 -0
  105. data/csslint/tests/rules/star-property-hack.js +24 -0
  106. data/csslint/tests/rules/text-indent.js +55 -0
  107. data/csslint/tests/rules/underscore-property-hack.js +24 -0
  108. data/csslint/tests/rules/unique-headings.js +47 -0
  109. data/csslint/tests/rules/universal-selector.js +31 -0
  110. data/csslint/tests/rules/unqualified-attributes.js +37 -0
  111. data/csslint/tests/rules/vendor-prefix.js +76 -0
  112. data/csslint/tests/rules/zero-units.js +44 -0
  113. data/csslint/tests/testrunner.htm +138 -0
  114. data/js.jar +0 -0
  115. data/lib/ruby_css_lint.rb +168 -0
  116. data/test/helper.rb +17 -0
  117. data/test/test_ruby_css_lint.rb +7 -0
  118. metadata +240 -0
@@ -0,0 +1,18 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Import Rule Errors",
9
+
10
+ "Using @import should result in a warning": function(){
11
+ var result = CSSLint.verify("@import url('foo.css');", { "import": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("@import prevents parallel downloads, use <link> instead.", result.messages[0].message);
15
+ }
16
+ }));
17
+
18
+ })();
@@ -0,0 +1,27 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "!important; Errors",
9
+
10
+ "!important declarations should result in a warning": function(){
11
+ var result = CSSLint.verify("h1 { color:#fff !important; }", { "important": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Use of !important", result.messages[0].message);
15
+ },
16
+
17
+ "Using !important at least 10 times should result in an error": function(){
18
+ 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; }";
19
+ var result = CSSLint.verify(css, { "important": 1 });
20
+ Assert.areEqual(11, result.messages.length);
21
+ Assert.areEqual("warning", result.messages[10].type);
22
+ Assert.areEqual("Too many !important declarations (10), try to use less than 10 to avoid specificity issues.", result.messages[10].message);
23
+ }
24
+
25
+ }));
26
+
27
+ })();
@@ -0,0 +1,44 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Known Properties Errors",
9
+
10
+ "Using an unknown property should result in a warning": function(){
11
+ var result = CSSLint.verify("h1 { foo: red;}", { "known-properties": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Unknown property 'foo'.", result.messages[0].message);
15
+ },
16
+
17
+ "Using a known property should not result in a warning": function(){
18
+ var result = CSSLint.verify("h1 { color: red;}", { "known-properties": 1 });
19
+ Assert.areEqual(0, result.messages.length);
20
+ },
21
+
22
+ "Using a known property with the star hack should not result in a warning": function(){
23
+ var result = CSSLint.verify("h1 { *color: red;}", { "known-properties": 1 });
24
+ Assert.areEqual(0, result.messages.length);
25
+ },
26
+
27
+ "Using a known property with the underscore hack should not result in a warning": function(){
28
+ var result = CSSLint.verify("h1 { _color: red;}", { "known-properties": 1 });
29
+ Assert.areEqual(0, result.messages.length);
30
+ },
31
+
32
+ "Using a vendor-prefix property should not result in a warning": function(){
33
+ var result = CSSLint.verify("h2 { -moz-border-radius: 5px; }", { "known-properties": 1 });
34
+ Assert.areEqual(0, result.messages.length);
35
+ },
36
+
37
+ "Using src in @font-face should not result in a warning": function(){
38
+ var result = CSSLint.verify("@font-face { src: url(foo.otf); }", { "known-properties": 1 });
39
+ Assert.areEqual(0, result.messages.length);
40
+ }
41
+
42
+ }));
43
+
44
+ })();
@@ -0,0 +1,50 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Outline:none Errors",
9
+
10
+ "Using outline: none should result in a warning": function(){
11
+ var result = CSSLint.verify(".foo { outline: none; }", { "outline-none": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Outlines should only be modified using :focus.", result.messages[0].message);
15
+ },
16
+
17
+ "Using outline: 0 should result in a warning": function(){
18
+ var result = CSSLint.verify(".foo { outline: 0; }", { "outline-none": 1 });
19
+ Assert.areEqual(1, result.messages.length);
20
+ Assert.areEqual("warning", result.messages[0].type);
21
+ Assert.areEqual("Outlines should only be modified using :focus.", result.messages[0].message);
22
+ },
23
+
24
+ "Using outline: none alone with :focus should result in a warning": function(){
25
+ var result = CSSLint.verify(".foo:focus { outline: none; }", { "outline-none": 1 });
26
+ Assert.areEqual(1, result.messages.length);
27
+ Assert.areEqual("warning", result.messages[0].type);
28
+ Assert.areEqual("Outlines shouldn't be hidden unless other visual changes are made.", result.messages[0].message);
29
+ },
30
+
31
+ "Using outline: 0 alone with :focus should result in a warning": function(){
32
+ var result = CSSLint.verify(".foo:focus { outline: 0; }", { "outline-none": 1 });
33
+ Assert.areEqual(1, result.messages.length);
34
+ Assert.areEqual("warning", result.messages[0].type);
35
+ Assert.areEqual("Outlines shouldn't be hidden unless other visual changes are made.", result.messages[0].message);
36
+ },
37
+
38
+ "Using outline: none with :focus and another property should not result in a warning": function(){
39
+ var result = CSSLint.verify(".foo:focus { outline: none; border: 1px solid black; }", { "outline-none": 1 });
40
+ Assert.areEqual(0, result.messages.length);
41
+ },
42
+
43
+ "Using outline: 0 with :focus and another property should not result in a warning": function(){
44
+ var result = CSSLint.verify(".foo:focus { outline: 0; border: 1px solid black;}", { "outline-none": 1 });
45
+ Assert.areEqual(0, result.messages.length);
46
+ }
47
+
48
+ }));
49
+
50
+ })();
@@ -0,0 +1,41 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Overqualified Elements Errors",
9
+
10
+ "Using an ID with an element should result in one warning": function(){
11
+ var result = CSSLint.verify("li#foo { float: left;}", { "overqualified-elements": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Element (li#foo) is overqualified, just use #foo without element name.", result.messages[0].message);
15
+ },
16
+
17
+ "Using a class without an element should not result in a warning": function(){
18
+ var result = CSSLint.verify(".foo { float: left;}", { "overqualified-elements": 1 });
19
+ Assert.areEqual(0, result.messages.length);
20
+ },
21
+
22
+ "Using a class with an element should result in one warning": function(){
23
+ var result = CSSLint.verify("li.foo { float: left;}", { "overqualified-elements": 1 });
24
+ Assert.areEqual(1, result.messages.length);
25
+ Assert.areEqual("warning", result.messages[0].type);
26
+ Assert.areEqual("Element (li.foo) is overqualified, just use .foo without element name.", result.messages[0].message);
27
+ },
28
+
29
+ "Using a class with two different elements should not result in a warning": function(){
30
+ var result = CSSLint.verify("li.foo { float: left;} p.foo { float: right; }", { "overqualified-elements": 1 });
31
+ Assert.areEqual(0, result.messages.length);
32
+ },
33
+
34
+ "Using a class with an element and without should not result in a warning": function(){
35
+ var result = CSSLint.verify("li.foo { float: left;} .foo { float: right; }", { "overqualified-elements": 1 });
36
+ Assert.areEqual(0, result.messages.length);
37
+ }
38
+
39
+ }));
40
+
41
+ })();
@@ -0,0 +1,19 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Qualified Headings Errors",
9
+
10
+ "Using a heading as a descendant should result in one warning": function(){
11
+ var result = CSSLint.verify("li h3{ float: left;}", { "qualified-headings": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Heading (h3) should not be qualified.", result.messages[0].message);
15
+ }
16
+
17
+ }));
18
+
19
+ })();
@@ -0,0 +1,52 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Regex Selectors Errors",
9
+
10
+ "Using |= in an attribute selector should result in one warning": function(){
11
+ var result = CSSLint.verify("li[class|=foo]{ color: red; }", { "regex-selectors": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Attribute selectors with |= are slow!", result.messages[0].message);
15
+ },
16
+
17
+ "Using *= in an attribute selector should result in one warning": function(){
18
+ var result = CSSLint.verify("li[class*=foo]{ color: red; }", { "regex-selectors": 1 });
19
+ Assert.areEqual(1, result.messages.length);
20
+ Assert.areEqual("warning", result.messages[0].type);
21
+ Assert.areEqual("Attribute selectors with *= are slow!", result.messages[0].message);
22
+ },
23
+
24
+ "Using $= in an attribute selector should result in one warning": function(){
25
+ var result = CSSLint.verify("li[class$=foo]{ color: red; }", { "regex-selectors": 1 });
26
+ Assert.areEqual(1, result.messages.length);
27
+ Assert.areEqual("warning", result.messages[0].type);
28
+ Assert.areEqual("Attribute selectors with $= are slow!", result.messages[0].message);
29
+ },
30
+
31
+ "Using ~= in an attribute selector should result in one warning": function(){
32
+ var result = CSSLint.verify("li[class~=foo]{ color: red; }", { "regex-selectors": 1 });
33
+ Assert.areEqual(1, result.messages.length);
34
+ Assert.areEqual("warning", result.messages[0].type);
35
+ Assert.areEqual("Attribute selectors with ~= are slow!", result.messages[0].message);
36
+ },
37
+
38
+ "Using ^= in an attribute selector should result in one warning": function(){
39
+ var result = CSSLint.verify("li[class^=foo]{ color: red; }", { "regex-selectors": 1 });
40
+ Assert.areEqual(1, result.messages.length);
41
+ Assert.areEqual("warning", result.messages[0].type);
42
+ Assert.areEqual("Attribute selectors with ^= are slow!", result.messages[0].message);
43
+ },
44
+
45
+ "Using = in an attribute selector should not result in a warning": function(){
46
+ var result = CSSLint.verify("li[class=foo]{ color: red; }", { "regex-selectors": 1 });
47
+ Assert.areEqual(0, result.messages.length);
48
+ }
49
+
50
+ }));
51
+
52
+ })();
@@ -0,0 +1,36 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Shorthand Rule Errors",
9
+
10
+ "All padding properties should result in a warning": function(){
11
+ var result = CSSLint.verify(".foo{padding-top: 0px; padding-left: 3px; padding-right: 25px; padding-bottom: 10px;}", {"shorthand": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("The properties padding-top, padding-bottom, padding-left, padding-right can be replaced by padding.", result.messages[0].message);
15
+ },
16
+
17
+ "All margin properties should result in a warning": function(){
18
+ var result = CSSLint.verify(".foo{margin-top: 0px; margin-left: 3px; margin-right: 25px; margin-bottom: 10px;}", {"shorthand": 1 });
19
+ Assert.areEqual(1, result.messages.length);
20
+ Assert.areEqual("warning", result.messages[0].type);
21
+ Assert.areEqual("The properties margin-top, margin-bottom, margin-left, margin-right can be replaced by margin.", result.messages[0].message);
22
+ },
23
+
24
+ "padding-left should not result in a warning": function(){
25
+ var result = CSSLint.verify(".foo{ padding-left: 8px;} ", {"shorthand": 1 });
26
+ Assert.areEqual(0, result.messages.length);
27
+ },
28
+
29
+ "margin-top should not result in a warning": function(){
30
+ var result = CSSLint.verify(".foo{ margin-top: 8px;} ", {"shorthand": 1 });
31
+ Assert.areEqual(0, result.messages.length);
32
+ }
33
+
34
+ }));
35
+
36
+ })();
@@ -0,0 +1,24 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "star-property-hack Rule Errors",
9
+
10
+ "a property with a star prefix should result in a warning": function(){
11
+ var result = CSSLint.verify(".foo{*width: 100px;}", {"star-property-hack": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Property with star prefix found.", result.messages[0].message);
15
+ },
16
+
17
+ "a property without a star prefix should not result in a warning": function(){
18
+ var result = CSSLint.verify(".foo{width: 100px;}", {"star-property-hack": 1 });
19
+ Assert.areEqual(0, result.messages.length);
20
+ }
21
+
22
+ }));
23
+
24
+ })();
@@ -0,0 +1,55 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "text-indent Rule Errors",
9
+
10
+ "-100px text-indent should result in a warning": function(){
11
+ var result = CSSLint.verify(".foo{text-indent: -100px;}", {"text-indent": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", result.messages[0].message);
15
+ },
16
+
17
+ "-99px text-indent should not result in a warning": function(){
18
+ var result = CSSLint.verify(".foo{text-indent: -99px;} ", {"text-indent": 1 });
19
+ Assert.areEqual(0, result.messages.length);
20
+ },
21
+
22
+ "-99em text-indent should not result in a warning": function(){
23
+ var result = CSSLint.verify(".foo{text-indent: -99em;} ", {"text-indent": 1 });
24
+ Assert.areEqual(0, result.messages.length);
25
+ },
26
+
27
+ "-100px text-indent with LTR should not result in a warning": function(){
28
+ var result = CSSLint.verify(".foo{text-indent: -100px; direction: ltr; }", {"text-indent": 1 });
29
+ Assert.areEqual(0, result.messages.length);
30
+ result = CSSLint.verify(".foo{direction: ltr; text-indent: -100px; }", {"text-indent": 1 });
31
+ Assert.areEqual(0, result.messages.length);
32
+ },
33
+
34
+ "-100em text-indent with RTL should result in a warning": function(){
35
+ var result = CSSLint.verify(".foo{text-indent: -100em; direction: rtl; }", {"text-indent": 1 });
36
+ Assert.areEqual(1, result.messages.length);
37
+ Assert.areEqual("warning", result.messages[0].type);
38
+ Assert.areEqual("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", result.messages[0].message);
39
+ },
40
+
41
+ "5px text-indent should not result in a warning": function(){
42
+ var result = CSSLint.verify(".foo{text-indent: 5px;}", {"text-indent": 1 });
43
+ Assert.areEqual(0, result.messages.length);
44
+ },
45
+
46
+ "This should cause a warning, not an error": function(){
47
+ var result = CSSLint.verify(".top h1 a { background: url(../images/background/logo.png) no-repeat; display: block; height: 44px; position: relative; text-indent: -9999px; width: 250px; }", { "text-indent": 1 });
48
+ Assert.areEqual(1, result.messages.length);
49
+ Assert.areEqual("warning", result.messages[0].type);
50
+ Assert.areEqual("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", result.messages[0].message);
51
+ }
52
+
53
+ }));
54
+
55
+ })();
@@ -0,0 +1,24 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "underscore-property-hack Rule Errors",
9
+
10
+ "a property with an underscore prefix should result in a warning": function(){
11
+ var result = CSSLint.verify(".foo{_width: 100px;}", {"underscore-property-hack": 1 });
12
+ Assert.areEqual(1, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Property with underscore prefix found.", result.messages[0].message);
15
+ },
16
+
17
+ "a property without an underscore prefix should not result in a warning": function(){
18
+ var result = CSSLint.verify(".foo{width: 100px;}", {"underscore-property-hack": 1 });
19
+ Assert.areEqual(0, result.messages.length);
20
+ }
21
+
22
+ }));
23
+
24
+ })();
@@ -0,0 +1,47 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Unique Headings Errors",
9
+
10
+ "Defining two rules for h1 should result in two warnings": function(){
11
+ var result = CSSLint.verify("h1 { color: red;} h1 {color: blue;}", { "unique-headings": 1 });
12
+ Assert.areEqual(2, result.messages.length);
13
+ Assert.areEqual("warning", result.messages[0].type);
14
+ Assert.areEqual("Heading (h1) has already been defined.", result.messages[0].message);
15
+ Assert.areEqual("warning", result.messages[1].type);
16
+ Assert.areEqual("You have 2 h1s defined in this stylesheet.", result.messages[1].message);
17
+ },
18
+
19
+ "Defining two rules for h1 and h2 should result in one warning": function(){
20
+ var result = CSSLint.verify("h1 { color: red;} h1 {color: blue;} h2 { color: red;} h2 {color: blue;}", { "unique-headings": 1 });
21
+ Assert.areEqual(3, result.messages.length);
22
+ Assert.areEqual("warning", result.messages[0].type);
23
+ Assert.areEqual("Heading (h1) has already been defined.", result.messages[0].message);
24
+ Assert.areEqual("warning", result.messages[1].type);
25
+ Assert.areEqual("Heading (h2) has already been defined.", result.messages[1].message);
26
+ Assert.areEqual("warning", result.messages[2].type);
27
+ Assert.areEqual("You have 2 h1s, 2 h2s defined in this stylesheet.", result.messages[2].message);
28
+ },
29
+
30
+ "Defining one rule for h1 should not result in a warning": function(){
31
+ var result = CSSLint.verify("h1 { color: red;}", { "unique-headings": 1 });
32
+ Assert.areEqual(0, result.messages.length);
33
+ },
34
+
35
+ "Defining a rule for h1 and h1:hover should not result in a warning": function(){
36
+ var result = CSSLint.verify("h1 { color: red;} h1:hover { color: blue; }", { "unique-headings": 1 });
37
+ Assert.areEqual(0, result.messages.length);
38
+ },
39
+
40
+ "Defining multiple rules that contain h1 should not result in a warning": function(){
41
+ var result = CSSLint.verify("h2 a, h2 a:active, h2 a:hover, h2 a:visited, h2 a:link { color: red;}", { "unique-headings": 1 });
42
+ Assert.areEqual(0, result.messages.length);
43
+ }
44
+
45
+ }));
46
+
47
+ })();