ruby_css_lint 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,64 @@
1
+ /*
2
+ * This file contains generic tests that are run against every rule. Early on,
3
+ * we found some common rule patterns that would cause errors under certain
4
+ * conditions. Instead of tracking them down individually, this file runs
5
+ * the same tests on every defined rule to track down these patterns.
6
+ *
7
+ * When run in addition to the other tests, this causes the Rhino CLI test
8
+ * to fail due to Java stack overflow. This must be run separate from other tests.
9
+ */
10
+ (function(){
11
+
12
+ /*global YUITest, CSSLint*/
13
+ var Assert = YUITest.Assert,
14
+ suite = new YUITest.TestSuite("General Tests for all Rules"),
15
+ rules = CSSLint.getRules(),
16
+ i, len;
17
+
18
+ for (i=0, len=25; i < len; i++){
19
+
20
+ (function(i, rules){
21
+
22
+ suite.add(new YUITest.TestCase({
23
+
24
+ name: "General Tests for " + rules[i].id,
25
+
26
+ setUp: function(){
27
+ this.options = {};
28
+ this.options[rules[i].id] = 1;
29
+ },
30
+
31
+ "Using @keyframes should not result in an error": function(){
32
+ var result = CSSLint.verify("@keyframes resize { 0% {padding: 0;} 50% {padding: 0;} 100% {padding: 0;}}", this.options);
33
+ Assert.areEqual(0, result.messages.length);
34
+ },
35
+
36
+ "Using @font-face should not result in an error": function(){
37
+ var result = CSSLint.verify("@font-face { src: local(foo); }", this.options);
38
+ Assert.areEqual(0, result.messages.length);
39
+ },
40
+
41
+ "Using @page should not result in an error": function(){
42
+ var result = CSSLint.verify("@page { width: 100px; }", this.options);
43
+ Assert.areEqual(0, result.messages.length);
44
+ },
45
+
46
+ "Using @page @top-left should not result in an error": function(){
47
+ var result = CSSLint.verify("@page { @top-left { content: ''; } }", this.options);
48
+ Assert.areEqual(0, result.messages.length);
49
+ },
50
+
51
+ "Using a regular rule should not result in an error": function(){
52
+ var result = CSSLint.verify("body { margin: 0; }", this.options);
53
+ Assert.areEqual(0, result.messages.length);
54
+ }
55
+
56
+ }));
57
+
58
+ })(i, rules);
59
+
60
+ }
61
+
62
+ YUITest.TestRunner.add(suite);
63
+
64
+ })();
@@ -0,0 +1,22 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "CSSLint object tests",
9
+
10
+ "Adjoining classes should not cause an error": function(){
11
+ var result = CSSLint.verify(".foo.bar{}", { });
12
+ Assert.areEqual(0, result.messages.length);
13
+ },
14
+
15
+ "@media (max-width:400px) should not cause an error": function(){
16
+ var result = CSSLint.verify("@media (max-width:400px) {}", { });
17
+ Assert.areEqual(0, result.messages.length);
18
+ }
19
+
20
+ }));
21
+
22
+ })();
@@ -0,0 +1,36 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint, Reporter*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Reporter Object Tests",
9
+
10
+ "Report should cause a warning": function(){
11
+ var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
12
+ reporter.report("Foo", 1, 1, { id: "fake-rule" });
13
+
14
+ Assert.areEqual(1, reporter.messages.length);
15
+ Assert.areEqual("warning", reporter.messages[0].type);
16
+ },
17
+
18
+ "Report should cause an error": function(){
19
+ var reporter = new CSSLint._Reporter([], { "fake-rule": 2});
20
+ reporter.report("Foo", 1, 1, { id: "fake-rule" });
21
+
22
+ Assert.areEqual(1, reporter.messages.length);
23
+ Assert.areEqual("error", reporter.messages[0].type);
24
+ },
25
+
26
+ "Calling error() should cause an error": function(){
27
+ var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
28
+ reporter.error("Foo", 1, 1, { id: "fake-rule" });
29
+
30
+ Assert.areEqual(1, reporter.messages.length);
31
+ Assert.areEqual("error", reporter.messages[0].type);
32
+ }
33
+
34
+ }));
35
+
36
+ })();
@@ -0,0 +1,76 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Untitled Document</title>
6
+ <style type="text/css">
7
+ .parent {padding: 100px;background-color:#999999}
8
+ .child {width:100%;background-color: #CCCCCC; border-collapse:collapse;}
9
+ td{border: 15px solid red;}
10
+ </style>
11
+
12
+ </head>
13
+
14
+ <body>
15
+ <div class="parent">
16
+ <div class="child">
17
+ width 100% child in a parent with padding.
18
+ </div>
19
+ </div>
20
+
21
+ <div class="parent">
22
+ <table class="child">
23
+ <tr>
24
+ <th scope="col">filler</th>
25
+ <th scope="col">filler</th>
26
+ <th scope="col">filler</th>
27
+ <th scope="col">filler</th>
28
+ <th scope="col">filler</th>
29
+ <th scope="col">filler</th>
30
+ </tr>
31
+ <tr>
32
+ <td>filler</td>
33
+ <td>filler</td>
34
+ <td>filler</td>
35
+ <td>filler</td>
36
+ <td>filler</td>
37
+ <td>filler</td>
38
+ </tr>
39
+ <tr>
40
+ <td>filler</td>
41
+ <td>filler</td>
42
+ <td>filler</td>
43
+ <td>filler</td>
44
+ <td>filler</td>
45
+ <td>filler</td>
46
+ </tr>
47
+ <tr>
48
+ <td>filler</td>
49
+ <td>filler</td>
50
+ <td>filler</td>
51
+ <td>filler</td>
52
+ <td>filler</td>
53
+ <td>filler</td>
54
+ </tr>
55
+ <tr>
56
+ <td>filler</td>
57
+ <td>filler</td>
58
+ <td>filler</td>
59
+ <td>filler</td>
60
+ <td>filler</td>
61
+ <td>filler</td>
62
+ </tr>
63
+ <tr>
64
+ <td>filler</td>
65
+ <td>filler</td>
66
+ <td>filler</td>
67
+ <td>filler</td>
68
+ <td>filler</td>
69
+ <td>filler</td>
70
+ </tr>
71
+ </table>
72
+
73
+ </div>
74
+
75
+ </body>
76
+ </html>
@@ -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: "Checkstyle XML formatter test",
9
+
10
+ "File with no problems should say so": function(){
11
+ var result = { messages: [], stats: [] },
12
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle></checkstyle>";
13
+ Assert.areEqual(expected, CSSLint.format(result, "FILE", "checkstyle-xml"));
14
+ },
15
+
16
+ "File with problems should list them": function(){
17
+ var result = { messages: [
18
+ { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "A Rule"} },
19
+ { type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "Some Other Rule"} }
20
+ ], stats: [] },
21
+ file = "<file name=\"FILE\">",
22
+ error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"BOGUS\" source=\"net.csslint.ARule\"/>",
23
+ error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"BOGUS\" source=\"net.csslint.SomeOtherRule\"/>",
24
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>" + file + error1 + error2 + "</file></checkstyle>",
25
+ actual = CSSLint.format(result, "FILE", "checkstyle-xml");
26
+ Assert.areEqual(expected, actual);
27
+ },
28
+
29
+ "Formatter should escape special characters": function() {
30
+ var specialCharsSting = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
31
+ result = { messages: [
32
+ { type: "warning", line: 1, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] },
33
+ { type: "error", line: 2, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] }
34
+ ], stats: [] },
35
+ file = "<file name=\"FILE\">",
36
+ error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"sneaky, &quot;sneaky&quot;, &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
37
+ error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"sneaky, &quot;sneaky&quot;, &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
38
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>" + file + error1 + error2 + "</file></checkstyle>",
39
+ actual = CSSLint.format(result, "FILE", "checkstyle-xml");
40
+ Assert.areEqual(expected, actual);
41
+ }
42
+
43
+ }));
44
+ })();
@@ -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
+ name: "Compact formatter",
8
+
9
+ "File with no problems should say so": function() {
10
+ var result = { messages: [], stats: [] },
11
+ actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
12
+ Assert.areEqual("path/to/FILE: Lint Free!", actual);
13
+ },
14
+
15
+ "Should have no output when quiet option is specified and no errors": function() {
16
+ var result = { messages: [], stats: [] },
17
+ actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});
18
+ Assert.areEqual("", actual);
19
+ },
20
+
21
+ "File with problems should list them": function() {
22
+ var result = { messages: [
23
+ { type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
24
+ { type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
25
+ ], stats: [] },
26
+ err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
27
+ warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
28
+ expected = err + warning,
29
+ actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
30
+ Assert.areEqual(expected, actual);
31
+ },
32
+
33
+ "Should output relative file paths": function() {
34
+ var result = { messages: [
35
+ { type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
36
+ { type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
37
+ ], stats: [] },
38
+ err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
39
+ warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
40
+ expected = err + warning,
41
+ actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
42
+ Assert.areEqual(expected, actual);
43
+ }
44
+
45
+ }));
46
+
47
+ })();
@@ -0,0 +1,42 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+ name: "CSSLint XML formatter test",
8
+
9
+ "File with no problems should say so": function(){
10
+ var result = { messages: [], stats: [] },
11
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint></csslint>";
12
+ Assert.areEqual(expected, CSSLint.format(result, "FILE", "csslint-xml"));
13
+ },
14
+
15
+ "File with problems should list them": function(){
16
+ var result = { messages: [
17
+ { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] },
18
+ { type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
19
+ ], stats: [] },
20
+ file = "<file name=\"FILE\">",
21
+ error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
22
+ error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
23
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>" + file + error1 + error2 + "</file></csslint>",
24
+ actual = CSSLint.format(result, "FILE", "csslint-xml");
25
+ Assert.areEqual(expected, actual);
26
+ },
27
+
28
+ "Formatter should escape double quotes": function() {
29
+ var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
30
+ result = { messages: [
31
+ { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
32
+ { type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
33
+ ], stats: [] },
34
+ file = "<file name=\"FILE\">",
35
+ error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\"/>",
36
+ error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\"/>",
37
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>" + file + error1 + error2 + "</file></csslint>",
38
+ actual = CSSLint.format(result, "FILE", "csslint-xml");
39
+ Assert.areEqual(expected, actual);
40
+ }
41
+ }));
42
+ })();
@@ -0,0 +1,43 @@
1
+ (function(){
2
+
3
+ /*global YUITest, CSSLint*/
4
+ var Assert = YUITest.Assert;
5
+
6
+ YUITest.TestRunner.add(new YUITest.TestCase({
7
+
8
+ name: "Lint XML formatter test",
9
+
10
+ "File with no problems should say so": function(){
11
+ var result = { messages: [], stats: [] },
12
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint></lint>";
13
+ Assert.areEqual(expected, CSSLint.format(result, "FILE", "lint-xml"));
14
+ },
15
+
16
+ "File with problems should list them": function(){
17
+ var result = { messages: [
18
+ { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] },
19
+ { type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
20
+ ], stats: [] },
21
+ file = "<file name=\"FILE\">",
22
+ error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
23
+ error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
24
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>" + file + error1 + error2 + "</file></lint>",
25
+ actual = CSSLint.format(result, "FILE", "lint-xml");
26
+ Assert.areEqual(expected, actual);
27
+ },
28
+
29
+ "Formatter should escape double quotes": function() {
30
+ var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
31
+ result = { messages: [
32
+ { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
33
+ { type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
34
+ ], stats: [] },
35
+ file = "<file name=\"FILE\">",
36
+ error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\"/>",
37
+ error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\"/>",
38
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>" + file + error1 + error2 + "</file></lint>",
39
+ actual = CSSLint.format(result, "FILE", "lint-xml");
40
+ Assert.areEqual(expected, actual);
41
+ }
42
+ }));
43
+ })();
@@ -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: "Text formatter",
9
+
10
+ "File with no problems should say so": function() {
11
+ var result = { messages: [], stats: [] },
12
+ actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
13
+ Assert.areEqual("\n\ncsslint: No errors in path/to/FILE.", actual);
14
+ },
15
+
16
+ "Should have no output when quiet option is specified and no errors": function() {
17
+ var result = { messages: [], stats: [] },
18
+ actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});
19
+ Assert.areEqual("", actual);
20
+ },
21
+
22
+ "File with problems should list them": function() {
23
+ var result = { messages: [
24
+ { type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] },
25
+ { type: 'error', line: 2, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
26
+ ], stats: [] },
27
+ error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
28
+ error2 = "\n2: error at line 2, col 1\nBOGUS\nALSO BOGUS",
29
+ expected = "\n\ncsslint: There are 2 problems in path/to/FILE.\n\nFILE" + error1 + "\n\nFILE" + error2,
30
+ actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
31
+ Assert.areEqual(expected, actual);
32
+ }
33
+
34
+ }));
35
+
36
+ })();
@@ -0,0 +1,31 @@
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
+ "Adjoining classes should result in an error": function(){
18
+ var result = CSSLint.verify(".foo.bar { }", { "adjoining-classes": 2 });
19
+ Assert.areEqual(1, result.messages.length);
20
+ Assert.areEqual("error", result.messages[0].type);
21
+ Assert.areEqual("Don't use adjoining classes.", result.messages[0].message);
22
+ },
23
+
24
+ "Descendant selector with classes should not result in a warning": function(){
25
+ var result = CSSLint.verify(".foo .bar { }", { "adjoining-classes": 1 });
26
+ Assert.areEqual(0, result.messages.length);
27
+ }
28
+
29
+ }));
30
+
31
+ })();