sasslint 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 (46) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +29 -0
  4. data/bin/sasslint +6 -0
  5. data/lib/sasslint.rb +10 -0
  6. data/lib/sasslint/cli.rb +28 -0
  7. data/lib/sasslint/helpers/path_helper.rb +10 -0
  8. data/lib/sasslint/helpers/rule_importer.rb +25 -0
  9. data/lib/sasslint/rules/css/adjoining-classes.rb +52 -0
  10. data/lib/sasslint/rules/css/box-model.rb +108 -0
  11. data/lib/sasslint/rules/css/box-sizing.rb +35 -0
  12. data/lib/sasslint/rules/css/bulletproof-font-face.rb +73 -0
  13. data/lib/sasslint/rules/css/compatible-vendor-prefixes.rb +193 -0
  14. data/lib/sasslint/rules/css/display-property-grouping.rb +124 -0
  15. data/lib/sasslint/rules/css/duplicate-background-images.rb +44 -0
  16. data/lib/sasslint/rules/css/duplicate-properties.rb +53 -0
  17. data/lib/sasslint/rules/css/empty-rules.rb +41 -0
  18. data/lib/sasslint/rules/css/errors.rb +30 -0
  19. data/lib/sasslint/rules/css/fallback-colors.rb +84 -0
  20. data/lib/sasslint/rules/css/floats.rb +43 -0
  21. data/lib/sasslint/rules/css/font-faces.rb +37 -0
  22. data/lib/sasslint/rules/css/font-sizes.rb +42 -0
  23. data/lib/sasslint/rules/css/gradients.rb +71 -0
  24. data/lib/sasslint/rules/css/ids.rb +57 -0
  25. data/lib/sasslint/rules/css/import.rb +30 -0
  26. data/lib/sasslint/rules/css/important.rb +44 -0
  27. data/lib/sasslint/rules/css/known-properties.rb +36 -0
  28. data/lib/sasslint/rules/css/outline-none.rb +80 -0
  29. data/lib/sasslint/rules/css/overqualified-elements.rb +70 -0
  30. data/lib/sasslint/rules/css/qualified-headings.rb +45 -0
  31. data/lib/sasslint/rules/css/regex-selectors.rb +51 -0
  32. data/lib/sasslint/rules/css/rules-count.rb +35 -0
  33. data/lib/sasslint/rules/css/selector-max-approaching.rb +35 -0
  34. data/lib/sasslint/rules/css/selector-max.rb +35 -0
  35. data/lib/sasslint/rules/css/shorthand.rb +94 -0
  36. data/lib/sasslint/rules/css/star-property-hack.rb +34 -0
  37. data/lib/sasslint/rules/css/text-indent.rb +60 -0
  38. data/lib/sasslint/rules/css/underscore-property-hack.rb +34 -0
  39. data/lib/sasslint/rules/css/unique-headings.rb +81 -0
  40. data/lib/sasslint/rules/css/universal-selector.rb +42 -0
  41. data/lib/sasslint/rules/css/unqualified-attributes.rb +49 -0
  42. data/lib/sasslint/rules/css/vendor-prefix.rb +150 -0
  43. data/lib/sasslint/rules/css/zero-units.rb +41 -0
  44. data/lib/sasslint/version.rb +3 -0
  45. data/sasslint.gemspec +29 -0
  46. metadata +146 -0
