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,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
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
/*global CSSLint*/
|
6
|
+
CSSLint.addRule({
|
7
|
+
|
8
|
+
//rule information
|
9
|
+
id: "text-indent",
|
10
|
+
name: "Disallow negative text-indent",
|
11
|
+
desc: "Checks for text indent less than -99px",
|
12
|
+
browsers: "All",
|
13
|
+
|
14
|
+
//initialization
|
15
|
+
init: function(parser, reporter){
|
16
|
+
var rule = this,
|
17
|
+
textIndent,
|
18
|
+
direction;
|
19
|
+
|
20
|
+
|
21
|
+
function startRule(event){
|
22
|
+
textIndent = false;
|
23
|
+
direction = "inherit";
|
24
|
+
}
|
25
|
+
|
26
|
+
//event handler for end of rules
|
27
|
+
function endRule(event){
|
28
|
+
if (textIndent && direction != "ltr"){
|
29
|
+
reporter.report("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.", textIndent.line, textIndent.col, rule);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
parser.addListener("startrule", startRule);
|
34
|
+
parser.addListener("startfontface", startRule);
|
35
|
+
|
36
|
+
//check for use of "font-size"
|
37
|
+
parser.addListener("property", function(event){
|
38
|
+
var name = event.property.toString().toLowerCase(),
|
39
|
+
value = event.value;
|
40
|
+
|
41
|
+
if (name == "text-indent" && value.parts[0].value < -99){
|
42
|
+
textIndent = event.property;
|
43
|
+
} else if (name == "direction" && value == "ltr"){
|
44
|
+
direction = "ltr";
|
45
|
+
}
|
46
|
+
});
|
47
|
+
|
48
|
+
parser.addListener("endrule", endRule);
|
49
|
+
parser.addListener("endfontface", endRule);
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
});
|
@@ -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
|
+
});
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: Headings (h1-h6) should be defined only once.
|
3
|
+
*/
|
4
|
+
/*global CSSLint*/
|
5
|
+
CSSLint.addRule({
|
6
|
+
|
7
|
+
//rule information
|
8
|
+
id: "unique-headings",
|
9
|
+
name: "Headings should only be defined once",
|
10
|
+
desc: "Headings should be defined only once.",
|
11
|
+
browsers: "All",
|
12
|
+
|
13
|
+
//initialization
|
14
|
+
init: function(parser, reporter){
|
15
|
+
var rule = this;
|
16
|
+
|
17
|
+
var headings = {
|
18
|
+
h1: 0,
|
19
|
+
h2: 0,
|
20
|
+
h3: 0,
|
21
|
+
h4: 0,
|
22
|
+
h5: 0,
|
23
|
+
h6: 0
|
24
|
+
};
|
25
|
+
|
26
|
+
parser.addListener("startrule", function(event){
|
27
|
+
var selectors = event.selectors,
|
28
|
+
selector,
|
29
|
+
part,
|
30
|
+
pseudo,
|
31
|
+
i, j;
|
32
|
+
|
33
|
+
for (i=0; i < selectors.length; i++){
|
34
|
+
selector = selectors[i];
|
35
|
+
part = selector.parts[selector.parts.length-1];
|
36
|
+
|
37
|
+
if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())){
|
38
|
+
|
39
|
+
for (j=0; j < part.modifiers.length; j++){
|
40
|
+
if (part.modifiers[j].type == "pseudo"){
|
41
|
+
pseudo = true;
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!pseudo){
|
47
|
+
headings[RegExp.$1]++;
|
48
|
+
if (headings[RegExp.$1] > 1) {
|
49
|
+
reporter.report("Heading (" + part.elementName + ") has already been defined.", part.line, part.col, rule);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
parser.addListener("endstylesheet", function(event){
|
57
|
+
var prop,
|
58
|
+
messages = [];
|
59
|
+
|
60
|
+
for (prop in headings){
|
61
|
+
if (headings.hasOwnProperty(prop)){
|
62
|
+
if (headings[prop] > 1){
|
63
|
+
messages.push(headings[prop] + " " + prop + "s");
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
if (messages.length){
|
69
|
+
reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
|
70
|
+
}
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: Don't use universal selector because it's slow.
|
3
|
+
*/
|
4
|
+
/*global CSSLint*/
|
5
|
+
CSSLint.addRule({
|
6
|
+
|
7
|
+
//rule information
|
8
|
+
id: "universal-selector",
|
9
|
+
name: "Disallow universal selector",
|
10
|
+
desc: "The universal selector (*) is known to be slow.",
|
11
|
+
browsers: "All",
|
12
|
+
|
13
|
+
//initialization
|
14
|
+
init: function(parser, reporter){
|
15
|
+
var rule = this;
|
16
|
+
|
17
|
+
parser.addListener("startrule", function(event){
|
18
|
+
var selectors = event.selectors,
|
19
|
+
selector,
|
20
|
+
part,
|
21
|
+
modifier,
|
22
|
+
i, j, k;
|
23
|
+
|
24
|
+
for (i=0; i < selectors.length; i++){
|
25
|
+
selector = selectors[i];
|
26
|
+
|
27
|
+
part = selector.parts[selector.parts.length-1];
|
28
|
+
if (part.elementName == "*"){
|
29
|
+
reporter.report(rule.desc, part.line, part.col, rule);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: Don't use unqualified attribute selectors because they're just like universal selectors.
|
3
|
+
*/
|
4
|
+
/*global CSSLint*/
|
5
|
+
CSSLint.addRule({
|
6
|
+
|
7
|
+
//rule information
|
8
|
+
id: "unqualified-attributes",
|
9
|
+
name: "Disallow unqualified attribute selectors",
|
10
|
+
desc: "Unqualified attribute selectors are known to be slow.",
|
11
|
+
browsers: "All",
|
12
|
+
|
13
|
+
//initialization
|
14
|
+
init: function(parser, reporter){
|
15
|
+
var rule = this;
|
16
|
+
|
17
|
+
parser.addListener("startrule", function(event){
|
18
|
+
|
19
|
+
var selectors = event.selectors,
|
20
|
+
selector,
|
21
|
+
part,
|
22
|
+
modifier,
|
23
|
+
i, j, k;
|
24
|
+
|
25
|
+
for (i=0; i < selectors.length; i++){
|
26
|
+
selector = selectors[i];
|
27
|
+
|
28
|
+
part = selector.parts[selector.parts.length-1];
|
29
|
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
30
|
+
for (k=0; k < part.modifiers.length; k++){
|
31
|
+
modifier = part.modifiers[k];
|
32
|
+
if (modifier.type == "attribute" && (!part.elementName || part.elementName == "*")){
|
33
|
+
reporter.report(rule.desc, part.line, part.col, rule);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
});
|
@@ -0,0 +1,143 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: When using a vendor-prefixed property, make sure to
|
3
|
+
* include the standard one.
|
4
|
+
*/
|
5
|
+
/*global CSSLint*/
|
6
|
+
CSSLint.addRule({
|
7
|
+
|
8
|
+
//rule information
|
9
|
+
id: "vendor-prefix",
|
10
|
+
name: "Require standard property with vendor prefix",
|
11
|
+
desc: "When using a vendor-prefixed property, make sure to include the standard one.",
|
12
|
+
browsers: "All",
|
13
|
+
|
14
|
+
//initialization
|
15
|
+
init: function(parser, reporter){
|
16
|
+
var rule = this,
|
17
|
+
properties,
|
18
|
+
num,
|
19
|
+
propertiesToCheck = {
|
20
|
+
"-webkit-border-radius": "border-radius",
|
21
|
+
"-webkit-border-top-left-radius": "border-top-left-radius",
|
22
|
+
"-webkit-border-top-right-radius": "border-top-right-radius",
|
23
|
+
"-webkit-border-bottom-left-radius": "border-bottom-left-radius",
|
24
|
+
"-webkit-border-bottom-right-radius": "border-bottom-right-radius",
|
25
|
+
|
26
|
+
"-o-border-radius": "border-radius",
|
27
|
+
"-o-border-top-left-radius": "border-top-left-radius",
|
28
|
+
"-o-border-top-right-radius": "border-top-right-radius",
|
29
|
+
"-o-border-bottom-left-radius": "border-bottom-left-radius",
|
30
|
+
"-o-border-bottom-right-radius": "border-bottom-right-radius",
|
31
|
+
|
32
|
+
"-moz-border-radius": "border-radius",
|
33
|
+
"-moz-border-radius-topleft": "border-top-left-radius",
|
34
|
+
"-moz-border-radius-topright": "border-top-right-radius",
|
35
|
+
"-moz-border-radius-bottomleft": "border-bottom-left-radius",
|
36
|
+
"-moz-border-radius-bottomright": "border-bottom-right-radius",
|
37
|
+
|
38
|
+
"-moz-column-count": "column-count",
|
39
|
+
"-webkit-column-count": "column-count",
|
40
|
+
|
41
|
+
"-moz-column-gap": "column-gap",
|
42
|
+
"-webkit-column-gap": "column-gap",
|
43
|
+
|
44
|
+
"-moz-column-rule": "column-rule",
|
45
|
+
"-webkit-column-rule": "column-rule",
|
46
|
+
|
47
|
+
"-moz-column-rule-style": "column-rule-style",
|
48
|
+
"-webkit-column-rule-style": "column-rule-style",
|
49
|
+
|
50
|
+
"-moz-column-rule-color": "column-rule-color",
|
51
|
+
"-webkit-column-rule-color": "column-rule-color",
|
52
|
+
|
53
|
+
"-moz-column-rule-width": "column-rule-width",
|
54
|
+
"-webkit-column-rule-width": "column-rule-width",
|
55
|
+
|
56
|
+
"-moz-column-width": "column-width",
|
57
|
+
"-webkit-column-width": "column-width",
|
58
|
+
|
59
|
+
"-webkit-column-span": "column-span",
|
60
|
+
"-webkit-columns": "columns",
|
61
|
+
|
62
|
+
"-moz-box-shadow": "box-shadow",
|
63
|
+
"-webkit-box-shadow": "box-shadow",
|
64
|
+
|
65
|
+
"-moz-transform" : "transform",
|
66
|
+
"-webkit-transform" : "transform",
|
67
|
+
"-o-transform" : "transform",
|
68
|
+
"-ms-transform" : "transform",
|
69
|
+
|
70
|
+
"-moz-transform-origin" : "transform-origin",
|
71
|
+
"-webkit-transform-origin" : "transform-origin",
|
72
|
+
"-o-transform-origin" : "transform-origin",
|
73
|
+
"-ms-transform-origin" : "transform-origin",
|
74
|
+
|
75
|
+
"-moz-box-sizing" : "box-sizing",
|
76
|
+
"-webkit-box-sizing" : "box-sizing",
|
77
|
+
|
78
|
+
"-moz-user-select" : "user-select",
|
79
|
+
"-khtml-user-select" : "user-select",
|
80
|
+
"-webkit-user-select" : "user-select"
|
81
|
+
};
|
82
|
+
|
83
|
+
//event handler for beginning of rules
|
84
|
+
function startRule(){
|
85
|
+
properties = {};
|
86
|
+
num=1;
|
87
|
+
}
|
88
|
+
|
89
|
+
//event handler for end of rules
|
90
|
+
function endRule(event){
|
91
|
+
var prop,
|
92
|
+
i, len,
|
93
|
+
standard,
|
94
|
+
needed,
|
95
|
+
actual,
|
96
|
+
needsStandard = [];
|
97
|
+
|
98
|
+
for (prop in properties){
|
99
|
+
if (propertiesToCheck[prop]){
|
100
|
+
needsStandard.push({ actual: prop, needed: propertiesToCheck[prop]});
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
for (i=0, len=needsStandard.length; i < len; i++){
|
105
|
+
needed = needsStandard[i].needed;
|
106
|
+
actual = needsStandard[i].actual;
|
107
|
+
|
108
|
+
if (!properties[needed]){
|
109
|
+
reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
|
110
|
+
} else {
|
111
|
+
//make sure standard property is last
|
112
|
+
if (properties[needed][0].pos < properties[actual][0].pos){
|
113
|
+
reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
}
|
119
|
+
|
120
|
+
parser.addListener("startrule", startRule);
|
121
|
+
parser.addListener("startfontface", startRule);
|
122
|
+
parser.addListener("startpage", startRule);
|
123
|
+
parser.addListener("startpagemargin", startRule);
|
124
|
+
parser.addListener("startkeyframerule", startRule);
|
125
|
+
|
126
|
+
parser.addListener("property", function(event){
|
127
|
+
var name = event.property.text.toLowerCase();
|
128
|
+
|
129
|
+
if (!properties[name]){
|
130
|
+
properties[name] = [];
|
131
|
+
}
|
132
|
+
|
133
|
+
properties[name].push({ name: event.property, value : event.value, pos:num++ });
|
134
|
+
});
|
135
|
+
|
136
|
+
parser.addListener("endrule", endRule);
|
137
|
+
parser.addListener("endfontface", endRule);
|
138
|
+
parser.addListener("endpage", endRule);
|
139
|
+
parser.addListener("endpagemargin", endRule);
|
140
|
+
parser.addListener("endkeyframerule", endRule);
|
141
|
+
}
|
142
|
+
|
143
|
+
});
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/*
|
2
|
+
* Rule: You don't need to specify units when a value is 0.
|
3
|
+
*/
|
4
|
+
/*global CSSLint*/
|
5
|
+
CSSLint.addRule({
|
6
|
+
|
7
|
+
//rule information
|
8
|
+
id: "zero-units",
|
9
|
+
name: "Disallow units for 0 values",
|
10
|
+
desc: "You don't need to specify units when a value is 0.",
|
11
|
+
browsers: "All",
|
12
|
+
|
13
|
+
//initialization
|
14
|
+
init: function(parser, reporter){
|
15
|
+
var rule = this;
|
16
|
+
|
17
|
+
//count how many times "float" is used
|
18
|
+
parser.addListener("property", function(event){
|
19
|
+
var parts = event.value.parts,
|
20
|
+
i = 0,
|
21
|
+
len = parts.length;
|
22
|
+
|
23
|
+
while(i < len){
|
24
|
+
if ((parts[i].units || parts[i].type == "percentage") && parts[i].value === 0 && parts[i].type != "time"){
|
25
|
+
reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
|
26
|
+
}
|
27
|
+
i++;
|
28
|
+
}
|
29
|
+
|
30
|
+
});
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
* Web worker for CSSLint
|
3
|
+
*/
|
4
|
+
/*global self, CSSLint, JSON*/
|
5
|
+
//message indicates to start linting
|
6
|
+
self.onmessage = function(event){
|
7
|
+
|
8
|
+
var data = event.data,
|
9
|
+
message,
|
10
|
+
text,
|
11
|
+
ruleset,
|
12
|
+
results;
|
13
|
+
|
14
|
+
try {
|
15
|
+
message = JSON.parse(data);
|
16
|
+
text = message.text;
|
17
|
+
ruleset = message.ruleset;
|
18
|
+
} catch (ex){
|
19
|
+
text = data;
|
20
|
+
}
|
21
|
+
|
22
|
+
results = CSSLint.verify(text, ruleset);
|
23
|
+
|
24
|
+
//Not all browsers support structured clone, so JSON stringify results
|
25
|
+
self.postMessage(JSON.stringify(results));
|
26
|
+
};
|