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.
- checksums.yaml +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/bin/sasslint +6 -0
- data/lib/sasslint.rb +10 -0
- data/lib/sasslint/cli.rb +28 -0
- data/lib/sasslint/helpers/path_helper.rb +10 -0
- data/lib/sasslint/helpers/rule_importer.rb +25 -0
- data/lib/sasslint/rules/css/adjoining-classes.rb +52 -0
- data/lib/sasslint/rules/css/box-model.rb +108 -0
- data/lib/sasslint/rules/css/box-sizing.rb +35 -0
- data/lib/sasslint/rules/css/bulletproof-font-face.rb +73 -0
- data/lib/sasslint/rules/css/compatible-vendor-prefixes.rb +193 -0
- data/lib/sasslint/rules/css/display-property-grouping.rb +124 -0
- data/lib/sasslint/rules/css/duplicate-background-images.rb +44 -0
- data/lib/sasslint/rules/css/duplicate-properties.rb +53 -0
- data/lib/sasslint/rules/css/empty-rules.rb +41 -0
- data/lib/sasslint/rules/css/errors.rb +30 -0
- data/lib/sasslint/rules/css/fallback-colors.rb +84 -0
- data/lib/sasslint/rules/css/floats.rb +43 -0
- data/lib/sasslint/rules/css/font-faces.rb +37 -0
- data/lib/sasslint/rules/css/font-sizes.rb +42 -0
- data/lib/sasslint/rules/css/gradients.rb +71 -0
- data/lib/sasslint/rules/css/ids.rb +57 -0
- data/lib/sasslint/rules/css/import.rb +30 -0
- data/lib/sasslint/rules/css/important.rb +44 -0
- data/lib/sasslint/rules/css/known-properties.rb +36 -0
- data/lib/sasslint/rules/css/outline-none.rb +80 -0
- data/lib/sasslint/rules/css/overqualified-elements.rb +70 -0
- data/lib/sasslint/rules/css/qualified-headings.rb +45 -0
- data/lib/sasslint/rules/css/regex-selectors.rb +51 -0
- data/lib/sasslint/rules/css/rules-count.rb +35 -0
- data/lib/sasslint/rules/css/selector-max-approaching.rb +35 -0
- data/lib/sasslint/rules/css/selector-max.rb +35 -0
- data/lib/sasslint/rules/css/shorthand.rb +94 -0
- data/lib/sasslint/rules/css/star-property-hack.rb +34 -0
- data/lib/sasslint/rules/css/text-indent.rb +60 -0
- data/lib/sasslint/rules/css/underscore-property-hack.rb +34 -0
- data/lib/sasslint/rules/css/unique-headings.rb +81 -0
- data/lib/sasslint/rules/css/universal-selector.rb +42 -0
- data/lib/sasslint/rules/css/unqualified-attributes.rb +49 -0
- data/lib/sasslint/rules/css/vendor-prefix.rb +150 -0
- data/lib/sasslint/rules/css/zero-units.rb +41 -0
- data/lib/sasslint/version.rb +3 -0
- data/sasslint.gemspec +29 -0
- metadata +146 -0
@@ -0,0 +1,124 @@
|
|
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: Certain properties don't play well with certain display values.
|
10
|
+
# * - float should not be used with inline-block
|
11
|
+
# * - height, width, margin-top, margin-bottom, float should not be used with inline
|
12
|
+
# * - vertical-align should not be used with block
|
13
|
+
# * - margin, float should not be used with table-*
|
14
|
+
# */
|
15
|
+
# /*global CSSLint*/
|
16
|
+
# CSSLint.addRule({
|
17
|
+
#
|
18
|
+
# //rule information
|
19
|
+
# id: "display-property-grouping",
|
20
|
+
# name: "Require properties appropriate for display",
|
21
|
+
# desc: "Certain properties shouldn't be used with certain display property values.",
|
22
|
+
# browsers: "All",
|
23
|
+
#
|
24
|
+
# //initialization
|
25
|
+
# init: function(parser, reporter){
|
26
|
+
# var rule = this;
|
27
|
+
#
|
28
|
+
# var propertiesToCheck = {
|
29
|
+
# display: 1,
|
30
|
+
# "float": "none",
|
31
|
+
# height: 1,
|
32
|
+
# width: 1,
|
33
|
+
# margin: 1,
|
34
|
+
# "margin-left": 1,
|
35
|
+
# "margin-right": 1,
|
36
|
+
# "margin-bottom": 1,
|
37
|
+
# "margin-top": 1,
|
38
|
+
# padding: 1,
|
39
|
+
# "padding-left": 1,
|
40
|
+
# "padding-right": 1,
|
41
|
+
# "padding-bottom": 1,
|
42
|
+
# "padding-top": 1,
|
43
|
+
# "vertical-align": 1
|
44
|
+
# },
|
45
|
+
# properties;
|
46
|
+
#
|
47
|
+
# function reportProperty(name, display, msg){
|
48
|
+
# if (properties[name]){
|
49
|
+
# if (typeof propertiesToCheck[name] != "string" || properties[name].value.toLowerCase() != propertiesToCheck[name]){
|
50
|
+
# reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
|
51
|
+
# }
|
52
|
+
# }
|
53
|
+
# }
|
54
|
+
#
|
55
|
+
# function startRule(){
|
56
|
+
# properties = {};
|
57
|
+
# }
|
58
|
+
#
|
59
|
+
# function endRule(){
|
60
|
+
#
|
61
|
+
# var display = properties.display ? properties.display.value : null;
|
62
|
+
# if (display){
|
63
|
+
# switch(display){
|
64
|
+
#
|
65
|
+
# case "inline":
|
66
|
+
# //height, width, margin-top, margin-bottom, float should not be used with inline
|
67
|
+
# reportProperty("height", display);
|
68
|
+
# reportProperty("width", display);
|
69
|
+
# reportProperty("margin", display);
|
70
|
+
# reportProperty("margin-top", display);
|
71
|
+
# reportProperty("margin-bottom", display);
|
72
|
+
# reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
|
73
|
+
# break;
|
74
|
+
#
|
75
|
+
# case "block":
|
76
|
+
# //vertical-align should not be used with block
|
77
|
+
# reportProperty("vertical-align", display);
|
78
|
+
# break;
|
79
|
+
#
|
80
|
+
# case "inline-block":
|
81
|
+
# //float should not be used with inline-block
|
82
|
+
# reportProperty("float", display);
|
83
|
+
# break;
|
84
|
+
#
|
85
|
+
# default:
|
86
|
+
# //margin, float should not be used with table
|
87
|
+
# if (display.indexOf("table-") === 0){
|
88
|
+
# reportProperty("margin", display);
|
89
|
+
# reportProperty("margin-left", display);
|
90
|
+
# reportProperty("margin-right", display);
|
91
|
+
# reportProperty("margin-top", display);
|
92
|
+
# reportProperty("margin-bottom", display);
|
93
|
+
# reportProperty("float", display);
|
94
|
+
# }
|
95
|
+
#
|
96
|
+
# //otherwise do nothing
|
97
|
+
# }
|
98
|
+
# }
|
99
|
+
#
|
100
|
+
# }
|
101
|
+
#
|
102
|
+
# parser.addListener("startrule", startRule);
|
103
|
+
# parser.addListener("startfontface", startRule);
|
104
|
+
# parser.addListener("startkeyframerule", startRule);
|
105
|
+
# parser.addListener("startpagemargin", startRule);
|
106
|
+
# parser.addListener("startpage", startRule);
|
107
|
+
#
|
108
|
+
# parser.addListener("property", function(event){
|
109
|
+
# var name = event.property.text.toLowerCase();
|
110
|
+
#
|
111
|
+
# if (propertiesToCheck[name]){
|
112
|
+
# properties[name] = { value: event.value.text, line: event.property.line, col: event.property.col };
|
113
|
+
# }
|
114
|
+
# });
|
115
|
+
#
|
116
|
+
# parser.addListener("endrule", endRule);
|
117
|
+
# parser.addListener("endfontface", endRule);
|
118
|
+
# parser.addListener("endkeyframerule", endRule);
|
119
|
+
# parser.addListener("endpagemargin", endRule);
|
120
|
+
# parser.addListener("endpage", endRule);
|
121
|
+
#
|
122
|
+
# }
|
123
|
+
#
|
124
|
+
# });
|
@@ -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: Disallow duplicate background-images (using url).
|
10
|
+
# */
|
11
|
+
# /*global CSSLint*/
|
12
|
+
# CSSLint.addRule({
|
13
|
+
#
|
14
|
+
# //rule information
|
15
|
+
# id: "duplicate-background-images",
|
16
|
+
# name: "Disallow duplicate background images",
|
17
|
+
# desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
|
18
|
+
# browsers: "All",
|
19
|
+
#
|
20
|
+
# //initialization
|
21
|
+
# init: function(parser, reporter){
|
22
|
+
# var rule = this,
|
23
|
+
# stack = {};
|
24
|
+
#
|
25
|
+
# parser.addListener("property", function(event){
|
26
|
+
# var name = event.property.text,
|
27
|
+
# value = event.value,
|
28
|
+
# i, len;
|
29
|
+
#
|
30
|
+
# if (name.match(/background/i)) {
|
31
|
+
# for (i=0, len=value.parts.length; i < len; i++) {
|
32
|
+
# if (value.parts[i].type == 'uri') {
|
33
|
+
# if (typeof stack[value.parts[i].uri] === 'undefined') {
|
34
|
+
# stack[value.parts[i].uri] = event;
|
35
|
+
# }
|
36
|
+
# else {
|
37
|
+
# reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
|
38
|
+
# }
|
39
|
+
# }
|
40
|
+
# }
|
41
|
+
# }
|
42
|
+
# });
|
43
|
+
# }
|
44
|
+
# });
|
@@ -0,0 +1,53 @@
|
|
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: Duplicate properties must appear one after the other. If an already-defined
|
10
|
+
# * property appears somewhere else in the rule, then it's likely an error.
|
11
|
+
# */
|
12
|
+
# /*global CSSLint*/
|
13
|
+
# CSSLint.addRule({
|
14
|
+
#
|
15
|
+
# //rule information
|
16
|
+
# id: "duplicate-properties",
|
17
|
+
# name: "Disallow duplicate properties",
|
18
|
+
# desc: "Duplicate properties must appear one after the other.",
|
19
|
+
# browsers: "All",
|
20
|
+
#
|
21
|
+
# //initialization
|
22
|
+
# init: function(parser, reporter){
|
23
|
+
# var rule = this,
|
24
|
+
# properties,
|
25
|
+
# lastProperty;
|
26
|
+
#
|
27
|
+
# function startRule(event){
|
28
|
+
# properties = {};
|
29
|
+
# }
|
30
|
+
#
|
31
|
+
# parser.addListener("startrule", startRule);
|
32
|
+
# parser.addListener("startfontface", startRule);
|
33
|
+
# parser.addListener("startpage", startRule);
|
34
|
+
# parser.addListener("startpagemargin", startRule);
|
35
|
+
# parser.addListener("startkeyframerule", startRule);
|
36
|
+
#
|
37
|
+
# parser.addListener("property", function(event){
|
38
|
+
# var property = event.property,
|
39
|
+
# name = property.text.toLowerCase();
|
40
|
+
#
|
41
|
+
# if (properties[name] && (lastProperty != name || properties[name] == event.value.text)){
|
42
|
+
# reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
|
43
|
+
# }
|
44
|
+
#
|
45
|
+
# properties[name] = event.value.text;
|
46
|
+
# lastProperty = name;
|
47
|
+
#
|
48
|
+
# });
|
49
|
+
#
|
50
|
+
#
|
51
|
+
# }
|
52
|
+
#
|
53
|
+
# });
|
@@ -0,0 +1,41 @@
|
|
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: Style rules without any properties defined should be removed.
|
10
|
+
# */
|
11
|
+
# /*global CSSLint*/
|
12
|
+
# CSSLint.addRule({
|
13
|
+
#
|
14
|
+
# //rule information
|
15
|
+
# id: "empty-rules",
|
16
|
+
# name: "Disallow empty rules",
|
17
|
+
# desc: "Rules without any properties specified should be removed.",
|
18
|
+
# browsers: "All",
|
19
|
+
#
|
20
|
+
# //initialization
|
21
|
+
# init: function(parser, reporter){
|
22
|
+
# var rule = this,
|
23
|
+
# count = 0;
|
24
|
+
#
|
25
|
+
# parser.addListener("startrule", function(){
|
26
|
+
# count=0;
|
27
|
+
# });
|
28
|
+
#
|
29
|
+
# parser.addListener("property", function(){
|
30
|
+
# count++;
|
31
|
+
# });
|
32
|
+
#
|
33
|
+
# parser.addListener("endrule", function(event){
|
34
|
+
# var selectors = event.selectors;
|
35
|
+
# if (count === 0){
|
36
|
+
# reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
|
37
|
+
# }
|
38
|
+
# });
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# });
|
@@ -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: There should be no syntax errors. (Duh.)
|
10
|
+
# */
|
11
|
+
# /*global CSSLint*/
|
12
|
+
# CSSLint.addRule({
|
13
|
+
#
|
14
|
+
# //rule information
|
15
|
+
# id: "errors",
|
16
|
+
# name: "Parsing Errors",
|
17
|
+
# desc: "This rule looks for recoverable syntax errors.",
|
18
|
+
# browsers: "All",
|
19
|
+
#
|
20
|
+
# //initialization
|
21
|
+
# init: function(parser, reporter){
|
22
|
+
# var rule = this;
|
23
|
+
#
|
24
|
+
# parser.addListener("error", function(event){
|
25
|
+
# reporter.error(event.message, event.line, event.col, rule);
|
26
|
+
# });
|
27
|
+
#
|
28
|
+
# }
|
29
|
+
#
|
30
|
+
# });
|
@@ -0,0 +1,84 @@
|
|
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
|
+
# /*global CSSLint*/
|
10
|
+
# CSSLint.addRule({
|
11
|
+
#
|
12
|
+
# //rule information
|
13
|
+
# id: "fallback-colors",
|
14
|
+
# name: "Require fallback colors",
|
15
|
+
# desc: "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",
|
16
|
+
# browsers: "IE6,IE7,IE8",
|
17
|
+
#
|
18
|
+
# //initialization
|
19
|
+
# init: function(parser, reporter){
|
20
|
+
# var rule = this,
|
21
|
+
# lastProperty,
|
22
|
+
# propertiesToCheck = {
|
23
|
+
# color: 1,
|
24
|
+
# background: 1,
|
25
|
+
# "border-color": 1,
|
26
|
+
# "border-top-color": 1,
|
27
|
+
# "border-right-color": 1,
|
28
|
+
# "border-bottom-color": 1,
|
29
|
+
# "border-left-color": 1,
|
30
|
+
# border: 1,
|
31
|
+
# "border-top": 1,
|
32
|
+
# "border-right": 1,
|
33
|
+
# "border-bottom": 1,
|
34
|
+
# "border-left": 1,
|
35
|
+
# "background-color": 1
|
36
|
+
# },
|
37
|
+
# properties;
|
38
|
+
#
|
39
|
+
# function startRule(event){
|
40
|
+
# properties = {};
|
41
|
+
# lastProperty = null;
|
42
|
+
# }
|
43
|
+
#
|
44
|
+
# parser.addListener("startrule", startRule);
|
45
|
+
# parser.addListener("startfontface", startRule);
|
46
|
+
# parser.addListener("startpage", startRule);
|
47
|
+
# parser.addListener("startpagemargin", startRule);
|
48
|
+
# parser.addListener("startkeyframerule", startRule);
|
49
|
+
#
|
50
|
+
# parser.addListener("property", function(event){
|
51
|
+
# var property = event.property,
|
52
|
+
# name = property.text.toLowerCase(),
|
53
|
+
# parts = event.value.parts,
|
54
|
+
# i = 0,
|
55
|
+
# colorType = "",
|
56
|
+
# len = parts.length;
|
57
|
+
#
|
58
|
+
# if(propertiesToCheck[name]){
|
59
|
+
# while(i < len){
|
60
|
+
# if (parts[i].type == "color"){
|
61
|
+
# if ("alpha" in parts[i] || "hue" in parts[i]){
|
62
|
+
#
|
63
|
+
# if (/([^\)]+)\(/.test(parts[i])){
|
64
|
+
# colorType = RegExp.$1.toUpperCase();
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# if (!lastProperty || (lastProperty.property.text.toLowerCase() != name || lastProperty.colorType != "compat")){
|
68
|
+
# reporter.report("Fallback " + name + " (hex or RGB) should precede " + colorType + " " + name + ".", event.line, event.col, rule);
|
69
|
+
# }
|
70
|
+
# } else {
|
71
|
+
# event.colorType = "compat";
|
72
|
+
# }
|
73
|
+
# }
|
74
|
+
#
|
75
|
+
# i++;
|
76
|
+
# }
|
77
|
+
# }
|
78
|
+
#
|
79
|
+
# lastProperty = event;
|
80
|
+
# });
|
81
|
+
#
|
82
|
+
# }
|
83
|
+
#
|
84
|
+
# });
|
@@ -0,0 +1,43 @@
|
|
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 use more than 10 floats. If you do, there's probably
|
10
|
+
# * room for some abstraction.
|
11
|
+
# */
|
12
|
+
# /*global CSSLint*/
|
13
|
+
# CSSLint.addRule({
|
14
|
+
#
|
15
|
+
# //rule information
|
16
|
+
# id: "floats",
|
17
|
+
# name: "Disallow too many floats",
|
18
|
+
# desc: "This rule tests if the float property is used too many times",
|
19
|
+
# browsers: "All",
|
20
|
+
#
|
21
|
+
# //initialization
|
22
|
+
# init: function(parser, reporter){
|
23
|
+
# var rule = this;
|
24
|
+
# var count = 0;
|
25
|
+
#
|
26
|
+
# //count how many times "float" is used
|
27
|
+
# parser.addListener("property", function(event){
|
28
|
+
# if (event.property.text.toLowerCase() == "float" &&
|
29
|
+
# event.value.text.toLowerCase() != "none"){
|
30
|
+
# count++;
|
31
|
+
# }
|
32
|
+
# });
|
33
|
+
#
|
34
|
+
# //report the results
|
35
|
+
# parser.addListener("endstylesheet", function(){
|
36
|
+
# reporter.stat("floats", count);
|
37
|
+
# if (count >= 10){
|
38
|
+
# reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
|
39
|
+
# }
|
40
|
+
# });
|
41
|
+
# }
|
42
|
+
#
|
43
|
+
# });
|
@@ -0,0 +1,37 @@
|
|
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: Avoid too many @font-face declarations in the same stylesheet.
|
10
|
+
# */
|
11
|
+
# /*global CSSLint*/
|
12
|
+
# CSSLint.addRule({
|
13
|
+
#
|
14
|
+
# //rule information
|
15
|
+
# id: "font-faces",
|
16
|
+
# name: "Don't use too many web fonts",
|
17
|
+
# desc: "Too many different web fonts in the same stylesheet.",
|
18
|
+
# browsers: "All",
|
19
|
+
#
|
20
|
+
# //initialization
|
21
|
+
# init: function(parser, reporter){
|
22
|
+
# var rule = this,
|
23
|
+
# count = 0;
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# parser.addListener("startfontface", function(){
|
27
|
+
# count++;
|
28
|
+
# });
|
29
|
+
#
|
30
|
+
# parser.addListener("endstylesheet", function(){
|
31
|
+
# if (count > 5){
|
32
|
+
# reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
|
33
|
+
# }
|
34
|
+
# });
|
35
|
+
# }
|
36
|
+
#
|
37
|
+
# });
|