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.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +71 -0
- data/VERSION +1 -0
- data/csslint/CHANGELOG +286 -0
- data/csslint/LICENSE +20 -0
- data/csslint/README.md +25 -0
- data/csslint/build.xml +242 -0
- data/csslint/demos/CSSLintDemo.htm +105 -0
- data/csslint/demos/demo.css +43 -0
- data/csslint/lib/js.jar +0 -0
- data/csslint/lib/jshint.js +3963 -0
- data/csslint/lib/parserlib.js +6295 -0
- data/csslint/lib/yuitest-rhino-cli.js +3955 -0
- data/csslint/lib/yuitest.js +4561 -0
- data/csslint/npm/package.json +30 -0
- data/csslint/release/csslint-node.js +9125 -0
- data/csslint/release/csslint-rhino.js +9390 -0
- data/csslint/release/csslint-tests.js +1921 -0
- data/csslint/release/csslint-worker.js +9148 -0
- data/csslint/release/csslint-wsh.js +9477 -0
- data/csslint/release/csslint.js +9127 -0
- data/csslint/release/npm/cli.js +307 -0
- data/csslint/release/npm/lib/csslint-node.js +9125 -0
- data/csslint/release/npm/package.json +30 -0
- data/csslint/src/cli/common.js +215 -0
- data/csslint/src/cli/node.js +87 -0
- data/csslint/src/cli/rhino.js +47 -0
- data/csslint/src/cli/wsh.js +134 -0
- data/csslint/src/core/CSSLint.js +181 -0
- data/csslint/src/core/Reporter.js +161 -0
- data/csslint/src/core/Util.js +62 -0
- data/csslint/src/formatters/checkstyle-xml.js +109 -0
- data/csslint/src/formatters/compact.js +59 -0
- data/csslint/src/formatters/csslint-xml.js +68 -0
- data/csslint/src/formatters/lint-xml.js +69 -0
- data/csslint/src/formatters/text.js +64 -0
- data/csslint/src/rules/adjoining-classes.js +45 -0
- data/csslint/src/rules/box-model.js +93 -0
- data/csslint/src/rules/box-sizing.js +28 -0
- data/csslint/src/rules/compatible-vendor-prefixes.js +171 -0
- data/csslint/src/rules/display-property-grouping.js +117 -0
- data/csslint/src/rules/duplicate-background-images.js +37 -0
- data/csslint/src/rules/duplicate-properties.js +46 -0
- data/csslint/src/rules/empty-rules.js +34 -0
- data/csslint/src/rules/errors.js +23 -0
- data/csslint/src/rules/fallback-colors.js +67 -0
- data/csslint/src/rules/floats.js +36 -0
- data/csslint/src/rules/font-faces.js +30 -0
- data/csslint/src/rules/font-sizes.js +35 -0
- data/csslint/src/rules/gradients.js +69 -0
- data/csslint/src/rules/ids.js +50 -0
- data/csslint/src/rules/import.js +23 -0
- data/csslint/src/rules/important.js +37 -0
- data/csslint/src/rules/known-properties.js +29 -0
- data/csslint/src/rules/outline-none.js +73 -0
- data/csslint/src/rules/overqualified-elements.js +63 -0
- data/csslint/src/rules/qualified-headings.js +38 -0
- data/csslint/src/rules/regex-selectors.js +44 -0
- data/csslint/src/rules/rules-count.js +28 -0
- data/csslint/src/rules/shorthand.js +87 -0
- data/csslint/src/rules/star-property-hack.js +27 -0
- data/csslint/src/rules/text-indent.js +53 -0
- data/csslint/src/rules/underscore-property-hack.js +27 -0
- data/csslint/src/rules/unique-headings.js +74 -0
- data/csslint/src/rules/universal-selector.js +35 -0
- data/csslint/src/rules/unqualified-attributes.js +42 -0
- data/csslint/src/rules/vendor-prefix.js +143 -0
- data/csslint/src/rules/zero-units.js +34 -0
- data/csslint/src/worker/Worker.js +26 -0
- data/csslint/tests/all-rules.js +64 -0
- data/csslint/tests/core/CSSLint.js +22 -0
- data/csslint/tests/core/Reporter.js +36 -0
- data/csslint/tests/css/width-100.html +76 -0
- data/csslint/tests/formatters/checkstyle-xml.js +44 -0
- data/csslint/tests/formatters/compact.js +47 -0
- data/csslint/tests/formatters/csslint-xml.js +42 -0
- data/csslint/tests/formatters/lint-xml.js +43 -0
- data/csslint/tests/formatters/text.js +36 -0
- data/csslint/tests/rules/adjoining-classes.js +31 -0
- data/csslint/tests/rules/box-model.js +211 -0
- data/csslint/tests/rules/box-sizing.js +23 -0
- data/csslint/tests/rules/compatible-vendor-prefixes.js +56 -0
- data/csslint/tests/rules/display-property-grouping.js +213 -0
- data/csslint/tests/rules/duplicate-background-images.js +25 -0
- data/csslint/tests/rules/duplicate-properties.js +54 -0
- data/csslint/tests/rules/empty-rules.js +18 -0
- data/csslint/tests/rules/errors.js +17 -0
- data/csslint/tests/rules/fallback-colors.js +162 -0
- data/csslint/tests/rules/floats.js +35 -0
- data/csslint/tests/rules/font-faces.js +28 -0
- data/csslint/tests/rules/font-sizes.js +30 -0
- data/csslint/tests/rules/gradients.js +60 -0
- data/csslint/tests/rules/ids.js +25 -0
- data/csslint/tests/rules/import.js +18 -0
- data/csslint/tests/rules/important.js +27 -0
- data/csslint/tests/rules/known-properties.js +44 -0
- data/csslint/tests/rules/outline-none.js +50 -0
- data/csslint/tests/rules/overqualified-elements.js +41 -0
- data/csslint/tests/rules/qualified-headings.js +19 -0
- data/csslint/tests/rules/regex-selectors.js +52 -0
- data/csslint/tests/rules/shorthand.js +36 -0
- data/csslint/tests/rules/star-property-hack.js +24 -0
- data/csslint/tests/rules/text-indent.js +55 -0
- data/csslint/tests/rules/underscore-property-hack.js +24 -0
- data/csslint/tests/rules/unique-headings.js +47 -0
- data/csslint/tests/rules/universal-selector.js +31 -0
- data/csslint/tests/rules/unqualified-attributes.js +37 -0
- data/csslint/tests/rules/vendor-prefix.js +76 -0
- data/csslint/tests/rules/zero-units.js +44 -0
- data/csslint/tests/testrunner.htm +138 -0
- data/js.jar +0 -0
- data/lib/ruby_css_lint.rb +168 -0
- data/test/helper.rb +17 -0
- data/test/test_ruby_css_lint.rb +7 -0
- metadata +240 -0
|
@@ -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: "Universal Selector Errors",
|
|
9
|
+
|
|
10
|
+
"Using a universal selector alone should result in a warning": function(){
|
|
11
|
+
var result = CSSLint.verify("* { font-size: 10px; }", {"universal-selector": 1 });
|
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
14
|
+
Assert.areEqual("The universal selector (*) is known to be slow.", result.messages[0].message);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"Using a universal selector as the right-most part should result in a warning": function(){
|
|
18
|
+
var result = CSSLint.verify("p div * { font-size: 10px; }", {"universal-selector": 1 });
|
|
19
|
+
Assert.areEqual(1, result.messages.length);
|
|
20
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
21
|
+
Assert.areEqual("The universal selector (*) is known to be slow.", result.messages[0].message);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
"Using a universal selector in the middle should not result in a warning": function(){
|
|
25
|
+
var result = CSSLint.verify("* .foo { font-size: 10px; } ", {"universal-selector": 1 });
|
|
26
|
+
Assert.areEqual(0, result.messages.length);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
})();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
|
|
3
|
+
/*global YUITest, CSSLint*/
|
|
4
|
+
var Assert = YUITest.Assert;
|
|
5
|
+
|
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
|
7
|
+
|
|
8
|
+
name: "Unqualified Attributes Errors",
|
|
9
|
+
|
|
10
|
+
"Using an unqualified attribute selector alone should result in a warning": function(){
|
|
11
|
+
var result = CSSLint.verify("[type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
|
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
14
|
+
Assert.areEqual("Unqualified attribute selectors are known to be slow.", result.messages[0].message);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"Using an unqualified attribute selector as the right-most part should result in a warning": function(){
|
|
18
|
+
var result = CSSLint.verify("p div [type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
|
|
19
|
+
Assert.areEqual(1, result.messages.length);
|
|
20
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
21
|
+
Assert.areEqual("Unqualified attribute selectors are known to be slow.", result.messages[0].message);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
"Using an unqualified attribute selector in the middle should not result in a warning": function(){
|
|
25
|
+
var result = CSSLint.verify("[type=text] .foo { font-size: 10px; } ", {"unqualified-attributes": 1 });
|
|
26
|
+
Assert.areEqual(0, result.messages.length);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"Using a qualified attribute selector should not result in a warning": function(){
|
|
30
|
+
var result = CSSLint.verify("input[type=text] { font-size: 10px; } ", {"unqualified-attributes": 1 });
|
|
31
|
+
Assert.areEqual(0, result.messages.length);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
})();
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
|
|
3
|
+
/*global YUITest, CSSLint*/
|
|
4
|
+
var Assert = YUITest.Assert;
|
|
5
|
+
|
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
|
7
|
+
|
|
8
|
+
name: "Vendor Prefix Errors",
|
|
9
|
+
|
|
10
|
+
"Using -moz-border-radius without border-radius should result in one warning": function(){
|
|
11
|
+
var result = CSSLint.verify("h1 {\n -moz-border-radius: 5px; \n}", { "vendor-prefix": 1 });
|
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
14
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-moz-border-radius'.", result.messages[0].message);
|
|
15
|
+
Assert.areEqual(2, result.messages[0].line);
|
|
16
|
+
Assert.areEqual(5, result.messages[0].col);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
"Using -webkit-border-radius without border-radius should result in one warning": function(){
|
|
20
|
+
var result = CSSLint.verify("h1 { -webkit-border-radius: 5px; }", { "vendor-prefix": 1 });
|
|
21
|
+
Assert.areEqual(1, result.messages.length);
|
|
22
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
23
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-webkit-border-radius'.", result.messages[0].message);
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
"Using -o-border-radius without border-radius should result in one warning": function(){
|
|
27
|
+
var result = CSSLint.verify("h1 { -o-border-radius: 5px; }", { "vendor-prefix": 1 });
|
|
28
|
+
Assert.areEqual(1, result.messages.length);
|
|
29
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
30
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-o-border-radius'.", result.messages[0].message);
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
"Using -moz-border-radius after border-radius should result in one warning": function(){
|
|
34
|
+
var result = CSSLint.verify("h1 { \nborder-radius: 5px; \n -moz-border-radius: 5px; }", { "vendor-prefix": 1 });
|
|
35
|
+
Assert.areEqual(1, result.messages.length);
|
|
36
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
37
|
+
Assert.areEqual("Standard property 'border-radius' should come after vendor-prefixed property '-moz-border-radius'.", result.messages[0].message);
|
|
38
|
+
Assert.areEqual(3, result.messages[0].line);
|
|
39
|
+
Assert.areEqual(5, result.messages[0].col);
|
|
40
|
+
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
"Using -webkit-border-bottom-left-radius with border-bottom-left-radius should not result in a warning.": function(){
|
|
44
|
+
var result = CSSLint.verify("h1 { -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }", { "vendor-prefix": 1 });
|
|
45
|
+
Assert.areEqual(0, result.messages.length);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
"Using -moz-border-radius-bottomleft should result in a warning.": function(){
|
|
49
|
+
var result = CSSLint.verify("h1 { -moz-border-radius-bottomleft: 5px; }", { "vendor-prefix": 1 });
|
|
50
|
+
Assert.areEqual(1, result.messages.length);
|
|
51
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
52
|
+
Assert.areEqual("Missing standard property 'border-bottom-left-radius' to go along with '-moz-border-radius-bottomleft'.", result.messages[0].message);
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
"Using -moz-box-shadow should result in a warning.": function(){
|
|
56
|
+
var result = CSSLint.verify("h1 { -moz-box-shadow: 5px; }", { "vendor-prefix": 1 });
|
|
57
|
+
Assert.areEqual(1, result.messages.length);
|
|
58
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
59
|
+
Assert.areEqual("Missing standard property 'box-shadow' to go along with '-moz-box-shadow'.", result.messages[0].message);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"Using -moz-user-select should result in a warning.": function(){
|
|
63
|
+
var result = CSSLint.verify("h1 { -moz-user-select:none; }", { "vendor-prefix": 1 });
|
|
64
|
+
Assert.areEqual(1, result.messages.length);
|
|
65
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
66
|
+
Assert.areEqual("Missing standard property 'user-select' to go along with '-moz-user-select'.", result.messages[0].message);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"Using @font-face should not result in an error (#90)": function(){
|
|
70
|
+
var result = CSSLint.verify("@font-face { src:url('../fonts/UniversBold.otf');font-family:Univers;advancedAntiAliasing: true;}", { "vendor-prefix": 1 });
|
|
71
|
+
Assert.areEqual(0, result.messages.length);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
})();
|
|
@@ -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: "Zero Units Errors",
|
|
9
|
+
|
|
10
|
+
"Using 0px should result in one warning": function(){
|
|
11
|
+
var result = CSSLint.verify("h1 { left: 0px; }", { "zero-units": 1 });
|
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
14
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"Using 0em should result in one warning": function(){
|
|
18
|
+
var result = CSSLint.verify("h1 { left: 0em; }", { "zero-units": 1 });
|
|
19
|
+
Assert.areEqual(1, result.messages.length);
|
|
20
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
21
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
"Using 0% should result in one warning": function(){
|
|
25
|
+
var result = CSSLint.verify("h1 { left: 0%; }", { "zero-units": 1 });
|
|
26
|
+
Assert.areEqual(1, result.messages.length);
|
|
27
|
+
Assert.areEqual("warning", result.messages[0].type);
|
|
28
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"Using 0 should not result in a warning": function(){
|
|
32
|
+
var result = CSSLint.verify("h1 { left: 0; }", { "zero-units": 1 });
|
|
33
|
+
Assert.areEqual(0, result.messages.length);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
"Using 0s for animation-duration should not result in a warning": function(){
|
|
37
|
+
var result = CSSLint.verify("h1 { animation-duration: 0s; }", { "zero-units": 1 });
|
|
38
|
+
Assert.areEqual(0, result.messages.length);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
})();
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>YUI Test</title>
|
|
5
|
+
|
|
6
|
+
<!-- JS -->
|
|
7
|
+
<script src="../build/csslint.js"></script>
|
|
8
|
+
<script src="../lib/yuitest.js"></script>
|
|
9
|
+
<script src="../build/csslint-tests.js"></script>
|
|
10
|
+
<script src="all-rules.js"></script>
|
|
11
|
+
<style type="text/css">
|
|
12
|
+
.passed {
|
|
13
|
+
color: green;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.failed, .error {
|
|
17
|
+
color: red;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ignored {
|
|
21
|
+
color: silver;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<div id="doc">
|
|
28
|
+
<h1>YUI Test - Test Runner</h1>
|
|
29
|
+
<button id="run">Run</button>
|
|
30
|
+
|
|
31
|
+
<h2>Results</h2>
|
|
32
|
+
<ul id="results"></ul>
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<script >
|
|
37
|
+
(function(){
|
|
38
|
+
|
|
39
|
+
//some helpful variables
|
|
40
|
+
var runButton = document.getElementById("run"),
|
|
41
|
+
resultsList = document.getElementById("results"),
|
|
42
|
+
resultNode = resultsList,
|
|
43
|
+
events = [
|
|
44
|
+
YUITest.TestRunner.TEST_CASE_BEGIN_EVENT,
|
|
45
|
+
YUITest.TestRunner.TEST_CASE_COMPLETE_EVENT,
|
|
46
|
+
YUITest.TestRunner.TEST_SUITE_BEGIN_EVENT,
|
|
47
|
+
YUITest.TestRunner.TEST_SUITE_COMPLETE_EVENT,
|
|
48
|
+
YUITest.TestRunner.TEST_PASS_EVENT,
|
|
49
|
+
YUITest.TestRunner.TEST_FAIL_EVENT,
|
|
50
|
+
YUITest.TestRunner.TEST_IGNORE_EVENT,
|
|
51
|
+
YUITest.TestRunner.COMPLETE_EVENT,
|
|
52
|
+
YUITest.TestRunner.BEGIN_EVENT,
|
|
53
|
+
YUITest.TestRunner.ERROR_EVENT
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
for (var i=0; i < events.length; i++){
|
|
57
|
+
YUITest.TestRunner.attach(events[i], function(event){
|
|
58
|
+
var node;
|
|
59
|
+
|
|
60
|
+
switch(event.type){
|
|
61
|
+
case this.BEGIN_EVENT:
|
|
62
|
+
message = "Testing began at " + (new Date()).toString() + ".";
|
|
63
|
+
messageType = "info";
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case this.COMPLETE_EVENT:
|
|
67
|
+
message = "Testing completed at " + (new Date()).toString() + ".\nPassed:" +
|
|
68
|
+
event.results.passed + " Failed:" + event.results.failed + " Total:" + event.results.total;
|
|
69
|
+
messageType = "info";
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case this.TEST_FAIL_EVENT:
|
|
73
|
+
node = document.createElement("li");
|
|
74
|
+
node.className = "failed";
|
|
75
|
+
node.innerHTML = event.testName + ": " + event.error.getMessage().replace(/\n/g, "<br>");
|
|
76
|
+
resultNode.appendChild(node);
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case this.ERROR_EVENT:
|
|
80
|
+
node = document.createElement("li");
|
|
81
|
+
node.className = "error";
|
|
82
|
+
node.innerHTML = "ERROR: " + event.methodName + "() caused an error: " + event.error.message.replace(/\n/g, "<br>");
|
|
83
|
+
resultNode.appendChild(node);
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case this.TEST_IGNORE_EVENT:
|
|
87
|
+
node = document.createElement("li");
|
|
88
|
+
node.className = "ignored";
|
|
89
|
+
node.innerHTML = event.testName;
|
|
90
|
+
resultNode.appendChild(node);
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case this.TEST_PASS_EVENT:
|
|
94
|
+
node = document.createElement("li");
|
|
95
|
+
node.className = "passed";
|
|
96
|
+
node.innerHTML = event.testName;
|
|
97
|
+
resultNode.appendChild(node);
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case this.TEST_SUITE_BEGIN_EVENT:
|
|
101
|
+
node = document.createElement("li");
|
|
102
|
+
node.innerHTML = event.testSuite.name;
|
|
103
|
+
resultNode.appendChild(node);
|
|
104
|
+
resultNode = resultNode.appendChild(document.createElement("ul"));
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case this.TEST_CASE_COMPLETE_EVENT:
|
|
108
|
+
case this.TEST_SUITE_COMPLETE_EVENT:
|
|
109
|
+
resultNode.previousSibling.innerHTML += " (passed: " + event.results.passed + ", failed: " + event.results.failed + ", total: " + event.results.total + ", errors: " + event.results.errors + ", ignored: " + event.results.ignored + ")";
|
|
110
|
+
resultNode = resultNode.parentNode;
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case this.TEST_CASE_BEGIN_EVENT:
|
|
114
|
+
node = document.createElement("li");
|
|
115
|
+
node.innerHTML = event.testCase.name;
|
|
116
|
+
resultNode.appendChild(node);
|
|
117
|
+
resultNode = resultNode.appendChild(document.createElement("ul"));
|
|
118
|
+
break;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
runButton.onclick = function(){
|
|
126
|
+
|
|
127
|
+
//reset the interface
|
|
128
|
+
resultsList.innerHTML = "";
|
|
129
|
+
resultNode = resultsList;
|
|
130
|
+
|
|
131
|
+
YUITest.TestRunner.run();
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
})();
|
|
135
|
+
|
|
136
|
+
</script>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
data/js.jar
ADDED
|
Binary file
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
|
|
3
|
+
if defined?(Rails)
|
|
4
|
+
require 'rake'
|
|
5
|
+
module RubyCssLint
|
|
6
|
+
class Railtie < Rails::Railtie
|
|
7
|
+
extend Rake::DSL
|
|
8
|
+
rake_tasks do
|
|
9
|
+
namespace :css_lint do
|
|
10
|
+
|
|
11
|
+
task :run => :environment do |t|
|
|
12
|
+
RubyCssLint::construct_js_and_run_rhino(RubyCssLint::location_of_css_files(Rails.root))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
task :generate_config => :environment do |t|
|
|
16
|
+
File.open("#{Rails.root.to_s}/config/initializers/css_lint.rb", "w") do |filehandle|
|
|
17
|
+
filehandle.puts <<-CSS_LINT_INIT
|
|
18
|
+
module RubyCssLint
|
|
19
|
+
#{RubyCssLint::DEFAULT_CONFIG}
|
|
20
|
+
end
|
|
21
|
+
CSS_LINT_INIT
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module RubyCssLint
|
|
34
|
+
WARNING = 1
|
|
35
|
+
ERROR = 2
|
|
36
|
+
DONT_CARE = nil
|
|
37
|
+
|
|
38
|
+
DEFAULT_CONFIG = <<-CSS_LINT_DEFAULT
|
|
39
|
+
def self.ruleset_classifications
|
|
40
|
+
{
|
|
41
|
+
"adjoining-classes" => RubyCssLint::WARNING,
|
|
42
|
+
"box-model" => RubyCssLint::WARNING,
|
|
43
|
+
"box-sizing" => RubyCssLint::WARNING,
|
|
44
|
+
"compatible-vendor-prefixes" => RubyCssLint::WARNING,
|
|
45
|
+
"display-property-grouping" => RubyCssLint::WARNING,
|
|
46
|
+
"duplicate-background-images" => RubyCssLint::WARNING,
|
|
47
|
+
"duplicate-properties" => RubyCssLint::WARNING,
|
|
48
|
+
"empty-rules" => RubyCssLint::WARNING,
|
|
49
|
+
"errors" => RubyCssLint::WARNING,
|
|
50
|
+
"fallback-colors" => RubyCssLint::WARNING,
|
|
51
|
+
"floats" => RubyCssLint::WARNING,
|
|
52
|
+
"font-faces" => RubyCssLint::WARNING,
|
|
53
|
+
"font-sizes" => RubyCssLint::WARNING,
|
|
54
|
+
"gradients" => RubyCssLint::WARNING,
|
|
55
|
+
"ids" => RubyCssLint::WARNING,
|
|
56
|
+
"import" => RubyCssLint::WARNING,
|
|
57
|
+
"important" => RubyCssLint::WARNING,
|
|
58
|
+
"known-properties" => RubyCssLint::WARNING,
|
|
59
|
+
"outline-none" => RubyCssLint::WARNING,
|
|
60
|
+
"overqualified-elements" => RubyCssLint::WARNING,
|
|
61
|
+
"qualified-headings" => RubyCssLint::WARNING,
|
|
62
|
+
"regex-selectors" => RubyCssLint::WARNING,
|
|
63
|
+
"rules-count" => RubyCssLint::WARNING,
|
|
64
|
+
"shorthand" => RubyCssLint::WARNING,
|
|
65
|
+
"star-property-hack" => RubyCssLint::WARNING,
|
|
66
|
+
"text-indent" => RubyCssLint::WARNING,
|
|
67
|
+
"underscore-property-hack" => RubyCssLint::WARNING,
|
|
68
|
+
"unique-headings" => RubyCssLint::WARNING,
|
|
69
|
+
"universal-selector" => RubyCssLint::WARNING,
|
|
70
|
+
"unqualified-attributes" => RubyCssLint::WARNING,
|
|
71
|
+
"vendor-prefix" => RubyCssLint::WARNING,
|
|
72
|
+
"zero-units" => RubyCssLint::WARNING,
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.location_of_custom_rules(rails_root)
|
|
77
|
+
[]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.location_of_css_files(rails_root)
|
|
81
|
+
[rails_root.to_s+"/public/assets/application.css"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
CSS_LINT_DEFAULT
|
|
85
|
+
|
|
86
|
+
self.class_eval(DEFAULT_CONFIG)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def self.construct_error_and_warning_options
|
|
90
|
+
rc = self.ruleset_classifications
|
|
91
|
+
warnings = rc.keys.select{|k| rc[k] == RubyCssLint::WARNING}
|
|
92
|
+
errors = rc.keys.select{|k| rc[k] == RubyCssLint::ERROR}
|
|
93
|
+
result = " "
|
|
94
|
+
result += "--warnings=#{warnings.join(',')} " if warnings.size > 0
|
|
95
|
+
result += "--errors=#{errors.join(',')} " if errors.size > 0
|
|
96
|
+
result
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def self.construct_js_and_run_rhino(css_files)
|
|
100
|
+
css_files = css_files.join(" ") if css_files.is_a?(Array)
|
|
101
|
+
|
|
102
|
+
Tempfile.open("csslint_temp_js") do |tempfile|
|
|
103
|
+
tempfile.puts <<-HEADER
|
|
104
|
+
var CSSLint = (function(){
|
|
105
|
+
HEADER
|
|
106
|
+
tempfile.puts`cat #{list_of_js_files_to_compile_step_1}`
|
|
107
|
+
tempfile.puts <<-FOOTER
|
|
108
|
+
return CSSLint;
|
|
109
|
+
})();
|
|
110
|
+
FOOTER
|
|
111
|
+
tempfile.puts`cat #{list_of_js_files_to_compile_step_2}`
|
|
112
|
+
tempfile.flush
|
|
113
|
+
run_rhino_with_js_file(tempfile.path, css_files)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def self.run_rhino_with_js_file(file, css_files)
|
|
120
|
+
rhino_jarfile = File.dirname(__FILE__) + "/../js.jar"
|
|
121
|
+
command = "java -jar #{rhino_jarfile} #{file} #{construct_error_and_warning_options} #{css_files}"
|
|
122
|
+
result = `#{command}`
|
|
123
|
+
puts result
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.list_of_js_files_to_compile_step_1
|
|
127
|
+
css_lint_root_directory = File.dirname(__FILE__) + "/../csslint/"
|
|
128
|
+
|
|
129
|
+
parserlib_location = css_lint_root_directory + "/lib/parserlib.js"
|
|
130
|
+
csslint_main_location = css_lint_root_directory + "/src/core/CSSLint.js"
|
|
131
|
+
other_core_files = `ls -d #{(css_lint_root_directory+"/src/core/*.js")} | grep -v CSSLint`.split(/\n/).join(" ")
|
|
132
|
+
built_in_rules_file = css_lint_root_directory + "/src/rules/*.js"
|
|
133
|
+
|
|
134
|
+
custom_rules_files = location_of_custom_rules(Rails.root).join(" ")
|
|
135
|
+
|
|
136
|
+
formatters = css_lint_root_directory + "/src/formatters/*.js"
|
|
137
|
+
|
|
138
|
+
[
|
|
139
|
+
parserlib_location,
|
|
140
|
+
csslint_main_location,
|
|
141
|
+
other_core_files,
|
|
142
|
+
built_in_rules_file,
|
|
143
|
+
custom_rules_files,
|
|
144
|
+
formatters
|
|
145
|
+
].join(" ")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def self.list_of_js_files_to_compile_step_2
|
|
149
|
+
css_lint_root_directory = File.dirname(__FILE__) + "/../csslint/"
|
|
150
|
+
|
|
151
|
+
cli_common = css_lint_root_directory + "/src/cli/common.js"
|
|
152
|
+
cli_rhino = css_lint_root_directory + "/src/cli/rhino.js"
|
|
153
|
+
[
|
|
154
|
+
cli_common,
|
|
155
|
+
cli_rhino
|
|
156
|
+
].join(" ")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def self.run
|
|
161
|
+
rhino_jarfile = File.dirname(__FILE__) + "../js.jar"
|
|
162
|
+
rhino_csslint_file = File.dirname(__FILE__) + "../csslint/"
|
|
163
|
+
command = "java -jar js.jar "
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
|