@@ -0,0 +1,42 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: You shouldn't need more than 9 font-size declarations.
10
+ # */
11
+ #
12
+ # /*global CSSLint*/
13
+ # CSSLint.addRule({
14
+ #
15
+ # //rule information
16
+ # id: "font-sizes",
17
+ # name: "Disallow too many font sizes",
18
+ # desc: "Checks the number of font-size declarations.",
19
+ # browsers: "All",
20
+ #
21
+ # //initialization
22
+ # init: function(parser, reporter){
23
+ # var rule = this,
24
+ # count = 0;
25
+ #
26
+ # //check for use of "font-size"
27
+ # parser.addListener("property", function(event){
28
+ # if (event.property == "font-size"){
29
+ # count++;
30
+ # }
31
+ # });
32
+ #
33
+ # //report the results
34
+ # parser.addListener("endstylesheet", function(){
35
+ # reporter.stat("font-sizes", count);
36
+ # if (count >= 10){
37
+ # reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
38
+ # }
39
+ # });
40
+ # }
41
+ #
42
+ # });
@@ -0,0 +1,71 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: When using a vendor-prefixed gradient, make sure to use them all.
10
+ # */
11
+ # /*global CSSLint*/
12
+ # CSSLint.addRule({
13
+ #
14
+ # //rule information
15
+ # id: "gradients",
16
+ # name: "Require all gradient definitions",
17
+ # desc: "When using a vendor-prefixed gradient, make sure to use them all.",
18
+ # browsers: "All",
19
+ #
20
+ # //initialization
21
+ # init: function(parser, reporter){
22
+ # var rule = this,
23
+ # gradients;
24
+ #
25
+ # parser.addListener("startrule", function(){
26
+ # gradients = {
27
+ # moz: 0,
28
+ # webkit: 0,
29
+ # oldWebkit: 0,
30
+ # o: 0
31
+ # };
32
+ # });
33
+ #
34
+ # parser.addListener("property", function(event){
35
+ #
36
+ # if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){
37
+ # gradients[RegExp.$1] = 1;
38
+ # } else if (/\-webkit\-gradient/i.test(event.value)){
39
+ # gradients.oldWebkit = 1;
40
+ # }
41
+ #
42
+ # });
43
+ #
44
+ # parser.addListener("endrule", function(event){
45
+ # var missing = [];
46
+ #
47
+ # if (!gradients.moz){
48
+ # missing.push("Firefox 3.6+");
49
+ # }
50
+ #
51
+ # if (!gradients.webkit){
52
+ # missing.push("Webkit (Safari 5+, Chrome)");
53
+ # }
54
+ #
55
+ # if (!gradients.oldWebkit){
56
+ # missing.push("Old Webkit (Safari 4+, Chrome)");
57
+ # }
58
+ #
59
+ # if (!gradients.o){
60
+ # missing.push("Opera 11.1+");
61
+ # }
62
+ #
63
+ # if (missing.length && missing.length < 4){
64
+ # reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
65
+ # }
66
+ #
67
+ # });
68
+ #
69
+ # }
70
+ #
71
+ # });
@@ -0,0 +1,57 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Don't use IDs for selectors.
10
+ # */
11
+ # /*global CSSLint*/
12
+ # CSSLint.addRule({
13
+ #
14
+ # //rule information
15
+ # id: "ids",
16
+ # name: "Disallow IDs in selectors",
17
+ # desc: "Selectors should not contain IDs.",
18
+ # browsers: "All",
19
+ #
20
+ # //initialization
21
+ # init: function(parser, reporter){
22
+ # var rule = this;
23
+ # parser.addListener("startrule", function(event){
24
+ # var selectors = event.selectors,
25
+ # selector,
26
+ # part,
27
+ # modifier,
28
+ # idCount,
29
+ # i, j, k;
30
+ #
31
+ # for (i=0; i < selectors.length; i++){
32
+ # selector = selectors[i];
33
+ # idCount = 0;
34
+ #
35
+ # for (j=0; j < selector.parts.length; j++){
36
+ # part = selector.parts[j];
37
+ # if (part.type == parser.SELECTOR_PART_TYPE){
38
+ # for (k=0; k < part.modifiers.length; k++){
39
+ # modifier = part.modifiers[k];
40
+ # if (modifier.type == "id"){
41
+ # idCount++;
42
+ # }
43
+ # }
44
+ # }
45
+ # }
46
+ #
47
+ # if (idCount == 1){
48
+ # reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
49
+ # } else if (idCount > 1){
50
+ # reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
51
+ # }
52
+ # }
53
+ #
54
+ # });
55
+ # }
56
+ #
57
+ # });
@@ -0,0 +1,30 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Don't use @import, use <link> instead.
10
+ # */
11
+ # /*global CSSLint*/
12
+ # CSSLint.addRule({
13
+ #
14
+ # //rule information
15
+ # id: "import",
16
+ # name: "Disallow @import",
17
+ # desc: "Don't use @import, use <link> instead.",
18
+ # browsers: "All",
19
+ #
20
+ # //initialization
21
+ # init: function(parser, reporter){
22
+ # var rule = this;
23
+ #
24
+ # parser.addListener("import", function(event){
25
+ # reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
26
+ # });
27
+ #
28
+ # }
29
+ #
30
+ # });
@@ -0,0 +1,44 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Make sure !important is not overused, this could lead to specificity
10
+ # * war. Display a warning on !important declarations, an error if it's
11
+ # * used more at least 10 times.
12
+ # */
13
+ # /*global CSSLint*/
14
+ # CSSLint.addRule({
15
+ #
16
+ # //rule information
17
+ # id: "important",
18
+ # name: "Disallow !important",
19
+ # desc: "Be careful when using !important declaration",
20
+ # browsers: "All",
21
+ #
22
+ # //initialization
23
+ # init: function(parser, reporter){
24
+ # var rule = this,
25
+ # count = 0;
26
+ #
27
+ # //warn that important is used and increment the declaration counter
28
+ # parser.addListener("property", function(event){
29
+ # if (event.important === true){
30
+ # count++;
31
+ # reporter.report("Use of !important", event.line, event.col, rule);
32
+ # }
33
+ # });
34
+ #
35
+ # //if there are more than 10, show an error
36
+ # parser.addListener("endstylesheet", function(){
37
+ # reporter.stat("important", count);
38
+ # if (count >= 10){
39
+ # reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
40
+ # }
41
+ # });
42
+ # }
43
+ #
44
+ # });
@@ -0,0 +1,36 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Properties should be known (listed in CSS3 specification) or
10
+ # * be a vendor-prefixed property.
11
+ # */
12
+ # /*global CSSLint*/
13
+ # CSSLint.addRule({
14
+ #
15
+ # //rule information
16
+ # id: "known-properties",
17
+ # name: "Require use of known properties",
18
+ # desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
19
+ # browsers: "All",
20
+ #
21
+ # //initialization
22
+ # init: function(parser, reporter){
23
+ # var rule = this;
24
+ #
25
+ # parser.addListener("property", function(event){
26
+ # var name = event.property.text.toLowerCase();
27
+ #
28
+ # // the check is handled entirely by the parser-lib (https://github.com/nzakas/parser-lib)
29
+ # if (event.invalid) {
30
+ # reporter.report(event.invalid.message, event.line, event.col, rule);
31
+ # }
32
+ #
33
+ # });
34
+ # }
35
+ #
36
+ # });
@@ -0,0 +1,80 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: outline: none or outline: 0 should only be used in a :focus rule
10
+ # * and only if there are other properties in the same rule.
11
+ # */
12
+ # /*global CSSLint*/
13
+ # CSSLint.addRule({
14
+ #
15
+ # //rule information
16
+ # id: "outline-none",
17
+ # name: "Disallow outline: none",
18
+ # desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
19
+ # browsers: "All",
20
+ # tags: ["Accessibility"],
21
+ #
22
+ # //initialization
23
+ # init: function(parser, reporter){
24
+ # var rule = this,
25
+ # lastRule;
26
+ #
27
+ # function startRule(event){
28
+ # if (event.selectors){
29
+ # lastRule = {
30
+ # line: event.line,
31
+ # col: event.col,
32
+ # selectors: event.selectors,
33
+ # propCount: 0,
34
+ # outline: false
35
+ # };
36
+ # } else {
37
+ # lastRule = null;
38
+ # }
39
+ # }
40
+ #
41
+ # function endRule(event){
42
+ # if (lastRule){
43
+ # if (lastRule.outline){
44
+ # if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") == -1){
45
+ # reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
46
+ # } else if (lastRule.propCount == 1) {
47
+ # reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
48
+ # }
49
+ # }
50
+ # }
51
+ # }
52
+ #
53
+ # parser.addListener("startrule", startRule);
54
+ # parser.addListener("startfontface", startRule);
55
+ # parser.addListener("startpage", startRule);
56
+ # parser.addListener("startpagemargin", startRule);
57
+ # parser.addListener("startkeyframerule", startRule);
58
+ #
59
+ # parser.addListener("property", function(event){
60
+ # var name = event.property.text.toLowerCase(),
61
+ # value = event.value;
62
+ #
63
+ # if (lastRule){
64
+ # lastRule.propCount++;
65
+ # if (name == "outline" && (value == "none" || value == "0")){
66
+ # lastRule.outline = true;
67
+ # }
68
+ # }
69
+ #
70
+ # });
71
+ #
72
+ # parser.addListener("endrule", endRule);
73
+ # parser.addListener("endfontface", endRule);
74
+ # parser.addListener("endpage", endRule);
75
+ # parser.addListener("endpagemargin", endRule);
76
+ # parser.addListener("endkeyframerule", endRule);
77
+ #
78
+ # }
79
+ #
80
+ # });
@@ -0,0 +1,70 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Don't use classes or IDs with elements (a.foo or a#foo).
10
+ # */
11
+ # /*global CSSLint*/
12
+ # CSSLint.addRule({
13
+ #
14
+ # //rule information
15
+ # id: "overqualified-elements",
16
+ # name: "Disallow overqualified elements",
17
+ # desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
18
+ # browsers: "All",
19
+ #
20
+ # //initialization
21
+ # init: function(parser, reporter){
22
+ # var rule = this,
23
+ # classes = {};
24
+ #
25
+ # parser.addListener("startrule", function(event){
26
+ # var selectors = event.selectors,
27
+ # selector,
28
+ # part,
29
+ # modifier,
30
+ # i, j, k;
31
+ #
32
+ # for (i=0; i < selectors.length; i++){
33
+ # selector = selectors[i];
34
+ #
35
+ # for (j=0; j < selector.parts.length; j++){
36
+ # part = selector.parts[j];
37
+ # if (part.type == parser.SELECTOR_PART_TYPE){
38
+ # for (k=0; k < part.modifiers.length; k++){
39
+ # modifier = part.modifiers[k];
40
+ # if (part.elementName && modifier.type == "id"){
41
+ # reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
42
+ # } else if (modifier.type == "class"){
43
+ #
44
+ # if (!classes[modifier]){
45
+ # classes[modifier] = [];
46
+ # }
47
+ # classes[modifier].push({ modifier: modifier, part: part });
48
+ # }
49
+ # }
50
+ # }
51
+ # }
52
+ # }
53
+ # });
54
+ #
55
+ # parser.addListener("endstylesheet", function(){
56
+ #
57
+ # var prop;
58
+ # for (prop in classes){
59
+ # if (classes.hasOwnProperty(prop)){
60
+ #
61
+ # //one use means that this is overqualified
62
+ # if (classes[prop].length == 1 && classes[prop][0].part.elementName){
63
+ # reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
64
+ # }
65
+ # }
66
+ # }
67
+ # });
68
+ # }
69
+ #
70
+ # });
@@ -0,0 +1,45 @@
1
+ # This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules
2
+ #
3
+ #
4
+ # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
+ # TODO: Paste the CSSLint LICENSE here.
6
+ #
7
+ #
8
+ # /*
9
+ # * Rule: Headings (h1-h6) should not be qualified (namespaced).
10
+ # */
11
+ # /*global CSSLint*/
12
+ # CSSLint.addRule({
13
+ #
14
+ # //rule information
15
+ # id: "qualified-headings",
16
+ # name: "Disallow qualified headings",
17
+ # desc: "Headings should not be qualified (namespaced).",
18
+ # browsers: "All",
19
+ #
20
+ # //initialization
21
+ # init: function(parser, reporter){
22
+ # var rule = this;
23
+ #
24
+ # parser.addListener("startrule", function(event){
25
+ # var selectors = event.selectors,
26
+ # selector,
27
+ # part,
28
+ # i, j;
29
+ #
30
+ # for (i=0; i < selectors.length; i++){
31
+ # selector = selectors[i];
32
+ #
33
+ # for (j=0; j < selector.parts.length; j++){
34
+ # part = selector.parts[j];
35
+ # if (part.type == parser.SELECTOR_PART_TYPE){
36
+ # if (part.elementName && /h[1-6]/.test(part.elementName.toString()) && j > 0){
37
+ # reporter.report("Heading (" + part.elementName + ") should not be qualified.", part.line, part.col, rule);
38
+ # }
39
+ # }
40
+ # }
41
+ # }
42
+ # });
43
+ # }
44
+ #
45
+ # });