scss-lint-bliss 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/scss-lint +6 -0
- data/config/default.yml +220 -0
- data/data/prefixed-identifiers/base.txt +107 -0
- data/data/prefixed-identifiers/bourbon.txt +71 -0
- data/data/properties.txt +477 -0
- data/data/property-sort-orders/concentric.txt +134 -0
- data/data/property-sort-orders/recess.txt +149 -0
- data/data/property-sort-orders/smacss.txt +137 -0
- data/lib/scss_lint.rb +31 -0
- data/lib/scss_lint/cli.rb +215 -0
- data/lib/scss_lint/config.rb +251 -0
- data/lib/scss_lint/constants.rb +8 -0
- data/lib/scss_lint/control_comment_processor.rb +126 -0
- data/lib/scss_lint/engine.rb +56 -0
- data/lib/scss_lint/exceptions.rb +21 -0
- data/lib/scss_lint/file_finder.rb +68 -0
- data/lib/scss_lint/lint.rb +24 -0
- data/lib/scss_lint/linter.rb +161 -0
- data/lib/scss_lint/linter/bang_format.rb +52 -0
- data/lib/scss_lint/linter/bliss.rb +8 -0
- data/lib/scss_lint/linter/bliss/module.rb +101 -0
- data/lib/scss_lint/linter/border_zero.rb +39 -0
- data/lib/scss_lint/linter/color_keyword.rb +32 -0
- data/lib/scss_lint/linter/color_variable.rb +49 -0
- data/lib/scss_lint/linter/comment.rb +21 -0
- data/lib/scss_lint/linter/compass.rb +7 -0
- data/lib/scss_lint/linter/compass/property_with_mixin.rb +47 -0
- data/lib/scss_lint/linter/debug_statement.rb +10 -0
- data/lib/scss_lint/linter/declaration_order.rb +71 -0
- data/lib/scss_lint/linter/duplicate_property.rb +58 -0
- data/lib/scss_lint/linter/else_placement.rb +48 -0
- data/lib/scss_lint/linter/empty_line_between_blocks.rb +85 -0
- data/lib/scss_lint/linter/empty_rule.rb +11 -0
- data/lib/scss_lint/linter/final_newline.rb +20 -0
- data/lib/scss_lint/linter/hex_length.rb +56 -0
- data/lib/scss_lint/linter/hex_notation.rb +38 -0
- data/lib/scss_lint/linter/hex_validation.rb +23 -0
- data/lib/scss_lint/linter/id_selector.rb +10 -0
- data/lib/scss_lint/linter/import_path.rb +62 -0
- data/lib/scss_lint/linter/important_rule.rb +12 -0
- data/lib/scss_lint/linter/indentation.rb +197 -0
- data/lib/scss_lint/linter/leading_zero.rb +49 -0
- data/lib/scss_lint/linter/mergeable_selector.rb +60 -0
- data/lib/scss_lint/linter/name_format.rb +117 -0
- data/lib/scss_lint/linter/nesting_depth.rb +24 -0
- data/lib/scss_lint/linter/placeholder_in_extend.rb +22 -0
- data/lib/scss_lint/linter/property_count.rb +44 -0
- data/lib/scss_lint/linter/property_sort_order.rb +189 -0
- data/lib/scss_lint/linter/property_spelling.rb +49 -0
- data/lib/scss_lint/linter/property_units.rb +59 -0
- data/lib/scss_lint/linter/qualifying_element.rb +42 -0
- data/lib/scss_lint/linter/selector_depth.rb +64 -0
- data/lib/scss_lint/linter/selector_format.rb +102 -0
- data/lib/scss_lint/linter/shorthand.rb +139 -0
- data/lib/scss_lint/linter/single_line_per_property.rb +59 -0
- data/lib/scss_lint/linter/single_line_per_selector.rb +35 -0
- data/lib/scss_lint/linter/space_after_comma.rb +110 -0
- data/lib/scss_lint/linter/space_after_property_colon.rb +84 -0
- data/lib/scss_lint/linter/space_after_property_name.rb +27 -0
- data/lib/scss_lint/linter/space_before_brace.rb +72 -0
- data/lib/scss_lint/linter/space_between_parens.rb +35 -0
- data/lib/scss_lint/linter/string_quotes.rb +94 -0
- data/lib/scss_lint/linter/trailing_semicolon.rb +67 -0
- data/lib/scss_lint/linter/trailing_zero.rb +41 -0
- data/lib/scss_lint/linter/unnecessary_mantissa.rb +42 -0
- data/lib/scss_lint/linter/unnecessary_parent_reference.rb +49 -0
- data/lib/scss_lint/linter/url_format.rb +56 -0
- data/lib/scss_lint/linter/url_quotes.rb +27 -0
- data/lib/scss_lint/linter/variable_for_property.rb +30 -0
- data/lib/scss_lint/linter/vendor_prefix.rb +64 -0
- data/lib/scss_lint/linter/zero_unit.rb +39 -0
- data/lib/scss_lint/linter_registry.rb +26 -0
- data/lib/scss_lint/location.rb +38 -0
- data/lib/scss_lint/options.rb +109 -0
- data/lib/scss_lint/rake_task.rb +106 -0
- data/lib/scss_lint/reporter.rb +18 -0
- data/lib/scss_lint/reporter/config_reporter.rb +26 -0
- data/lib/scss_lint/reporter/default_reporter.rb +27 -0
- data/lib/scss_lint/reporter/files_reporter.rb +8 -0
- data/lib/scss_lint/reporter/json_reporter.rb +30 -0
- data/lib/scss_lint/reporter/xml_reporter.rb +33 -0
- data/lib/scss_lint/runner.rb +51 -0
- data/lib/scss_lint/sass/script.rb +78 -0
- data/lib/scss_lint/sass/tree.rb +168 -0
- data/lib/scss_lint/selector_visitor.rb +34 -0
- data/lib/scss_lint/utils.rb +112 -0
- data/lib/scss_lint/version.rb +4 -0
- data/spec/scss_lint/cli_spec.rb +177 -0
- data/spec/scss_lint/config_spec.rb +253 -0
- data/spec/scss_lint/engine_spec.rb +24 -0
- data/spec/scss_lint/file_finder_spec.rb +134 -0
- data/spec/scss_lint/linter/bang_format_spec.rb +121 -0
- data/spec/scss_lint/linter/bliss/module_spec.rb +254 -0
- data/spec/scss_lint/linter/border_zero_spec.rb +118 -0
- data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
- data/spec/scss_lint/linter/color_variable_spec.rb +145 -0
- data/spec/scss_lint/linter/comment_spec.rb +79 -0
- data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
- data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
- data/spec/scss_lint/linter/declaration_order_spec.rb +575 -0
- data/spec/scss_lint/linter/duplicate_property_spec.rb +189 -0
- data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
- data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +276 -0
- data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
- data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
- data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
- data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
- data/spec/scss_lint/linter/hex_validation_spec.rb +40 -0
- data/spec/scss_lint/linter/id_selector_spec.rb +62 -0
- data/spec/scss_lint/linter/import_path_spec.rb +300 -0
- data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
- data/spec/scss_lint/linter/indentation_spec.rb +347 -0
- data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
- data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
- data/spec/scss_lint/linter/name_format_spec.rb +282 -0
- data/spec/scss_lint/linter/nesting_depth_spec.rb +114 -0
- data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
- data/spec/scss_lint/linter/property_count_spec.rb +104 -0
- data/spec/scss_lint/linter/property_sort_order_spec.rb +426 -0
- data/spec/scss_lint/linter/property_spelling_spec.rb +84 -0
- data/spec/scss_lint/linter/property_units_spec.rb +229 -0
- data/spec/scss_lint/linter/qualifying_element_spec.rb +125 -0
- data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
- data/spec/scss_lint/linter/selector_format_spec.rb +632 -0
- data/spec/scss_lint/linter/shorthand_spec.rb +198 -0
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +130 -0
- data/spec/scss_lint/linter/space_after_comma_spec.rb +332 -0
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +264 -0
- data/spec/scss_lint/linter/space_after_property_name_spec.rb +37 -0
- data/spec/scss_lint/linter/space_before_brace_spec.rb +829 -0
- data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
- data/spec/scss_lint/linter/string_quotes_spec.rb +335 -0
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +304 -0
- data/spec/scss_lint/linter/trailing_zero_spec.rb +176 -0
- data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
- data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +98 -0
- data/spec/scss_lint/linter/url_format_spec.rb +55 -0
- data/spec/scss_lint/linter/url_quotes_spec.rb +73 -0
- data/spec/scss_lint/linter/variable_for_property_spec.rb +145 -0
- data/spec/scss_lint/linter/vendor_prefix_spec.rb +371 -0
- data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
- data/spec/scss_lint/linter_registry_spec.rb +50 -0
- data/spec/scss_lint/linter_spec.rb +292 -0
- data/spec/scss_lint/location_spec.rb +42 -0
- data/spec/scss_lint/options_spec.rb +34 -0
- data/spec/scss_lint/rake_task_spec.rb +43 -0
- data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
- data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
- data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
- data/spec/scss_lint/reporter/json_reporter_spec.rb +96 -0
- data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
- data/spec/scss_lint/reporter_spec.rb +11 -0
- data/spec/scss_lint/runner_spec.rb +123 -0
- data/spec/scss_lint/selector_visitor_spec.rb +264 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/support/isolated_environment.rb +25 -0
- data/spec/support/matchers/report_lint.rb +48 -0
- metadata +342 -0
@@ -0,0 +1,263 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::SpaceBetweenParens do
|
4
|
+
context 'when the opening parens is followed by a space' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
p {
|
7
|
+
property: ( value);
|
8
|
+
}
|
9
|
+
SCSS
|
10
|
+
|
11
|
+
it { should report_lint line: 2 }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when the closing parens is preceded by a space' do
|
15
|
+
let(:scss) { <<-SCSS }
|
16
|
+
p {
|
17
|
+
property: (value );
|
18
|
+
}
|
19
|
+
SCSS
|
20
|
+
|
21
|
+
it { should report_lint line: 2 }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when both parens are space padded' do
|
25
|
+
let(:scss) { <<-SCSS }
|
26
|
+
p {
|
27
|
+
property: ( value );
|
28
|
+
}
|
29
|
+
SCSS
|
30
|
+
|
31
|
+
it { should report_lint line: 2, count: 2 }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when neither parens are space padded' do
|
35
|
+
let(:scss) { <<-SCSS }
|
36
|
+
p {
|
37
|
+
property: (value);
|
38
|
+
}
|
39
|
+
SCSS
|
40
|
+
|
41
|
+
it { should_not report_lint }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when parens are multi-line' do
|
45
|
+
let(:scss) { <<-SCSS }
|
46
|
+
p {
|
47
|
+
property: (
|
48
|
+
value
|
49
|
+
);
|
50
|
+
}
|
51
|
+
SCSS
|
52
|
+
|
53
|
+
it { should_not report_lint }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when parens are multi-line with tabs' do
|
57
|
+
let(:scss) { <<-SCSS }
|
58
|
+
\t\t\tp {
|
59
|
+
\t\t\t\tproperty: (
|
60
|
+
\t\t\t\t\tvalue
|
61
|
+
\t\t\t\t);
|
62
|
+
\t\t\t}
|
63
|
+
SCSS
|
64
|
+
|
65
|
+
it { should_not report_lint }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when outer parens are space padded' do
|
69
|
+
let(:scss) { <<-SCSS }
|
70
|
+
p {
|
71
|
+
property: fn( fn2(val1, val2) );
|
72
|
+
}
|
73
|
+
SCSS
|
74
|
+
|
75
|
+
it { should report_lint line: 2, count: 2 }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when inner parens are space padded' do
|
79
|
+
let(:scss) { <<-SCSS }
|
80
|
+
p {
|
81
|
+
property: fn(fn2( val1, val2 ));
|
82
|
+
}
|
83
|
+
SCSS
|
84
|
+
|
85
|
+
it { should report_lint line: 2, count: 2 }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when both parens are not space padded' do
|
89
|
+
let(:scss) { <<-SCSS }
|
90
|
+
p {
|
91
|
+
property: fn(fn2(val1, val2));
|
92
|
+
}
|
93
|
+
SCSS
|
94
|
+
|
95
|
+
it { should_not report_lint }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when both parens are space padded' do
|
99
|
+
let(:scss) { <<-SCSS }
|
100
|
+
p {
|
101
|
+
property: fn( fn2( val1, val2 ) );
|
102
|
+
}
|
103
|
+
SCSS
|
104
|
+
|
105
|
+
it { should report_lint line: 2, count: 4 }
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when multi level parens are multi-line' do
|
109
|
+
let(:scss) { <<-SCSS }
|
110
|
+
p {
|
111
|
+
property: fn(
|
112
|
+
fn2(
|
113
|
+
val1, val2
|
114
|
+
)
|
115
|
+
);
|
116
|
+
}
|
117
|
+
SCSS
|
118
|
+
|
119
|
+
it { should_not report_lint }
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when parens exist in a silent comment' do
|
123
|
+
let(:scss) { <<-SCSS }
|
124
|
+
p {
|
125
|
+
margin: 0; // Some comment ( with parens )
|
126
|
+
}
|
127
|
+
SCSS
|
128
|
+
|
129
|
+
it { should_not report_lint }
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when parens exist in an outputted comment' do
|
133
|
+
let(:scss) { <<-SCSS }
|
134
|
+
p {
|
135
|
+
margin: 0; /* Some comment ( with parens ) */
|
136
|
+
}
|
137
|
+
SCSS
|
138
|
+
|
139
|
+
it { should_not report_lint }
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'when the number of spaces has been explicitly set' do
|
143
|
+
let(:linter_config) { { 'spaces' => 1 } }
|
144
|
+
|
145
|
+
context 'when the opening parens is followed by a space' do
|
146
|
+
let(:scss) { <<-SCSS }
|
147
|
+
p {
|
148
|
+
property: ( value);
|
149
|
+
}
|
150
|
+
SCSS
|
151
|
+
|
152
|
+
it { should report_lint line: 2 }
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when the closing parens is preceded by a space' do
|
156
|
+
let(:scss) { <<-SCSS }
|
157
|
+
p {
|
158
|
+
property: (value );
|
159
|
+
}
|
160
|
+
SCSS
|
161
|
+
|
162
|
+
it { should report_lint line: 2 }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'when neither parens are space padded' do
|
166
|
+
let(:scss) { <<-SCSS }
|
167
|
+
p {
|
168
|
+
property: (value);
|
169
|
+
}
|
170
|
+
SCSS
|
171
|
+
|
172
|
+
it { should report_lint line: 2, count: 2 }
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'when both parens are space padded' do
|
176
|
+
let(:scss) { <<-SCSS }
|
177
|
+
p {
|
178
|
+
property: ( value );
|
179
|
+
}
|
180
|
+
SCSS
|
181
|
+
|
182
|
+
it { should_not report_lint }
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'when parens are multi-line' do
|
186
|
+
let(:scss) { <<-SCSS }
|
187
|
+
p {
|
188
|
+
property: (
|
189
|
+
value
|
190
|
+
);
|
191
|
+
}
|
192
|
+
SCSS
|
193
|
+
|
194
|
+
it { should_not report_lint }
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when parens are multi-line with tabs' do
|
198
|
+
let(:scss) { <<-SCSS }
|
199
|
+
\t\t\t\tp {
|
200
|
+
\t\t\t\t\tproperty: (
|
201
|
+
\t\t\t\t\t\tvalue
|
202
|
+
\t\t\t\t\t);
|
203
|
+
\t\t\t\t}
|
204
|
+
SCSS
|
205
|
+
|
206
|
+
it { should_not report_lint }
|
207
|
+
end
|
208
|
+
|
209
|
+
context 'when outer parens are space padded' do
|
210
|
+
let(:scss) { <<-SCSS }
|
211
|
+
p {
|
212
|
+
property: fn( fn2(val1, val2) );
|
213
|
+
}
|
214
|
+
SCSS
|
215
|
+
|
216
|
+
it { should report_lint line: 2, count: 2 }
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'when inner parens are space padded' do
|
220
|
+
let(:scss) { <<-SCSS }
|
221
|
+
p {
|
222
|
+
property: fn(fn2( val1, val2 ));
|
223
|
+
}
|
224
|
+
SCSS
|
225
|
+
|
226
|
+
it { should report_lint line: 2, count: 2 }
|
227
|
+
end
|
228
|
+
|
229
|
+
context 'when both parens are not space padded' do
|
230
|
+
let(:scss) { <<-SCSS }
|
231
|
+
p {
|
232
|
+
property: fn(fn2(val1, val2));
|
233
|
+
}
|
234
|
+
SCSS
|
235
|
+
|
236
|
+
it { should report_lint line: 2, count: 4 }
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'when both parens are space padded' do
|
240
|
+
let(:scss) { <<-SCSS }
|
241
|
+
p {
|
242
|
+
property: fn( fn2( val1, val2 ) );
|
243
|
+
}
|
244
|
+
SCSS
|
245
|
+
|
246
|
+
it { should_not report_lint }
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'when multi level parens are multi-line' do
|
250
|
+
let(:scss) { <<-SCSS }
|
251
|
+
p {
|
252
|
+
property: fn(
|
253
|
+
fn2(
|
254
|
+
val1, val2
|
255
|
+
)
|
256
|
+
);
|
257
|
+
}
|
258
|
+
SCSS
|
259
|
+
|
260
|
+
it { should_not report_lint }
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
@@ -0,0 +1,335 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::StringQuotes do
|
4
|
+
context 'when string is written with single quotes' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
p {
|
7
|
+
content: 'hello';
|
8
|
+
}
|
9
|
+
SCSS
|
10
|
+
|
11
|
+
it { should_not report_lint }
|
12
|
+
|
13
|
+
context 'and contains escaped single quotes' do
|
14
|
+
let(:scss) { <<-SCSS }
|
15
|
+
p {
|
16
|
+
content: 'hello \\'world\\'';
|
17
|
+
}
|
18
|
+
SCSS
|
19
|
+
|
20
|
+
it { should report_lint line: 2 }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'and contains single quotes escaped as hex' do
|
24
|
+
let(:scss) { <<-SCSS }
|
25
|
+
p {
|
26
|
+
content: 'hello \\27world\\27';
|
27
|
+
}
|
28
|
+
SCSS
|
29
|
+
|
30
|
+
it { should_not report_lint }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'and contains double quotes' do
|
34
|
+
let(:scss) { <<-SCSS }
|
35
|
+
p {
|
36
|
+
content: 'hello "world"';
|
37
|
+
}
|
38
|
+
SCSS
|
39
|
+
|
40
|
+
it { should_not report_lint }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'and contains interpolation' do
|
44
|
+
let(:scss) { <<-SCSS }
|
45
|
+
p {
|
46
|
+
content: 'hello \#{$world}';
|
47
|
+
}
|
48
|
+
SCSS
|
49
|
+
|
50
|
+
it { should_not report_lint }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when @import uses single quotes' do
|
55
|
+
let(:scss) { "@import 'file';" }
|
56
|
+
|
57
|
+
it { should_not report_lint }
|
58
|
+
|
59
|
+
context 'and has no trailing semicolon' do
|
60
|
+
let(:scss) { "@import 'file'\n" }
|
61
|
+
|
62
|
+
it { should_not report_lint }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when @charset uses single quotes' do
|
67
|
+
let(:scss) { "@charset 'UTF-8';" }
|
68
|
+
|
69
|
+
it { should_not report_lint }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when string is written with double quotes' do
|
73
|
+
let(:scss) { <<-SCSS }
|
74
|
+
p {
|
75
|
+
content: "hello";
|
76
|
+
}
|
77
|
+
SCSS
|
78
|
+
|
79
|
+
it { should report_lint line: 2 }
|
80
|
+
|
81
|
+
context 'and contains escaped double quotes' do
|
82
|
+
let(:scss) { <<-SCSS }
|
83
|
+
p {
|
84
|
+
content: "hello \\"world\\"";
|
85
|
+
}
|
86
|
+
SCSS
|
87
|
+
|
88
|
+
it { should report_lint line: 2 }
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'and contains double quotes escaped as hex' do
|
92
|
+
let(:scss) { <<-SCSS }
|
93
|
+
p {
|
94
|
+
content: "hello \\22world\\22";
|
95
|
+
}
|
96
|
+
SCSS
|
97
|
+
|
98
|
+
it { should report_lint line: 2 }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'and contains single quotes' do
|
102
|
+
let(:scss) { <<-SCSS }
|
103
|
+
p {
|
104
|
+
content: "hello 'world'";
|
105
|
+
}
|
106
|
+
SCSS
|
107
|
+
|
108
|
+
it { should_not report_lint }
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'and contains interpolation' do
|
112
|
+
let(:scss) { <<-SCSS }
|
113
|
+
p {
|
114
|
+
content: "hello \#{$world}"
|
115
|
+
}
|
116
|
+
SCSS
|
117
|
+
|
118
|
+
it { should_not report_lint }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when @import uses double quotes' do
|
123
|
+
let(:scss) { '@import "file";' }
|
124
|
+
|
125
|
+
it { should report_lint }
|
126
|
+
|
127
|
+
context 'and has no trailing semicolon' do
|
128
|
+
let(:scss) { '@import "file"' }
|
129
|
+
|
130
|
+
it { should report_lint }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'when @charset uses double quotes' do
|
135
|
+
let(:scss) { '@charset "UTF-8";' }
|
136
|
+
|
137
|
+
it { should report_lint }
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when property has a literal identifier' do
|
141
|
+
let(:scss) { <<-SCSS }
|
142
|
+
p {
|
143
|
+
display: none;
|
144
|
+
}
|
145
|
+
SCSS
|
146
|
+
|
147
|
+
it { should_not report_lint }
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'when property is a URL with single quotes' do
|
151
|
+
let(:scss) { <<-SCSS }
|
152
|
+
p {
|
153
|
+
background: url('image.png');
|
154
|
+
}
|
155
|
+
SCSS
|
156
|
+
|
157
|
+
it { should_not report_lint }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'when property is a URL with double quotes' do
|
161
|
+
let(:scss) { <<-SCSS }
|
162
|
+
p {
|
163
|
+
background: url("image.png");
|
164
|
+
}
|
165
|
+
SCSS
|
166
|
+
|
167
|
+
it { should report_lint line: 2 }
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'when Sass script is written in a non-silent comment' do
|
171
|
+
let(:scss) { <<-SCSS }
|
172
|
+
/**
|
173
|
+
* .thing-\#{$key} {
|
174
|
+
* color: \#{value}
|
175
|
+
* }
|
176
|
+
*/
|
177
|
+
SCSS
|
178
|
+
|
179
|
+
it { should_not report_lint }
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'when the configuration has been set to prefer double quotes' do
|
183
|
+
let(:linter_config) { { 'style' => 'double_quotes' } }
|
184
|
+
|
185
|
+
context 'and string is written with single quotes' do
|
186
|
+
let(:scss) { <<-SCSS }
|
187
|
+
p {
|
188
|
+
content: 'hello';
|
189
|
+
}
|
190
|
+
SCSS
|
191
|
+
|
192
|
+
it { should report_lint line: 2 }
|
193
|
+
|
194
|
+
context 'and contains escaped single quotes' do
|
195
|
+
let(:scss) { <<-SCSS }
|
196
|
+
p {
|
197
|
+
content: 'hello \\'world\\'';
|
198
|
+
}
|
199
|
+
SCSS
|
200
|
+
|
201
|
+
it { should report_lint line: 2 }
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'and contains single quotes escaped as hex' do
|
205
|
+
let(:scss) { <<-SCSS }
|
206
|
+
p {
|
207
|
+
content: 'hello \\27world\\27';
|
208
|
+
}
|
209
|
+
SCSS
|
210
|
+
|
211
|
+
it { should report_lint line: 2 }
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'and contains double quotes' do
|
215
|
+
let(:scss) { <<-SCSS }
|
216
|
+
p {
|
217
|
+
content: 'hello "world"';
|
218
|
+
}
|
219
|
+
SCSS
|
220
|
+
|
221
|
+
it { should_not report_lint }
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'and contains interpolation' do
|
225
|
+
let(:scss) { <<-SCSS }
|
226
|
+
p {
|
227
|
+
content: 'hello \#{$world}';
|
228
|
+
}
|
229
|
+
SCSS
|
230
|
+
|
231
|
+
it { should_not report_lint }
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'and contains interpolation inside a substring with single quotes' do
|
235
|
+
let(:scss) { <<-SCSS }
|
236
|
+
p {
|
237
|
+
content: "<svg width='\#{$something}'>";
|
238
|
+
}
|
239
|
+
SCSS
|
240
|
+
|
241
|
+
it { should_not report_lint }
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'and contains a single-quoted string inside interpolation' do
|
245
|
+
let(:scss) { <<-SCSS }
|
246
|
+
p {
|
247
|
+
content: "<svg width='\#{func('hello')}'>";
|
248
|
+
}
|
249
|
+
SCSS
|
250
|
+
|
251
|
+
it { should report_lint }
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context 'and string is written with double quotes' do
|
256
|
+
let(:scss) { <<-SCSS }
|
257
|
+
p {
|
258
|
+
content: "hello";
|
259
|
+
}
|
260
|
+
SCSS
|
261
|
+
|
262
|
+
it { should_not report_lint }
|
263
|
+
|
264
|
+
context 'and contains escaped double quotes' do
|
265
|
+
let(:scss) { <<-SCSS }
|
266
|
+
p {
|
267
|
+
content: "hello \\"world\\"";
|
268
|
+
}
|
269
|
+
SCSS
|
270
|
+
|
271
|
+
it { should report_lint line: 2 }
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'and contains double quotes escaped as hex' do
|
275
|
+
let(:scss) { <<-SCSS }
|
276
|
+
p {
|
277
|
+
content: "hello \\22world\\22";
|
278
|
+
}
|
279
|
+
SCSS
|
280
|
+
|
281
|
+
it { should_not report_lint }
|
282
|
+
end
|
283
|
+
|
284
|
+
context 'and contains single quotes' do
|
285
|
+
let(:scss) { <<-SCSS }
|
286
|
+
p {
|
287
|
+
content: "hello 'world'";
|
288
|
+
}
|
289
|
+
SCSS
|
290
|
+
|
291
|
+
it { should_not report_lint }
|
292
|
+
end
|
293
|
+
|
294
|
+
context 'and contains interpolation' do
|
295
|
+
let(:scss) { <<-SCSS }
|
296
|
+
p {
|
297
|
+
content: "hello \#{$world}";
|
298
|
+
}
|
299
|
+
SCSS
|
300
|
+
|
301
|
+
it { should_not report_lint }
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
context 'when property has a literal identifier' do
|
306
|
+
let(:scss) { <<-SCSS }
|
307
|
+
p {
|
308
|
+
display: none;
|
309
|
+
}
|
310
|
+
SCSS
|
311
|
+
|
312
|
+
it { should_not report_lint }
|
313
|
+
end
|
314
|
+
|
315
|
+
context 'when property is a URL with single quotes' do
|
316
|
+
let(:scss) { <<-SCSS }
|
317
|
+
p {
|
318
|
+
background: url('image.png');
|
319
|
+
}
|
320
|
+
SCSS
|
321
|
+
|
322
|
+
it { should report_lint line: 2 }
|
323
|
+
end
|
324
|
+
|
325
|
+
context 'when property is a URL with double quotes' do
|
326
|
+
let(:scss) { <<-SCSS }
|
327
|
+
p {
|
328
|
+
background: url("image.png");
|
329
|
+
}
|
330
|
+
SCSS
|
331
|
+
|
332
|
+
it { should_not report_lint }
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|