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,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,482 @@
|
|
|
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 nested properties in unsorted order' do
|
|
27
|
+
let(:scss) { <<-SCSS }
|
|
28
|
+
p {
|
|
29
|
+
font: {
|
|
30
|
+
family: Arial;
|
|
31
|
+
weight: bold;
|
|
32
|
+
size: 1.2em;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
SCSS
|
|
36
|
+
|
|
37
|
+
it { should report_lint line: 4 }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'when rule contains mixins followed by properties in sorted order' do
|
|
41
|
+
let(:scss) { <<-SCSS }
|
|
42
|
+
p {
|
|
43
|
+
@include border-radius(5px);
|
|
44
|
+
background: #000;
|
|
45
|
+
display: none;
|
|
46
|
+
margin: 5px;
|
|
47
|
+
padding: 10px;
|
|
48
|
+
}
|
|
49
|
+
SCSS
|
|
50
|
+
|
|
51
|
+
it { should_not report_lint }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context 'when rule contains nested rules after sorted properties' do
|
|
55
|
+
let(:scss) { <<-SCSS }
|
|
56
|
+
p {
|
|
57
|
+
background: #000;
|
|
58
|
+
display: none;
|
|
59
|
+
margin: 5px;
|
|
60
|
+
padding: 10px;
|
|
61
|
+
a {
|
|
62
|
+
color: #555;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
SCSS
|
|
66
|
+
|
|
67
|
+
it { should_not report_lint }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'when rule contains properties in random order' do
|
|
71
|
+
let(:scss) { <<-SCSS }
|
|
72
|
+
p {
|
|
73
|
+
padding: 5px;
|
|
74
|
+
display: block;
|
|
75
|
+
margin: 10px;
|
|
76
|
+
}
|
|
77
|
+
SCSS
|
|
78
|
+
|
|
79
|
+
it { should report_lint line: 2 }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'when there are multiple rules with out of order properties' do
|
|
83
|
+
let(:scss) { <<-SCSS }
|
|
84
|
+
p {
|
|
85
|
+
display: block;
|
|
86
|
+
background: #fff;
|
|
87
|
+
}
|
|
88
|
+
a {
|
|
89
|
+
margin: 5px;
|
|
90
|
+
color: #444;
|
|
91
|
+
}
|
|
92
|
+
SCSS
|
|
93
|
+
|
|
94
|
+
it { should report_lint line: 2 }
|
|
95
|
+
it { should report_lint line: 6 }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context 'when there are nested rules with out of order properties' do
|
|
99
|
+
let(:scss) { <<-SCSS }
|
|
100
|
+
p {
|
|
101
|
+
display: block;
|
|
102
|
+
background: #fff;
|
|
103
|
+
a {
|
|
104
|
+
margin: 5px;
|
|
105
|
+
color: #444;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
SCSS
|
|
109
|
+
|
|
110
|
+
it { should report_lint line: 2 }
|
|
111
|
+
it { should report_lint line: 5 }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
context 'when out-of-order property is the second last in the list of sorted properties' do
|
|
115
|
+
let(:scss) { <<-SCSS }
|
|
116
|
+
p {
|
|
117
|
+
border: 0;
|
|
118
|
+
border-radius: 3px;
|
|
119
|
+
float: left;
|
|
120
|
+
display: block;
|
|
121
|
+
}
|
|
122
|
+
SCSS
|
|
123
|
+
|
|
124
|
+
it { should report_lint line: 4 }
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
context 'when vendor-prefixed properties are ordered after the non-prefixed property' do
|
|
128
|
+
let(:scss) { <<-SCSS }
|
|
129
|
+
p {
|
|
130
|
+
border-radius: 3px;
|
|
131
|
+
-moz-border-radius: 3px;
|
|
132
|
+
-o-border-radius: 3px;
|
|
133
|
+
-webkit-border-radius: 3px;
|
|
134
|
+
}
|
|
135
|
+
SCSS
|
|
136
|
+
|
|
137
|
+
it { should report_lint line: 2 }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'when vendor-prefixed properties are ordered before the non-prefixed property' do
|
|
141
|
+
let(:scss) { <<-SCSS }
|
|
142
|
+
p {
|
|
143
|
+
-moz-border-radius: 3px;
|
|
144
|
+
-o-border-radius: 3px;
|
|
145
|
+
-webkit-border-radius: 3px;
|
|
146
|
+
border-radius: 3px;
|
|
147
|
+
}
|
|
148
|
+
SCSS
|
|
149
|
+
|
|
150
|
+
it { should_not report_lint }
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
context 'when using -moz-osx vendor-prefixed property' do
|
|
154
|
+
let(:scss) { <<-SCSS }
|
|
155
|
+
p {
|
|
156
|
+
-moz-osx-font-smoothing: grayscale;
|
|
157
|
+
-webkit-font-smoothing: antialiased;
|
|
158
|
+
}
|
|
159
|
+
SCSS
|
|
160
|
+
|
|
161
|
+
it { should_not report_lint }
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
context 'when vendor properties are ordered out-of-order before the non-prefixed property' do
|
|
165
|
+
let(:scss) { <<-SCSS }
|
|
166
|
+
p {
|
|
167
|
+
-moz-border-radius: 3px;
|
|
168
|
+
-webkit-border-radius: 3px;
|
|
169
|
+
-o-border-radius: 3px;
|
|
170
|
+
border-radius: 3px;
|
|
171
|
+
}
|
|
172
|
+
SCSS
|
|
173
|
+
|
|
174
|
+
it { should report_lint line: 3 }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
context 'when include block contains properties in sorted order' do
|
|
178
|
+
let(:scss) { <<-SCSS }
|
|
179
|
+
@include some-mixin {
|
|
180
|
+
background: #000;
|
|
181
|
+
display: none;
|
|
182
|
+
margin: 5px;
|
|
183
|
+
padding: 10px;
|
|
184
|
+
}
|
|
185
|
+
SCSS
|
|
186
|
+
|
|
187
|
+
it { should_not report_lint }
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
context 'when include block contains properties not in sorted order' do
|
|
191
|
+
let(:scss) { <<-SCSS }
|
|
192
|
+
@include some-mixin {
|
|
193
|
+
background: #000;
|
|
194
|
+
margin: 5px;
|
|
195
|
+
display: none;
|
|
196
|
+
}
|
|
197
|
+
SCSS
|
|
198
|
+
|
|
199
|
+
it { should report_lint line: 3 }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
context 'when @media block contains properties not in sorted order' do
|
|
203
|
+
let(:scss) { <<-SCSS }
|
|
204
|
+
@media screen and (min-width: 500px) {
|
|
205
|
+
margin: 5px;
|
|
206
|
+
display: none;
|
|
207
|
+
}
|
|
208
|
+
SCSS
|
|
209
|
+
|
|
210
|
+
it { should report_lint line: 2 }
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
context 'when if block contains properties in sorted order' do
|
|
214
|
+
let(:scss) { <<-SCSS }
|
|
215
|
+
@if $var {
|
|
216
|
+
background: #000;
|
|
217
|
+
display: none;
|
|
218
|
+
margin: 5px;
|
|
219
|
+
padding: 10px;
|
|
220
|
+
}
|
|
221
|
+
SCSS
|
|
222
|
+
|
|
223
|
+
it { should_not report_lint }
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
context 'when if block contains properties not in sorted order' do
|
|
227
|
+
let(:scss) { <<-SCSS }
|
|
228
|
+
@if $var {
|
|
229
|
+
background: #000;
|
|
230
|
+
margin: 5px;
|
|
231
|
+
display: none;
|
|
232
|
+
}
|
|
233
|
+
SCSS
|
|
234
|
+
|
|
235
|
+
it { should report_lint line: 3 }
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
context 'when if block contains properties in sorted order' do
|
|
239
|
+
let(:scss) { <<-SCSS }
|
|
240
|
+
@if $var {
|
|
241
|
+
// Content
|
|
242
|
+
} @else {
|
|
243
|
+
background: #000;
|
|
244
|
+
display: none;
|
|
245
|
+
margin: 5px;
|
|
246
|
+
padding: 10px;
|
|
247
|
+
}
|
|
248
|
+
SCSS
|
|
249
|
+
|
|
250
|
+
it { should_not report_lint }
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
context 'when else block contains properties not in sorted order' do
|
|
254
|
+
let(:scss) { <<-SCSS }
|
|
255
|
+
@if $var {
|
|
256
|
+
// Content
|
|
257
|
+
} @else {
|
|
258
|
+
background: #000;
|
|
259
|
+
margin: 5px;
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
SCSS
|
|
263
|
+
|
|
264
|
+
it { should report_lint line: 5 }
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
context 'when the order has been explicitly set' do
|
|
268
|
+
let(:linter_config) { { 'order' => %w[position display padding margin width] } }
|
|
269
|
+
|
|
270
|
+
context 'and the properties match the specified order' do
|
|
271
|
+
let(:scss) { <<-SCSS }
|
|
272
|
+
p {
|
|
273
|
+
display: block;
|
|
274
|
+
padding: 5px;
|
|
275
|
+
margin: 10px;
|
|
276
|
+
}
|
|
277
|
+
SCSS
|
|
278
|
+
|
|
279
|
+
it { should_not report_lint }
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
context 'and the properties do not match the specified order' do
|
|
283
|
+
let(:scss) { <<-SCSS }
|
|
284
|
+
p {
|
|
285
|
+
padding: 5px;
|
|
286
|
+
display: block;
|
|
287
|
+
margin: 10px;
|
|
288
|
+
}
|
|
289
|
+
SCSS
|
|
290
|
+
|
|
291
|
+
it { should report_lint line: 2 }
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
context 'and there are properties that are not specified in the explicit ordering' do
|
|
295
|
+
let(:scss) { <<-SCSS }
|
|
296
|
+
p {
|
|
297
|
+
display: block;
|
|
298
|
+
padding: 5px;
|
|
299
|
+
font-weight: bold; // Unspecified
|
|
300
|
+
margin: 10px;
|
|
301
|
+
border: 0; // Unspecified
|
|
302
|
+
background: red; // Unspecified
|
|
303
|
+
width: 100%;
|
|
304
|
+
}
|
|
305
|
+
SCSS
|
|
306
|
+
|
|
307
|
+
context 'and the ignore_unspecified option is enabled' do
|
|
308
|
+
let(:linter_config) { super().merge('ignore_unspecified' => true) }
|
|
309
|
+
|
|
310
|
+
it { should_not report_lint }
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
context 'and the ignore_unspecified option is disabled' do
|
|
314
|
+
let(:linter_config) { super().merge('ignore_unspecified' => false) }
|
|
315
|
+
|
|
316
|
+
it { should report_lint }
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
context 'when sort order is set to a preset order' do
|
|
322
|
+
let(:linter_config) { { 'order' => 'concentric' } }
|
|
323
|
+
|
|
324
|
+
context 'and the properties match the order' do
|
|
325
|
+
let(:scss) { <<-SCSS }
|
|
326
|
+
p {
|
|
327
|
+
display: block;
|
|
328
|
+
position: absolute;
|
|
329
|
+
float: left;
|
|
330
|
+
clear: both;
|
|
331
|
+
}
|
|
332
|
+
SCSS
|
|
333
|
+
|
|
334
|
+
it { should_not report_lint }
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
context 'and the properties do not match the order' do
|
|
338
|
+
let(:scss) { <<-SCSS }
|
|
339
|
+
p {
|
|
340
|
+
clear: both;
|
|
341
|
+
display: block;
|
|
342
|
+
float: left;
|
|
343
|
+
position: absolute;
|
|
344
|
+
}
|
|
345
|
+
SCSS
|
|
346
|
+
|
|
347
|
+
it { should report_lint }
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
context 'when separation between groups of properties is enforced' do
|
|
352
|
+
let(:order) do
|
|
353
|
+
%w[display position top right bottom left] + [nil] +
|
|
354
|
+
%w[width height margin padding] + [nil] +
|
|
355
|
+
%w[float clear]
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
let(:linter_config) { { 'separate_groups' => true, 'order' => order } }
|
|
359
|
+
|
|
360
|
+
context 'and the groups are separated correctly' do
|
|
361
|
+
let(:scss) { <<-SCSS }
|
|
362
|
+
p {
|
|
363
|
+
display: none;
|
|
364
|
+
position: absolute;
|
|
365
|
+
|
|
366
|
+
margin: 0;
|
|
367
|
+
padding: 0;
|
|
368
|
+
|
|
369
|
+
float: left;
|
|
370
|
+
}
|
|
371
|
+
SCSS
|
|
372
|
+
|
|
373
|
+
it { should_not report_lint }
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
context 'and the groups are separated incorrectly' do
|
|
377
|
+
let(:scss) { <<-SCSS }
|
|
378
|
+
p {
|
|
379
|
+
display: none;
|
|
380
|
+
position: absolute;
|
|
381
|
+
margin: 0;
|
|
382
|
+
|
|
383
|
+
padding: 0;
|
|
384
|
+
|
|
385
|
+
float: left;
|
|
386
|
+
}
|
|
387
|
+
SCSS
|
|
388
|
+
|
|
389
|
+
it { should report_lint line: 4 }
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
context 'and the groups are separated by a comment' do
|
|
393
|
+
let(:scss) { <<-SCSS }
|
|
394
|
+
p {
|
|
395
|
+
display: none;
|
|
396
|
+
position: absolute;
|
|
397
|
+
//
|
|
398
|
+
margin: 0;
|
|
399
|
+
padding: 0;
|
|
400
|
+
//
|
|
401
|
+
float: left;
|
|
402
|
+
}
|
|
403
|
+
SCSS
|
|
404
|
+
|
|
405
|
+
it { should_not report_lint }
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
context 'when the sort order has multiple gaps separating two groups' do
|
|
409
|
+
let(:order) { %w[display position] + [nil, nil] + %w[margin padding] }
|
|
410
|
+
|
|
411
|
+
context 'and the groups are separated correctly' do
|
|
412
|
+
let(:scss) { <<-SCSS }
|
|
413
|
+
p {
|
|
414
|
+
display: none;
|
|
415
|
+
position: absolute;
|
|
416
|
+
|
|
417
|
+
margin: 0;
|
|
418
|
+
padding: 0;
|
|
419
|
+
}
|
|
420
|
+
SCSS
|
|
421
|
+
|
|
422
|
+
it { should_not report_lint }
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
context 'and the groups are separated incorrectly' do
|
|
426
|
+
let(:scss) { <<-SCSS }
|
|
427
|
+
p {
|
|
428
|
+
display: none;
|
|
429
|
+
position: absolute;
|
|
430
|
+
margin: 0;
|
|
431
|
+
|
|
432
|
+
padding: 0;
|
|
433
|
+
}
|
|
434
|
+
SCSS
|
|
435
|
+
|
|
436
|
+
it { should report_lint line: 4 }
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
context 'when a minimum number of properties is required' do
|
|
442
|
+
let(:linter_config) { { 'min_properties' => 3 } }
|
|
443
|
+
|
|
444
|
+
context 'when fewer than the minimum number of properties are out of order' do
|
|
445
|
+
let(:scss) { <<-SCSS }
|
|
446
|
+
p {
|
|
447
|
+
margin: 0;
|
|
448
|
+
display: none;
|
|
449
|
+
}
|
|
450
|
+
SCSS
|
|
451
|
+
|
|
452
|
+
it { should_not report_lint }
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
context 'when at least the minimum number of properties are out of order' do
|
|
456
|
+
let(:scss) { <<-SCSS }
|
|
457
|
+
p {
|
|
458
|
+
margin: 0;
|
|
459
|
+
position: absolute;
|
|
460
|
+
display: none;
|
|
461
|
+
}
|
|
462
|
+
SCSS
|
|
463
|
+
|
|
464
|
+
it { should report_lint line: 2 }
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
context 'when the minimum number of properties are out of order in a nested property' do
|
|
468
|
+
let(:scss) { <<-SCSS }
|
|
469
|
+
p {
|
|
470
|
+
margin: 0;
|
|
471
|
+
font: {
|
|
472
|
+
size: 16px;
|
|
473
|
+
weight: bold;
|
|
474
|
+
family: Arial;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
SCSS
|
|
478
|
+
|
|
479
|
+
it { should report_lint line: 4 }
|
|
480
|
+
end
|
|
481
|
+
end
|
|
482
|
+
end
|