ruby_css_lint 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +19 -0
  5. data/Rakefile +71 -0
  6. data/VERSION +1 -0
  7. data/csslint/CHANGELOG +286 -0
  8. data/csslint/LICENSE +20 -0
  9. data/csslint/README.md +25 -0
  10. data/csslint/build.xml +242 -0
  11. data/csslint/demos/CSSLintDemo.htm +105 -0
  12. data/csslint/demos/demo.css +43 -0
  13. data/csslint/lib/js.jar +0 -0
  14. data/csslint/lib/jshint.js +3963 -0
  15. data/csslint/lib/parserlib.js +6295 -0
  16. data/csslint/lib/yuitest-rhino-cli.js +3955 -0
  17. data/csslint/lib/yuitest.js +4561 -0
  18. data/csslint/npm/package.json +30 -0
  19. data/csslint/release/csslint-node.js +9125 -0
  20. data/csslint/release/csslint-rhino.js +9390 -0
  21. data/csslint/release/csslint-tests.js +1921 -0
  22. data/csslint/release/csslint-worker.js +9148 -0
  23. data/csslint/release/csslint-wsh.js +9477 -0
  24. data/csslint/release/csslint.js +9127 -0
  25. data/csslint/release/npm/cli.js +307 -0
  26. data/csslint/release/npm/lib/csslint-node.js +9125 -0
  27. data/csslint/release/npm/package.json +30 -0
  28. data/csslint/src/cli/common.js +215 -0
  29. data/csslint/src/cli/node.js +87 -0
  30. data/csslint/src/cli/rhino.js +47 -0
  31. data/csslint/src/cli/wsh.js +134 -0
  32. data/csslint/src/core/CSSLint.js +181 -0
  33. data/csslint/src/core/Reporter.js +161 -0
  34. data/csslint/src/core/Util.js +62 -0
  35. data/csslint/src/formatters/checkstyle-xml.js +109 -0
  36. data/csslint/src/formatters/compact.js +59 -0
  37. data/csslint/src/formatters/csslint-xml.js +68 -0
  38. data/csslint/src/formatters/lint-xml.js +69 -0
  39. data/csslint/src/formatters/text.js +64 -0
  40. data/csslint/src/rules/adjoining-classes.js +45 -0
  41. data/csslint/src/rules/box-model.js +93 -0
  42. data/csslint/src/rules/box-sizing.js +28 -0
  43. data/csslint/src/rules/compatible-vendor-prefixes.js +171 -0
  44. data/csslint/src/rules/display-property-grouping.js +117 -0
  45. data/csslint/src/rules/duplicate-background-images.js +37 -0
  46. data/csslint/src/rules/duplicate-properties.js +46 -0
  47. data/csslint/src/rules/empty-rules.js +34 -0
  48. data/csslint/src/rules/errors.js +23 -0
  49. data/csslint/src/rules/fallback-colors.js +67 -0
  50. data/csslint/src/rules/floats.js +36 -0
  51. data/csslint/src/rules/font-faces.js +30 -0
  52. data/csslint/src/rules/font-sizes.js +35 -0
  53. data/csslint/src/rules/gradients.js +69 -0
  54. data/csslint/src/rules/ids.js +50 -0
  55. data/csslint/src/rules/import.js +23 -0
  56. data/csslint/src/rules/important.js +37 -0
  57. data/csslint/src/rules/known-properties.js +29 -0
  58. data/csslint/src/rules/outline-none.js +73 -0
  59. data/csslint/src/rules/overqualified-elements.js +63 -0
  60. data/csslint/src/rules/qualified-headings.js +38 -0
  61. data/csslint/src/rules/regex-selectors.js +44 -0
  62. data/csslint/src/rules/rules-count.js +28 -0
  63. data/csslint/src/rules/shorthand.js +87 -0
  64. data/csslint/src/rules/star-property-hack.js +27 -0
  65. data/csslint/src/rules/text-indent.js +53 -0
  66. data/csslint/src/rules/underscore-property-hack.js +27 -0
  67. data/csslint/src/rules/unique-headings.js +74 -0
  68. data/csslint/src/rules/universal-selector.js +35 -0
  69. data/csslint/src/rules/unqualified-attributes.js +42 -0
  70. data/csslint/src/rules/vendor-prefix.js +143 -0
  71. data/csslint/src/rules/zero-units.js +34 -0
  72. data/csslint/src/worker/Worker.js +26 -0
  73. data/csslint/tests/all-rules.js +64 -0
  74. data/csslint/tests/core/CSSLint.js +22 -0
  75. data/csslint/tests/core/Reporter.js +36 -0
  76. data/csslint/tests/css/width-100.html +76 -0
  77. data/csslint/tests/formatters/checkstyle-xml.js +44 -0
  78. data/csslint/tests/formatters/compact.js +47 -0
  79. data/csslint/tests/formatters/csslint-xml.js +42 -0
  80. data/csslint/tests/formatters/lint-xml.js +43 -0
  81. data/csslint/tests/formatters/text.js +36 -0
  82. data/csslint/tests/rules/adjoining-classes.js +31 -0
  83. data/csslint/tests/rules/box-model.js +211 -0
  84. data/csslint/tests/rules/box-sizing.js +23 -0
  85. data/csslint/tests/rules/compatible-vendor-prefixes.js +56 -0
  86. data/csslint/tests/rules/display-property-grouping.js +213 -0
  87. data/csslint/tests/rules/duplicate-background-images.js +25 -0
  88. data/csslint/tests/rules/duplicate-properties.js +54 -0
  89. data/csslint/tests/rules/empty-rules.js +18 -0
  90. data/csslint/tests/rules/errors.js +17 -0
  91. data/csslint/tests/rules/fallback-colors.js +162 -0
  92. data/csslint/tests/rules/floats.js +35 -0
  93. data/csslint/tests/rules/font-faces.js +28 -0
  94. data/csslint/tests/rules/font-sizes.js +30 -0
  95. data/csslint/tests/rules/gradients.js +60 -0
  96. data/csslint/tests/rules/ids.js +25 -0
  97. data/csslint/tests/rules/import.js +18 -0
  98. data/csslint/tests/rules/important.js +27 -0
  99. data/csslint/tests/rules/known-properties.js +44 -0
  100. data/csslint/tests/rules/outline-none.js +50 -0
  101. data/csslint/tests/rules/overqualified-elements.js +41 -0
  102. data/csslint/tests/rules/qualified-headings.js +19 -0
  103. data/csslint/tests/rules/regex-selectors.js +52 -0
  104. data/csslint/tests/rules/shorthand.js +36 -0
  105. data/csslint/tests/rules/star-property-hack.js +24 -0
  106. data/csslint/tests/rules/text-indent.js +55 -0
  107. data/csslint/tests/rules/underscore-property-hack.js +24 -0
  108. data/csslint/tests/rules/unique-headings.js +47 -0
  109. data/csslint/tests/rules/universal-selector.js +31 -0
  110. data/csslint/tests/rules/unqualified-attributes.js +37 -0
  111. data/csslint/tests/rules/vendor-prefix.js +76 -0
  112. data/csslint/tests/rules/zero-units.js +44 -0
  113. data/csslint/tests/testrunner.htm +138 -0
  114. data/js.jar +0 -0
  115. data/lib/ruby_css_lint.rb +168 -0
  116. data/test/helper.rb +17 -0
  117. data/test/test_ruby_css_lint.rb +7 -0
  118. 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
+ };