Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adds all variations of border to the fallback-colors rule

  • Loading branch information...
commit fa406e8e45ccbd27a5c5644ee041ed609364f67b 1 parent c6d79d2
@fracmak authored
Showing with 80 additions and 3 deletions.
  1. +7 −1 src/rules/fallback-colors.js
  2. +73 −2 tests/rules/fallback-colors.js
View
8 src/rules/fallback-colors.js
@@ -15,7 +15,13 @@ CSSLint.addRule({
propertiesToCheck = {
color: 1,
background: 1,
- "background-color": 1
+ "border-color": 1,
+ border: 1,
+ "border-top": 1,
+ "border-right": 1,
+ "border-bottom": 1,
+ "border-left": 1,
+ "background-color": 1
},
properties;
View
75 tests/rules/fallback-colors.js
@@ -150,10 +150,81 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback background-color (hex or RGB) should precede HSLA background-color.", result.messages[0].message);
- }
+ },
+ // border color tests
-
+ "Using only a named border should not result in a warning": function(){
+ var result = CSSLint.verify(".hex { border: 1px solid red; }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using only a hex border should not result in a warning": function(){
+ var result = CSSLint.verify(".hex { border: 1px solid #fff; }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using only rgb() border should not result in a warning": function(){
+ var result = CSSLint.verify(".rgb { border: 1px solid rgb(0, 0, 0); }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using only rgba() border should result in a warning": function(){
+ var result = CSSLint.verify(".rgba { border: 1px solid rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede RGBA border.", result.messages[0].message);
+ },
+
+ "Using only hsl() border should result in a warning": function(){
+ var result = CSSLint.verify(".hsl { border: 1px solid hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede HSL border.", result.messages[0].message);
+ },
+
+ "Using only hsla() border should result in a warning": function(){
+ var result = CSSLint.verify(".hsla { border: 1px solid hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede HSLA border.", result.messages[0].message);
+ },
+
+ "Using rgba() with a fallback border should not result in a warning": function(){
+ var result = CSSLint.verify(".rgba { border: 1px solid #fff; border: 1px solid rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using hsl() with a fallback border should not result in a warning": function(){
+ var result = CSSLint.verify(".hsl { border: 1px solid #fff; border: 1px solid hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using hsla() with a fallback border should not result in a warning": function(){
+ var result = CSSLint.verify(".hsla { border: 1px solid #fff; border: 1px solid hsla(0, 0%, 0%, 0.5); }", { "fallback-colors": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Using rgba() with fallback border afterwards should result in a warning": function(){
+ var result = CSSLint.verify(".rgba { border: 1px solid rgba(0, 0, 0, 0.5); border: 1px solid #fff; }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede RGBA border.", result.messages[0].message);
+ },
+
+ "Using hsl() with fallback border afterwards should result in a warning": function(){
+ var result = CSSLint.verify(".hsl { border: 1px solid hsl(0, 0%, 0%); border: 1px solid #fff; }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede HSL border.", result.messages[0].message);
+ },
+
+ "Using hsla() with fallback border afterwards should result in a warning": function(){
+ var result = CSSLint.verify(".hsla { border: 1px solid hsla(0, 0%, 0%, 0.5); border: 1px solid #fff; }", { "fallback-colors": 1 });
+ Assert.areEqual(1, result.messages.length);
+ Assert.areEqual("warning", result.messages[0].type);
+ Assert.areEqual("Fallback border (hex or RGB) should precede HSLA border.", result.messages[0].message);
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.