ruby_css_lint 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,25 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "Duplicate Background-URL Rule Errors",
|
9
|
+
|
10
|
+
"duplicate background-image should result in a warning": function(){
|
11
|
+
var result = CSSLint.verify(".foo { background-image: url('mega-sprite.png'); } .foofoo { background-image: url('fancy-sprite.png'); } .bar { background-image: url(\"mega-sprite.png\"); } .foobar { background: white url(mega-sprite.png); }", {"duplicate-background-images": 1 });
|
12
|
+
Assert.areEqual(2, result.messages.length);
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
14
|
+
Assert.areEqual("Background image 'mega-sprite.png' was used multiple times, first declared at line 1, col 8.", result.messages[0].message);
|
15
|
+
},
|
16
|
+
|
17
|
+
"duplicate background with url should result in a warning": function(){
|
18
|
+
var result = CSSLint.verify(".foo { background: url(mega-sprite.png) repeat-x; } .foofoo { background-image: url('fancy-sprite.png'); } .bar { background: white url(\"mega-sprite.png\") no-repeat left top; } .foobar { background: white url('mega-sprite.png'); }", {"duplicate-background-images": 1 });
|
19
|
+
Assert.areEqual(2, result.messages.length);
|
20
|
+
Assert.areEqual("warning", result.messages[0].type);
|
21
|
+
Assert.areEqual("Background image 'mega-sprite.png' was used multiple times, first declared at line 1, col 8.", result.messages[0].message);
|
22
|
+
}
|
23
|
+
}));
|
24
|
+
|
25
|
+
})();
|
@@ -0,0 +1,54 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "Duplicate Property Rule Errors",
|
9
|
+
|
10
|
+
"Duplicate properties back-to-back should not result in a warning": function(){
|
11
|
+
var result = CSSLint.verify(".foo { float: left; float: right }", { "duplicate-properties": 1 });
|
12
|
+
Assert.areEqual(0, result.messages.length);
|
13
|
+
},
|
14
|
+
|
15
|
+
"Duplicate properties in @font-face back-to-back should not result in a warning": function(){
|
16
|
+
var result = CSSLint.verify("@font-face { src: url(foo.svg); src: url(foo1.svg) }", { "duplicate-properties": 1 });
|
17
|
+
Assert.areEqual(0, result.messages.length);
|
18
|
+
},
|
19
|
+
|
20
|
+
"Duplicate properties in @page back-to-back should not result in a warning": function(){
|
21
|
+
var result = CSSLint.verify("@page :left { margin: 5px; margin: 4px; }", { "duplicate-properties": 1 });
|
22
|
+
Assert.areEqual(0, result.messages.length);
|
23
|
+
},
|
24
|
+
|
25
|
+
"Duplicate properties not back-to-back should result in a warning": function(){
|
26
|
+
var result = CSSLint.verify(".foo { float: left; margin: 0; float: right }", { "duplicate-properties": 1 });
|
27
|
+
Assert.areEqual(1, result.messages.length);
|
28
|
+
Assert.areEqual("warning", result.messages[0].type);
|
29
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
30
|
+
},
|
31
|
+
|
32
|
+
"Duplicate properties not back-to-back with same values should result in a warning": function(){
|
33
|
+
var result = CSSLint.verify(".foo { float: left; margin: 0; float: left }", { "duplicate-properties": 1 });
|
34
|
+
Assert.areEqual(1, result.messages.length);
|
35
|
+
Assert.areEqual("warning", result.messages[0].type);
|
36
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
37
|
+
},
|
38
|
+
|
39
|
+
"Duplicate properties back-to-back with same values should result in a warning": function(){
|
40
|
+
var result = CSSLint.verify(".foo { float: left; float: left }", { "duplicate-properties": 1 });
|
41
|
+
Assert.areEqual(1, result.messages.length);
|
42
|
+
Assert.areEqual("warning", result.messages[0].type);
|
43
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
44
|
+
},
|
45
|
+
|
46
|
+
"Duplicate properties in @keyframe rules should not result in a warning": function(){
|
47
|
+
var result = CSSLint.verify("@-webkit-keyframes slide_up { from { bottom:-91px; } to { bottom:0; } }", { "duplicate-properties": 1 });
|
48
|
+
Assert.areEqual(0, result.messages.length);
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
}));
|
53
|
+
|
54
|
+
})();
|
@@ -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: "Empty Rule Errors",
|
9
|
+
|
10
|
+
"Empty rule should result in a warning": function(){
|
11
|
+
var result = CSSLint.verify("li { }", { "empty-rules": 1 });
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
14
|
+
Assert.areEqual("Rule is empty.", result.messages[0].message);
|
15
|
+
}
|
16
|
+
}));
|
17
|
+
|
18
|
+
})();
|
@@ -0,0 +1,17 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "Parsing Errors",
|
9
|
+
|
10
|
+
"Parsing error should result in one parsing error message": function(){
|
11
|
+
var result = CSSLint.verify("li { float left;}", { errors: 1 });
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
13
|
+
Assert.areEqual("error", result.messages[0].type);
|
14
|
+
}
|
15
|
+
}));
|
16
|
+
|
17
|
+
})();
|
@@ -0,0 +1,162 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "Fallback Colors Rule Errors",
|
9
|
+
|
10
|
+
"Using only a named color should not result in a warning": function(){
|
11
|
+
var result = CSSLint.verify(".hex { color: red; }", { "fallback-colors": 1 });
|
12
|
+
Assert.areEqual(0, result.messages.length);
|
13
|
+
},
|
14
|
+
|
15
|
+
"Using only a hex color should not result in a warning": function(){
|
16
|
+
var result = CSSLint.verify(".hex { color: #fff; }", { "fallback-colors": 1 });
|
17
|
+
Assert.areEqual(0, result.messages.length);
|
18
|
+
},
|
19
|
+
|
20
|
+
"Using only rgb() should not result in a warning": function(){
|
21
|
+
var result = CSSLint.verify(".rgb { color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
|
22
|
+
Assert.areEqual(0, result.messages.length);
|
23
|
+
},
|
24
|
+
|
25
|
+
"Using only rgba() should result in a warning": function(){
|
26
|
+
var result = CSSLint.verify(".rgba { color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
27
|
+
Assert.areEqual(1, result.messages.length);
|
28
|
+
Assert.areEqual("warning", result.messages[0].type);
|
29
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
|
30
|
+
},
|
31
|
+
|
32
|
+
"Using only hsl() should result in a warning": function(){
|
33
|
+
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
34
|
+
Assert.areEqual(1, result.messages.length);
|
35
|
+
Assert.areEqual("warning", result.messages[0].type);
|
36
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSL color.", result.messages[0].message);
|
37
|
+
},
|
38
|
+
|
39
|
+
"Using only hsla() should result in a warning": function(){
|
40
|
+
var result = CSSLint.verify(".hsla { color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
41
|
+
Assert.areEqual(1, result.messages.length);
|
42
|
+
Assert.areEqual("warning", result.messages[0].type);
|
43
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSLA color.", result.messages[0].message);
|
44
|
+
},
|
45
|
+
|
46
|
+
"Using rgba() with a fallback should not result in a warning": function(){
|
47
|
+
var result = CSSLint.verify(".rgba { color: #fff; color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
48
|
+
Assert.areEqual(0, result.messages.length);
|
49
|
+
},
|
50
|
+
|
51
|
+
"Using hsl() with a fallback should not result in a warning": function(){
|
52
|
+
var result = CSSLint.verify(".hsl { color: #fff; color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
53
|
+
Assert.areEqual(0, result.messages.length);
|
54
|
+
},
|
55
|
+
|
56
|
+
"Using hsla() with a fallback should not result in a warning": function(){
|
57
|
+
var result = CSSLint.verify(".hsla { color: #fff; color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
58
|
+
Assert.areEqual(0, result.messages.length);
|
59
|
+
},
|
60
|
+
|
61
|
+
"Using rgba() with fallback color afterwards should result in a warning": function(){
|
62
|
+
var result = CSSLint.verify(".rgba { color: rgba(0, 0, 0, 0.5); color: #fff; }", { "fallback-colors": 1 });
|
63
|
+
Assert.areEqual(1, result.messages.length);
|
64
|
+
Assert.areEqual("warning", result.messages[0].type);
|
65
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
|
66
|
+
},
|
67
|
+
|
68
|
+
"Using hsl() with fallback color afterwards should result in a warning": function(){
|
69
|
+
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); color: #fff; }", { "fallback-colors": 1 });
|
70
|
+
Assert.areEqual(1, result.messages.length);
|
71
|
+
Assert.areEqual("warning", result.messages[0].type);
|
72
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSL color.", result.messages[0].message);
|
73
|
+
},
|
74
|
+
|
75
|
+
"Using hsla() with fallback color afterwards should result in a warning": function(){
|
76
|
+
var result = CSSLint.verify(".hsla { color: hsla(0, 0%, 0%, 0.5); color: #fff; }", { "fallback-colors": 1 });
|
77
|
+
Assert.areEqual(1, result.messages.length);
|
78
|
+
Assert.areEqual("warning", result.messages[0].type);
|
79
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSLA color.", result.messages[0].message);
|
80
|
+
},
|
81
|
+
|
82
|
+
|
83
|
+
"Using only a named background-color should not result in a warning": function(){
|
84
|
+
var result = CSSLint.verify(".hex { background-color: red; }", { "fallback-colors": 1 });
|
85
|
+
Assert.areEqual(0, result.messages.length);
|
86
|
+
},
|
87
|
+
|
88
|
+
"Using only a hex background-color should not result in a warning": function(){
|
89
|
+
var result = CSSLint.verify(".hex { background-color: #fff; }", { "fallback-colors": 1 });
|
90
|
+
Assert.areEqual(0, result.messages.length);
|
91
|
+
},
|
92
|
+
|
93
|
+
"Using only rgb() background-color should not result in a warning": function(){
|
94
|
+
var result = CSSLint.verify(".rgb { background-color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
|
95
|
+
Assert.areEqual(0, result.messages.length);
|
96
|
+
},
|
97
|
+
|
98
|
+
"Using only rgba() background-color should result in a warning": function(){
|
99
|
+
var result = CSSLint.verify(".rgba { background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
100
|
+
Assert.areEqual(1, result.messages.length);
|
101
|
+
Assert.areEqual("warning", result.messages[0].type);
|
102
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
|
103
|
+
},
|
104
|
+
|
105
|
+
"Using only hsl() background-color should result in a warning": function(){
|
106
|
+
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
107
|
+
Assert.areEqual(1, result.messages.length);
|
108
|
+
Assert.areEqual("warning", result.messages[0].type);
|
109
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSL background-color.", result.messages[0].message);
|
110
|
+
},
|
111
|
+
|
112
|
+
"Using only hsla() background-color should result in a warning": function(){
|
113
|
+
var result = CSSLint.verify(".hsla { background-color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
114
|
+
Assert.areEqual(1, result.messages.length);
|
115
|
+
Assert.areEqual("warning", result.messages[0].type);
|
116
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
|
117
|
+
},
|
118
|
+
|
119
|
+
"Using rgba() with a fallback background-color should not result in a warning": function(){
|
120
|
+
var result = CSSLint.verify(".rgba { background-color: #fff; background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
121
|
+
Assert.areEqual(0, result.messages.length);
|
122
|
+
},
|
123
|
+
|
124
|
+
"Using hsl() with a fallback background-color should not result in a warning": function(){
|
125
|
+
var result = CSSLint.verify(".hsl { background-color: #fff; background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
126
|
+
Assert.areEqual(0, result.messages.length);
|
127
|
+
},
|
128
|
+
|
129
|
+
"Using hsla() with a fallback background-color should not result in a warning": function(){
|
130
|
+
var result = CSSLint.verify(".hsla { background-color: #fff; background-color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
131
|
+
Assert.areEqual(0, result.messages.length);
|
132
|
+
},
|
133
|
+
|
134
|
+
"Using rgba() with fallback background-color afterwards should result in a warning": function(){
|
135
|
+
var result = CSSLint.verify(".rgba { background-color: rgba(0, 0, 0, 0.5); background-color: #fff; }", { "fallback-colors": 1 });
|
136
|
+
Assert.areEqual(1, result.messages.length);
|
137
|
+
Assert.areEqual("warning", result.messages[0].type);
|
138
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
|
139
|
+
},
|
140
|
+
|
141
|
+
"Using hsl() with fallback background-color afterwards should result in a warning": function(){
|
142
|
+
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); background-color: #fff; }", { "fallback-colors": 1 });
|
143
|
+
Assert.areEqual(1, result.messages.length);
|
144
|
+
Assert.areEqual("warning", result.messages[0].type);
|
145
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSL background-color.", result.messages[0].message);
|
146
|
+
},
|
147
|
+
|
148
|
+
"Using hsla() with fallback background-color afterwards should result in a warning": function(){
|
149
|
+
var result = CSSLint.verify(".hsla { background-color: hsla(0, 0%, 0%, 0.5); background-color: #fff; }", { "fallback-colors": 1 });
|
150
|
+
Assert.areEqual(1, result.messages.length);
|
151
|
+
Assert.areEqual("warning", result.messages[0].type);
|
152
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
}));
|
161
|
+
|
162
|
+
})();
|
@@ -0,0 +1,35 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "Floats Rule Errors",
|
9
|
+
|
10
|
+
"10 floats should result in a warning": function(){
|
11
|
+
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 });
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
14
|
+
Assert.areEqual("Too many floats (10), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
|
15
|
+
},
|
16
|
+
|
17
|
+
"9 floats should not result in a warning": function(){
|
18
|
+
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 });
|
19
|
+
Assert.areEqual(0, result.messages.length);
|
20
|
+
},
|
21
|
+
|
22
|
+
"11 floats should result in a warning": function(){
|
23
|
+
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 });
|
24
|
+
Assert.areEqual(1, result.messages.length);
|
25
|
+
Assert.areEqual("warning", result.messages[0].type);
|
26
|
+
Assert.areEqual("Too many floats (11), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
|
27
|
+
},
|
28
|
+
|
29
|
+
"float: none should not count and therefore should not result in a warning": function(){
|
30
|
+
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 });
|
31
|
+
Assert.areEqual(0, result.messages.length);
|
32
|
+
}
|
33
|
+
}));
|
34
|
+
|
35
|
+
})();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "font-faces Rule Errors",
|
9
|
+
|
10
|
+
"5 font-faces should result in a warning": function(){
|
11
|
+
var result = CSSLint.verify("@font-face{ } @font-face{ } @font-face{ } @font-face{ } @font-face{ }", { "font-faces": 1 });
|
12
|
+
Assert.areEqual(0, result.messages.length);
|
13
|
+
},
|
14
|
+
|
15
|
+
"4 font-faces should not result in a warning": function(){
|
16
|
+
var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
|
17
|
+
Assert.areEqual(0, result.messages.length);
|
18
|
+
},
|
19
|
+
|
20
|
+
"6 font-faces should result in a warning": function(){
|
21
|
+
var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
|
22
|
+
Assert.areEqual(1, result.messages.length);
|
23
|
+
Assert.areEqual("warning", result.messages[0].type);
|
24
|
+
Assert.areEqual("Too many @font-face declarations (6).", result.messages[0].message);
|
25
|
+
}
|
26
|
+
}));
|
27
|
+
|
28
|
+
})();
|
@@ -0,0 +1,30 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "font-size Rule Errors",
|
9
|
+
|
10
|
+
"10 font-sizes should result in a warning": function(){
|
11
|
+
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 });
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
14
|
+
Assert.areEqual("Too many font-size declarations (10), abstraction needed.", result.messages[0].message);
|
15
|
+
},
|
16
|
+
|
17
|
+
"9 font-sizes should not result in a warning": function(){
|
18
|
+
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 });
|
19
|
+
Assert.areEqual(0, result.messages.length);
|
20
|
+
},
|
21
|
+
|
22
|
+
"11 font-sizes should result in a warning": function(){
|
23
|
+
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 });
|
24
|
+
Assert.areEqual(1, result.messages.length);
|
25
|
+
Assert.areEqual("warning", result.messages[0].type);
|
26
|
+
Assert.areEqual("Too many font-size declarations (11), abstraction needed.", result.messages[0].message);
|
27
|
+
}
|
28
|
+
}));
|
29
|
+
|
30
|
+
})();
|
@@ -0,0 +1,60 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
/*
|
9
|
+
background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
|
10
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
|
11
|
+
background: -webkit-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
12
|
+
background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
13
|
+
background: -ms-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
14
|
+
|
15
|
+
*/
|
16
|
+
|
17
|
+
name: "Gradients Rule Errors",
|
18
|
+
|
19
|
+
"Only using Mozilla gradients should result in a warning": function(){
|
20
|
+
var result = CSSLint.verify(".foo { background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
21
|
+
Assert.areEqual(1, result.messages.length);
|
22
|
+
Assert.areEqual("warning", result.messages[0].type);
|
23
|
+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
|
24
|
+
},
|
25
|
+
|
26
|
+
"Only using Opera gradients should result in a warning": function(){
|
27
|
+
var result = CSSLint.verify(".foo { background: -o-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
28
|
+
Assert.areEqual(1, result.messages.length);
|
29
|
+
Assert.areEqual("warning", result.messages[0].type);
|
30
|
+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Internet Explorer 10+.", result.messages[0].message);
|
31
|
+
},
|
32
|
+
|
33
|
+
"Only using IE gradients should result in a warning": function(){
|
34
|
+
var result = CSSLint.verify(".foo { background: -ms-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
35
|
+
Assert.areEqual(1, result.messages.length);
|
36
|
+
Assert.areEqual("warning", result.messages[0].type);
|
37
|
+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Opera 11.1+.", result.messages[0].message);
|
38
|
+
},
|
39
|
+
|
40
|
+
"Only using WebKit gradients should result in a warning": function(){
|
41
|
+
var result = CSSLint.verify(".foo { background: -webkit-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
42
|
+
Assert.areEqual(1, result.messages.length);
|
43
|
+
Assert.areEqual("warning", result.messages[0].type);
|
44
|
+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Old Webkit (Safari 4+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
|
45
|
+
},
|
46
|
+
|
47
|
+
"Only using old WebKit gradients should result in a warning": function(){
|
48
|
+
var result = CSSLint.verify(".foo { background: -webkit-gradient(linear, left top, left bottom, color-stop(10%,#1e5799), color-stop(20%,#2989d8), color-stop(30%,#207cca), color-stop(100%,#7db9e8)); }", {"gradients": 1 });
|
49
|
+
Assert.areEqual(1, result.messages.length);
|
50
|
+
Assert.areEqual("warning", result.messages[0].type);
|
51
|
+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
|
52
|
+
},
|
53
|
+
|
54
|
+
"Using all vendor-prefixed gradients should not result in a warning": function(){
|
55
|
+
var result = CSSLint.verify("div.box {\n background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);\n background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color- stop(100%,#7db9e8));\n background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%); \n}", { "gradients": 1 });
|
56
|
+
Assert.areEqual(0, result.messages.length);
|
57
|
+
}
|
58
|
+
}));
|
59
|
+
|
60
|
+
})();
|
@@ -0,0 +1,25 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
/*global YUITest, CSSLint*/
|
4
|
+
var Assert = YUITest.Assert;
|
5
|
+
|
6
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
7
|
+
|
8
|
+
name: "IDs Rule Errors",
|
9
|
+
|
10
|
+
"Using an ID should result in one warning": function(){
|
11
|
+
var result = CSSLint.verify("#foo { float: left;}", { ids: 1 });
|
12
|
+
Assert.areEqual(1, result.messages.length);
|
13
|
+
Assert.areEqual("warning", result.messages[0].type);
|
14
|
+
Assert.areEqual("Don't use IDs in selectors.", result.messages[0].message);
|
15
|
+
},
|
16
|
+
|
17
|
+
"Using multiple IDs should result in one warning": function(){
|
18
|
+
var result = CSSLint.verify("#foo #bar { float: left;}", { ids: 1 });
|
19
|
+
Assert.areEqual(1, result.messages.length);
|
20
|
+
Assert.areEqual("warning", result.messages[0].type);
|
21
|
+
Assert.areEqual("2 IDs in the selector, really?", result.messages[0].message);
|
22
|
+
}
|
23
|
+
}));
|
24
|
+
|
25
|
+
})();
|