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,114 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::NestingDepth do
|
4
|
+
context 'and selectors are nested up to depth 3' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
.one {
|
7
|
+
.two {
|
8
|
+
.three {
|
9
|
+
background: #f00;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
SCSS
|
14
|
+
|
15
|
+
it { should_not report_lint }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'and selectors are nested greater than depth 3' do
|
19
|
+
let(:scss) { <<-SCSS }
|
20
|
+
.one {
|
21
|
+
.two {
|
22
|
+
.three {
|
23
|
+
.four {
|
24
|
+
background: #f00;
|
25
|
+
}
|
26
|
+
.four-other {
|
27
|
+
background: #f00;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
SCSS
|
33
|
+
|
34
|
+
it { should report_lint line: 4 }
|
35
|
+
it { should report_lint line: 7 }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when max_depth is set to 1' do
|
39
|
+
let(:linter_config) { { 'max_depth' => 1 } }
|
40
|
+
|
41
|
+
context 'when nesting has a depth of one' do
|
42
|
+
let(:scss) { <<-SCSS }
|
43
|
+
.one {
|
44
|
+
font-style: italic;
|
45
|
+
}
|
46
|
+
SCSS
|
47
|
+
|
48
|
+
it { should_not report_lint }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when nesting has a depth of two' do
|
52
|
+
let(:scss) { <<-SCSS }
|
53
|
+
.one {
|
54
|
+
.two {
|
55
|
+
font-style: italic;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
.one {
|
59
|
+
font-style: italic;
|
60
|
+
}
|
61
|
+
SCSS
|
62
|
+
|
63
|
+
it { should report_lint line: 2 }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when nesting has a depth of three' do
|
67
|
+
let(:scss) { <<-SCSS }
|
68
|
+
.one {
|
69
|
+
.two {
|
70
|
+
.three {
|
71
|
+
background: #f00;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
.two-other {
|
75
|
+
font-style: italic;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
SCSS
|
79
|
+
|
80
|
+
it { should report_lint line: 2 }
|
81
|
+
it { should report_lint line: 7 }
|
82
|
+
it { should_not report_lint line: 3 }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when nesting properties' do
|
86
|
+
let(:scss) { <<-SCSS }
|
87
|
+
.one {
|
88
|
+
font: {
|
89
|
+
family: monospace;
|
90
|
+
style: italic;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
SCSS
|
94
|
+
|
95
|
+
it { should_not report_lint }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when sequence contains a @keyframe' do
|
99
|
+
let(:scss) { <<-SCSS }
|
100
|
+
@keyframe my-keyframe {
|
101
|
+
0% {
|
102
|
+
background: #000;
|
103
|
+
}
|
104
|
+
|
105
|
+
50% {
|
106
|
+
background: #fff;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
SCSS
|
110
|
+
|
111
|
+
it { should_not report_lint }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::PlaceholderInExtend do
|
4
|
+
context 'when extending with a class' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
p {
|
7
|
+
@extend .error;
|
8
|
+
}
|
9
|
+
SCSS
|
10
|
+
|
11
|
+
it { should report_lint line: 2 }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when extending with a type' do
|
15
|
+
let(:scss) { <<-SCSS }
|
16
|
+
p {
|
17
|
+
@extend span;
|
18
|
+
}
|
19
|
+
SCSS
|
20
|
+
|
21
|
+
it { should report_lint line: 2 }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when extending with an id' do
|
25
|
+
let(:scss) { <<-SCSS }
|
26
|
+
p {
|
27
|
+
@extend #some-identifer;
|
28
|
+
}
|
29
|
+
SCSS
|
30
|
+
|
31
|
+
it { should report_lint line: 2 }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when extending with a placeholder' do
|
35
|
+
let(:scss) { <<-SCSS }
|
36
|
+
p {
|
37
|
+
@extend %placeholder;
|
38
|
+
}
|
39
|
+
SCSS
|
40
|
+
|
41
|
+
it { should_not report_lint }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when extending with a selector whose prefix is not a placeholder' do
|
45
|
+
let(:scss) { <<-SCSS }
|
46
|
+
p {
|
47
|
+
@extend .blah-\#{$dynamically_generated_name};
|
48
|
+
}
|
49
|
+
SCSS
|
50
|
+
|
51
|
+
it { should report_lint line: 2 }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when extending with a selector whose prefix is dynamic' do
|
55
|
+
let(:scss) { <<-SCSS }
|
56
|
+
p {
|
57
|
+
@extend \#{$dynamically_generated_placeholder_name};
|
58
|
+
}
|
59
|
+
SCSS
|
60
|
+
|
61
|
+
it { should_not report_lint }
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::PropertyCount do
|
4
|
+
let(:linter_config) { { 'max_properties' => 3 } }
|
5
|
+
|
6
|
+
context 'when the number of properties in each individual rule set is under the limit' do
|
7
|
+
let(:scss) { <<-SCSS }
|
8
|
+
p {
|
9
|
+
margin: 0;
|
10
|
+
padding: 0;
|
11
|
+
float: left;
|
12
|
+
|
13
|
+
a {
|
14
|
+
color: #f00;
|
15
|
+
text-decoration: none;
|
16
|
+
text-transform: uppercase;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
i {
|
21
|
+
color: #000;
|
22
|
+
text-decoration: underline;
|
23
|
+
text-transform: lowercase;
|
24
|
+
}
|
25
|
+
SCSS
|
26
|
+
|
27
|
+
it { should_not report_lint }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the number of properties in an individual rule set is over the limit' do
|
31
|
+
let(:scss) { <<-SCSS }
|
32
|
+
p {
|
33
|
+
margin: 0;
|
34
|
+
padding: 0;
|
35
|
+
float: left;
|
36
|
+
|
37
|
+
a {
|
38
|
+
color: #f00;
|
39
|
+
font: 15px arial, sans-serif;
|
40
|
+
text-decoration: none;
|
41
|
+
text-transform: uppercase;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
i {
|
46
|
+
color: #000;
|
47
|
+
text-decoration: underline;
|
48
|
+
text-transform: lowercase;
|
49
|
+
}
|
50
|
+
SCSS
|
51
|
+
|
52
|
+
it { should_not report_lint line: 1 }
|
53
|
+
it { should report_lint line: 6 }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when nested rule sets are included in the count' do
|
57
|
+
let(:linter_config) { super().merge('include_nested' => true) }
|
58
|
+
|
59
|
+
context 'when the number of total nested properties under the limit' do
|
60
|
+
let(:scss) { <<-SCSS }
|
61
|
+
p {
|
62
|
+
margin: 0;
|
63
|
+
|
64
|
+
a {
|
65
|
+
color: #f00;
|
66
|
+
text-transform: uppercase;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
i {
|
71
|
+
color: #000;
|
72
|
+
text-decoration: underline;
|
73
|
+
text-transform: lowercase;
|
74
|
+
}
|
75
|
+
SCSS
|
76
|
+
|
77
|
+
it { should_not report_lint }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when the number of total nested properties is over the limit' do
|
81
|
+
let(:scss) { <<-SCSS }
|
82
|
+
p {
|
83
|
+
margin: 0;
|
84
|
+
padding: 0;
|
85
|
+
|
86
|
+
a {
|
87
|
+
color: #f00;
|
88
|
+
text-decoration: none;
|
89
|
+
text-transform: uppercase;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
i {
|
94
|
+
color: #000;
|
95
|
+
text-decoration: underline;
|
96
|
+
text-transform: lowercase;
|
97
|
+
}
|
98
|
+
SCSS
|
99
|
+
|
100
|
+
it { should report_lint line: 1 }
|
101
|
+
it { should_not report_lint line: 12 }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,426 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::PropertySortOrder 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 properties in sorted order' do
|
14
|
+
let(:scss) { <<-SCSS }
|
15
|
+
p {
|
16
|
+
background: #000;
|
17
|
+
display: none;
|
18
|
+
margin: 5px;
|
19
|
+
padding: 10px;
|
20
|
+
}
|
21
|
+
SCSS
|
22
|
+
|
23
|
+
it { should_not report_lint }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when rule contains mixins followed by properties in sorted order' do
|
27
|
+
let(:scss) { <<-SCSS }
|
28
|
+
p {
|
29
|
+
@include border-radius(5px);
|
30
|
+
background: #000;
|
31
|
+
display: none;
|
32
|
+
margin: 5px;
|
33
|
+
padding: 10px;
|
34
|
+
}
|
35
|
+
SCSS
|
36
|
+
|
37
|
+
it { should_not report_lint }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when rule contains nested rules after sorted properties' do
|
41
|
+
let(:scss) { <<-SCSS }
|
42
|
+
p {
|
43
|
+
background: #000;
|
44
|
+
display: none;
|
45
|
+
margin: 5px;
|
46
|
+
padding: 10px;
|
47
|
+
a {
|
48
|
+
color: #555;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
SCSS
|
52
|
+
|
53
|
+
it { should_not report_lint }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when rule contains properties in random order' do
|
57
|
+
let(:scss) { <<-SCSS }
|
58
|
+
p {
|
59
|
+
padding: 5px;
|
60
|
+
display: block;
|
61
|
+
margin: 10px;
|
62
|
+
}
|
63
|
+
SCSS
|
64
|
+
|
65
|
+
it { should report_lint line: 2 }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when there are multiple rules with out of order properties' do
|
69
|
+
let(:scss) { <<-SCSS }
|
70
|
+
p {
|
71
|
+
display: block;
|
72
|
+
background: #fff;
|
73
|
+
}
|
74
|
+
a {
|
75
|
+
margin: 5px;
|
76
|
+
color: #444;
|
77
|
+
}
|
78
|
+
SCSS
|
79
|
+
|
80
|
+
it { should report_lint line: 2 }
|
81
|
+
it { should report_lint line: 6 }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when there are nested rules with out of order properties' do
|
85
|
+
let(:scss) { <<-SCSS }
|
86
|
+
p {
|
87
|
+
display: block;
|
88
|
+
background: #fff;
|
89
|
+
a {
|
90
|
+
margin: 5px;
|
91
|
+
color: #444;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
SCSS
|
95
|
+
|
96
|
+
it { should report_lint line: 2 }
|
97
|
+
it { should report_lint line: 5 }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when out-of-order property is the second last in the list of sorted properties' do
|
101
|
+
let(:scss) { <<-SCSS }
|
102
|
+
p {
|
103
|
+
border: 0;
|
104
|
+
border-radius: 3px;
|
105
|
+
float: left;
|
106
|
+
display: block;
|
107
|
+
}
|
108
|
+
SCSS
|
109
|
+
|
110
|
+
it { should report_lint line: 4 }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when vendor-prefixed properties are ordered after the non-prefixed property' do
|
114
|
+
let(:scss) { <<-SCSS }
|
115
|
+
p {
|
116
|
+
border-radius: 3px;
|
117
|
+
-moz-border-radius: 3px;
|
118
|
+
-o-border-radius: 3px;
|
119
|
+
-webkit-border-radius: 3px;
|
120
|
+
}
|
121
|
+
SCSS
|
122
|
+
|
123
|
+
it { should report_lint line: 2 }
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when vendor-prefixed properties are ordered before the non-prefixed property' do
|
127
|
+
let(:scss) { <<-SCSS }
|
128
|
+
p {
|
129
|
+
-moz-border-radius: 3px;
|
130
|
+
-o-border-radius: 3px;
|
131
|
+
-webkit-border-radius: 3px;
|
132
|
+
border-radius: 3px;
|
133
|
+
}
|
134
|
+
SCSS
|
135
|
+
|
136
|
+
it { should_not report_lint }
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when using -moz-osx vendor-prefixed property' do
|
140
|
+
let(:scss) { <<-SCSS }
|
141
|
+
p {
|
142
|
+
-moz-osx-font-smoothing: grayscale;
|
143
|
+
-webkit-font-smoothing: antialiased;
|
144
|
+
}
|
145
|
+
SCSS
|
146
|
+
|
147
|
+
it { should_not report_lint }
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'when vendor properties are ordered out-of-order before the non-prefixed property' do
|
151
|
+
let(:scss) { <<-SCSS }
|
152
|
+
p {
|
153
|
+
-moz-border-radius: 3px;
|
154
|
+
-webkit-border-radius: 3px;
|
155
|
+
-o-border-radius: 3px;
|
156
|
+
border-radius: 3px;
|
157
|
+
}
|
158
|
+
SCSS
|
159
|
+
|
160
|
+
it { should report_lint line: 3 }
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'when include block contains properties in sorted order' do
|
164
|
+
let(:scss) { <<-SCSS }
|
165
|
+
@include some-mixin {
|
166
|
+
background: #000;
|
167
|
+
display: none;
|
168
|
+
margin: 5px;
|
169
|
+
padding: 10px;
|
170
|
+
}
|
171
|
+
SCSS
|
172
|
+
|
173
|
+
it { should_not report_lint }
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'when include block contains properties not in sorted order' do
|
177
|
+
let(:scss) { <<-SCSS }
|
178
|
+
@include some-mixin {
|
179
|
+
background: #000;
|
180
|
+
margin: 5px;
|
181
|
+
display: none;
|
182
|
+
}
|
183
|
+
SCSS
|
184
|
+
|
185
|
+
it { should report_lint line: 3 }
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'when @media block contains properties not in sorted order' do
|
189
|
+
let(:scss) { <<-SCSS }
|
190
|
+
@media screen and (min-width: 500px) {
|
191
|
+
margin: 5px;
|
192
|
+
display: none;
|
193
|
+
}
|
194
|
+
SCSS
|
195
|
+
|
196
|
+
it { should report_lint line: 2 }
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'when if block contains properties in sorted order' do
|
200
|
+
let(:scss) { <<-SCSS }
|
201
|
+
@if $var {
|
202
|
+
background: #000;
|
203
|
+
display: none;
|
204
|
+
margin: 5px;
|
205
|
+
padding: 10px;
|
206
|
+
}
|
207
|
+
SCSS
|
208
|
+
|
209
|
+
it { should_not report_lint }
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'when if block contains properties not in sorted order' do
|
213
|
+
let(:scss) { <<-SCSS }
|
214
|
+
@if $var {
|
215
|
+
background: #000;
|
216
|
+
margin: 5px;
|
217
|
+
display: none;
|
218
|
+
}
|
219
|
+
SCSS
|
220
|
+
|
221
|
+
it { should report_lint line: 3 }
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'when if block contains properties in sorted order' do
|
225
|
+
let(:scss) { <<-SCSS }
|
226
|
+
@if $var {
|
227
|
+
// Content
|
228
|
+
} @else {
|
229
|
+
background: #000;
|
230
|
+
display: none;
|
231
|
+
margin: 5px;
|
232
|
+
padding: 10px;
|
233
|
+
}
|
234
|
+
SCSS
|
235
|
+
|
236
|
+
it { should_not report_lint }
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'when else block contains properties not in sorted order' do
|
240
|
+
let(:scss) { <<-SCSS }
|
241
|
+
@if $var {
|
242
|
+
// Content
|
243
|
+
} @else {
|
244
|
+
background: #000;
|
245
|
+
margin: 5px;
|
246
|
+
display: none;
|
247
|
+
}
|
248
|
+
SCSS
|
249
|
+
|
250
|
+
it { should report_lint line: 5 }
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'when the order has been explicitly set' do
|
254
|
+
let(:linter_config) { { 'order' => %w[position display padding margin width] } }
|
255
|
+
|
256
|
+
context 'and the properties match the specified order' do
|
257
|
+
let(:scss) { <<-SCSS }
|
258
|
+
p {
|
259
|
+
display: block;
|
260
|
+
padding: 5px;
|
261
|
+
margin: 10px;
|
262
|
+
}
|
263
|
+
SCSS
|
264
|
+
|
265
|
+
it { should_not report_lint }
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'and the properties do not match the specified order' do
|
269
|
+
let(:scss) { <<-SCSS }
|
270
|
+
p {
|
271
|
+
padding: 5px;
|
272
|
+
display: block;
|
273
|
+
margin: 10px;
|
274
|
+
}
|
275
|
+
SCSS
|
276
|
+
|
277
|
+
it { should report_lint line: 2 }
|
278
|
+
end
|
279
|
+
|
280
|
+
context 'and there are properties that are not specified in the explicit ordering' do
|
281
|
+
let(:scss) { <<-SCSS }
|
282
|
+
p {
|
283
|
+
display: block;
|
284
|
+
padding: 5px;
|
285
|
+
font-weight: bold; // Unspecified
|
286
|
+
margin: 10px;
|
287
|
+
border: 0; // Unspecified
|
288
|
+
background: red; // Unspecified
|
289
|
+
width: 100%;
|
290
|
+
}
|
291
|
+
SCSS
|
292
|
+
|
293
|
+
context 'and the ignore_unspecified option is enabled' do
|
294
|
+
let(:linter_config) { super().merge('ignore_unspecified' => true) }
|
295
|
+
|
296
|
+
it { should_not report_lint }
|
297
|
+
end
|
298
|
+
|
299
|
+
context 'and the ignore_unspecified option is disabled' do
|
300
|
+
let(:linter_config) { super().merge('ignore_unspecified' => false) }
|
301
|
+
|
302
|
+
it { should report_lint }
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context 'when sort order is set to a preset order' do
|
308
|
+
let(:linter_config) { { 'order' => 'concentric' } }
|
309
|
+
|
310
|
+
context 'and the properties match the order' do
|
311
|
+
let(:scss) { <<-SCSS }
|
312
|
+
p {
|
313
|
+
display: block;
|
314
|
+
position: absolute;
|
315
|
+
float: left;
|
316
|
+
clear: both;
|
317
|
+
}
|
318
|
+
SCSS
|
319
|
+
|
320
|
+
it { should_not report_lint }
|
321
|
+
end
|
322
|
+
|
323
|
+
context 'and the properties do not match the order' do
|
324
|
+
let(:scss) { <<-SCSS }
|
325
|
+
p {
|
326
|
+
clear: both;
|
327
|
+
display: block;
|
328
|
+
float: left;
|
329
|
+
position: absolute;
|
330
|
+
}
|
331
|
+
SCSS
|
332
|
+
|
333
|
+
it { should report_lint }
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
context 'when separation between groups of properties is enforced' do
|
338
|
+
let(:order) do
|
339
|
+
%w[display position top right bottom left] + [nil] +
|
340
|
+
%w[width height margin padding] + [nil] +
|
341
|
+
%w[float clear]
|
342
|
+
end
|
343
|
+
|
344
|
+
let(:linter_config) { { 'separate_groups' => true, 'order' => order } }
|
345
|
+
|
346
|
+
context 'and the groups are separated correctly' do
|
347
|
+
let(:scss) { <<-SCSS }
|
348
|
+
p {
|
349
|
+
display: none;
|
350
|
+
position: absolute;
|
351
|
+
|
352
|
+
margin: 0;
|
353
|
+
padding: 0;
|
354
|
+
|
355
|
+
float: left;
|
356
|
+
}
|
357
|
+
SCSS
|
358
|
+
|
359
|
+
it { should_not report_lint }
|
360
|
+
end
|
361
|
+
|
362
|
+
context 'and the groups are separated incorrectly' do
|
363
|
+
let(:scss) { <<-SCSS }
|
364
|
+
p {
|
365
|
+
display: none;
|
366
|
+
position: absolute;
|
367
|
+
margin: 0;
|
368
|
+
|
369
|
+
padding: 0;
|
370
|
+
|
371
|
+
float: left;
|
372
|
+
}
|
373
|
+
SCSS
|
374
|
+
|
375
|
+
it { should report_lint line: 4 }
|
376
|
+
end
|
377
|
+
|
378
|
+
context 'and the groups are separated by a comment' do
|
379
|
+
let(:scss) { <<-SCSS }
|
380
|
+
p {
|
381
|
+
display: none;
|
382
|
+
position: absolute;
|
383
|
+
//
|
384
|
+
margin: 0;
|
385
|
+
padding: 0;
|
386
|
+
//
|
387
|
+
float: left;
|
388
|
+
}
|
389
|
+
SCSS
|
390
|
+
|
391
|
+
it { should_not report_lint }
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'when the sort order has multiple gaps separating two groups' do
|
395
|
+
let(:order) { %w[display position] + [nil, nil] + %w[margin padding] }
|
396
|
+
|
397
|
+
context 'and the groups are separated correctly' do
|
398
|
+
let(:scss) { <<-SCSS }
|
399
|
+
p {
|
400
|
+
display: none;
|
401
|
+
position: absolute;
|
402
|
+
|
403
|
+
margin: 0;
|
404
|
+
padding: 0;
|
405
|
+
}
|
406
|
+
SCSS
|
407
|
+
|
408
|
+
it { should_not report_lint }
|
409
|
+
end
|
410
|
+
|
411
|
+
context 'and the groups are separated incorrectly' do
|
412
|
+
let(:scss) { <<-SCSS }
|
413
|
+
p {
|
414
|
+
display: none;
|
415
|
+
position: absolute;
|
416
|
+
margin: 0;
|
417
|
+
|
418
|
+
padding: 0;
|
419
|
+
}
|
420
|
+
SCSS
|
421
|
+
|
422
|
+
it { should report_lint line: 4 }
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|