scss-lint 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +19 -1
- data/data/properties.txt +4 -0
- data/lib/scss_lint.rb +1 -0
- data/lib/scss_lint/cli.rb +4 -42
- data/lib/scss_lint/config.rb +1 -45
- data/lib/scss_lint/control_comment_processor.rb +47 -15
- data/lib/scss_lint/file_finder.rb +57 -0
- data/lib/scss_lint/linter/bang_format.rb +1 -1
- data/lib/scss_lint/linter/border_zero.rb +25 -9
- data/lib/scss_lint/linter/color_keyword.rb +3 -13
- data/lib/scss_lint/linter/color_variable.rb +36 -0
- data/lib/scss_lint/linter/declaration_order.rb +2 -2
- data/lib/scss_lint/linter/important_rule.rb +12 -0
- data/lib/scss_lint/linter/indentation.rb +7 -1
- data/lib/scss_lint/linter/property_count.rb +44 -0
- data/lib/scss_lint/linter/property_sort_order.rb +73 -19
- data/lib/scss_lint/linter/string_quotes.rb +9 -0
- data/lib/scss_lint/linter/variable_for_property.rb +20 -0
- data/lib/scss_lint/linter/vendor_prefixes.rb +3 -3
- data/lib/scss_lint/runner.rb +5 -7
- data/lib/scss_lint/utils.rb +34 -0
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +1 -1
- data/spec/scss_lint/config_spec.rb +4 -203
- data/spec/scss_lint/engine_spec.rb +4 -4
- data/spec/scss_lint/file_finder_spec.rb +110 -0
- data/spec/scss_lint/linter/bang_format_spec.rb +28 -18
- data/spec/scss_lint/linter/border_zero_spec.rb +50 -16
- data/spec/scss_lint/linter/color_keyword_spec.rb +16 -16
- data/spec/scss_lint/linter/color_variable_spec.rb +102 -0
- data/spec/scss_lint/linter/comment_spec.rb +9 -9
- data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +10 -10
- data/spec/scss_lint/linter/debug_statement_spec.rb +4 -4
- data/spec/scss_lint/linter/declaration_order_spec.rb +80 -80
- data/spec/scss_lint/linter/duplicate_property_spec.rb +30 -30
- data/spec/scss_lint/linter/else_placement_spec.rb +16 -16
- data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +38 -38
- data/spec/scss_lint/linter/empty_rule_spec.rb +4 -4
- data/spec/scss_lint/linter/final_newline_spec.rb +6 -6
- data/spec/scss_lint/linter/hex_length_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_notation_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_validation_spec.rb +6 -6
- data/spec/scss_lint/linter/id_selector_spec.rb +10 -10
- data/spec/scss_lint/linter/import_path_spec.rb +45 -45
- data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
- data/spec/scss_lint/linter/indentation_spec.rb +103 -43
- data/spec/scss_lint/linter/leading_zero_spec.rb +45 -45
- data/spec/scss_lint/linter/mergeable_selector_spec.rb +32 -32
- data/spec/scss_lint/linter/name_format_spec.rb +75 -41
- data/spec/scss_lint/linter/nesting_depth_spec.rb +14 -14
- data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +12 -12
- data/spec/scss_lint/linter/property_count_spec.rb +104 -0
- data/spec/scss_lint/linter/property_sort_order_spec.rb +138 -48
- data/spec/scss_lint/linter/property_spelling_spec.rb +14 -14
- data/spec/scss_lint/linter/qualifying_element_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_depth_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_format_spec.rb +114 -114
- data/spec/scss_lint/linter/shorthand_spec.rb +32 -32
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +10 -10
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +24 -24
- data/spec/scss_lint/linter/space_after_comma_spec.rb +60 -60
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +44 -44
- data/spec/scss_lint/linter/space_after_property_name_spec.rb +6 -6
- data/spec/scss_lint/linter/space_before_brace_spec.rb +119 -119
- data/spec/scss_lint/linter/space_between_parens_spec.rb +48 -48
- data/spec/scss_lint/linter/string_quotes_spec.rb +74 -62
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +53 -54
- data/spec/scss_lint/linter/trailing_zero_spec.rb +34 -34
- data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +10 -10
- data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +18 -18
- data/spec/scss_lint/linter/url_format_spec.rb +4 -4
- data/spec/scss_lint/linter/url_quotes_spec.rb +14 -14
- data/spec/scss_lint/linter/variable_for_property_spec.rb +115 -0
- data/spec/scss_lint/linter/vendor_prefixes_spec.rb +66 -56
- data/spec/scss_lint/linter/zero_unit_spec.rb +22 -22
- data/spec/scss_lint/linter_spec.rb +72 -28
- data/spec/scss_lint/runner_spec.rb +0 -1
- data/spec/scss_lint/selector_visitor_spec.rb +23 -23
- data/spec/spec_helper.rb +2 -2
- metadata +27 -12
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::ColorVariable do
|
4
|
+
context 'when a color literal is used in a variable declaration' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
$my-color: #f00;
|
7
|
+
SCSS
|
8
|
+
|
9
|
+
it { should_not report_lint }
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when a color literal is used in a property' do
|
13
|
+
let(:scss) { <<-SCSS }
|
14
|
+
p {
|
15
|
+
color: #f00;
|
16
|
+
}
|
17
|
+
SCSS
|
18
|
+
|
19
|
+
it { should report_lint line: 2 }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when a color literal is used in a function call' do
|
23
|
+
let(:scss) { <<-SCSS }
|
24
|
+
p {
|
25
|
+
color: my-func(#f00);
|
26
|
+
}
|
27
|
+
SCSS
|
28
|
+
|
29
|
+
it { should report_lint line: 2 }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when a color literal is used in a mixin' do
|
33
|
+
let(:scss) { <<-SCSS }
|
34
|
+
p {
|
35
|
+
@include my-mixin(#f00);
|
36
|
+
}
|
37
|
+
SCSS
|
38
|
+
|
39
|
+
it { should report_lint line: 2 }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when a color literal is used in a shorthand property' do
|
43
|
+
let(:scss) { <<-SCSS }
|
44
|
+
p {
|
45
|
+
border: 1px solid #f00;
|
46
|
+
}
|
47
|
+
SCSS
|
48
|
+
|
49
|
+
it { should report_lint line: 2 }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when a number is used in a property' do
|
53
|
+
let(:scss) { <<-SCSS }
|
54
|
+
p {
|
55
|
+
z-index: 9000;
|
56
|
+
transition-duration: 250ms;
|
57
|
+
}
|
58
|
+
SCSS
|
59
|
+
|
60
|
+
it { should_not report_lint }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when a non-color keyword is used in a property' do
|
64
|
+
let(:scss) { <<-SCSS }
|
65
|
+
p {
|
66
|
+
overflow: hidden;
|
67
|
+
}
|
68
|
+
SCSS
|
69
|
+
|
70
|
+
it { should_not report_lint }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when a variable is used in a property' do
|
74
|
+
let(:scss) { <<-SCSS }
|
75
|
+
p {
|
76
|
+
color: $my-color;
|
77
|
+
}
|
78
|
+
SCSS
|
79
|
+
|
80
|
+
it { should_not report_lint }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when a variable is used in a function call' do
|
84
|
+
let(:scss) { <<-SCSS }
|
85
|
+
p {
|
86
|
+
color: my-func($my-color);
|
87
|
+
}
|
88
|
+
SCSS
|
89
|
+
|
90
|
+
it { should_not report_lint }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when a variable is used in a shorthand property' do
|
94
|
+
let(:scss) { <<-SCSS }
|
95
|
+
p {
|
96
|
+
border: 1px solid $my-color;
|
97
|
+
}
|
98
|
+
SCSS
|
99
|
+
|
100
|
+
it { should_not report_lint }
|
101
|
+
end
|
102
|
+
end
|
@@ -2,33 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::Comment do
|
4
4
|
context 'when no comments exist' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
margin: 0;
|
8
8
|
}
|
9
|
-
|
9
|
+
SCSS
|
10
10
|
|
11
11
|
it { should_not report_lint }
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when comment is a single line comment' do
|
15
|
-
let(:
|
15
|
+
let(:scss) { '// Single line comment' }
|
16
16
|
|
17
17
|
it { should_not report_lint }
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when comment is a single line comment at the end of a line' do
|
21
|
-
let(:
|
21
|
+
let(:scss) { <<-SCSS }
|
22
22
|
p {
|
23
23
|
margin: 0; // Comment at end of line
|
24
24
|
}
|
25
|
-
|
25
|
+
SCSS
|
26
26
|
|
27
27
|
it { should_not report_lint }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'when comment is a multi-line comment' do
|
31
|
-
let(:
|
31
|
+
let(:scss) { <<-SCSS }
|
32
32
|
h1 {
|
33
33
|
color: #eee;
|
34
34
|
}
|
@@ -38,17 +38,17 @@ describe SCSSLint::Linter::Comment do
|
|
38
38
|
p {
|
39
39
|
color: #DDD;
|
40
40
|
}
|
41
|
-
|
41
|
+
SCSS
|
42
42
|
|
43
43
|
it { should report_lint line: 4 }
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'when multi-line-style comment is a at the end of a line' do
|
47
|
-
let(:
|
47
|
+
let(:scss) { <<-SCSS }
|
48
48
|
h1 {
|
49
49
|
color: #eee; /* This is a comment */
|
50
50
|
}
|
51
|
-
|
51
|
+
SCSS
|
52
52
|
|
53
53
|
it { should report_lint line: 2 }
|
54
54
|
end
|
@@ -2,41 +2,41 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::Compass::PropertyWithMixin do
|
4
4
|
context 'when a rule has a property with an equivalent Compass mixin' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
opacity: .5;
|
8
8
|
}
|
9
|
-
|
9
|
+
SCSS
|
10
10
|
|
11
11
|
it { should report_lint line: 2 }
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when a rule includes a Compass property mixin' do
|
15
|
-
let(:
|
15
|
+
let(:scss) { <<-SCSS }
|
16
16
|
p {
|
17
17
|
@include opacity(.5);
|
18
18
|
}
|
19
|
-
|
19
|
+
SCSS
|
20
20
|
|
21
21
|
it { should_not report_lint }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'when a rule does not have a property with a corresponding Compass mixin' do
|
25
|
-
let(:
|
25
|
+
let(:scss) { <<-SCSS }
|
26
26
|
p {
|
27
27
|
margin: 0;
|
28
28
|
}
|
29
|
-
|
29
|
+
SCSS
|
30
30
|
|
31
31
|
it { should_not report_lint }
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when a rule includes display: inline-block' do
|
35
|
-
let(:
|
35
|
+
let(:scss) { <<-SCSS }
|
36
36
|
p {
|
37
37
|
display: inline-block;
|
38
38
|
}
|
39
|
-
|
39
|
+
SCSS
|
40
40
|
|
41
41
|
it { should report_lint line: 2 }
|
42
42
|
end
|
@@ -44,11 +44,11 @@ describe SCSSLint::Linter::Compass::PropertyWithMixin do
|
|
44
44
|
context 'when properties are ignored' do
|
45
45
|
let(:linter_config) { { 'ignore' => %w[inline-block] } }
|
46
46
|
|
47
|
-
let(:
|
47
|
+
let(:scss) { <<-SCSS }
|
48
48
|
p {
|
49
49
|
display: inline-block;
|
50
50
|
}
|
51
|
-
|
51
|
+
SCSS
|
52
52
|
|
53
53
|
it { should_not report_lint }
|
54
54
|
end
|
@@ -2,19 +2,19 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::DebugStatement do
|
4
4
|
context 'when no debug statements are present' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
color: #fff;
|
8
8
|
}
|
9
|
-
|
9
|
+
SCSS
|
10
10
|
|
11
11
|
it { should_not report_lint }
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when a debug statement is present' do
|
15
|
-
let(:
|
15
|
+
let(:scss) { <<-SCSS }
|
16
16
|
@debug 'This is a debug statement';
|
17
|
-
|
17
|
+
SCSS
|
18
18
|
|
19
19
|
it { should report_lint line: 1 }
|
20
20
|
end
|
@@ -2,50 +2,50 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::DeclarationOrder do
|
4
4
|
context 'when rule is empty' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
}
|
8
|
-
|
8
|
+
SCSS
|
9
9
|
|
10
10
|
it { should_not report_lint }
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when rule contains only properties' do
|
14
|
-
let(:
|
14
|
+
let(:scss) { <<-SCSS }
|
15
15
|
p {
|
16
16
|
background: #000;
|
17
17
|
margin: 5px;
|
18
18
|
}
|
19
|
-
|
19
|
+
SCSS
|
20
20
|
|
21
21
|
it { should_not report_lint }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'when rule contains only mixins' do
|
25
|
-
let(:
|
25
|
+
let(:scss) { <<-SCSS }
|
26
26
|
p {
|
27
27
|
@include border-radius(5px);
|
28
28
|
@include box-shadow(5px);
|
29
29
|
}
|
30
|
-
|
30
|
+
SCSS
|
31
31
|
|
32
32
|
it { should_not report_lint }
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'when rule contains no mixins or properties' do
|
36
|
-
let(:
|
36
|
+
let(:scss) { <<-SCSS }
|
37
37
|
p {
|
38
38
|
a {
|
39
39
|
color: #f00;
|
40
40
|
}
|
41
41
|
}
|
42
|
-
|
42
|
+
SCSS
|
43
43
|
|
44
44
|
it { should_not report_lint }
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'when rule contains properties after nested rules' do
|
48
|
-
let(:
|
48
|
+
let(:scss) { <<-SCSS }
|
49
49
|
p {
|
50
50
|
a {
|
51
51
|
color: #f00;
|
@@ -53,13 +53,13 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
53
53
|
color: #f00;
|
54
54
|
margin: 5px;
|
55
55
|
}
|
56
|
-
|
56
|
+
SCSS
|
57
57
|
|
58
58
|
it { should report_lint }
|
59
59
|
end
|
60
60
|
|
61
61
|
context 'when @extend appears before any properties or rules' do
|
62
|
-
let(:
|
62
|
+
let(:scss) { <<-SCSS }
|
63
63
|
.warn {
|
64
64
|
font-weight: bold;
|
65
65
|
}
|
@@ -70,13 +70,13 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
70
70
|
color: #ccc;
|
71
71
|
}
|
72
72
|
}
|
73
|
-
|
73
|
+
SCSS
|
74
74
|
|
75
75
|
it { should_not report_lint }
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'when @extend appears after a property' do
|
79
|
-
let(:
|
79
|
+
let(:scss) { <<-SCSS }
|
80
80
|
.warn {
|
81
81
|
font-weight: bold;
|
82
82
|
}
|
@@ -87,40 +87,40 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
87
87
|
color: #ccc;
|
88
88
|
}
|
89
89
|
}
|
90
|
-
|
90
|
+
SCSS
|
91
91
|
|
92
92
|
it { should report_lint }
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'when nested rule set' do
|
96
96
|
context 'contains @extend before a property' do
|
97
|
-
let(:
|
97
|
+
let(:scss) { <<-SCSS }
|
98
98
|
p {
|
99
99
|
a {
|
100
100
|
@extend foo;
|
101
101
|
color: #f00;
|
102
102
|
}
|
103
103
|
}
|
104
|
-
|
104
|
+
SCSS
|
105
105
|
|
106
106
|
it { should_not report_lint }
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'contains @extend after a property' do
|
110
|
-
let(:
|
110
|
+
let(:scss) { <<-SCSS }
|
111
111
|
p {
|
112
112
|
a {
|
113
113
|
color: #f00;
|
114
114
|
@extend foo;
|
115
115
|
}
|
116
116
|
}
|
117
|
-
|
117
|
+
SCSS
|
118
118
|
|
119
119
|
it { should report_lint }
|
120
120
|
end
|
121
121
|
|
122
122
|
context 'contains @extend after nested rule set' do
|
123
|
-
let(:
|
123
|
+
let(:scss) { <<-SCSS }
|
124
124
|
p {
|
125
125
|
a {
|
126
126
|
span {
|
@@ -129,7 +129,7 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
129
129
|
@extend foo;
|
130
130
|
}
|
131
131
|
}
|
132
|
-
|
132
|
+
SCSS
|
133
133
|
|
134
134
|
it { should report_lint }
|
135
135
|
end
|
@@ -137,7 +137,7 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
137
137
|
|
138
138
|
context 'when @include appears' do
|
139
139
|
context 'before a property and rule set' do
|
140
|
-
let(:
|
140
|
+
let(:scss) { <<-SCSS }
|
141
141
|
.error {
|
142
142
|
@include warn;
|
143
143
|
color: #f00;
|
@@ -145,13 +145,13 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
145
145
|
color: #ccc;
|
146
146
|
}
|
147
147
|
}
|
148
|
-
|
148
|
+
SCSS
|
149
149
|
|
150
150
|
it { should_not report_lint }
|
151
151
|
end
|
152
152
|
|
153
153
|
context 'after a property and before a rule set' do
|
154
|
-
let(:
|
154
|
+
let(:scss) { <<-SCSS }
|
155
155
|
.error {
|
156
156
|
color: #f00;
|
157
157
|
@include warn;
|
@@ -159,7 +159,7 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
159
159
|
color: #ccc;
|
160
160
|
}
|
161
161
|
}
|
162
|
-
|
162
|
+
SCSS
|
163
163
|
|
164
164
|
it { should report_lint }
|
165
165
|
end
|
@@ -167,46 +167,46 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
167
167
|
|
168
168
|
context 'when @include that features @content appears' do
|
169
169
|
context 'before a property' do
|
170
|
-
let(:
|
170
|
+
let(:scss) { <<-SCSS }
|
171
171
|
.foo {
|
172
172
|
@include breakpoint("phone") {
|
173
173
|
color: #ccc;
|
174
174
|
}
|
175
175
|
color: #f00;
|
176
176
|
}
|
177
|
-
|
177
|
+
SCSS
|
178
178
|
|
179
179
|
it { should report_lint }
|
180
180
|
end
|
181
181
|
|
182
182
|
context 'after a property' do
|
183
|
-
let(:
|
183
|
+
let(:scss) { <<-SCSS }
|
184
184
|
.foo {
|
185
185
|
color: #f00;
|
186
186
|
@include breakpoint("phone") {
|
187
187
|
color: #ccc;
|
188
188
|
}
|
189
189
|
}
|
190
|
-
|
190
|
+
SCSS
|
191
191
|
|
192
192
|
it { should_not report_lint }
|
193
193
|
end
|
194
194
|
|
195
195
|
context 'before an @extend' do
|
196
|
-
let(:
|
196
|
+
let(:scss) { <<-SCSS }
|
197
197
|
.foo {
|
198
198
|
@include breakpoint("phone") {
|
199
199
|
color: #ccc;
|
200
200
|
}
|
201
201
|
@extend .bar;
|
202
202
|
}
|
203
|
-
|
203
|
+
SCSS
|
204
204
|
|
205
205
|
it { should report_lint }
|
206
206
|
end
|
207
207
|
|
208
208
|
context 'before a rule set' do
|
209
|
-
let(:
|
209
|
+
let(:scss) { <<-SCSS }
|
210
210
|
.foo {
|
211
211
|
@include breakpoint("phone") {
|
212
212
|
color: #ccc;
|
@@ -215,13 +215,13 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
215
215
|
color: #fff;
|
216
216
|
}
|
217
217
|
}
|
218
|
-
|
218
|
+
SCSS
|
219
219
|
|
220
220
|
it { should_not report_lint }
|
221
221
|
end
|
222
222
|
|
223
223
|
context 'after a rule set' do
|
224
|
-
let(:
|
224
|
+
let(:scss) { <<-SCSS }
|
225
225
|
.foo {
|
226
226
|
a {
|
227
227
|
color: #fff;
|
@@ -230,34 +230,34 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
230
230
|
color: #ccc;
|
231
231
|
}
|
232
232
|
}
|
233
|
-
|
233
|
+
SCSS
|
234
234
|
|
235
235
|
it { should report_lint }
|
236
236
|
end
|
237
237
|
|
238
238
|
context 'with its own nested rule set' do
|
239
239
|
context 'before a property' do
|
240
|
-
let(:
|
240
|
+
let(:scss) { <<-SCSS }
|
241
241
|
@include breakpoint("phone") {
|
242
242
|
a {
|
243
243
|
color: #000;
|
244
244
|
}
|
245
245
|
color: #ccc;
|
246
246
|
}
|
247
|
-
|
247
|
+
SCSS
|
248
248
|
|
249
249
|
it { should report_lint }
|
250
250
|
end
|
251
251
|
|
252
252
|
context 'after a property' do
|
253
|
-
let(:
|
253
|
+
let(:scss) { <<-SCSS }
|
254
254
|
@include breakpoint("phone") {
|
255
255
|
color: #ccc;
|
256
256
|
a {
|
257
257
|
color: #000;
|
258
258
|
}
|
259
259
|
}
|
260
|
-
|
260
|
+
SCSS
|
261
261
|
|
262
262
|
it { should_not report_lint }
|
263
263
|
end
|
@@ -266,7 +266,7 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
266
266
|
|
267
267
|
context 'when the nesting is crazy deep' do
|
268
268
|
context 'and nothing is wrong' do
|
269
|
-
let(:
|
269
|
+
let(:scss) { <<-SCSS }
|
270
270
|
div {
|
271
271
|
ul {
|
272
272
|
@extend .thing;
|
@@ -282,13 +282,13 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
282
282
|
}
|
283
283
|
}
|
284
284
|
}
|
285
|
-
|
285
|
+
SCSS
|
286
286
|
|
287
287
|
it { should_not report_lint }
|
288
288
|
end
|
289
289
|
|
290
290
|
context 'and something is wrong' do
|
291
|
-
let(:
|
291
|
+
let(:scss) { <<-SCSS }
|
292
292
|
div {
|
293
293
|
ul {
|
294
294
|
li {
|
@@ -301,7 +301,7 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
301
301
|
}
|
302
302
|
}
|
303
303
|
}
|
304
|
-
|
304
|
+
SCSS
|
305
305
|
|
306
306
|
it { should report_lint }
|
307
307
|
end
|
@@ -309,33 +309,33 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
309
309
|
|
310
310
|
context 'when inside a @media query and rule set' do
|
311
311
|
context 'contains @extend before a property' do
|
312
|
-
let(:
|
312
|
+
let(:scss) { <<-SCSS }
|
313
313
|
@media only screen and (max-width: 1px) {
|
314
314
|
a {
|
315
315
|
@extend foo;
|
316
316
|
color: #f00;
|
317
317
|
}
|
318
318
|
}
|
319
|
-
|
319
|
+
SCSS
|
320
320
|
|
321
321
|
it { should_not report_lint }
|
322
322
|
end
|
323
323
|
|
324
324
|
context 'contains @extend after a property' do
|
325
|
-
let(:
|
325
|
+
let(:scss) { <<-SCSS }
|
326
326
|
@media only screen and (max-width: 1px) {
|
327
327
|
a {
|
328
328
|
color: #f00;
|
329
329
|
@extend foo;
|
330
330
|
}
|
331
331
|
}
|
332
|
-
|
332
|
+
SCSS
|
333
333
|
|
334
334
|
it { should report_lint }
|
335
335
|
end
|
336
336
|
|
337
337
|
context 'contains @extend after nested rule set' do
|
338
|
-
let(:
|
338
|
+
let(:scss) { <<-SCSS }
|
339
339
|
@media only screen and (max-width: 1px) {
|
340
340
|
a {
|
341
341
|
span {
|
@@ -344,216 +344,216 @@ describe SCSSLint::Linter::DeclarationOrder do
|
|
344
344
|
@extend foo;
|
345
345
|
}
|
346
346
|
}
|
347
|
-
|
347
|
+
SCSS
|
348
348
|
|
349
349
|
it { should report_lint }
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
353
353
|
context 'when a pseudo-element appears before a property' do
|
354
|
-
let(:
|
354
|
+
let(:scss) { <<-SCSS }
|
355
355
|
a {
|
356
356
|
&:hover {
|
357
357
|
color: #000;
|
358
358
|
}
|
359
359
|
color: #fff;
|
360
360
|
}
|
361
|
-
|
361
|
+
SCSS
|
362
362
|
|
363
363
|
it { should report_lint }
|
364
364
|
end
|
365
365
|
|
366
366
|
context 'when a pseudo-element appears after a property' do
|
367
|
-
let(:
|
367
|
+
let(:scss) { <<-SCSS }
|
368
368
|
a {
|
369
369
|
color: #fff;
|
370
370
|
&:focus {
|
371
371
|
color: #000;
|
372
372
|
}
|
373
373
|
}
|
374
|
-
|
374
|
+
SCSS
|
375
375
|
|
376
376
|
it { should_not report_lint }
|
377
377
|
end
|
378
378
|
|
379
379
|
context 'when a chained selector appears after a property' do
|
380
|
-
let(:
|
380
|
+
let(:scss) { <<-SCSS }
|
381
381
|
a {
|
382
382
|
color: #fff;
|
383
383
|
&.is-active {
|
384
384
|
color: #000;
|
385
385
|
}
|
386
386
|
}
|
387
|
-
|
387
|
+
SCSS
|
388
388
|
|
389
389
|
it { should_not report_lint }
|
390
390
|
end
|
391
391
|
|
392
392
|
context 'when a chained selector appears before a property' do
|
393
|
-
let(:
|
393
|
+
let(:scss) { <<-SCSS }
|
394
394
|
a {
|
395
395
|
&.is-active {
|
396
396
|
color: #000;
|
397
397
|
}
|
398
398
|
color: #fff;
|
399
399
|
}
|
400
|
-
|
400
|
+
SCSS
|
401
401
|
|
402
402
|
it { should report_lint }
|
403
403
|
end
|
404
404
|
|
405
405
|
context 'when a selector with parent reference appears after a property' do
|
406
|
-
let(:
|
406
|
+
let(:scss) { <<-SCSS }
|
407
407
|
a {
|
408
408
|
color: #fff;
|
409
409
|
.is-active & {
|
410
410
|
color: #000;
|
411
411
|
}
|
412
412
|
}
|
413
|
-
|
413
|
+
SCSS
|
414
414
|
|
415
415
|
it { should_not report_lint }
|
416
416
|
end
|
417
417
|
|
418
418
|
context 'when a selector with parent reference appears before a property' do
|
419
|
-
let(:
|
419
|
+
let(:scss) { <<-SCSS }
|
420
420
|
a {
|
421
421
|
.is-active & {
|
422
422
|
color: #000;
|
423
423
|
}
|
424
424
|
color: #fff;
|
425
425
|
}
|
426
|
-
|
426
|
+
SCSS
|
427
427
|
|
428
428
|
it { should report_lint }
|
429
429
|
end
|
430
430
|
|
431
431
|
context 'when a pseudo-element appears after a property' do
|
432
|
-
let(:
|
432
|
+
let(:scss) { <<-SCSS }
|
433
433
|
a {
|
434
434
|
color: #fff;
|
435
435
|
&:before {
|
436
436
|
color: #000;
|
437
437
|
}
|
438
438
|
}
|
439
|
-
|
439
|
+
SCSS
|
440
440
|
|
441
441
|
it { should_not report_lint }
|
442
442
|
end
|
443
443
|
|
444
444
|
context 'when a pseudo-element appears before a property' do
|
445
|
-
let(:
|
445
|
+
let(:scss) { <<-SCSS }
|
446
446
|
a {
|
447
447
|
&:before {
|
448
448
|
color: #000;
|
449
449
|
}
|
450
450
|
color: #fff;
|
451
451
|
}
|
452
|
-
|
452
|
+
SCSS
|
453
453
|
|
454
454
|
it { should report_lint }
|
455
455
|
end
|
456
456
|
|
457
457
|
context 'when a direct descendent appears after a property' do
|
458
|
-
let(:
|
458
|
+
let(:scss) { <<-SCSS }
|
459
459
|
a {
|
460
460
|
color: #fff;
|
461
461
|
> .foo {
|
462
462
|
color: #000;
|
463
463
|
}
|
464
464
|
}
|
465
|
-
|
465
|
+
SCSS
|
466
466
|
|
467
467
|
it { should_not report_lint }
|
468
468
|
end
|
469
469
|
|
470
470
|
context 'when a direct descendent appears before a property' do
|
471
|
-
let(:
|
471
|
+
let(:scss) { <<-SCSS }
|
472
472
|
a {
|
473
473
|
> .foo {
|
474
474
|
color: #000;
|
475
475
|
}
|
476
476
|
color: #fff;
|
477
477
|
}
|
478
|
-
|
478
|
+
SCSS
|
479
479
|
|
480
480
|
it { should report_lint }
|
481
481
|
end
|
482
482
|
|
483
483
|
context 'when an adjacent sibling appears after a property' do
|
484
|
-
let(:
|
484
|
+
let(:scss) { <<-SCSS }
|
485
485
|
a {
|
486
486
|
color: #fff;
|
487
487
|
& + .foo {
|
488
488
|
color: #000;
|
489
489
|
}
|
490
490
|
}
|
491
|
-
|
491
|
+
SCSS
|
492
492
|
|
493
493
|
it { should_not report_lint }
|
494
494
|
end
|
495
495
|
|
496
496
|
context 'when an adjacent sibling appears before a property' do
|
497
|
-
let(:
|
497
|
+
let(:scss) { <<-SCSS }
|
498
498
|
a {
|
499
499
|
& + .foo {
|
500
500
|
color: #000;
|
501
501
|
}
|
502
502
|
color: #fff;
|
503
503
|
}
|
504
|
-
|
504
|
+
SCSS
|
505
505
|
|
506
506
|
it { should report_lint }
|
507
507
|
end
|
508
508
|
|
509
509
|
context 'when a general sibling appears after a property' do
|
510
|
-
let(:
|
510
|
+
let(:scss) { <<-SCSS }
|
511
511
|
a {
|
512
512
|
color: #fff;
|
513
513
|
& ~ .foo {
|
514
514
|
color: #000;
|
515
515
|
}
|
516
516
|
}
|
517
|
-
|
517
|
+
SCSS
|
518
518
|
|
519
519
|
it { should_not report_lint }
|
520
520
|
end
|
521
521
|
|
522
522
|
context 'when a general sibling appears before a property' do
|
523
|
-
let(:
|
523
|
+
let(:scss) { <<-SCSS }
|
524
524
|
a {
|
525
525
|
& ~ .foo {
|
526
526
|
color: #000;
|
527
527
|
}
|
528
528
|
color: #fff;
|
529
529
|
}
|
530
|
-
|
530
|
+
SCSS
|
531
531
|
|
532
532
|
it { should report_lint }
|
533
533
|
end
|
534
534
|
|
535
535
|
context 'when a descendent appears after a property' do
|
536
|
-
let(:
|
536
|
+
let(:scss) { <<-SCSS }
|
537
537
|
a {
|
538
538
|
color: #fff;
|
539
539
|
.foo {
|
540
540
|
color: #000;
|
541
541
|
}
|
542
542
|
}
|
543
|
-
|
543
|
+
SCSS
|
544
544
|
|
545
545
|
it { should_not report_lint }
|
546
546
|
end
|
547
547
|
|
548
548
|
context 'when a descendent appears before a property' do
|
549
|
-
let(:
|
549
|
+
let(:scss) { <<-SCSS }
|
550
550
|
a {
|
551
551
|
.foo {
|
552
552
|
color: #000;
|
553
553
|
}
|
554
554
|
color: #fff;
|
555
555
|
}
|
556
|
-
|
556
|
+
SCSS
|
557
557
|
|
558
558
|
it { should report_lint }
|
559
559
|
end
|