Skip to content

Commit 3864557

Browse files
committed
Merge branch 'master' of github.com:stubbornella/csslint
2 parents f2f3dc0 + 6edc79a commit 3864557

8 files changed

Lines changed: 110 additions & 8 deletions

File tree

demos/CSSLintDemo.htm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>CSSLint Demo</title>
5-
<script type="text/javascript" src="../build/csslint.js"></script>
5+
<script type="text/javascript" src="../release/csslint.js"></script>
66
<style type="text/css">
77
.error { color: red; }
88
</style>
@@ -12,7 +12,7 @@ <h1>CSSLint Demo</h1>
1212
<textarea rows="50" cols="100" id="input">
1313
@charset "UTF-8";
1414

15-
@import url("booya.css") print,screen;
15+
@import url("booya.css") print, screen;
1616
@import "whatup.css" screen;
1717
@import "wicked.css";
1818

@@ -78,17 +78,17 @@ <h1>CSSLint Demo</h1>
7878
<script>
7979
(function(){
8080

81-
document.body.onclick = function(event){
81+
document.body.onclick = function(event) {
8282
event = event || window.event;
8383
var target = event.target || event.srcElement,
8484
results, messages, i, len;
8585

8686

87-
if (target.id == "lint-btn"){
87+
if (target.id == "lint-btn") {
8888
document.getElementById("output").innerHTML = "";
8989
results = CSSLint.verify(document.getElementById("input").value);
9090
messages = results.messages;
91-
for (i=0, len=messages.length; i < len; i++){
91+
for (i=0, len=messages.length; i < len; i++) {
9292
log(messages[i].message + " (line " + messages[i].line + ", col " + messages[i].col + ")", messages[i].type);
9393
}
9494

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "@VERSION@",
44
"description": "CSSLint",
55
"author": "Nicholas C. Zakas",
6-
"os": ["darwin", "linux"],
6+
"os": ["darwin", "linux", "win32"],
77
"contributors": [
88
"Nicole Sullivan"
99
],

src/rules/important.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CSSLint.addRule({
2929
parser.addListener("endstylesheet", function(){
3030
reporter.stat("important", count);
3131
if (count >= 10){
32-
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specifity issues.", rule);
32+
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
3333
}
3434
});
3535
}

src/rules/star-property-hack.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Rule: Don't use properties with a star prefix.
3+
*
4+
*/
5+
/*global CSSLint*/
6+
CSSLint.addRule({
7+
8+
//rule information
9+
id: "star-property-hack",
10+
name: "Disallow properties with a star prefix",
11+
desc: "Checks for the star property hack (targets IE6/7)",
12+
browsers: "All",
13+
14+
//initialization
15+
init: function(parser, reporter){
16+
var rule = this;
17+
18+
//check if property name starts with "*"
19+
parser.addListener("property", function(event){
20+
var property = event.property;
21+
22+
if (property.hack == "*") {
23+
reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
24+
}
25+
});
26+
}
27+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Rule: Don't use properties with a underscore prefix.
3+
*
4+
*/
5+
/*global CSSLint*/
6+
CSSLint.addRule({
7+
8+
//rule information
9+
id: "underscore-property-hack",
10+
name: "Disallow properties with an underscore prefix",
11+
desc: "Checks for the underscore property hack (targets IE6)",
12+
browsers: "All",
13+
14+
//initialization
15+
init: function(parser, reporter){
16+
var rule = this;
17+
18+
//check if property name starts with "_"
19+
parser.addListener("property", function(event){
20+
var property = event.property;
21+
22+
if (property.hack == "_") {
23+
reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
24+
}
25+
});
26+
}
27+
});

tests/rules/important.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
var result = CSSLint.verify(css, { "important": 1 });
2020
Assert.areEqual(11, result.messages.length);
2121
Assert.areEqual("warning", result.messages[10].type);
22-
Assert.areEqual("Too many !important declarations (10), try to use less than 10 to avoid specifity issues.", result.messages[10].message);
22+
Assert.areEqual("Too many !important declarations (10), try to use less than 10 to avoid specificity issues.", result.messages[10].message);
2323
}
2424

2525
}));

tests/rules/star-property-hack.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function(){
2+
3+
/*global YUITest, CSSLint*/
4+
var Assert = YUITest.Assert;
5+
6+
YUITest.TestRunner.add(new YUITest.TestCase({
7+
8+
name: "star-property-hack Rule Errors",
9+
10+
"a property with a star prefix should result in a warning": function(){
11+
var result = CSSLint.verify(".foo{*width: 100px;}", {"star-property-hack": 1 });
12+
Assert.areEqual(1, result.messages.length);
13+
Assert.areEqual("warning", result.messages[0].type);
14+
Assert.areEqual("Property with star prefix found.", result.messages[0].message);
15+
},
16+
17+
"a property without a star prefix should not result in a warning": function(){
18+
var result = CSSLint.verify(".foo{width: 100px;}", {"star-property-hack": 1 });
19+
Assert.areEqual(0, result.messages.length);
20+
}
21+
22+
}));
23+
24+
})();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function(){
2+
3+
/*global YUITest, CSSLint*/
4+
var Assert = YUITest.Assert;
5+
6+
YUITest.TestRunner.add(new YUITest.TestCase({
7+
8+
name: "underscore-property-hack Rule Errors",
9+
10+
"a property with an underscore prefix should result in a warning": function(){
11+
var result = CSSLint.verify(".foo{_width: 100px;}", {"underscore-property-hack": 1 });
12+
Assert.areEqual(1, result.messages.length);
13+
Assert.areEqual("warning", result.messages[0].type);
14+
Assert.areEqual("Property with underscore prefix found.", result.messages[0].message);
15+
},
16+
17+
"a property without an underscore prefix should not result in a warning": function(){
18+
var result = CSSLint.verify(".foo{width: 100px;}", {"underscore-property-hack": 1 });
19+
Assert.areEqual(0, result.messages.length);
20+
}
21+
22+
}));
23+
24+
})();

0 commit comments

Comments
 (0)