scss-lint-bliss 1.0.0

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