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,1921 @@
|
|
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
|
+
})();
|
23
|
+
|
24
|
+
(function(){
|
25
|
+
|
26
|
+
/*global YUITest, CSSLint, Reporter*/
|
27
|
+
var Assert = YUITest.Assert;
|
28
|
+
|
29
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
30
|
+
|
31
|
+
name: "Reporter Object Tests",
|
32
|
+
|
33
|
+
"Report should cause a warning": function(){
|
34
|
+
var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
|
35
|
+
reporter.report("Foo", 1, 1, { id: "fake-rule" });
|
36
|
+
|
37
|
+
Assert.areEqual(1, reporter.messages.length);
|
38
|
+
Assert.areEqual("warning", reporter.messages[0].type);
|
39
|
+
},
|
40
|
+
|
41
|
+
"Report should cause an error": function(){
|
42
|
+
var reporter = new CSSLint._Reporter([], { "fake-rule": 2});
|
43
|
+
reporter.report("Foo", 1, 1, { id: "fake-rule" });
|
44
|
+
|
45
|
+
Assert.areEqual(1, reporter.messages.length);
|
46
|
+
Assert.areEqual("error", reporter.messages[0].type);
|
47
|
+
},
|
48
|
+
|
49
|
+
"Calling error() should cause an error": function(){
|
50
|
+
var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
|
51
|
+
reporter.error("Foo", 1, 1, { id: "fake-rule" });
|
52
|
+
|
53
|
+
Assert.areEqual(1, reporter.messages.length);
|
54
|
+
Assert.areEqual("error", reporter.messages[0].type);
|
55
|
+
}
|
56
|
+
|
57
|
+
}));
|
58
|
+
|
59
|
+
})();
|
60
|
+
|
61
|
+
(function(){
|
62
|
+
|
63
|
+
/*global YUITest, CSSLint*/
|
64
|
+
var Assert = YUITest.Assert;
|
65
|
+
|
66
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
67
|
+
|
68
|
+
name: "Checkstyle XML formatter test",
|
69
|
+
|
70
|
+
"File with no problems should say so": function(){
|
71
|
+
var result = { messages: [], stats: [] },
|
72
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle></checkstyle>";
|
73
|
+
Assert.areEqual(expected, CSSLint.format(result, "FILE", "checkstyle-xml"));
|
74
|
+
},
|
75
|
+
|
76
|
+
"File with problems should list them": function(){
|
77
|
+
var result = { messages: [
|
78
|
+
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "A Rule"} },
|
79
|
+
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "Some Other Rule"} }
|
80
|
+
], stats: [] },
|
81
|
+
file = "<file name=\"FILE\">",
|
82
|
+
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"BOGUS\" source=\"net.csslint.ARule\"/>",
|
83
|
+
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"BOGUS\" source=\"net.csslint.SomeOtherRule\"/>",
|
84
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>" + file + error1 + error2 + "</file></checkstyle>",
|
85
|
+
actual = CSSLint.format(result, "FILE", "checkstyle-xml");
|
86
|
+
Assert.areEqual(expected, actual);
|
87
|
+
},
|
88
|
+
|
89
|
+
"Formatter should escape special characters": function() {
|
90
|
+
var specialCharsSting = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
|
91
|
+
result = { messages: [
|
92
|
+
{ type: "warning", line: 1, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] },
|
93
|
+
{ type: "error", line: 2, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] }
|
94
|
+
], stats: [] },
|
95
|
+
file = "<file name=\"FILE\">",
|
96
|
+
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"sneaky, "sneaky", <sneaky>, sneak & sneaky\" source=\"\"/>",
|
97
|
+
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"sneaky, "sneaky", <sneaky>, sneak & sneaky\" source=\"\"/>",
|
98
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>" + file + error1 + error2 + "</file></checkstyle>",
|
99
|
+
actual = CSSLint.format(result, "FILE", "checkstyle-xml");
|
100
|
+
Assert.areEqual(expected, actual);
|
101
|
+
}
|
102
|
+
|
103
|
+
}));
|
104
|
+
})();
|
105
|
+
|
106
|
+
(function(){
|
107
|
+
|
108
|
+
/*global YUITest, CSSLint*/
|
109
|
+
var Assert = YUITest.Assert;
|
110
|
+
|
111
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
112
|
+
name: "Compact formatter",
|
113
|
+
|
114
|
+
"File with no problems should say so": function() {
|
115
|
+
var result = { messages: [], stats: [] },
|
116
|
+
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
|
117
|
+
Assert.areEqual("path/to/FILE: Lint Free!", actual);
|
118
|
+
},
|
119
|
+
|
120
|
+
"Should have no output when quiet option is specified and no errors": function() {
|
121
|
+
var result = { messages: [], stats: [] },
|
122
|
+
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});
|
123
|
+
Assert.areEqual("", actual);
|
124
|
+
},
|
125
|
+
|
126
|
+
"File with problems should list them": function() {
|
127
|
+
var result = { messages: [
|
128
|
+
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
|
129
|
+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
|
130
|
+
], stats: [] },
|
131
|
+
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
|
132
|
+
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
|
133
|
+
expected = err + warning,
|
134
|
+
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
|
135
|
+
Assert.areEqual(expected, actual);
|
136
|
+
},
|
137
|
+
|
138
|
+
"Should output relative file paths": function() {
|
139
|
+
var result = { messages: [
|
140
|
+
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
|
141
|
+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
|
142
|
+
], stats: [] },
|
143
|
+
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
|
144
|
+
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
|
145
|
+
expected = err + warning,
|
146
|
+
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
|
147
|
+
Assert.areEqual(expected, actual);
|
148
|
+
}
|
149
|
+
|
150
|
+
}));
|
151
|
+
|
152
|
+
})();
|
153
|
+
|
154
|
+
(function(){
|
155
|
+
|
156
|
+
/*global YUITest, CSSLint*/
|
157
|
+
var Assert = YUITest.Assert;
|
158
|
+
|
159
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
160
|
+
name: "CSSLint XML formatter test",
|
161
|
+
|
162
|
+
"File with no problems should say so": function(){
|
163
|
+
var result = { messages: [], stats: [] },
|
164
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint></csslint>";
|
165
|
+
Assert.areEqual(expected, CSSLint.format(result, "FILE", "csslint-xml"));
|
166
|
+
},
|
167
|
+
|
168
|
+
"File with problems should list them": function(){
|
169
|
+
var result = { messages: [
|
170
|
+
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] },
|
171
|
+
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
|
172
|
+
], stats: [] },
|
173
|
+
file = "<file name=\"FILE\">",
|
174
|
+
error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
|
175
|
+
error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
|
176
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>" + file + error1 + error2 + "</file></csslint>",
|
177
|
+
actual = CSSLint.format(result, "FILE", "csslint-xml");
|
178
|
+
Assert.areEqual(expected, actual);
|
179
|
+
},
|
180
|
+
|
181
|
+
"Formatter should escape double quotes": function() {
|
182
|
+
var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
|
183
|
+
result = { messages: [
|
184
|
+
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
|
185
|
+
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
|
186
|
+
], stats: [] },
|
187
|
+
file = "<file name=\"FILE\">",
|
188
|
+
error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', <sneaky>, sneak & sneaky\"/>",
|
189
|
+
error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', <sneaky>, sneak & sneaky\"/>",
|
190
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>" + file + error1 + error2 + "</file></csslint>",
|
191
|
+
actual = CSSLint.format(result, "FILE", "csslint-xml");
|
192
|
+
Assert.areEqual(expected, actual);
|
193
|
+
}
|
194
|
+
}));
|
195
|
+
})();
|
196
|
+
|
197
|
+
(function(){
|
198
|
+
|
199
|
+
/*global YUITest, CSSLint*/
|
200
|
+
var Assert = YUITest.Assert;
|
201
|
+
|
202
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
203
|
+
|
204
|
+
name: "Lint XML formatter test",
|
205
|
+
|
206
|
+
"File with no problems should say so": function(){
|
207
|
+
var result = { messages: [], stats: [] },
|
208
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint></lint>";
|
209
|
+
Assert.areEqual(expected, CSSLint.format(result, "FILE", "lint-xml"));
|
210
|
+
},
|
211
|
+
|
212
|
+
"File with problems should list them": function(){
|
213
|
+
var result = { messages: [
|
214
|
+
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] },
|
215
|
+
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
|
216
|
+
], stats: [] },
|
217
|
+
file = "<file name=\"FILE\">",
|
218
|
+
error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
|
219
|
+
error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"ALSO BOGUS\"/>",
|
220
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>" + file + error1 + error2 + "</file></lint>",
|
221
|
+
actual = CSSLint.format(result, "FILE", "lint-xml");
|
222
|
+
Assert.areEqual(expected, actual);
|
223
|
+
},
|
224
|
+
|
225
|
+
"Formatter should escape double quotes": function() {
|
226
|
+
var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
|
227
|
+
result = { messages: [
|
228
|
+
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
|
229
|
+
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
|
230
|
+
], stats: [] },
|
231
|
+
file = "<file name=\"FILE\">",
|
232
|
+
error1 = "<issue line=\"1\" char=\"1\" severity=\"warning\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', <sneaky>, sneak & sneaky\"/>",
|
233
|
+
error2 = "<issue line=\"2\" char=\"1\" severity=\"error\" reason=\"BOGUS\" evidence=\"sneaky, 'sneaky', <sneaky>, sneak & sneaky\"/>",
|
234
|
+
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>" + file + error1 + error2 + "</file></lint>",
|
235
|
+
actual = CSSLint.format(result, "FILE", "lint-xml");
|
236
|
+
Assert.areEqual(expected, actual);
|
237
|
+
}
|
238
|
+
}));
|
239
|
+
})();
|
240
|
+
|
241
|
+
(function(){
|
242
|
+
|
243
|
+
/*global YUITest, CSSLint*/
|
244
|
+
var Assert = YUITest.Assert;
|
245
|
+
|
246
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
247
|
+
|
248
|
+
name: "Text formatter",
|
249
|
+
|
250
|
+
"File with no problems should say so": function() {
|
251
|
+
var result = { messages: [], stats: [] },
|
252
|
+
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
|
253
|
+
Assert.areEqual("\n\ncsslint: No errors in path/to/FILE.", actual);
|
254
|
+
},
|
255
|
+
|
256
|
+
"Should have no output when quiet option is specified and no errors": function() {
|
257
|
+
var result = { messages: [], stats: [] },
|
258
|
+
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});
|
259
|
+
Assert.areEqual("", actual);
|
260
|
+
},
|
261
|
+
|
262
|
+
"File with problems should list them": function() {
|
263
|
+
var result = { messages: [
|
264
|
+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] },
|
265
|
+
{ type: 'error', line: 2, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
|
266
|
+
], stats: [] },
|
267
|
+
error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
|
268
|
+
error2 = "\n2: error at line 2, col 1\nBOGUS\nALSO BOGUS",
|
269
|
+
expected = "\n\ncsslint: There are 2 problems in path/to/FILE.\n\nFILE" + error1 + "\n\nFILE" + error2,
|
270
|
+
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
|
271
|
+
Assert.areEqual(expected, actual);
|
272
|
+
}
|
273
|
+
|
274
|
+
}));
|
275
|
+
|
276
|
+
})();
|
277
|
+
|
278
|
+
(function(){
|
279
|
+
|
280
|
+
/*global YUITest, CSSLint*/
|
281
|
+
var Assert = YUITest.Assert;
|
282
|
+
|
283
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
284
|
+
|
285
|
+
name: "Adjoining Selector Rule Errors",
|
286
|
+
|
287
|
+
"Adjoining classes should result in a warning": function(){
|
288
|
+
var result = CSSLint.verify(".foo.bar { }", { "adjoining-classes": 1 });
|
289
|
+
Assert.areEqual(1, result.messages.length);
|
290
|
+
Assert.areEqual("warning", result.messages[0].type);
|
291
|
+
Assert.areEqual("Don't use adjoining classes.", result.messages[0].message);
|
292
|
+
},
|
293
|
+
|
294
|
+
"Adjoining classes should result in an error": function(){
|
295
|
+
var result = CSSLint.verify(".foo.bar { }", { "adjoining-classes": 2 });
|
296
|
+
Assert.areEqual(1, result.messages.length);
|
297
|
+
Assert.areEqual("error", result.messages[0].type);
|
298
|
+
Assert.areEqual("Don't use adjoining classes.", result.messages[0].message);
|
299
|
+
},
|
300
|
+
|
301
|
+
"Descendant selector with classes should not result in a warning": function(){
|
302
|
+
var result = CSSLint.verify(".foo .bar { }", { "adjoining-classes": 1 });
|
303
|
+
Assert.areEqual(0, result.messages.length);
|
304
|
+
}
|
305
|
+
|
306
|
+
}));
|
307
|
+
|
308
|
+
})();
|
309
|
+
|
310
|
+
(function(){
|
311
|
+
|
312
|
+
/*global YUITest, CSSLint*/
|
313
|
+
var Assert = YUITest.Assert;
|
314
|
+
|
315
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
316
|
+
|
317
|
+
name: "Box Model Rule Errors",
|
318
|
+
|
319
|
+
"Using width and padding should result in a warning": function(){
|
320
|
+
var result = CSSLint.verify(".foo { width: 100px; padding: 10px; }", { "box-model": 1 });
|
321
|
+
Assert.areEqual(1, result.messages.length);
|
322
|
+
Assert.areEqual("warning", result.messages[0].type);
|
323
|
+
Assert.areEqual("Using width with padding can sometimes make elements larger than you expect.", result.messages[0].message);
|
324
|
+
},
|
325
|
+
|
326
|
+
"Using width when padding is zero should not result in a warning": function(){
|
327
|
+
var result = CSSLint.verify(".foo { width: 100px; padding: 0; }", { "box-model": 1 });
|
328
|
+
Assert.areEqual(0, result.messages.length);
|
329
|
+
},
|
330
|
+
|
331
|
+
"Using width and padding-left should result in a warning": function(){
|
332
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-left: 10px; }", { "box-model": 1 });
|
333
|
+
Assert.areEqual(1, result.messages.length);
|
334
|
+
Assert.areEqual("warning", result.messages[0].type);
|
335
|
+
Assert.areEqual("Using width with padding-left can sometimes make elements larger than you expect.", result.messages[0].message);
|
336
|
+
},
|
337
|
+
|
338
|
+
"Using width when padding-left is zero should not result in a warning": function(){
|
339
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-left: 0; }", { "box-model": 1 });
|
340
|
+
Assert.areEqual(0, result.messages.length);
|
341
|
+
},
|
342
|
+
|
343
|
+
"Using width and padding-right should result in a warning": function(){
|
344
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-right: 10px; }", { "box-model": 1 });
|
345
|
+
Assert.areEqual(1, result.messages.length);
|
346
|
+
Assert.areEqual("warning", result.messages[0].type);
|
347
|
+
Assert.areEqual("Using width with padding-right can sometimes make elements larger than you expect.", result.messages[0].message);
|
348
|
+
},
|
349
|
+
|
350
|
+
"Using width when padding-right is zero should not result in a warning": function(){
|
351
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-right: 0; }", { "box-model": 1 });
|
352
|
+
Assert.areEqual(0, result.messages.length);
|
353
|
+
},
|
354
|
+
|
355
|
+
"Using width and padding-top should not result in a warning": function(){
|
356
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-top: 10px; }", { "box-model": 1 });
|
357
|
+
Assert.areEqual(0, result.messages.length);
|
358
|
+
},
|
359
|
+
|
360
|
+
"Using width and padding-bottom should not result in a warning": function(){
|
361
|
+
var result = CSSLint.verify(".foo { width: 100px; padding-bottom: 10px; }", { "box-model": 1 });
|
362
|
+
Assert.areEqual(0, result.messages.length);
|
363
|
+
},
|
364
|
+
|
365
|
+
"Using width and padding-to-bottom should not result in a warning": function(){
|
366
|
+
var result = CSSLint.verify(".foo { width: 100px; padding: 10px 0; }", { "box-model": 1 });
|
367
|
+
Assert.areEqual(0, result.messages.length);
|
368
|
+
},
|
369
|
+
|
370
|
+
"Using width and border should result in a warning": function(){
|
371
|
+
var result = CSSLint.verify(".foo { width: 100px; border: 10px; }", { "box-model": 1 });
|
372
|
+
Assert.areEqual(1, result.messages.length);
|
373
|
+
Assert.areEqual("warning", result.messages[0].type);
|
374
|
+
Assert.areEqual("Using width with border can sometimes make elements larger than you expect.", result.messages[0].message);
|
375
|
+
},
|
376
|
+
|
377
|
+
"Using width and border-left should result in a warning": function(){
|
378
|
+
var result = CSSLint.verify(".foo { width: 100px; border-left: 10px; }", { "box-model": 1 });
|
379
|
+
Assert.areEqual(1, result.messages.length);
|
380
|
+
Assert.areEqual("warning", result.messages[0].type);
|
381
|
+
Assert.areEqual("Using width with border-left can sometimes make elements larger than you expect.", result.messages[0].message);
|
382
|
+
},
|
383
|
+
|
384
|
+
"Using width when border-left is zero should not result in a warning": function(){
|
385
|
+
var result = CSSLint.verify(".foo { width: 100px; border-left: 0; }", { "box-model": 1 });
|
386
|
+
Assert.areEqual(0, result.messages.length);
|
387
|
+
},
|
388
|
+
|
389
|
+
"Using width and border-right should result in a warning": function(){
|
390
|
+
var result = CSSLint.verify(".foo { width: 100px; border-right: 10px; }", { "box-model": 1 });
|
391
|
+
Assert.areEqual(1, result.messages.length);
|
392
|
+
Assert.areEqual("warning", result.messages[0].type);
|
393
|
+
Assert.areEqual("Using width with border-right can sometimes make elements larger than you expect.", result.messages[0].message);
|
394
|
+
},
|
395
|
+
|
396
|
+
"Using width when border-right is zero should not result in a warning": function(){
|
397
|
+
var result = CSSLint.verify(".foo { width: 100px; border-right: 0; }", { "box-model": 1 });
|
398
|
+
Assert.areEqual(0, result.messages.length);
|
399
|
+
},
|
400
|
+
|
401
|
+
"Using width and border-top should not result in a warning": function(){
|
402
|
+
var result = CSSLint.verify(".foo { width: 100px; border-top: 10px; }", { "box-model": 1 });
|
403
|
+
Assert.areEqual(0, result.messages.length);
|
404
|
+
},
|
405
|
+
|
406
|
+
"Using width and border-bottom should not result in a warning": function(){
|
407
|
+
var result = CSSLint.verify(".foo { width: 100px; border-bottom: 10px; }", { "box-model": 1 });
|
408
|
+
Assert.areEqual(0, result.messages.length);
|
409
|
+
},
|
410
|
+
|
411
|
+
"Using height and padding should result in a warning": function(){
|
412
|
+
var result = CSSLint.verify(".foo { height: 100px; padding: 10px; }", { "box-model": 1 });
|
413
|
+
Assert.areEqual(1, result.messages.length);
|
414
|
+
Assert.areEqual("warning", result.messages[0].type);
|
415
|
+
Assert.areEqual("Using height with padding can sometimes make elements larger than you expect.", result.messages[0].message);
|
416
|
+
},
|
417
|
+
|
418
|
+
"Using height when padding is zero should not result in a warning": function(){
|
419
|
+
var result = CSSLint.verify(".foo { height: 100px; padding: 0; }", { "box-model": 1 });
|
420
|
+
Assert.areEqual(0, result.messages.length);
|
421
|
+
},
|
422
|
+
|
423
|
+
"Using height and padding-left should not result in a warning": function(){
|
424
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-left: 10px; }", { "box-model": 1 });
|
425
|
+
Assert.areEqual(0, result.messages.length);
|
426
|
+
},
|
427
|
+
|
428
|
+
"Using height and padding-right should not result in a warning": function(){
|
429
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-right: 10px; }", { "box-model": 1 });
|
430
|
+
Assert.areEqual(0, result.messages.length);
|
431
|
+
},
|
432
|
+
|
433
|
+
"Using height and padding-left-right should not result in a warning": function(){
|
434
|
+
var result = CSSLint.verify(".foo { height: 100px; padding: 0 10px; }", { "box-model": 1 });
|
435
|
+
Assert.areEqual(0, result.messages.length);
|
436
|
+
},
|
437
|
+
|
438
|
+
"Using height and padding-top should result in a warning": function(){
|
439
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-top: 10px; }", { "box-model": 1 });
|
440
|
+
Assert.areEqual(1, result.messages.length);
|
441
|
+
Assert.areEqual("warning", result.messages[0].type);
|
442
|
+
Assert.areEqual("Using height with padding-top can sometimes make elements larger than you expect.", result.messages[0].message);
|
443
|
+
},
|
444
|
+
|
445
|
+
"Using height when padding-top is zero should not result in a warning": function(){
|
446
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-top: 0; }", { "box-model": 1 });
|
447
|
+
Assert.areEqual(0, result.messages.length);
|
448
|
+
},
|
449
|
+
|
450
|
+
"Using height and padding-bottom should result in a warning": function(){
|
451
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-bottom: 10px; }", { "box-model": 1 });
|
452
|
+
Assert.areEqual(1, result.messages.length);
|
453
|
+
Assert.areEqual("warning", result.messages[0].type);
|
454
|
+
Assert.areEqual("Using height with padding-bottom can sometimes make elements larger than you expect.", result.messages[0].message);
|
455
|
+
},
|
456
|
+
|
457
|
+
"Using height when padding-bottom is zero should not result in a warning": function(){
|
458
|
+
var result = CSSLint.verify(".foo { height: 100px; padding-bottom: 0; }", { "box-model": 1 });
|
459
|
+
Assert.areEqual(0, result.messages.length);
|
460
|
+
},
|
461
|
+
|
462
|
+
"Using height and border should result in a warning": function(){
|
463
|
+
var result = CSSLint.verify(".foo { height: 100px; border: 10px; }", { "box-model": 1 });
|
464
|
+
Assert.areEqual(1, result.messages.length);
|
465
|
+
Assert.areEqual("warning", result.messages[0].type);
|
466
|
+
Assert.areEqual("Using height with border can sometimes make elements larger than you expect.", result.messages[0].message);
|
467
|
+
},
|
468
|
+
|
469
|
+
"Using height and border: none should not result in a warning": function(){
|
470
|
+
var result = CSSLint.verify(".foo { height: 100px; border: none; }", { "box-model": 1 });
|
471
|
+
Assert.areEqual(0, result.messages.length);
|
472
|
+
},
|
473
|
+
|
474
|
+
"Using height and border: 0 should not result in a warning": function(){
|
475
|
+
var result = CSSLint.verify(".foo { height: 100px; border: 0; }", { "box-model": 1 });
|
476
|
+
Assert.areEqual(0, result.messages.length);
|
477
|
+
},
|
478
|
+
|
479
|
+
"Using height and border-left should not result in a warning": function(){
|
480
|
+
var result = CSSLint.verify(".foo { height: 100px; border-left: 10px; }", { "box-model": 1 });
|
481
|
+
Assert.areEqual(0, result.messages.length);
|
482
|
+
},
|
483
|
+
|
484
|
+
"Using height and border-right should not result in a warning": function(){
|
485
|
+
var result = CSSLint.verify(".foo { height: 100px; border-right: 10px; }", { "box-model": 1 });
|
486
|
+
Assert.areEqual(0, result.messages.length);
|
487
|
+
},
|
488
|
+
|
489
|
+
"Using height and border-top should result in a warning": function(){
|
490
|
+
var result = CSSLint.verify(".foo { height: 100px; border-top: 10px; }", { "box-model": 1 });
|
491
|
+
Assert.areEqual(1, result.messages.length);
|
492
|
+
Assert.areEqual("warning", result.messages[0].type);
|
493
|
+
Assert.areEqual("Using height with border-top can sometimes make elements larger than you expect.", result.messages[0].message);
|
494
|
+
},
|
495
|
+
|
496
|
+
"Using height when border-top is zero should not result in a warning": function(){
|
497
|
+
var result = CSSLint.verify(".foo { height: 100px; border-top: 0; }", { "box-model": 1 });
|
498
|
+
Assert.areEqual(0, result.messages.length);
|
499
|
+
},
|
500
|
+
|
501
|
+
"Using height and border-bottom should result in a warning": function(){
|
502
|
+
var result = CSSLint.verify(".foo { height: 100px; border-bottom: 10px; }", { "box-model": 1 });
|
503
|
+
Assert.areEqual(1, result.messages.length);
|
504
|
+
Assert.areEqual("warning", result.messages[0].type);
|
505
|
+
Assert.areEqual("Using height with border-bottom can sometimes make elements larger than you expect.", result.messages[0].message);
|
506
|
+
},
|
507
|
+
|
508
|
+
"Using height when border-bottom is zero should not result in a warning": function(){
|
509
|
+
var result = CSSLint.verify(".foo { height: 100px; border-bottom: 0px; }", { "box-model": 1 });
|
510
|
+
Assert.areEqual(0, result.messages.length);
|
511
|
+
},
|
512
|
+
|
513
|
+
"Using height when border-bottom is zero should not result in a warning": function(){
|
514
|
+
var result = CSSLint.verify(".foo { height: 100px; border-bottom: 0; }", { "box-model": 1 });
|
515
|
+
Assert.areEqual(0, result.messages.length);
|
516
|
+
}
|
517
|
+
|
518
|
+
}));
|
519
|
+
|
520
|
+
})();
|
521
|
+
|
522
|
+
(function(){
|
523
|
+
|
524
|
+
/*global YUITest, CSSLint*/
|
525
|
+
var Assert = YUITest.Assert;
|
526
|
+
|
527
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
528
|
+
|
529
|
+
name: "Box Sizing Rule Errors",
|
530
|
+
|
531
|
+
"Using box-sizing should result in a warning": function(){
|
532
|
+
var result = CSSLint.verify(".foo { box-sizing: border-box; }", { "box-sizing": 1 });
|
533
|
+
Assert.areEqual(1, result.messages.length);
|
534
|
+
Assert.areEqual("warning", result.messages[0].type);
|
535
|
+
Assert.areEqual("The box-sizing property isn't supported in IE6 and IE7.", result.messages[0].message);
|
536
|
+
},
|
537
|
+
|
538
|
+
"No box-sizing should not result in a warning": function(){
|
539
|
+
var result = CSSLint.verify(".foo { width: 100px; padding: 0; }", { "box-sizing": 1 });
|
540
|
+
Assert.areEqual(0, result.messages.length);
|
541
|
+
}
|
542
|
+
}));
|
543
|
+
|
544
|
+
})();
|
545
|
+
|
546
|
+
(function(){
|
547
|
+
|
548
|
+
/*global YUITest, CSSLint*/
|
549
|
+
var Assert = YUITest.Assert;
|
550
|
+
|
551
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
552
|
+
|
553
|
+
name: "Compatible Vendor Prefix Warnings",
|
554
|
+
|
555
|
+
"Using -webkit-border-radius should warn to also include -moz-border-radius.": function(){
|
556
|
+
var result = CSSLint.verify("h1 { -webkit-border-radius: 5px; }", { "compatible-vendor-prefixes": 1 });
|
557
|
+
Assert.areEqual(1, result.messages.length);
|
558
|
+
Assert.areEqual("warning", result.messages[0].type);
|
559
|
+
Assert.areEqual("The property -moz-border-radius is compatible with -webkit-border-radius and should be included as well.", result.messages[0].message);
|
560
|
+
Assert.areEqual(6, result.messages[0].col);
|
561
|
+
Assert.areEqual(1, result.messages[0].line);
|
562
|
+
},
|
563
|
+
|
564
|
+
"Using -webkit-transition and -moz-transition should warn to also include -o-transition and -ms-transition.": function(){
|
565
|
+
var result = CSSLint.verify("h1 { -webkit-transition: height 20px 1s; -moz-transition: height 20px 1s; }", { "compatible-vendor-prefixes": 1 });
|
566
|
+
Assert.areEqual(2, result.messages.length);
|
567
|
+
Assert.areEqual("warning", result.messages[0].type);
|
568
|
+
Assert.areEqual("The property -o-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[0].message);
|
569
|
+
Assert.areEqual(6, result.messages[0].col);
|
570
|
+
Assert.areEqual(1, result.messages[0].line);
|
571
|
+
Assert.areEqual("warning", result.messages[1].type);
|
572
|
+
Assert.areEqual("The property -ms-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[1].message);
|
573
|
+
Assert.areEqual(6, result.messages[1].col);
|
574
|
+
Assert.areEqual(1, result.messages[1].line);
|
575
|
+
|
576
|
+
},
|
577
|
+
|
578
|
+
"Using -webkit-transform should warn to also include -moz-transform, -ms-transform, and -o-transform.": function(){
|
579
|
+
var result = CSSLint.verify("div.box { -webkit-transform: translate(50px, 100px); }", { "compatible-vendor-prefixes": 3 });
|
580
|
+
Assert.areEqual(3, result.messages.length);
|
581
|
+
Assert.areEqual("warning", result.messages[0].type);
|
582
|
+
Assert.areEqual("The property -moz-transform is compatible with -webkit-transform and should be included as well.", result.messages[0].message);
|
583
|
+
Assert.areEqual("warning", result.messages[1].type);
|
584
|
+
Assert.areEqual("The property -ms-transform is compatible with -webkit-transform and should be included as well.", result.messages[1].message);
|
585
|
+
Assert.areEqual("warning", result.messages[2].type);
|
586
|
+
Assert.areEqual("The property -o-transform is compatible with -webkit-transform and should be included as well.", result.messages[2].message);
|
587
|
+
},
|
588
|
+
|
589
|
+
"Using all compatible vendor prefixes for animation should be allowed with no warnings.": function(){
|
590
|
+
var result = CSSLint.verify(".next:focus { -moz-animation: 'diagonal-slide' 5s 10; -webkit-animation: 'diagonal-slide' 5s 10; -ms-animation: 'diagonal-slide' 5s 10; }", { "compatible-vendor-prefixes": 0 });
|
591
|
+
Assert.areEqual(0, result.messages.length);
|
592
|
+
},
|
593
|
+
|
594
|
+
"Using box-shadow with no vendor prefixes should be allowed with no warnings.": function(){
|
595
|
+
var result = CSSLint.verify("h1 { box-shadow: 5px 5px 5px #ccc; }", { "compatible-vendor-prefixes": 0 });
|
596
|
+
Assert.areEqual(0, result.messages.length);
|
597
|
+
}
|
598
|
+
|
599
|
+
}));
|
600
|
+
|
601
|
+
})();
|
602
|
+
|
603
|
+
(function(){
|
604
|
+
|
605
|
+
/*global YUITest, CSSLint*/
|
606
|
+
var Assert = YUITest.Assert;
|
607
|
+
|
608
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
609
|
+
|
610
|
+
name: "Display Property Grouping Rule Errors",
|
611
|
+
|
612
|
+
/*
|
613
|
+
* - float should not be used with inline-block
|
614
|
+
* - height, width, margin-top, margin-bottom, float should not be used with inline
|
615
|
+
* - vertical-align should not be used with block
|
616
|
+
* - margin, float should not be used with table-*
|
617
|
+
*/
|
618
|
+
"Float with inline-block should result in a warning": function(){
|
619
|
+
var result = CSSLint.verify(".foo { float: left; display: inline-block; }", { "display-property-grouping": 1 });
|
620
|
+
Assert.areEqual(1, result.messages.length);
|
621
|
+
Assert.areEqual("warning", result.messages[0].type);
|
622
|
+
Assert.areEqual("float can't be used with display: inline-block.", result.messages[0].message);
|
623
|
+
},
|
624
|
+
|
625
|
+
"Float with inline should result in a warning": function(){
|
626
|
+
var result = CSSLint.verify(".foo { float: left; display: inline; }", { "display-property-grouping": 1 });
|
627
|
+
Assert.areEqual(1, result.messages.length);
|
628
|
+
Assert.areEqual("warning", result.messages[0].type);
|
629
|
+
Assert.areEqual("display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).", result.messages[0].message);
|
630
|
+
},
|
631
|
+
|
632
|
+
"Float:none with inline-block should not result in a warning": function(){
|
633
|
+
var result = CSSLint.verify(".foo { float: none; display: inline-block; }", { "display-property-grouping": 1 });
|
634
|
+
Assert.areEqual(0, result.messages.length);
|
635
|
+
},
|
636
|
+
|
637
|
+
"Float:none with inline should result not in a warning": function(){
|
638
|
+
var result = CSSLint.verify(".foo { float: none; display: inline; }", { "display-property-grouping": 1 });
|
639
|
+
Assert.areEqual(0, result.messages.length);
|
640
|
+
},
|
641
|
+
|
642
|
+
"Height with inline should result in a warning": function(){
|
643
|
+
var result = CSSLint.verify(".foo { height: 100px; display: inline; }", { "display-property-grouping": 1 });
|
644
|
+
Assert.areEqual(1, result.messages.length);
|
645
|
+
Assert.areEqual("warning", result.messages[0].type);
|
646
|
+
Assert.areEqual("height can't be used with display: inline.", result.messages[0].message);
|
647
|
+
},
|
648
|
+
|
649
|
+
"Width with inline should result in a warning": function(){
|
650
|
+
var result = CSSLint.verify(".foo { width: 100px; display: inline; }", { "display-property-grouping": 1 });
|
651
|
+
Assert.areEqual(1, result.messages.length);
|
652
|
+
Assert.areEqual("warning", result.messages[0].type);
|
653
|
+
Assert.areEqual("width can't be used with display: inline.", result.messages[0].message);
|
654
|
+
},
|
655
|
+
|
656
|
+
"Margin with inline should result in a warning": function(){
|
657
|
+
var result = CSSLint.verify(".foo { margin: 100px; display: inline; }", { "display-property-grouping": 1 });
|
658
|
+
Assert.areEqual(1, result.messages.length);
|
659
|
+
Assert.areEqual("warning", result.messages[0].type);
|
660
|
+
Assert.areEqual("margin can't be used with display: inline.", result.messages[0].message);
|
661
|
+
},
|
662
|
+
|
663
|
+
"Margin-left with inline should not result in a warning": function(){
|
664
|
+
var result = CSSLint.verify(".foo { margin-left: 100px; display: inline; }", { "display-property-grouping": 1 });
|
665
|
+
Assert.areEqual(0, result.messages.length);
|
666
|
+
},
|
667
|
+
|
668
|
+
"Margin-right with inline should not result in a warning": function(){
|
669
|
+
var result = CSSLint.verify(".foo { margin-right: 100px; display: inline; }", { "display-property-grouping": 1 });
|
670
|
+
Assert.areEqual(0, result.messages.length);
|
671
|
+
},
|
672
|
+
|
673
|
+
"Margin-top with inline should result in a warning": function(){
|
674
|
+
var result = CSSLint.verify(".foo { margin-top: 100px; display: inline; }", { "display-property-grouping": 1 });
|
675
|
+
Assert.areEqual(1, result.messages.length);
|
676
|
+
Assert.areEqual("warning", result.messages[0].type);
|
677
|
+
Assert.areEqual("margin-top can't be used with display: inline.", result.messages[0].message);
|
678
|
+
},
|
679
|
+
|
680
|
+
"Margin-bottom with inline should result in a warning": function(){
|
681
|
+
var result = CSSLint.verify(".foo { margin-bottom: 100px; display: inline; }", { "display-property-grouping": 1 });
|
682
|
+
Assert.areEqual(1, result.messages.length);
|
683
|
+
Assert.areEqual("warning", result.messages[0].type);
|
684
|
+
Assert.areEqual("margin-bottom can't be used with display: inline.", result.messages[0].message);
|
685
|
+
},
|
686
|
+
|
687
|
+
"Padding with inline should not result in a warning": function(){
|
688
|
+
var result = CSSLint.verify(".foo { padding: 100px; display: inline; }", { "display-property-grouping": 1 });
|
689
|
+
Assert.areEqual(0, result.messages.length);
|
690
|
+
},
|
691
|
+
|
692
|
+
"Padding-left with inline should not result in a warning": function(){
|
693
|
+
var result = CSSLint.verify(".foo { padding-left: 100px; display: inline; }", { "display-property-grouping": 1 });
|
694
|
+
Assert.areEqual(0, result.messages.length);
|
695
|
+
},
|
696
|
+
|
697
|
+
"Padding-right with inline should not result in a warning": function(){
|
698
|
+
var result = CSSLint.verify(".foo { padding-right: 100px; display: inline; }", { "display-property-grouping": 1 });
|
699
|
+
Assert.areEqual(0, result.messages.length);
|
700
|
+
},
|
701
|
+
|
702
|
+
"Padding-top with inline should not result in a warning": function(){
|
703
|
+
var result = CSSLint.verify(".foo { padding-top: 100px; display: inline; }", { "display-property-grouping": 1 });
|
704
|
+
Assert.areEqual(0, result.messages.length);
|
705
|
+
},
|
706
|
+
|
707
|
+
"Padding-bottom with inline should result in a warning": function(){
|
708
|
+
var result = CSSLint.verify(".foo { padding-bottom: 100px; display: inline; }", { "display-property-grouping": 1 });
|
709
|
+
Assert.areEqual(0, result.messages.length);
|
710
|
+
},
|
711
|
+
|
712
|
+
"Vertical-align with block should result in a warning": function(){
|
713
|
+
var result = CSSLint.verify(".foo { vertical-align: bottom; display: block; }", { "display-property-grouping": 1 });
|
714
|
+
Assert.areEqual(1, result.messages.length);
|
715
|
+
Assert.areEqual("warning", result.messages[0].type);
|
716
|
+
Assert.areEqual("vertical-align can't be used with display: block.", result.messages[0].message);
|
717
|
+
},
|
718
|
+
|
719
|
+
"Margin with table-cell should result in a warning": function(){
|
720
|
+
var result = CSSLint.verify(".foo { margin: 100px; display: table-cell; }", { "display-property-grouping": 1 });
|
721
|
+
Assert.areEqual(1, result.messages.length);
|
722
|
+
Assert.areEqual("warning", result.messages[0].type);
|
723
|
+
Assert.areEqual("margin can't be used with display: table-cell.", result.messages[0].message);
|
724
|
+
},
|
725
|
+
|
726
|
+
"Margin-left with table-cell should result in a warning": function(){
|
727
|
+
var result = CSSLint.verify(".foo { margin-left: 100px; display: table-cell; }", { "display-property-grouping": 1 });
|
728
|
+
Assert.areEqual(1, result.messages.length);
|
729
|
+
Assert.areEqual("warning", result.messages[0].type);
|
730
|
+
Assert.areEqual("margin-left can't be used with display: table-cell.", result.messages[0].message);
|
731
|
+
},
|
732
|
+
|
733
|
+
"Margin-right with table-cell should result in a warning": function(){
|
734
|
+
var result = CSSLint.verify(".foo { margin-right: 100px; display: table-cell; }", { "display-property-grouping": 1 });
|
735
|
+
Assert.areEqual(1, result.messages.length);
|
736
|
+
Assert.areEqual("warning", result.messages[0].type);
|
737
|
+
Assert.areEqual("margin-right can't be used with display: table-cell.", result.messages[0].message);
|
738
|
+
},
|
739
|
+
|
740
|
+
"Margin-top with table-cell should result in a warning": function(){
|
741
|
+
var result = CSSLint.verify(".foo { margin-top: 100px; display: table-cell; }", { "display-property-grouping": 1 });
|
742
|
+
Assert.areEqual(1, result.messages.length);
|
743
|
+
Assert.areEqual("warning", result.messages[0].type);
|
744
|
+
Assert.areEqual("margin-top can't be used with display: table-cell.", result.messages[0].message);
|
745
|
+
},
|
746
|
+
|
747
|
+
"Margin-bottom with table-cell should result in a warning": function(){
|
748
|
+
var result = CSSLint.verify(".foo { margin-bottom: 100px; display: table-cell; }", { "display-property-grouping": 1 });
|
749
|
+
Assert.areEqual(1, result.messages.length);
|
750
|
+
Assert.areEqual("warning", result.messages[0].type);
|
751
|
+
Assert.areEqual("margin-bottom can't be used with display: table-cell.", result.messages[0].message);
|
752
|
+
},
|
753
|
+
|
754
|
+
"Margin with table-row should result in a warning": function(){
|
755
|
+
var result = CSSLint.verify(".foo { margin: 100px; display: table-row; }", { "display-property-grouping": 1 });
|
756
|
+
Assert.areEqual(1, result.messages.length);
|
757
|
+
Assert.areEqual("warning", result.messages[0].type);
|
758
|
+
Assert.areEqual("margin can't be used with display: table-row.", result.messages[0].message);
|
759
|
+
},
|
760
|
+
|
761
|
+
"Margin-left with table-row should result in a warning": function(){
|
762
|
+
var result = CSSLint.verify(".foo { margin-left: 100px; display: table-row; }", { "display-property-grouping": 1 });
|
763
|
+
Assert.areEqual(1, result.messages.length);
|
764
|
+
Assert.areEqual("warning", result.messages[0].type);
|
765
|
+
Assert.areEqual("margin-left can't be used with display: table-row.", result.messages[0].message);
|
766
|
+
},
|
767
|
+
|
768
|
+
"Margin-right with table-row should result in a warning": function(){
|
769
|
+
var result = CSSLint.verify(".foo { margin-right: 100px; display: table-row; }", { "display-property-grouping": 1 });
|
770
|
+
Assert.areEqual(1, result.messages.length);
|
771
|
+
Assert.areEqual("warning", result.messages[0].type);
|
772
|
+
Assert.areEqual("margin-right can't be used with display: table-row.", result.messages[0].message);
|
773
|
+
},
|
774
|
+
|
775
|
+
"Margin-top with table-row should result in a warning": function(){
|
776
|
+
var result = CSSLint.verify(".foo { margin-top: 100px; display: table-row; }", { "display-property-grouping": 1 });
|
777
|
+
Assert.areEqual(1, result.messages.length);
|
778
|
+
Assert.areEqual("warning", result.messages[0].type);
|
779
|
+
Assert.areEqual("margin-top can't be used with display: table-row.", result.messages[0].message);
|
780
|
+
},
|
781
|
+
|
782
|
+
"Margin-bottom with table-row should result in a warning": function(){
|
783
|
+
var result = CSSLint.verify(".foo { margin-bottom: 100px; display: table-row; }", { "display-property-grouping": 1 });
|
784
|
+
Assert.areEqual(1, result.messages.length);
|
785
|
+
Assert.areEqual("warning", result.messages[0].type);
|
786
|
+
Assert.areEqual("margin-bottom can't be used with display: table-row.", result.messages[0].message);
|
787
|
+
},
|
788
|
+
|
789
|
+
"Float with table-row should result in a warning": function(){
|
790
|
+
var result = CSSLint.verify(".foo { float: left; display: table-row; }", { "display-property-grouping": 1 });
|
791
|
+
Assert.areEqual(1, result.messages.length);
|
792
|
+
Assert.areEqual("warning", result.messages[0].type);
|
793
|
+
Assert.areEqual("float can't be used with display: table-row.", result.messages[0].message);
|
794
|
+
},
|
795
|
+
|
796
|
+
"Float with table-cell should result in a warning": function(){
|
797
|
+
var result = CSSLint.verify(".foo { float: left; display: table-cell; }", { "display-property-grouping": 1 });
|
798
|
+
Assert.areEqual(1, result.messages.length);
|
799
|
+
Assert.areEqual("warning", result.messages[0].type);
|
800
|
+
Assert.areEqual("float can't be used with display: table-cell.", result.messages[0].message);
|
801
|
+
},
|
802
|
+
|
803
|
+
"Float:none with table-row should not result in a warning": function(){
|
804
|
+
var result = CSSLint.verify(".foo { float: none; display: table-row; }", { "display-property-grouping": 1 });
|
805
|
+
Assert.areEqual(0, result.messages.length);
|
806
|
+
},
|
807
|
+
|
808
|
+
"Float:none with table-cell should not result in a warning": function(){
|
809
|
+
var result = CSSLint.verify(".foo { float: none; display: table-cell; }", { "display-property-grouping": 1 });
|
810
|
+
Assert.areEqual(0, result.messages.length);
|
811
|
+
}
|
812
|
+
|
813
|
+
}));
|
814
|
+
|
815
|
+
})();
|
816
|
+
|
817
|
+
(function(){
|
818
|
+
|
819
|
+
/*global YUITest, CSSLint*/
|
820
|
+
var Assert = YUITest.Assert;
|
821
|
+
|
822
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
823
|
+
|
824
|
+
name: "Duplicate Background-URL Rule Errors",
|
825
|
+
|
826
|
+
"duplicate background-image should result in a warning": function(){
|
827
|
+
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 });
|
828
|
+
Assert.areEqual(2, result.messages.length);
|
829
|
+
Assert.areEqual("warning", result.messages[0].type);
|
830
|
+
Assert.areEqual("Background image 'mega-sprite.png' was used multiple times, first declared at line 1, col 8.", result.messages[0].message);
|
831
|
+
},
|
832
|
+
|
833
|
+
"duplicate background with url should result in a warning": function(){
|
834
|
+
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 });
|
835
|
+
Assert.areEqual(2, result.messages.length);
|
836
|
+
Assert.areEqual("warning", result.messages[0].type);
|
837
|
+
Assert.areEqual("Background image 'mega-sprite.png' was used multiple times, first declared at line 1, col 8.", result.messages[0].message);
|
838
|
+
}
|
839
|
+
}));
|
840
|
+
|
841
|
+
})();
|
842
|
+
|
843
|
+
(function(){
|
844
|
+
|
845
|
+
/*global YUITest, CSSLint*/
|
846
|
+
var Assert = YUITest.Assert;
|
847
|
+
|
848
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
849
|
+
|
850
|
+
name: "Duplicate Property Rule Errors",
|
851
|
+
|
852
|
+
"Duplicate properties back-to-back should not result in a warning": function(){
|
853
|
+
var result = CSSLint.verify(".foo { float: left; float: right }", { "duplicate-properties": 1 });
|
854
|
+
Assert.areEqual(0, result.messages.length);
|
855
|
+
},
|
856
|
+
|
857
|
+
"Duplicate properties in @font-face back-to-back should not result in a warning": function(){
|
858
|
+
var result = CSSLint.verify("@font-face { src: url(foo.svg); src: url(foo1.svg) }", { "duplicate-properties": 1 });
|
859
|
+
Assert.areEqual(0, result.messages.length);
|
860
|
+
},
|
861
|
+
|
862
|
+
"Duplicate properties in @page back-to-back should not result in a warning": function(){
|
863
|
+
var result = CSSLint.verify("@page :left { margin: 5px; margin: 4px; }", { "duplicate-properties": 1 });
|
864
|
+
Assert.areEqual(0, result.messages.length);
|
865
|
+
},
|
866
|
+
|
867
|
+
"Duplicate properties not back-to-back should result in a warning": function(){
|
868
|
+
var result = CSSLint.verify(".foo { float: left; margin: 0; float: right }", { "duplicate-properties": 1 });
|
869
|
+
Assert.areEqual(1, result.messages.length);
|
870
|
+
Assert.areEqual("warning", result.messages[0].type);
|
871
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
872
|
+
},
|
873
|
+
|
874
|
+
"Duplicate properties not back-to-back with same values should result in a warning": function(){
|
875
|
+
var result = CSSLint.verify(".foo { float: left; margin: 0; float: left }", { "duplicate-properties": 1 });
|
876
|
+
Assert.areEqual(1, result.messages.length);
|
877
|
+
Assert.areEqual("warning", result.messages[0].type);
|
878
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
879
|
+
},
|
880
|
+
|
881
|
+
"Duplicate properties back-to-back with same values should result in a warning": function(){
|
882
|
+
var result = CSSLint.verify(".foo { float: left; float: left }", { "duplicate-properties": 1 });
|
883
|
+
Assert.areEqual(1, result.messages.length);
|
884
|
+
Assert.areEqual("warning", result.messages[0].type);
|
885
|
+
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
|
886
|
+
},
|
887
|
+
|
888
|
+
"Duplicate properties in @keyframe rules should not result in a warning": function(){
|
889
|
+
var result = CSSLint.verify("@-webkit-keyframes slide_up { from { bottom:-91px; } to { bottom:0; } }", { "duplicate-properties": 1 });
|
890
|
+
Assert.areEqual(0, result.messages.length);
|
891
|
+
}
|
892
|
+
|
893
|
+
|
894
|
+
}));
|
895
|
+
|
896
|
+
})();
|
897
|
+
|
898
|
+
(function(){
|
899
|
+
|
900
|
+
/*global YUITest, CSSLint*/
|
901
|
+
var Assert = YUITest.Assert;
|
902
|
+
|
903
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
904
|
+
|
905
|
+
name: "Empty Rule Errors",
|
906
|
+
|
907
|
+
"Empty rule should result in a warning": function(){
|
908
|
+
var result = CSSLint.verify("li { }", { "empty-rules": 1 });
|
909
|
+
Assert.areEqual(1, result.messages.length);
|
910
|
+
Assert.areEqual("warning", result.messages[0].type);
|
911
|
+
Assert.areEqual("Rule is empty.", result.messages[0].message);
|
912
|
+
}
|
913
|
+
}));
|
914
|
+
|
915
|
+
})();
|
916
|
+
|
917
|
+
(function(){
|
918
|
+
|
919
|
+
/*global YUITest, CSSLint*/
|
920
|
+
var Assert = YUITest.Assert;
|
921
|
+
|
922
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
923
|
+
|
924
|
+
name: "Parsing Errors",
|
925
|
+
|
926
|
+
"Parsing error should result in one parsing error message": function(){
|
927
|
+
var result = CSSLint.verify("li { float left;}", { errors: 1 });
|
928
|
+
Assert.areEqual(1, result.messages.length);
|
929
|
+
Assert.areEqual("error", result.messages[0].type);
|
930
|
+
}
|
931
|
+
}));
|
932
|
+
|
933
|
+
})();
|
934
|
+
|
935
|
+
(function(){
|
936
|
+
|
937
|
+
/*global YUITest, CSSLint*/
|
938
|
+
var Assert = YUITest.Assert;
|
939
|
+
|
940
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
941
|
+
|
942
|
+
name: "Fallback Colors Rule Errors",
|
943
|
+
|
944
|
+
"Using only a named color should not result in a warning": function(){
|
945
|
+
var result = CSSLint.verify(".hex { color: red; }", { "fallback-colors": 1 });
|
946
|
+
Assert.areEqual(0, result.messages.length);
|
947
|
+
},
|
948
|
+
|
949
|
+
"Using only a hex color should not result in a warning": function(){
|
950
|
+
var result = CSSLint.verify(".hex { color: #fff; }", { "fallback-colors": 1 });
|
951
|
+
Assert.areEqual(0, result.messages.length);
|
952
|
+
},
|
953
|
+
|
954
|
+
"Using only rgb() should not result in a warning": function(){
|
955
|
+
var result = CSSLint.verify(".rgb { color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
|
956
|
+
Assert.areEqual(0, result.messages.length);
|
957
|
+
},
|
958
|
+
|
959
|
+
"Using only rgba() should result in a warning": function(){
|
960
|
+
var result = CSSLint.verify(".rgba { color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
961
|
+
Assert.areEqual(1, result.messages.length);
|
962
|
+
Assert.areEqual("warning", result.messages[0].type);
|
963
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
|
964
|
+
},
|
965
|
+
|
966
|
+
"Using only hsl() should result in a warning": function(){
|
967
|
+
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
968
|
+
Assert.areEqual(1, result.messages.length);
|
969
|
+
Assert.areEqual("warning", result.messages[0].type);
|
970
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSL color.", result.messages[0].message);
|
971
|
+
},
|
972
|
+
|
973
|
+
"Using only hsla() should result in a warning": function(){
|
974
|
+
var result = CSSLint.verify(".hsla { color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
975
|
+
Assert.areEqual(1, result.messages.length);
|
976
|
+
Assert.areEqual("warning", result.messages[0].type);
|
977
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSLA color.", result.messages[0].message);
|
978
|
+
},
|
979
|
+
|
980
|
+
"Using rgba() with a fallback should not result in a warning": function(){
|
981
|
+
var result = CSSLint.verify(".rgba { color: #fff; color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
982
|
+
Assert.areEqual(0, result.messages.length);
|
983
|
+
},
|
984
|
+
|
985
|
+
"Using hsl() with a fallback should not result in a warning": function(){
|
986
|
+
var result = CSSLint.verify(".hsl { color: #fff; color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
987
|
+
Assert.areEqual(0, result.messages.length);
|
988
|
+
},
|
989
|
+
|
990
|
+
"Using hsla() with a fallback should not result in a warning": function(){
|
991
|
+
var result = CSSLint.verify(".hsla { color: #fff; color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
992
|
+
Assert.areEqual(0, result.messages.length);
|
993
|
+
},
|
994
|
+
|
995
|
+
"Using rgba() with fallback color afterwards should result in a warning": function(){
|
996
|
+
var result = CSSLint.verify(".rgba { color: rgba(0, 0, 0, 0.5); color: #fff; }", { "fallback-colors": 1 });
|
997
|
+
Assert.areEqual(1, result.messages.length);
|
998
|
+
Assert.areEqual("warning", result.messages[0].type);
|
999
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
|
1000
|
+
},
|
1001
|
+
|
1002
|
+
"Using hsl() with fallback color afterwards should result in a warning": function(){
|
1003
|
+
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); color: #fff; }", { "fallback-colors": 1 });
|
1004
|
+
Assert.areEqual(1, result.messages.length);
|
1005
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1006
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSL color.", result.messages[0].message);
|
1007
|
+
},
|
1008
|
+
|
1009
|
+
"Using hsla() with fallback color afterwards should result in a warning": function(){
|
1010
|
+
var result = CSSLint.verify(".hsla { color: hsla(0, 0%, 0%, 0.5); color: #fff; }", { "fallback-colors": 1 });
|
1011
|
+
Assert.areEqual(1, result.messages.length);
|
1012
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1013
|
+
Assert.areEqual("Fallback color (hex or RGB) should precede HSLA color.", result.messages[0].message);
|
1014
|
+
},
|
1015
|
+
|
1016
|
+
|
1017
|
+
"Using only a named background-color should not result in a warning": function(){
|
1018
|
+
var result = CSSLint.verify(".hex { background-color: red; }", { "fallback-colors": 1 });
|
1019
|
+
Assert.areEqual(0, result.messages.length);
|
1020
|
+
},
|
1021
|
+
|
1022
|
+
"Using only a hex background-color should not result in a warning": function(){
|
1023
|
+
var result = CSSLint.verify(".hex { background-color: #fff; }", { "fallback-colors": 1 });
|
1024
|
+
Assert.areEqual(0, result.messages.length);
|
1025
|
+
},
|
1026
|
+
|
1027
|
+
"Using only rgb() background-color should not result in a warning": function(){
|
1028
|
+
var result = CSSLint.verify(".rgb { background-color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
|
1029
|
+
Assert.areEqual(0, result.messages.length);
|
1030
|
+
},
|
1031
|
+
|
1032
|
+
"Using only rgba() background-color should result in a warning": function(){
|
1033
|
+
var result = CSSLint.verify(".rgba { background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
1034
|
+
Assert.areEqual(1, result.messages.length);
|
1035
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1036
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
|
1037
|
+
},
|
1038
|
+
|
1039
|
+
"Using only hsl() background-color should result in a warning": function(){
|
1040
|
+
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
1041
|
+
Assert.areEqual(1, result.messages.length);
|
1042
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1043
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSL background-color.", result.messages[0].message);
|
1044
|
+
},
|
1045
|
+
|
1046
|
+
"Using only hsla() background-color should result in a warning": function(){
|
1047
|
+
var result = CSSLint.verify(".hsla { background-color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
1048
|
+
Assert.areEqual(1, result.messages.length);
|
1049
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1050
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
|
1051
|
+
},
|
1052
|
+
|
1053
|
+
"Using rgba() with a fallback background-color should not result in a warning": function(){
|
1054
|
+
var result = CSSLint.verify(".rgba { background-color: #fff; background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
|
1055
|
+
Assert.areEqual(0, result.messages.length);
|
1056
|
+
},
|
1057
|
+
|
1058
|
+
"Using hsl() with a fallback background-color should not result in a warning": function(){
|
1059
|
+
var result = CSSLint.verify(".hsl { background-color: #fff; background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
|
1060
|
+
Assert.areEqual(0, result.messages.length);
|
1061
|
+
},
|
1062
|
+
|
1063
|
+
"Using hsla() with a fallback background-color should not result in a warning": function(){
|
1064
|
+
var result = CSSLint.verify(".hsla { background-color: #fff; background-color: hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
|
1065
|
+
Assert.areEqual(0, result.messages.length);
|
1066
|
+
},
|
1067
|
+
|
1068
|
+
"Using rgba() with fallback background-color afterwards should result in a warning": function(){
|
1069
|
+
var result = CSSLint.verify(".rgba { background-color: rgba(0, 0, 0, 0.5); background-color: #fff; }", { "fallback-colors": 1 });
|
1070
|
+
Assert.areEqual(1, result.messages.length);
|
1071
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1072
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
|
1073
|
+
},
|
1074
|
+
|
1075
|
+
"Using hsl() with fallback background-color afterwards should result in a warning": function(){
|
1076
|
+
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); background-color: #fff; }", { "fallback-colors": 1 });
|
1077
|
+
Assert.areEqual(1, result.messages.length);
|
1078
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1079
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSL background-color.", result.messages[0].message);
|
1080
|
+
},
|
1081
|
+
|
1082
|
+
"Using hsla() with fallback background-color afterwards should result in a warning": function(){
|
1083
|
+
var result = CSSLint.verify(".hsla { background-color: hsla(0, 0%, 0%, 0.5); background-color: #fff; }", { "fallback-colors": 1 });
|
1084
|
+
Assert.areEqual(1, result.messages.length);
|
1085
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1086
|
+
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
|
1090
|
+
|
1091
|
+
|
1092
|
+
|
1093
|
+
|
1094
|
+
}));
|
1095
|
+
|
1096
|
+
})();
|
1097
|
+
|
1098
|
+
(function(){
|
1099
|
+
|
1100
|
+
/*global YUITest, CSSLint*/
|
1101
|
+
var Assert = YUITest.Assert;
|
1102
|
+
|
1103
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1104
|
+
|
1105
|
+
name: "Floats Rule Errors",
|
1106
|
+
|
1107
|
+
"10 floats should result in a warning": function(){
|
1108
|
+
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 });
|
1109
|
+
Assert.areEqual(1, result.messages.length);
|
1110
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1111
|
+
Assert.areEqual("Too many floats (10), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
|
1112
|
+
},
|
1113
|
+
|
1114
|
+
"9 floats should not result in a warning": function(){
|
1115
|
+
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 });
|
1116
|
+
Assert.areEqual(0, result.messages.length);
|
1117
|
+
},
|
1118
|
+
|
1119
|
+
"11 floats should result in a warning": function(){
|
1120
|
+
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 });
|
1121
|
+
Assert.areEqual(1, result.messages.length);
|
1122
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1123
|
+
Assert.areEqual("Too many floats (11), you're probably using them for layout. Consider using a grid system instead.", result.messages[0].message);
|
1124
|
+
},
|
1125
|
+
|
1126
|
+
"float: none should not count and therefore should not result in a warning": function(){
|
1127
|
+
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 });
|
1128
|
+
Assert.areEqual(0, result.messages.length);
|
1129
|
+
}
|
1130
|
+
}));
|
1131
|
+
|
1132
|
+
})();
|
1133
|
+
|
1134
|
+
(function(){
|
1135
|
+
|
1136
|
+
/*global YUITest, CSSLint*/
|
1137
|
+
var Assert = YUITest.Assert;
|
1138
|
+
|
1139
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1140
|
+
|
1141
|
+
name: "font-faces Rule Errors",
|
1142
|
+
|
1143
|
+
"5 font-faces should result in a warning": function(){
|
1144
|
+
var result = CSSLint.verify("@font-face{ } @font-face{ } @font-face{ } @font-face{ } @font-face{ }", { "font-faces": 1 });
|
1145
|
+
Assert.areEqual(0, result.messages.length);
|
1146
|
+
},
|
1147
|
+
|
1148
|
+
"4 font-faces should not result in a warning": function(){
|
1149
|
+
var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
|
1150
|
+
Assert.areEqual(0, result.messages.length);
|
1151
|
+
},
|
1152
|
+
|
1153
|
+
"6 font-faces should result in a warning": function(){
|
1154
|
+
var result = CSSLint.verify("@font-face{} @font-face{} @font-face{} @font-face{} @font-face{} @font-face{}", { "font-faces": 1 });
|
1155
|
+
Assert.areEqual(1, result.messages.length);
|
1156
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1157
|
+
Assert.areEqual("Too many @font-face declarations (6).", result.messages[0].message);
|
1158
|
+
}
|
1159
|
+
}));
|
1160
|
+
|
1161
|
+
})();
|
1162
|
+
|
1163
|
+
(function(){
|
1164
|
+
|
1165
|
+
/*global YUITest, CSSLint*/
|
1166
|
+
var Assert = YUITest.Assert;
|
1167
|
+
|
1168
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1169
|
+
|
1170
|
+
name: "font-size Rule Errors",
|
1171
|
+
|
1172
|
+
"10 font-sizes should result in a warning": function(){
|
1173
|
+
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 });
|
1174
|
+
Assert.areEqual(1, result.messages.length);
|
1175
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1176
|
+
Assert.areEqual("Too many font-size declarations (10), abstraction needed.", result.messages[0].message);
|
1177
|
+
},
|
1178
|
+
|
1179
|
+
"9 font-sizes should not result in a warning": function(){
|
1180
|
+
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 });
|
1181
|
+
Assert.areEqual(0, result.messages.length);
|
1182
|
+
},
|
1183
|
+
|
1184
|
+
"11 font-sizes should result in a warning": function(){
|
1185
|
+
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 });
|
1186
|
+
Assert.areEqual(1, result.messages.length);
|
1187
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1188
|
+
Assert.areEqual("Too many font-size declarations (11), abstraction needed.", result.messages[0].message);
|
1189
|
+
}
|
1190
|
+
}));
|
1191
|
+
|
1192
|
+
})();
|
1193
|
+
|
1194
|
+
(function(){
|
1195
|
+
|
1196
|
+
/*global YUITest, CSSLint*/
|
1197
|
+
var Assert = YUITest.Assert;
|
1198
|
+
|
1199
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1200
|
+
|
1201
|
+
/*
|
1202
|
+
background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
|
1203
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
|
1204
|
+
background: -webkit-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
1205
|
+
background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
1206
|
+
background: -ms-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
|
1207
|
+
|
1208
|
+
*/
|
1209
|
+
|
1210
|
+
name: "Gradients Rule Errors",
|
1211
|
+
|
1212
|
+
"Only using Mozilla gradients should result in a warning": function(){
|
1213
|
+
var result = CSSLint.verify(".foo { background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
1214
|
+
Assert.areEqual(1, result.messages.length);
|
1215
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1216
|
+
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);
|
1217
|
+
},
|
1218
|
+
|
1219
|
+
"Only using Opera gradients should result in a warning": function(){
|
1220
|
+
var result = CSSLint.verify(".foo { background: -o-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
1221
|
+
Assert.areEqual(1, result.messages.length);
|
1222
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1223
|
+
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);
|
1224
|
+
},
|
1225
|
+
|
1226
|
+
"Only using IE gradients should result in a warning": function(){
|
1227
|
+
var result = CSSLint.verify(".foo { background: -ms-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
1228
|
+
Assert.areEqual(1, result.messages.length);
|
1229
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1230
|
+
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);
|
1231
|
+
},
|
1232
|
+
|
1233
|
+
"Only using WebKit gradients should result in a warning": function(){
|
1234
|
+
var result = CSSLint.verify(".foo { background: -webkit-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
|
1235
|
+
Assert.areEqual(1, result.messages.length);
|
1236
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1237
|
+
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);
|
1238
|
+
},
|
1239
|
+
|
1240
|
+
"Only using old WebKit gradients should result in a warning": function(){
|
1241
|
+
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 });
|
1242
|
+
Assert.areEqual(1, result.messages.length);
|
1243
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1244
|
+
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);
|
1245
|
+
},
|
1246
|
+
|
1247
|
+
"Using all vendor-prefixed gradients should not result in a warning": function(){
|
1248
|
+
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 });
|
1249
|
+
Assert.areEqual(0, result.messages.length);
|
1250
|
+
}
|
1251
|
+
}));
|
1252
|
+
|
1253
|
+
})();
|
1254
|
+
|
1255
|
+
(function(){
|
1256
|
+
|
1257
|
+
/*global YUITest, CSSLint*/
|
1258
|
+
var Assert = YUITest.Assert;
|
1259
|
+
|
1260
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1261
|
+
|
1262
|
+
name: "IDs Rule Errors",
|
1263
|
+
|
1264
|
+
"Using an ID should result in one warning": function(){
|
1265
|
+
var result = CSSLint.verify("#foo { float: left;}", { ids: 1 });
|
1266
|
+
Assert.areEqual(1, result.messages.length);
|
1267
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1268
|
+
Assert.areEqual("Don't use IDs in selectors.", result.messages[0].message);
|
1269
|
+
},
|
1270
|
+
|
1271
|
+
"Using multiple IDs should result in one warning": function(){
|
1272
|
+
var result = CSSLint.verify("#foo #bar { float: left;}", { ids: 1 });
|
1273
|
+
Assert.areEqual(1, result.messages.length);
|
1274
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1275
|
+
Assert.areEqual("2 IDs in the selector, really?", result.messages[0].message);
|
1276
|
+
}
|
1277
|
+
}));
|
1278
|
+
|
1279
|
+
})();
|
1280
|
+
|
1281
|
+
(function(){
|
1282
|
+
|
1283
|
+
/*global YUITest, CSSLint*/
|
1284
|
+
var Assert = YUITest.Assert;
|
1285
|
+
|
1286
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1287
|
+
|
1288
|
+
name: "Import Rule Errors",
|
1289
|
+
|
1290
|
+
"Using @import should result in a warning": function(){
|
1291
|
+
var result = CSSLint.verify("@import url('foo.css');", { "import": 1 });
|
1292
|
+
Assert.areEqual(1, result.messages.length);
|
1293
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1294
|
+
Assert.areEqual("@import prevents parallel downloads, use <link> instead.", result.messages[0].message);
|
1295
|
+
}
|
1296
|
+
}));
|
1297
|
+
|
1298
|
+
})();
|
1299
|
+
|
1300
|
+
(function(){
|
1301
|
+
|
1302
|
+
/*global YUITest, CSSLint*/
|
1303
|
+
var Assert = YUITest.Assert;
|
1304
|
+
|
1305
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1306
|
+
|
1307
|
+
name: "!important; Errors",
|
1308
|
+
|
1309
|
+
"!important declarations should result in a warning": function(){
|
1310
|
+
var result = CSSLint.verify("h1 { color:#fff !important; }", { "important": 1 });
|
1311
|
+
Assert.areEqual(1, result.messages.length);
|
1312
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1313
|
+
Assert.areEqual("Use of !important", result.messages[0].message);
|
1314
|
+
},
|
1315
|
+
|
1316
|
+
"Using !important at least 10 times should result in an error": function(){
|
1317
|
+
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; }";
|
1318
|
+
var result = CSSLint.verify(css, { "important": 1 });
|
1319
|
+
Assert.areEqual(11, result.messages.length);
|
1320
|
+
Assert.areEqual("warning", result.messages[10].type);
|
1321
|
+
Assert.areEqual("Too many !important declarations (10), try to use less than 10 to avoid specificity issues.", result.messages[10].message);
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
}));
|
1325
|
+
|
1326
|
+
})();
|
1327
|
+
|
1328
|
+
(function(){
|
1329
|
+
|
1330
|
+
/*global YUITest, CSSLint*/
|
1331
|
+
var Assert = YUITest.Assert;
|
1332
|
+
|
1333
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1334
|
+
|
1335
|
+
name: "Known Properties Errors",
|
1336
|
+
|
1337
|
+
"Using an unknown property should result in a warning": function(){
|
1338
|
+
var result = CSSLint.verify("h1 { foo: red;}", { "known-properties": 1 });
|
1339
|
+
Assert.areEqual(1, result.messages.length);
|
1340
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1341
|
+
Assert.areEqual("Unknown property 'foo'.", result.messages[0].message);
|
1342
|
+
},
|
1343
|
+
|
1344
|
+
"Using a known property should not result in a warning": function(){
|
1345
|
+
var result = CSSLint.verify("h1 { color: red;}", { "known-properties": 1 });
|
1346
|
+
Assert.areEqual(0, result.messages.length);
|
1347
|
+
},
|
1348
|
+
|
1349
|
+
"Using a known property with the star hack should not result in a warning": function(){
|
1350
|
+
var result = CSSLint.verify("h1 { *color: red;}", { "known-properties": 1 });
|
1351
|
+
Assert.areEqual(0, result.messages.length);
|
1352
|
+
},
|
1353
|
+
|
1354
|
+
"Using a known property with the underscore hack should not result in a warning": function(){
|
1355
|
+
var result = CSSLint.verify("h1 { _color: red;}", { "known-properties": 1 });
|
1356
|
+
Assert.areEqual(0, result.messages.length);
|
1357
|
+
},
|
1358
|
+
|
1359
|
+
"Using a vendor-prefix property should not result in a warning": function(){
|
1360
|
+
var result = CSSLint.verify("h2 { -moz-border-radius: 5px; }", { "known-properties": 1 });
|
1361
|
+
Assert.areEqual(0, result.messages.length);
|
1362
|
+
},
|
1363
|
+
|
1364
|
+
"Using src in @font-face should not result in a warning": function(){
|
1365
|
+
var result = CSSLint.verify("@font-face { src: url(foo.otf); }", { "known-properties": 1 });
|
1366
|
+
Assert.areEqual(0, result.messages.length);
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
}));
|
1370
|
+
|
1371
|
+
})();
|
1372
|
+
|
1373
|
+
(function(){
|
1374
|
+
|
1375
|
+
/*global YUITest, CSSLint*/
|
1376
|
+
var Assert = YUITest.Assert;
|
1377
|
+
|
1378
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1379
|
+
|
1380
|
+
name: "Outline:none Errors",
|
1381
|
+
|
1382
|
+
"Using outline: none should result in a warning": function(){
|
1383
|
+
var result = CSSLint.verify(".foo { outline: none; }", { "outline-none": 1 });
|
1384
|
+
Assert.areEqual(1, result.messages.length);
|
1385
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1386
|
+
Assert.areEqual("Outlines should only be modified using :focus.", result.messages[0].message);
|
1387
|
+
},
|
1388
|
+
|
1389
|
+
"Using outline: 0 should result in a warning": function(){
|
1390
|
+
var result = CSSLint.verify(".foo { outline: 0; }", { "outline-none": 1 });
|
1391
|
+
Assert.areEqual(1, result.messages.length);
|
1392
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1393
|
+
Assert.areEqual("Outlines should only be modified using :focus.", result.messages[0].message);
|
1394
|
+
},
|
1395
|
+
|
1396
|
+
"Using outline: none alone with :focus should result in a warning": function(){
|
1397
|
+
var result = CSSLint.verify(".foo:focus { outline: none; }", { "outline-none": 1 });
|
1398
|
+
Assert.areEqual(1, result.messages.length);
|
1399
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1400
|
+
Assert.areEqual("Outlines shouldn't be hidden unless other visual changes are made.", result.messages[0].message);
|
1401
|
+
},
|
1402
|
+
|
1403
|
+
"Using outline: 0 alone with :focus should result in a warning": function(){
|
1404
|
+
var result = CSSLint.verify(".foo:focus { outline: 0; }", { "outline-none": 1 });
|
1405
|
+
Assert.areEqual(1, result.messages.length);
|
1406
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1407
|
+
Assert.areEqual("Outlines shouldn't be hidden unless other visual changes are made.", result.messages[0].message);
|
1408
|
+
},
|
1409
|
+
|
1410
|
+
"Using outline: none with :focus and another property should not result in a warning": function(){
|
1411
|
+
var result = CSSLint.verify(".foo:focus { outline: none; border: 1px solid black; }", { "outline-none": 1 });
|
1412
|
+
Assert.areEqual(0, result.messages.length);
|
1413
|
+
},
|
1414
|
+
|
1415
|
+
"Using outline: 0 with :focus and another property should not result in a warning": function(){
|
1416
|
+
var result = CSSLint.verify(".foo:focus { outline: 0; border: 1px solid black;}", { "outline-none": 1 });
|
1417
|
+
Assert.areEqual(0, result.messages.length);
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
}));
|
1421
|
+
|
1422
|
+
})();
|
1423
|
+
|
1424
|
+
(function(){
|
1425
|
+
|
1426
|
+
/*global YUITest, CSSLint*/
|
1427
|
+
var Assert = YUITest.Assert;
|
1428
|
+
|
1429
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1430
|
+
|
1431
|
+
name: "Overqualified Elements Errors",
|
1432
|
+
|
1433
|
+
"Using an ID with an element should result in one warning": function(){
|
1434
|
+
var result = CSSLint.verify("li#foo { float: left;}", { "overqualified-elements": 1 });
|
1435
|
+
Assert.areEqual(1, result.messages.length);
|
1436
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1437
|
+
Assert.areEqual("Element (li#foo) is overqualified, just use #foo without element name.", result.messages[0].message);
|
1438
|
+
},
|
1439
|
+
|
1440
|
+
"Using a class without an element should not result in a warning": function(){
|
1441
|
+
var result = CSSLint.verify(".foo { float: left;}", { "overqualified-elements": 1 });
|
1442
|
+
Assert.areEqual(0, result.messages.length);
|
1443
|
+
},
|
1444
|
+
|
1445
|
+
"Using a class with an element should result in one warning": function(){
|
1446
|
+
var result = CSSLint.verify("li.foo { float: left;}", { "overqualified-elements": 1 });
|
1447
|
+
Assert.areEqual(1, result.messages.length);
|
1448
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1449
|
+
Assert.areEqual("Element (li.foo) is overqualified, just use .foo without element name.", result.messages[0].message);
|
1450
|
+
},
|
1451
|
+
|
1452
|
+
"Using a class with two different elements should not result in a warning": function(){
|
1453
|
+
var result = CSSLint.verify("li.foo { float: left;} p.foo { float: right; }", { "overqualified-elements": 1 });
|
1454
|
+
Assert.areEqual(0, result.messages.length);
|
1455
|
+
},
|
1456
|
+
|
1457
|
+
"Using a class with an element and without should not result in a warning": function(){
|
1458
|
+
var result = CSSLint.verify("li.foo { float: left;} .foo { float: right; }", { "overqualified-elements": 1 });
|
1459
|
+
Assert.areEqual(0, result.messages.length);
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
}));
|
1463
|
+
|
1464
|
+
})();
|
1465
|
+
|
1466
|
+
(function(){
|
1467
|
+
|
1468
|
+
/*global YUITest, CSSLint*/
|
1469
|
+
var Assert = YUITest.Assert;
|
1470
|
+
|
1471
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1472
|
+
|
1473
|
+
name: "Qualified Headings Errors",
|
1474
|
+
|
1475
|
+
"Using a heading as a descendant should result in one warning": function(){
|
1476
|
+
var result = CSSLint.verify("li h3{ float: left;}", { "qualified-headings": 1 });
|
1477
|
+
Assert.areEqual(1, result.messages.length);
|
1478
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1479
|
+
Assert.areEqual("Heading (h3) should not be qualified.", result.messages[0].message);
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
}));
|
1483
|
+
|
1484
|
+
})();
|
1485
|
+
|
1486
|
+
(function(){
|
1487
|
+
|
1488
|
+
/*global YUITest, CSSLint*/
|
1489
|
+
var Assert = YUITest.Assert;
|
1490
|
+
|
1491
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1492
|
+
|
1493
|
+
name: "Regex Selectors Errors",
|
1494
|
+
|
1495
|
+
"Using |= in an attribute selector should result in one warning": function(){
|
1496
|
+
var result = CSSLint.verify("li[class|=foo]{ color: red; }", { "regex-selectors": 1 });
|
1497
|
+
Assert.areEqual(1, result.messages.length);
|
1498
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1499
|
+
Assert.areEqual("Attribute selectors with |= are slow!", result.messages[0].message);
|
1500
|
+
},
|
1501
|
+
|
1502
|
+
"Using *= in an attribute selector should result in one warning": function(){
|
1503
|
+
var result = CSSLint.verify("li[class*=foo]{ color: red; }", { "regex-selectors": 1 });
|
1504
|
+
Assert.areEqual(1, result.messages.length);
|
1505
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1506
|
+
Assert.areEqual("Attribute selectors with *= are slow!", result.messages[0].message);
|
1507
|
+
},
|
1508
|
+
|
1509
|
+
"Using $= in an attribute selector should result in one warning": function(){
|
1510
|
+
var result = CSSLint.verify("li[class$=foo]{ color: red; }", { "regex-selectors": 1 });
|
1511
|
+
Assert.areEqual(1, result.messages.length);
|
1512
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1513
|
+
Assert.areEqual("Attribute selectors with $= are slow!", result.messages[0].message);
|
1514
|
+
},
|
1515
|
+
|
1516
|
+
"Using ~= in an attribute selector should result in one warning": function(){
|
1517
|
+
var result = CSSLint.verify("li[class~=foo]{ color: red; }", { "regex-selectors": 1 });
|
1518
|
+
Assert.areEqual(1, result.messages.length);
|
1519
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1520
|
+
Assert.areEqual("Attribute selectors with ~= are slow!", result.messages[0].message);
|
1521
|
+
},
|
1522
|
+
|
1523
|
+
"Using ^= in an attribute selector should result in one warning": function(){
|
1524
|
+
var result = CSSLint.verify("li[class^=foo]{ color: red; }", { "regex-selectors": 1 });
|
1525
|
+
Assert.areEqual(1, result.messages.length);
|
1526
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1527
|
+
Assert.areEqual("Attribute selectors with ^= are slow!", result.messages[0].message);
|
1528
|
+
},
|
1529
|
+
|
1530
|
+
"Using = in an attribute selector should not result in a warning": function(){
|
1531
|
+
var result = CSSLint.verify("li[class=foo]{ color: red; }", { "regex-selectors": 1 });
|
1532
|
+
Assert.areEqual(0, result.messages.length);
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
}));
|
1536
|
+
|
1537
|
+
})();
|
1538
|
+
|
1539
|
+
(function(){
|
1540
|
+
|
1541
|
+
/*global YUITest, CSSLint*/
|
1542
|
+
var Assert = YUITest.Assert;
|
1543
|
+
|
1544
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1545
|
+
|
1546
|
+
name: "Shorthand Rule Errors",
|
1547
|
+
|
1548
|
+
"All padding properties should result in a warning": function(){
|
1549
|
+
var result = CSSLint.verify(".foo{padding-top: 0px; padding-left: 3px; padding-right: 25px; padding-bottom: 10px;}", {"shorthand": 1 });
|
1550
|
+
Assert.areEqual(1, result.messages.length);
|
1551
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1552
|
+
Assert.areEqual("The properties padding-top, padding-bottom, padding-left, padding-right can be replaced by padding.", result.messages[0].message);
|
1553
|
+
},
|
1554
|
+
|
1555
|
+
"All margin properties should result in a warning": function(){
|
1556
|
+
var result = CSSLint.verify(".foo{margin-top: 0px; margin-left: 3px; margin-right: 25px; margin-bottom: 10px;}", {"shorthand": 1 });
|
1557
|
+
Assert.areEqual(1, result.messages.length);
|
1558
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1559
|
+
Assert.areEqual("The properties margin-top, margin-bottom, margin-left, margin-right can be replaced by margin.", result.messages[0].message);
|
1560
|
+
},
|
1561
|
+
|
1562
|
+
"padding-left should not result in a warning": function(){
|
1563
|
+
var result = CSSLint.verify(".foo{ padding-left: 8px;} ", {"shorthand": 1 });
|
1564
|
+
Assert.areEqual(0, result.messages.length);
|
1565
|
+
},
|
1566
|
+
|
1567
|
+
"margin-top should not result in a warning": function(){
|
1568
|
+
var result = CSSLint.verify(".foo{ margin-top: 8px;} ", {"shorthand": 1 });
|
1569
|
+
Assert.areEqual(0, result.messages.length);
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
}));
|
1573
|
+
|
1574
|
+
})();
|
1575
|
+
|
1576
|
+
(function(){
|
1577
|
+
|
1578
|
+
/*global YUITest, CSSLint*/
|
1579
|
+
var Assert = YUITest.Assert;
|
1580
|
+
|
1581
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1582
|
+
|
1583
|
+
name: "star-property-hack Rule Errors",
|
1584
|
+
|
1585
|
+
"a property with a star prefix should result in a warning": function(){
|
1586
|
+
var result = CSSLint.verify(".foo{*width: 100px;}", {"star-property-hack": 1 });
|
1587
|
+
Assert.areEqual(1, result.messages.length);
|
1588
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1589
|
+
Assert.areEqual("Property with star prefix found.", result.messages[0].message);
|
1590
|
+
},
|
1591
|
+
|
1592
|
+
"a property without a star prefix should not result in a warning": function(){
|
1593
|
+
var result = CSSLint.verify(".foo{width: 100px;}", {"star-property-hack": 1 });
|
1594
|
+
Assert.areEqual(0, result.messages.length);
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
}));
|
1598
|
+
|
1599
|
+
})();
|
1600
|
+
|
1601
|
+
(function(){
|
1602
|
+
|
1603
|
+
/*global YUITest, CSSLint*/
|
1604
|
+
var Assert = YUITest.Assert;
|
1605
|
+
|
1606
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1607
|
+
|
1608
|
+
name: "text-indent Rule Errors",
|
1609
|
+
|
1610
|
+
"-100px text-indent should result in a warning": function(){
|
1611
|
+
var result = CSSLint.verify(".foo{text-indent: -100px;}", {"text-indent": 1 });
|
1612
|
+
Assert.areEqual(1, result.messages.length);
|
1613
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1614
|
+
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);
|
1615
|
+
},
|
1616
|
+
|
1617
|
+
"-99px text-indent should not result in a warning": function(){
|
1618
|
+
var result = CSSLint.verify(".foo{text-indent: -99px;} ", {"text-indent": 1 });
|
1619
|
+
Assert.areEqual(0, result.messages.length);
|
1620
|
+
},
|
1621
|
+
|
1622
|
+
"-99em text-indent should not result in a warning": function(){
|
1623
|
+
var result = CSSLint.verify(".foo{text-indent: -99em;} ", {"text-indent": 1 });
|
1624
|
+
Assert.areEqual(0, result.messages.length);
|
1625
|
+
},
|
1626
|
+
|
1627
|
+
"-100px text-indent with LTR should not result in a warning": function(){
|
1628
|
+
var result = CSSLint.verify(".foo{text-indent: -100px; direction: ltr; }", {"text-indent": 1 });
|
1629
|
+
Assert.areEqual(0, result.messages.length);
|
1630
|
+
result = CSSLint.verify(".foo{direction: ltr; text-indent: -100px; }", {"text-indent": 1 });
|
1631
|
+
Assert.areEqual(0, result.messages.length);
|
1632
|
+
},
|
1633
|
+
|
1634
|
+
"-100em text-indent with RTL should result in a warning": function(){
|
1635
|
+
var result = CSSLint.verify(".foo{text-indent: -100em; direction: rtl; }", {"text-indent": 1 });
|
1636
|
+
Assert.areEqual(1, result.messages.length);
|
1637
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1638
|
+
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);
|
1639
|
+
},
|
1640
|
+
|
1641
|
+
"5px text-indent should not result in a warning": function(){
|
1642
|
+
var result = CSSLint.verify(".foo{text-indent: 5px;}", {"text-indent": 1 });
|
1643
|
+
Assert.areEqual(0, result.messages.length);
|
1644
|
+
},
|
1645
|
+
|
1646
|
+
"This should cause a warning, not an error": function(){
|
1647
|
+
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 });
|
1648
|
+
Assert.areEqual(1, result.messages.length);
|
1649
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1650
|
+
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);
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
}));
|
1654
|
+
|
1655
|
+
})();
|
1656
|
+
|
1657
|
+
(function(){
|
1658
|
+
|
1659
|
+
/*global YUITest, CSSLint*/
|
1660
|
+
var Assert = YUITest.Assert;
|
1661
|
+
|
1662
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1663
|
+
|
1664
|
+
name: "underscore-property-hack Rule Errors",
|
1665
|
+
|
1666
|
+
"a property with an underscore prefix should result in a warning": function(){
|
1667
|
+
var result = CSSLint.verify(".foo{_width: 100px;}", {"underscore-property-hack": 1 });
|
1668
|
+
Assert.areEqual(1, result.messages.length);
|
1669
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1670
|
+
Assert.areEqual("Property with underscore prefix found.", result.messages[0].message);
|
1671
|
+
},
|
1672
|
+
|
1673
|
+
"a property without an underscore prefix should not result in a warning": function(){
|
1674
|
+
var result = CSSLint.verify(".foo{width: 100px;}", {"underscore-property-hack": 1 });
|
1675
|
+
Assert.areEqual(0, result.messages.length);
|
1676
|
+
}
|
1677
|
+
|
1678
|
+
}));
|
1679
|
+
|
1680
|
+
})();
|
1681
|
+
|
1682
|
+
(function(){
|
1683
|
+
|
1684
|
+
/*global YUITest, CSSLint*/
|
1685
|
+
var Assert = YUITest.Assert;
|
1686
|
+
|
1687
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1688
|
+
|
1689
|
+
name: "Unique Headings Errors",
|
1690
|
+
|
1691
|
+
"Defining two rules for h1 should result in two warnings": function(){
|
1692
|
+
var result = CSSLint.verify("h1 { color: red;} h1 {color: blue;}", { "unique-headings": 1 });
|
1693
|
+
Assert.areEqual(2, result.messages.length);
|
1694
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1695
|
+
Assert.areEqual("Heading (h1) has already been defined.", result.messages[0].message);
|
1696
|
+
Assert.areEqual("warning", result.messages[1].type);
|
1697
|
+
Assert.areEqual("You have 2 h1s defined in this stylesheet.", result.messages[1].message);
|
1698
|
+
},
|
1699
|
+
|
1700
|
+
"Defining two rules for h1 and h2 should result in one warning": function(){
|
1701
|
+
var result = CSSLint.verify("h1 { color: red;} h1 {color: blue;} h2 { color: red;} h2 {color: blue;}", { "unique-headings": 1 });
|
1702
|
+
Assert.areEqual(3, result.messages.length);
|
1703
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1704
|
+
Assert.areEqual("Heading (h1) has already been defined.", result.messages[0].message);
|
1705
|
+
Assert.areEqual("warning", result.messages[1].type);
|
1706
|
+
Assert.areEqual("Heading (h2) has already been defined.", result.messages[1].message);
|
1707
|
+
Assert.areEqual("warning", result.messages[2].type);
|
1708
|
+
Assert.areEqual("You have 2 h1s, 2 h2s defined in this stylesheet.", result.messages[2].message);
|
1709
|
+
},
|
1710
|
+
|
1711
|
+
"Defining one rule for h1 should not result in a warning": function(){
|
1712
|
+
var result = CSSLint.verify("h1 { color: red;}", { "unique-headings": 1 });
|
1713
|
+
Assert.areEqual(0, result.messages.length);
|
1714
|
+
},
|
1715
|
+
|
1716
|
+
"Defining a rule for h1 and h1:hover should not result in a warning": function(){
|
1717
|
+
var result = CSSLint.verify("h1 { color: red;} h1:hover { color: blue; }", { "unique-headings": 1 });
|
1718
|
+
Assert.areEqual(0, result.messages.length);
|
1719
|
+
},
|
1720
|
+
|
1721
|
+
"Defining multiple rules that contain h1 should not result in a warning": function(){
|
1722
|
+
var result = CSSLint.verify("h2 a, h2 a:active, h2 a:hover, h2 a:visited, h2 a:link { color: red;}", { "unique-headings": 1 });
|
1723
|
+
Assert.areEqual(0, result.messages.length);
|
1724
|
+
}
|
1725
|
+
|
1726
|
+
}));
|
1727
|
+
|
1728
|
+
})();
|
1729
|
+
|
1730
|
+
(function(){
|
1731
|
+
|
1732
|
+
/*global YUITest, CSSLint*/
|
1733
|
+
var Assert = YUITest.Assert;
|
1734
|
+
|
1735
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1736
|
+
|
1737
|
+
name: "Universal Selector Errors",
|
1738
|
+
|
1739
|
+
"Using a universal selector alone should result in a warning": function(){
|
1740
|
+
var result = CSSLint.verify("* { font-size: 10px; }", {"universal-selector": 1 });
|
1741
|
+
Assert.areEqual(1, result.messages.length);
|
1742
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1743
|
+
Assert.areEqual("The universal selector (*) is known to be slow.", result.messages[0].message);
|
1744
|
+
},
|
1745
|
+
|
1746
|
+
"Using a universal selector as the right-most part should result in a warning": function(){
|
1747
|
+
var result = CSSLint.verify("p div * { font-size: 10px; }", {"universal-selector": 1 });
|
1748
|
+
Assert.areEqual(1, result.messages.length);
|
1749
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1750
|
+
Assert.areEqual("The universal selector (*) is known to be slow.", result.messages[0].message);
|
1751
|
+
},
|
1752
|
+
|
1753
|
+
"Using a universal selector in the middle should not result in a warning": function(){
|
1754
|
+
var result = CSSLint.verify("* .foo { font-size: 10px; } ", {"universal-selector": 1 });
|
1755
|
+
Assert.areEqual(0, result.messages.length);
|
1756
|
+
}
|
1757
|
+
|
1758
|
+
}));
|
1759
|
+
|
1760
|
+
})();
|
1761
|
+
|
1762
|
+
(function(){
|
1763
|
+
|
1764
|
+
/*global YUITest, CSSLint*/
|
1765
|
+
var Assert = YUITest.Assert;
|
1766
|
+
|
1767
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1768
|
+
|
1769
|
+
name: "Unqualified Attributes Errors",
|
1770
|
+
|
1771
|
+
"Using an unqualified attribute selector alone should result in a warning": function(){
|
1772
|
+
var result = CSSLint.verify("[type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
|
1773
|
+
Assert.areEqual(1, result.messages.length);
|
1774
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1775
|
+
Assert.areEqual("Unqualified attribute selectors are known to be slow.", result.messages[0].message);
|
1776
|
+
},
|
1777
|
+
|
1778
|
+
"Using an unqualified attribute selector as the right-most part should result in a warning": function(){
|
1779
|
+
var result = CSSLint.verify("p div [type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
|
1780
|
+
Assert.areEqual(1, result.messages.length);
|
1781
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1782
|
+
Assert.areEqual("Unqualified attribute selectors are known to be slow.", result.messages[0].message);
|
1783
|
+
},
|
1784
|
+
|
1785
|
+
"Using an unqualified attribute selector in the middle should not result in a warning": function(){
|
1786
|
+
var result = CSSLint.verify("[type=text] .foo { font-size: 10px; } ", {"unqualified-attributes": 1 });
|
1787
|
+
Assert.areEqual(0, result.messages.length);
|
1788
|
+
},
|
1789
|
+
|
1790
|
+
"Using a qualified attribute selector should not result in a warning": function(){
|
1791
|
+
var result = CSSLint.verify("input[type=text] { font-size: 10px; } ", {"unqualified-attributes": 1 });
|
1792
|
+
Assert.areEqual(0, result.messages.length);
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
|
1796
|
+
}));
|
1797
|
+
|
1798
|
+
})();
|
1799
|
+
|
1800
|
+
(function(){
|
1801
|
+
|
1802
|
+
/*global YUITest, CSSLint*/
|
1803
|
+
var Assert = YUITest.Assert;
|
1804
|
+
|
1805
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1806
|
+
|
1807
|
+
name: "Vendor Prefix Errors",
|
1808
|
+
|
1809
|
+
"Using -moz-border-radius without border-radius should result in one warning": function(){
|
1810
|
+
var result = CSSLint.verify("h1 {\n -moz-border-radius: 5px; \n}", { "vendor-prefix": 1 });
|
1811
|
+
Assert.areEqual(1, result.messages.length);
|
1812
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1813
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-moz-border-radius'.", result.messages[0].message);
|
1814
|
+
Assert.areEqual(2, result.messages[0].line);
|
1815
|
+
Assert.areEqual(5, result.messages[0].col);
|
1816
|
+
},
|
1817
|
+
|
1818
|
+
"Using -webkit-border-radius without border-radius should result in one warning": function(){
|
1819
|
+
var result = CSSLint.verify("h1 { -webkit-border-radius: 5px; }", { "vendor-prefix": 1 });
|
1820
|
+
Assert.areEqual(1, result.messages.length);
|
1821
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1822
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-webkit-border-radius'.", result.messages[0].message);
|
1823
|
+
},
|
1824
|
+
|
1825
|
+
"Using -o-border-radius without border-radius should result in one warning": function(){
|
1826
|
+
var result = CSSLint.verify("h1 { -o-border-radius: 5px; }", { "vendor-prefix": 1 });
|
1827
|
+
Assert.areEqual(1, result.messages.length);
|
1828
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1829
|
+
Assert.areEqual("Missing standard property 'border-radius' to go along with '-o-border-radius'.", result.messages[0].message);
|
1830
|
+
},
|
1831
|
+
|
1832
|
+
"Using -moz-border-radius after border-radius should result in one warning": function(){
|
1833
|
+
var result = CSSLint.verify("h1 { \nborder-radius: 5px; \n -moz-border-radius: 5px; }", { "vendor-prefix": 1 });
|
1834
|
+
Assert.areEqual(1, result.messages.length);
|
1835
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1836
|
+
Assert.areEqual("Standard property 'border-radius' should come after vendor-prefixed property '-moz-border-radius'.", result.messages[0].message);
|
1837
|
+
Assert.areEqual(3, result.messages[0].line);
|
1838
|
+
Assert.areEqual(5, result.messages[0].col);
|
1839
|
+
|
1840
|
+
},
|
1841
|
+
|
1842
|
+
"Using -webkit-border-bottom-left-radius with border-bottom-left-radius should not result in a warning.": function(){
|
1843
|
+
var result = CSSLint.verify("h1 { -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }", { "vendor-prefix": 1 });
|
1844
|
+
Assert.areEqual(0, result.messages.length);
|
1845
|
+
},
|
1846
|
+
|
1847
|
+
"Using -moz-border-radius-bottomleft should result in a warning.": function(){
|
1848
|
+
var result = CSSLint.verify("h1 { -moz-border-radius-bottomleft: 5px; }", { "vendor-prefix": 1 });
|
1849
|
+
Assert.areEqual(1, result.messages.length);
|
1850
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1851
|
+
Assert.areEqual("Missing standard property 'border-bottom-left-radius' to go along with '-moz-border-radius-bottomleft'.", result.messages[0].message);
|
1852
|
+
},
|
1853
|
+
|
1854
|
+
"Using -moz-box-shadow should result in a warning.": function(){
|
1855
|
+
var result = CSSLint.verify("h1 { -moz-box-shadow: 5px; }", { "vendor-prefix": 1 });
|
1856
|
+
Assert.areEqual(1, result.messages.length);
|
1857
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1858
|
+
Assert.areEqual("Missing standard property 'box-shadow' to go along with '-moz-box-shadow'.", result.messages[0].message);
|
1859
|
+
},
|
1860
|
+
|
1861
|
+
"Using -moz-user-select should result in a warning.": function(){
|
1862
|
+
var result = CSSLint.verify("h1 { -moz-user-select:none; }", { "vendor-prefix": 1 });
|
1863
|
+
Assert.areEqual(1, result.messages.length);
|
1864
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1865
|
+
Assert.areEqual("Missing standard property 'user-select' to go along with '-moz-user-select'.", result.messages[0].message);
|
1866
|
+
},
|
1867
|
+
|
1868
|
+
"Using @font-face should not result in an error (#90)": function(){
|
1869
|
+
var result = CSSLint.verify("@font-face { src:url('../fonts/UniversBold.otf');font-family:Univers;advancedAntiAliasing: true;}", { "vendor-prefix": 1 });
|
1870
|
+
Assert.areEqual(0, result.messages.length);
|
1871
|
+
}
|
1872
|
+
|
1873
|
+
}));
|
1874
|
+
|
1875
|
+
})();
|
1876
|
+
|
1877
|
+
(function(){
|
1878
|
+
|
1879
|
+
/*global YUITest, CSSLint*/
|
1880
|
+
var Assert = YUITest.Assert;
|
1881
|
+
|
1882
|
+
YUITest.TestRunner.add(new YUITest.TestCase({
|
1883
|
+
|
1884
|
+
name: "Zero Units Errors",
|
1885
|
+
|
1886
|
+
"Using 0px should result in one warning": function(){
|
1887
|
+
var result = CSSLint.verify("h1 { left: 0px; }", { "zero-units": 1 });
|
1888
|
+
Assert.areEqual(1, result.messages.length);
|
1889
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1890
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
1891
|
+
},
|
1892
|
+
|
1893
|
+
"Using 0em should result in one warning": function(){
|
1894
|
+
var result = CSSLint.verify("h1 { left: 0em; }", { "zero-units": 1 });
|
1895
|
+
Assert.areEqual(1, result.messages.length);
|
1896
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1897
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
1898
|
+
},
|
1899
|
+
|
1900
|
+
"Using 0% should result in one warning": function(){
|
1901
|
+
var result = CSSLint.verify("h1 { left: 0%; }", { "zero-units": 1 });
|
1902
|
+
Assert.areEqual(1, result.messages.length);
|
1903
|
+
Assert.areEqual("warning", result.messages[0].type);
|
1904
|
+
Assert.areEqual("Values of 0 shouldn't have units specified.", result.messages[0].message);
|
1905
|
+
},
|
1906
|
+
|
1907
|
+
"Using 0 should not result in a warning": function(){
|
1908
|
+
var result = CSSLint.verify("h1 { left: 0; }", { "zero-units": 1 });
|
1909
|
+
Assert.areEqual(0, result.messages.length);
|
1910
|
+
},
|
1911
|
+
|
1912
|
+
"Using 0s for animation-duration should not result in a warning": function(){
|
1913
|
+
var result = CSSLint.verify("h1 { animation-duration: 0s; }", { "zero-units": 1 });
|
1914
|
+
Assert.areEqual(0, result.messages.length);
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
|
1918
|
+
}));
|
1919
|
+
|
1920
|
+
})();
|
1921
|
+
|