Skip to content

Commit fa406e8

Browse files
author
Merrifield, Jay
committed
adds all variations of border to the fallback-colors rule
1 parent c6d79d2 commit fa406e8

File tree

2 files changed

+80
-3
lines changed

2 files changed

+80
-3
lines changed

src/rules/fallback-colors.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ CSSLint.addRule({
1515
propertiesToCheck = {
1616
color: 1,
1717
background: 1,
18-
"background-color": 1
18+
"border-color": 1,
19+
border: 1,
20+
"border-top": 1,
21+
"border-right": 1,
22+
"border-bottom": 1,
23+
"border-left": 1,
24+
"background-color": 1
1925
},
2026
properties;
2127

tests/rules/fallback-colors.js

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,81 @@
150150
Assert.areEqual(1, result.messages.length);
151151
Assert.areEqual("warning", result.messages[0].type);
152152
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
153-
}
153+
},
154154

155+
// border color tests
155156

156-
157+
"Using only a named border should not result in a warning": function(){
158+
var result = CSSLint.verify(".hex { border: 1px solid red; }", { "fallback-colors": 1 });
159+
Assert.areEqual(0, result.messages.length);
160+
},
161+
162+
"Using only a hex border should not result in a warning": function(){
163+
var result = CSSLint.verify(".hex { border: 1px solid #fff; }", { "fallback-colors": 1 });
164+
Assert.areEqual(0, result.messages.length);
165+
},
166+
167+
"Using only rgb() border should not result in a warning": function(){
168+
var result = CSSLint.verify(".rgb { border: 1px solid rgb(0, 0, 0); }", { "fallback-colors": 1 });
169+
Assert.areEqual(0, result.messages.length);
170+
},
171+
172+
"Using only rgba() border should result in a warning": function(){
173+
var result = CSSLint.verify(".rgba { border: 1px solid rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
174+
Assert.areEqual(1, result.messages.length);
175+
Assert.areEqual("warning", result.messages[0].type);
176+
Assert.areEqual("Fallback border (hex or RGB) should precede RGBA border.", result.messages[0].message);
177+
},
178+
179+
"Using only hsl() border should result in a warning": function(){
180+
var result = CSSLint.verify(".hsl { border: 1px solid hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
181+
Assert.areEqual(1, result.messages.length);
182+
Assert.areEqual("warning", result.messages[0].type);
183+
Assert.areEqual("Fallback border (hex or RGB) should precede HSL border.", result.messages[0].message);
184+
},
185+
186+
"Using only hsla() border should result in a warning": function(){
187+
var result = CSSLint.verify(".hsla { border: 1px solid hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
188+
Assert.areEqual(1, result.messages.length);
189+
Assert.areEqual("warning", result.messages[0].type);
190+
Assert.areEqual("Fallback border (hex or RGB) should precede HSLA border.", result.messages[0].message);
191+
},
192+
193+
"Using rgba() with a fallback border should not result in a warning": function(){
194+
var result = CSSLint.verify(".rgba { border: 1px solid #fff; border: 1px solid rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
195+
Assert.areEqual(0, result.messages.length);
196+
},
197+
198+
"Using hsl() with a fallback border should not result in a warning": function(){
199+
var result = CSSLint.verify(".hsl { border: 1px solid #fff; border: 1px solid hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
200+
Assert.areEqual(0, result.messages.length);
201+
},
202+
203+
"Using hsla() with a fallback border should not result in a warning": function(){
204+
var result = CSSLint.verify(".hsla { border: 1px solid #fff; border: 1px solid hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
205+
Assert.areEqual(0, result.messages.length);
206+
},
207+
208+
"Using rgba() with fallback border afterwards should result in a warning": function(){
209+
var result = CSSLint.verify(".rgba { border: 1px solid rgba(0, 0, 0, 0.5); border: 1px solid #fff; }", { "fallback-colors": 1 });
210+
Assert.areEqual(1, result.messages.length);
211+
Assert.areEqual("warning", result.messages[0].type);
212+
Assert.areEqual("Fallback border (hex or RGB) should precede RGBA border.", result.messages[0].message);
213+
},
214+
215+
"Using hsl() with fallback border afterwards should result in a warning": function(){
216+
var result = CSSLint.verify(".hsl { border: 1px solid hsl(0, 0%, 0%); border: 1px solid #fff; }", { "fallback-colors": 1 });
217+
Assert.areEqual(1, result.messages.length);
218+
Assert.areEqual("warning", result.messages[0].type);
219+
Assert.areEqual("Fallback border (hex or RGB) should precede HSL border.", result.messages[0].message);
220+
},
221+
222+
"Using hsla() with fallback border afterwards should result in a warning": function(){
223+
var result = CSSLint.verify(".hsla { border: 1px solid hsla(0, 0%, 0%, 0.5); border: 1px solid #fff; }", { "fallback-colors": 1 });
224+
Assert.areEqual(1, result.messages.length);
225+
Assert.areEqual("warning", result.messages[0].type);
226+
Assert.areEqual("Fallback border (hex or RGB) should precede HSLA border.", result.messages[0].message);
227+
}
157228

158229

159230

0 commit comments

Comments
 (0)