Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure float: none doesn't count as a float for rules that care (f…

…ixes #10)
  • Loading branch information...
commit 8a133355f7121131490e449031329db2b22d2b40 1 parent a2ef767
@nzakas nzakas authored
View
9 build/csslint-node.js
@@ -9716,7 +9716,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -9798,7 +9798,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
@@ -9878,7 +9880,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
9 build/csslint-rhino.js
@@ -9717,7 +9717,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -9799,7 +9799,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
@@ -9879,7 +9881,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
27 build/csslint-tests.js
@@ -239,6 +239,16 @@
Assert.areEqual("float can't be used with display: inline.", result.messages[0].message);
},
+ "Float:none with inline-block should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: inline-block; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Float:none with inline should result not in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: inline; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
"Height with inline should result in a warning": function(){
var result = CSSLint.verify(".foo { height: 100px; display: inline; }", { "display-property-grouping": 1 });
Assert.areEqual(1, result.messages.length);
@@ -412,7 +422,17 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("float can't be used with display: table-cell.", result.messages[0].message);
- }
+ },
+
+ "Float:none with table-row should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: table-row; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Float:none with table-cell should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: table-cell; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ }
}));
@@ -481,6 +501,11 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Too many floats (11), abstraction needed.", result.messages[0].message);
+ },
+
+ "float: none should not count and therefore should not result in a warning": function(){
+ 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 });
+ Assert.areEqual(0, result.messages.length);
}
}));
View
9 build/csslint-worker.js
@@ -9716,7 +9716,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -9798,7 +9798,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
@@ -9878,7 +9880,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
9 build/csslint.js
@@ -9717,7 +9717,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -9799,7 +9799,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
@@ -9879,7 +9881,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
9 build/npm/lib/csslint-node.js
@@ -9716,7 +9716,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -9798,7 +9798,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
@@ -9878,7 +9880,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
6 src/rules/display-property-grouping.js
@@ -19,7 +19,7 @@ CSSLint.addRule({
var propertiesToCheck = {
display: 1,
- "float": 1,
+ "float": "none",
height: 1,
width: 1,
margin: 1,
@@ -101,7 +101,9 @@ CSSLint.addRule({
function reportProperty(name, display){
if (properties[name]){
- reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ if (!(typeof propertiesToCheck[name] == "string") || properties[name].value.toLowerCase() != propertiesToCheck[name]){
+ reporter.warn(name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
+ }
}
}
}
View
3  src/rules/floats.js
@@ -17,7 +17,8 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
- if (event.property == "float"){
+ if (event.property.text.toLowerCase() == "float" &&
+ event.value.text.toLowerCase() != "none"){
count++;
}
});
View
22 tests/rules/display-property-grouping.js
@@ -27,6 +27,16 @@
Assert.areEqual("float can't be used with display: inline.", result.messages[0].message);
},
+ "Float:none with inline-block should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: inline-block; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Float:none with inline should result not in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: inline; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
"Height with inline should result in a warning": function(){
var result = CSSLint.verify(".foo { height: 100px; display: inline; }", { "display-property-grouping": 1 });
Assert.areEqual(1, result.messages.length);
@@ -200,7 +210,17 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("float can't be used with display: table-cell.", result.messages[0].message);
- }
+ },
+
+ "Float:none with table-row should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: table-row; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ },
+
+ "Float:none with table-cell should not result in a warning": function(){
+ var result = CSSLint.verify(".foo { float: none; display: table-cell; }", { "display-property-grouping": 1 });
+ Assert.areEqual(0, result.messages.length);
+ }
}));
View
5 tests/rules/floats.js
@@ -24,6 +24,11 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Too many floats (11), abstraction needed.", result.messages[0].message);
+ },
+
+ "float: none should not count and therefore should not result in a warning": function(){
+ 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 });
+ Assert.areEqual(0, result.messages.length);
}
}));
Please sign in to comment.
Something went wrong with that request. Please try again.