scss_lint 0.38.0
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 +7 -0
- data/bin/scss-lint +6 -0
- data/config/default.yml +205 -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/border_zero.rb +39 -0
- data/lib/scss_lint/linter/color_keyword.rb +32 -0
- data/lib/scss_lint/linter/color_variable.rb +60 -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 +198 -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 +92 -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/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 +155 -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 +482 -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 +373 -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 +328 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe SCSSLint::Linter::TrailingSemicolon do
|
|
6
|
+
context 'when a property does not end with a semicolon' do
|
|
7
|
+
let(:scss) { <<-SCSS }
|
|
8
|
+
p {
|
|
9
|
+
margin: 0
|
|
10
|
+
}
|
|
11
|
+
SCSS
|
|
12
|
+
|
|
13
|
+
it { should report_lint line: 2 }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'when a property ends with a semicolon' do
|
|
17
|
+
let(:scss) { <<-SCSS }
|
|
18
|
+
p {
|
|
19
|
+
margin: 0;
|
|
20
|
+
}
|
|
21
|
+
SCSS
|
|
22
|
+
|
|
23
|
+
it { should_not report_lint }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'when a property ends with a space followed by a semicolon' do
|
|
27
|
+
let(:scss) { <<-SCSS }
|
|
28
|
+
p {
|
|
29
|
+
margin: 0 ;
|
|
30
|
+
}
|
|
31
|
+
SCSS
|
|
32
|
+
|
|
33
|
+
it { should report_lint line: 2 }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'when a property ends with a semicolon and is followed by a comment' do
|
|
37
|
+
let(:scss) { <<-SCSS }
|
|
38
|
+
p {
|
|
39
|
+
margin: 0; // This is a comment
|
|
40
|
+
padding: 0; /* This is another comment */
|
|
41
|
+
}
|
|
42
|
+
SCSS
|
|
43
|
+
|
|
44
|
+
it { should_not report_lint }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when a property contains nested properties' do
|
|
48
|
+
context 'and there is a value on the namespace' do
|
|
49
|
+
let(:scss) { <<-SCSS }
|
|
50
|
+
p {
|
|
51
|
+
font: 2px/3px {
|
|
52
|
+
style: italic;
|
|
53
|
+
weight: bold;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
SCSS
|
|
57
|
+
|
|
58
|
+
it { should_not report_lint }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context 'and there is no value on the namespace' do
|
|
62
|
+
let(:scss) { <<-SCSS }
|
|
63
|
+
p {
|
|
64
|
+
font: {
|
|
65
|
+
style: italic;
|
|
66
|
+
weight: bold;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
SCSS
|
|
70
|
+
|
|
71
|
+
it { should_not report_lint }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context 'when a nested property does not end with a semicolon' do
|
|
76
|
+
let(:scss) { <<-SCSS }
|
|
77
|
+
p {
|
|
78
|
+
font: {
|
|
79
|
+
weight: bold
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
SCSS
|
|
83
|
+
|
|
84
|
+
it { should report_lint line: 3 }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'when a multi-line property ends with a semicolon' do
|
|
88
|
+
let(:scss) { <<-SCSS }
|
|
89
|
+
p {
|
|
90
|
+
background:
|
|
91
|
+
top repeat-x url('top-image.jpg'),
|
|
92
|
+
right repeat-y url('right-image.jpg'),
|
|
93
|
+
bottom repeat-x url('bottom-image.jpg'),
|
|
94
|
+
left repeat-y url('left-image.jpg');
|
|
95
|
+
}
|
|
96
|
+
SCSS
|
|
97
|
+
|
|
98
|
+
it { should_not report_lint }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context 'when a multi-line property does not end with a semicolon' do
|
|
102
|
+
let(:scss) { <<-SCSS }
|
|
103
|
+
p {
|
|
104
|
+
background:
|
|
105
|
+
top repeat-x url('top-image.jpg'),
|
|
106
|
+
right repeat-y url('right-image.jpg'),
|
|
107
|
+
bottom repeat-x url('bottom-image.jpg'),
|
|
108
|
+
left repeat-y url('left-image.jpg')
|
|
109
|
+
}
|
|
110
|
+
SCSS
|
|
111
|
+
|
|
112
|
+
it { should report_lint line: 2 }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context 'when a oneline rule does not end with a semicolon' do
|
|
116
|
+
let(:scss) { <<-SCSS }
|
|
117
|
+
.foo { border: 0 }
|
|
118
|
+
SCSS
|
|
119
|
+
|
|
120
|
+
it { should report_lint line: 1 }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
context 'when a oneline rule has a space before a semicolon' do
|
|
124
|
+
let(:scss) { <<-SCSS }
|
|
125
|
+
.foo { border: 0 ; }
|
|
126
|
+
SCSS
|
|
127
|
+
|
|
128
|
+
it { should report_lint line: 1 }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
context 'when @extend does not end with a semicolon' do
|
|
132
|
+
let(:scss) { <<-SCSS }
|
|
133
|
+
.foo {
|
|
134
|
+
@extend %bar
|
|
135
|
+
}
|
|
136
|
+
SCSS
|
|
137
|
+
|
|
138
|
+
it { should report_lint line: 2 }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
context 'when @extend ends with a semicolon' do
|
|
142
|
+
let(:scss) { <<-SCSS }
|
|
143
|
+
.foo {
|
|
144
|
+
@extend %bar;
|
|
145
|
+
}
|
|
146
|
+
SCSS
|
|
147
|
+
|
|
148
|
+
it { should_not report_lint }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
context 'when @include does not end with a semicolon' do
|
|
152
|
+
let(:scss) { <<-SCSS }
|
|
153
|
+
.foo {
|
|
154
|
+
@include bar
|
|
155
|
+
}
|
|
156
|
+
SCSS
|
|
157
|
+
|
|
158
|
+
it { should report_lint line: 2 }
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
context 'when @include takes a block' do
|
|
162
|
+
let(:scss) { <<-SCSS }
|
|
163
|
+
.foo {
|
|
164
|
+
@include bar {
|
|
165
|
+
border: 0;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
SCSS
|
|
169
|
+
|
|
170
|
+
it { should_not report_lint }
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context 'when @include takes a block with nested props' do
|
|
174
|
+
let(:scss) { <<-SCSS }
|
|
175
|
+
.foo {
|
|
176
|
+
@include bar {
|
|
177
|
+
.bar {
|
|
178
|
+
border: 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
SCSS
|
|
183
|
+
|
|
184
|
+
it { should_not report_lint }
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
context 'when @include takes a block with an if-node' do
|
|
188
|
+
let(:scss) { <<-SCSS }
|
|
189
|
+
.foo {
|
|
190
|
+
@include bar {
|
|
191
|
+
@if $var {
|
|
192
|
+
border: 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
SCSS
|
|
197
|
+
|
|
198
|
+
it { should_not report_lint }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
context 'when @include ends with a semicolon' do
|
|
202
|
+
let(:scss) { <<-SCSS }
|
|
203
|
+
.foo {
|
|
204
|
+
@include bar;
|
|
205
|
+
}
|
|
206
|
+
SCSS
|
|
207
|
+
|
|
208
|
+
it { should_not report_lint }
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
context 'when @import ends with a semicolon' do
|
|
212
|
+
let(:scss) { '@import "something";' }
|
|
213
|
+
|
|
214
|
+
it { should_not report_lint }
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
context 'when @import does not end with a semicolon' do
|
|
218
|
+
let(:scss) { '@import "something"' }
|
|
219
|
+
|
|
220
|
+
it { should report_lint line: 1 }
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context 'when @import has a space before a semicolon' do
|
|
224
|
+
let(:scss) { '@import "something" ;' }
|
|
225
|
+
|
|
226
|
+
it { should report_lint line: 1 }
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
context 'when an import directive is split over multiple lines' do
|
|
230
|
+
context 'and is missing the trailing semicolon' do
|
|
231
|
+
let(:scss) { <<-SCSS }
|
|
232
|
+
@import 'functions/strip-units',
|
|
233
|
+
'functions/pc'
|
|
234
|
+
SCSS
|
|
235
|
+
|
|
236
|
+
it { should report_lint }
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
context 'and is not missing the trailing semicolon' do
|
|
240
|
+
let(:scss) { <<-SCSS }
|
|
241
|
+
@import 'functions/strip-units',
|
|
242
|
+
'functions/pc';
|
|
243
|
+
SCSS
|
|
244
|
+
|
|
245
|
+
it { should_not report_lint }
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
context 'when variable declaration does not end with a semicolon' do
|
|
250
|
+
let(:scss) { <<-SCSS }
|
|
251
|
+
.foo {
|
|
252
|
+
$bar: 1
|
|
253
|
+
}
|
|
254
|
+
SCSS
|
|
255
|
+
|
|
256
|
+
it { should report_lint line: 2 }
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
context 'when variable declaration ends with a semicolon' do
|
|
260
|
+
let(:scss) { <<-SCSS }
|
|
261
|
+
.foo {
|
|
262
|
+
$bar: 1;
|
|
263
|
+
}
|
|
264
|
+
SCSS
|
|
265
|
+
|
|
266
|
+
it { should_not report_lint }
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
context 'when variable declaration ends with multiple semicolons' do
|
|
270
|
+
let(:scss) { <<-SCSS }
|
|
271
|
+
.foo {
|
|
272
|
+
$bar: 1;;
|
|
273
|
+
}
|
|
274
|
+
SCSS
|
|
275
|
+
|
|
276
|
+
it { should report_lint line: 2 }
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
context 'when interpolation within single quotes is followed by property' do
|
|
280
|
+
context 'and property has a trailing semicolon' do
|
|
281
|
+
let(:scss) { "[class~='\#{$test}'] { width: 100%; }" }
|
|
282
|
+
|
|
283
|
+
it { should_not report_lint }
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
context 'and property does not have a trailing semicolon' do
|
|
287
|
+
let(:scss) { "[class~='\#{$test}'] { width : 100% }" }
|
|
288
|
+
|
|
289
|
+
it { should report_lint }
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
context 'when triggering a bug based on Windows IBM437 encoding' do
|
|
294
|
+
let(:scss) { <<-SCSS.force_encoding('IBM437') }
|
|
295
|
+
@charset "UTF-8";
|
|
296
|
+
|
|
297
|
+
.foo:before {
|
|
298
|
+
content: '▼';
|
|
299
|
+
}
|
|
300
|
+
SCSS
|
|
301
|
+
|
|
302
|
+
it { should_not report_lint }
|
|
303
|
+
end
|
|
304
|
+
end
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::TrailingZero do
|
|
4
|
+
context 'when no values exist' do
|
|
5
|
+
let(:scss) { 'p {}' }
|
|
6
|
+
|
|
7
|
+
it { should_not report_lint }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context 'when a zero exists' do
|
|
11
|
+
let(:scss) { <<-SCSS }
|
|
12
|
+
p {
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
SCSS
|
|
16
|
+
|
|
17
|
+
it { should_not report_lint }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'when an integer value exists' do
|
|
21
|
+
let(:scss) { <<-SCSS }
|
|
22
|
+
p {
|
|
23
|
+
line-height: 2;
|
|
24
|
+
}
|
|
25
|
+
SCSS
|
|
26
|
+
|
|
27
|
+
it { should_not report_lint }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'when an integer value with units exists' do
|
|
31
|
+
let(:scss) { <<-SCSS }
|
|
32
|
+
p {
|
|
33
|
+
margin: 5px;
|
|
34
|
+
}
|
|
35
|
+
SCSS
|
|
36
|
+
|
|
37
|
+
it { should_not report_lint }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'when a unitless fractional value with no trailing zero exists' do
|
|
41
|
+
let(:scss) { <<-SCSS }
|
|
42
|
+
p {
|
|
43
|
+
line-height: .5;
|
|
44
|
+
}
|
|
45
|
+
SCSS
|
|
46
|
+
|
|
47
|
+
it { should_not report_lint }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'when a negative unitless fractional value with no trailing zero exists' do
|
|
51
|
+
let(:scss) { <<-SCSS }
|
|
52
|
+
p {
|
|
53
|
+
line-height: -.5;
|
|
54
|
+
}
|
|
55
|
+
SCSS
|
|
56
|
+
|
|
57
|
+
it { should_not report_lint }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context 'when a fractional value with units and no trailing zero exists' do
|
|
61
|
+
let(:scss) { <<-SCSS }
|
|
62
|
+
p {
|
|
63
|
+
margin: .5em;
|
|
64
|
+
}
|
|
65
|
+
SCSS
|
|
66
|
+
|
|
67
|
+
it { should_not report_lint }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'when a negative fractional value with units and no trailing zero exists' do
|
|
71
|
+
let(:scss) { <<-SCSS }
|
|
72
|
+
p {
|
|
73
|
+
margin: -.5em;
|
|
74
|
+
}
|
|
75
|
+
SCSS
|
|
76
|
+
|
|
77
|
+
it { should_not report_lint }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context 'when a fractional value with a trailing zero exists' do
|
|
81
|
+
let(:scss) { <<-SCSS }
|
|
82
|
+
p {
|
|
83
|
+
line-height: .50;
|
|
84
|
+
}
|
|
85
|
+
SCSS
|
|
86
|
+
|
|
87
|
+
it { should report_lint line: 2 }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context 'when a fractional value with units and a trailing zero exists' do
|
|
91
|
+
let(:scss) { <<-SCSS }
|
|
92
|
+
p {
|
|
93
|
+
margin: .50em;
|
|
94
|
+
}
|
|
95
|
+
SCSS
|
|
96
|
+
|
|
97
|
+
it { should report_lint line: 2 }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context 'when a negative fractional value with units and a trailing zero exists' do
|
|
101
|
+
let(:scss) { <<-SCSS }
|
|
102
|
+
p {
|
|
103
|
+
margin: -.50em;
|
|
104
|
+
}
|
|
105
|
+
SCSS
|
|
106
|
+
|
|
107
|
+
it { should report_lint line: 2 }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context 'when a fractional value with a mantissa ending in zero exists' do
|
|
111
|
+
let(:scss) { <<-SCSS }
|
|
112
|
+
p {
|
|
113
|
+
line-height: 10.5;
|
|
114
|
+
}
|
|
115
|
+
SCSS
|
|
116
|
+
|
|
117
|
+
it { should_not report_lint }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
context 'when multiple fractional values with trailing zeros exist' do
|
|
121
|
+
let(:scss) { <<-SCSS }
|
|
122
|
+
p {
|
|
123
|
+
margin: 0.50em .50 0.10px .90pt;
|
|
124
|
+
}
|
|
125
|
+
SCSS
|
|
126
|
+
|
|
127
|
+
it { should report_lint count: 4, line: 2 }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
context 'when trailing zeros appear in function arguments' do
|
|
131
|
+
let(:scss) { <<-SCSS }
|
|
132
|
+
p {
|
|
133
|
+
margin: some-function(.50em, 0.40 0.30 .2);
|
|
134
|
+
}
|
|
135
|
+
SCSS
|
|
136
|
+
|
|
137
|
+
it { should report_lint count: 3, line: 2 }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'when trailing zeros appear in mixin arguments' do
|
|
141
|
+
let(:scss) { <<-SCSS }
|
|
142
|
+
p {
|
|
143
|
+
@include some-mixin(0.50em, 0.40 0.30 .2);
|
|
144
|
+
}
|
|
145
|
+
SCSS
|
|
146
|
+
|
|
147
|
+
it { should report_lint count: 3, line: 2 }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
context 'when trailiing zeros appear in variable declarations' do
|
|
151
|
+
let(:scss) { '$some-var: .50em;' }
|
|
152
|
+
|
|
153
|
+
it { should report_lint line: 1 }
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
context 'when trailing zeros appear in named arguments' do
|
|
157
|
+
let(:scss) { <<-SCSS }
|
|
158
|
+
p {
|
|
159
|
+
@include line-clamp($line-height: .90, $line-count: 2);
|
|
160
|
+
}
|
|
161
|
+
SCSS
|
|
162
|
+
|
|
163
|
+
it { should report_lint line: 2 }
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context 'when trailing zeros appear in parameter defaults' do
|
|
167
|
+
let(:scss) { <<-SCSS }
|
|
168
|
+
@mixin my-mixin($bad-value: .50, $good-value: .9, $string-value: ".90") {
|
|
169
|
+
margin: $some-value;
|
|
170
|
+
padding: $some-other-value;
|
|
171
|
+
}
|
|
172
|
+
SCSS
|
|
173
|
+
|
|
174
|
+
it { should report_lint count: 1, line: 1 }
|
|
175
|
+
end
|
|
176
|
+
end
|