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,118 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::BorderZero do
|
|
4
|
+
context 'when a 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 a property' do
|
|
14
|
+
context 'contains a normal border' do
|
|
15
|
+
let(:scss) { <<-SCSS }
|
|
16
|
+
p {
|
|
17
|
+
border: 1px solid #000;
|
|
18
|
+
}
|
|
19
|
+
SCSS
|
|
20
|
+
|
|
21
|
+
it { should_not report_lint }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'has a border of 0' do
|
|
25
|
+
let(:scss) { <<-SCSS }
|
|
26
|
+
p {
|
|
27
|
+
border: 0;
|
|
28
|
+
}
|
|
29
|
+
SCSS
|
|
30
|
+
|
|
31
|
+
it { should_not report_lint }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'has a border of none' do
|
|
35
|
+
let(:scss) { <<-SCSS }
|
|
36
|
+
p {
|
|
37
|
+
border: none;
|
|
38
|
+
}
|
|
39
|
+
SCSS
|
|
40
|
+
|
|
41
|
+
it { should report_lint line: 2 }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'has a border-top of none' do
|
|
45
|
+
let(:scss) { <<-SCSS }
|
|
46
|
+
p {
|
|
47
|
+
border-top: none;
|
|
48
|
+
}
|
|
49
|
+
SCSS
|
|
50
|
+
|
|
51
|
+
it { should report_lint line: 2 }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context 'has a border-right of none' do
|
|
55
|
+
let(:scss) { <<-SCSS }
|
|
56
|
+
p {
|
|
57
|
+
border-right: none;
|
|
58
|
+
}
|
|
59
|
+
SCSS
|
|
60
|
+
|
|
61
|
+
it { should report_lint line: 2 }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'has a border-bottom of none' do
|
|
65
|
+
let(:scss) { <<-SCSS }
|
|
66
|
+
p {
|
|
67
|
+
border-bottom: none;
|
|
68
|
+
}
|
|
69
|
+
SCSS
|
|
70
|
+
|
|
71
|
+
it { should report_lint line: 2 }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context 'has a border-left of none' do
|
|
75
|
+
let(:scss) { <<-SCSS }
|
|
76
|
+
p {
|
|
77
|
+
border-left: none;
|
|
78
|
+
}
|
|
79
|
+
SCSS
|
|
80
|
+
|
|
81
|
+
it { should report_lint line: 2 }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'when a convention of `none` is preferred' do
|
|
86
|
+
let(:linter_config) { { 'convention' => 'none' } }
|
|
87
|
+
|
|
88
|
+
context 'and the border is `none`' do
|
|
89
|
+
let(:scss) { <<-SCSS }
|
|
90
|
+
p {
|
|
91
|
+
border: none;
|
|
92
|
+
}
|
|
93
|
+
SCSS
|
|
94
|
+
|
|
95
|
+
it { should_not report_lint }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context 'and the border is `0`' do
|
|
99
|
+
let(:scss) { <<-SCSS }
|
|
100
|
+
p {
|
|
101
|
+
border: 0;
|
|
102
|
+
}
|
|
103
|
+
SCSS
|
|
104
|
+
|
|
105
|
+
it { should report_lint }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context 'and the border is a non-zero value' do
|
|
109
|
+
let(:scss) { <<-SCSS }
|
|
110
|
+
p {
|
|
111
|
+
border: 5px;
|
|
112
|
+
}
|
|
113
|
+
SCSS
|
|
114
|
+
|
|
115
|
+
it { should_not report_lint }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::ColorKeyword do
|
|
4
|
+
context 'when a color is specified as a hex' do
|
|
5
|
+
let(:scss) { <<-SCSS }
|
|
6
|
+
p {
|
|
7
|
+
color: #fff;
|
|
8
|
+
}
|
|
9
|
+
SCSS
|
|
10
|
+
|
|
11
|
+
it { should_not report_lint }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when a color is specified as a keyword' do
|
|
15
|
+
let(:scss) { <<-SCSS }
|
|
16
|
+
p {
|
|
17
|
+
color: white;
|
|
18
|
+
}
|
|
19
|
+
SCSS
|
|
20
|
+
|
|
21
|
+
it { should report_lint line: 2 }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when a color keyword exists in a shorthand property' do
|
|
25
|
+
let(:scss) { <<-SCSS }
|
|
26
|
+
p {
|
|
27
|
+
border: 1px solid black;
|
|
28
|
+
}
|
|
29
|
+
SCSS
|
|
30
|
+
|
|
31
|
+
it { should report_lint line: 2 }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'when a property contains a color keyword as a string' do
|
|
35
|
+
let(:scss) { <<-SCSS }
|
|
36
|
+
p {
|
|
37
|
+
content: 'white';
|
|
38
|
+
}
|
|
39
|
+
SCSS
|
|
40
|
+
|
|
41
|
+
it { should_not report_lint }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'when a function call contains a color keyword' do
|
|
45
|
+
let(:scss) { <<-SCSS }
|
|
46
|
+
p {
|
|
47
|
+
color: function(red);
|
|
48
|
+
}
|
|
49
|
+
SCSS
|
|
50
|
+
|
|
51
|
+
it { should report_lint line: 2 }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context 'when a mixin include contains a color keyword' do
|
|
55
|
+
let(:scss) { <<-SCSS }
|
|
56
|
+
p {
|
|
57
|
+
@include some-mixin(red);
|
|
58
|
+
}
|
|
59
|
+
SCSS
|
|
60
|
+
|
|
61
|
+
it { should report_lint line: 2 }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'when the "transparent" color keyword is used' do
|
|
65
|
+
let(:scss) { <<-SCSS }
|
|
66
|
+
p {
|
|
67
|
+
@include mixin(transparent);
|
|
68
|
+
}
|
|
69
|
+
SCSS
|
|
70
|
+
|
|
71
|
+
it { should_not report_lint }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context 'when color keyword appears in a string identifier' do
|
|
75
|
+
let(:scss) { <<-SCSS }
|
|
76
|
+
p {
|
|
77
|
+
content: content-with-blue-in-name;
|
|
78
|
+
}
|
|
79
|
+
SCSS
|
|
80
|
+
|
|
81
|
+
it { should_not report_lint }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::ColorVariable do
|
|
4
|
+
context 'when a color literal is used in a variable declaration' do
|
|
5
|
+
let(:scss) { <<-SCSS }
|
|
6
|
+
$my-color: #f00;
|
|
7
|
+
SCSS
|
|
8
|
+
|
|
9
|
+
it { should_not report_lint }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'when a color literal is used in a property' do
|
|
13
|
+
let(:scss) { <<-SCSS }
|
|
14
|
+
p {
|
|
15
|
+
color: #f00;
|
|
16
|
+
}
|
|
17
|
+
SCSS
|
|
18
|
+
|
|
19
|
+
it { should report_lint line: 2 }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'when a color literal is used in a function call' do
|
|
23
|
+
let(:scss) { <<-SCSS }
|
|
24
|
+
p {
|
|
25
|
+
color: my-func(#f00);
|
|
26
|
+
}
|
|
27
|
+
SCSS
|
|
28
|
+
|
|
29
|
+
it { should report_lint line: 2 }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'when a color literal is used in a mixin' do
|
|
33
|
+
let(:scss) { <<-SCSS }
|
|
34
|
+
p {
|
|
35
|
+
@include my-mixin(#f00);
|
|
36
|
+
}
|
|
37
|
+
SCSS
|
|
38
|
+
|
|
39
|
+
it { should report_lint line: 2 }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'when a color literal is used in a shorthand property' do
|
|
43
|
+
let(:scss) { <<-SCSS }
|
|
44
|
+
p {
|
|
45
|
+
border: 1px solid #f00;
|
|
46
|
+
}
|
|
47
|
+
SCSS
|
|
48
|
+
|
|
49
|
+
it { should report_lint line: 2 }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'when a number is used in a property' do
|
|
53
|
+
let(:scss) { <<-SCSS }
|
|
54
|
+
p {
|
|
55
|
+
z-index: 9000;
|
|
56
|
+
transition-duration: 250ms;
|
|
57
|
+
}
|
|
58
|
+
SCSS
|
|
59
|
+
|
|
60
|
+
it { should_not report_lint }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'when a non-color keyword is used in a property' do
|
|
64
|
+
let(:scss) { <<-SCSS }
|
|
65
|
+
p {
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
SCSS
|
|
69
|
+
|
|
70
|
+
it { should_not report_lint }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context 'when a variable is used in a property' do
|
|
74
|
+
let(:scss) { <<-SCSS }
|
|
75
|
+
p {
|
|
76
|
+
color: $my-color;
|
|
77
|
+
}
|
|
78
|
+
SCSS
|
|
79
|
+
|
|
80
|
+
it { should_not report_lint }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context 'when a variable is used in a function call' do
|
|
84
|
+
let(:scss) { <<-SCSS }
|
|
85
|
+
p {
|
|
86
|
+
color: my-func($my-color);
|
|
87
|
+
}
|
|
88
|
+
SCSS
|
|
89
|
+
|
|
90
|
+
it { should_not report_lint }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context 'when a variable is used in a shorthand property' do
|
|
94
|
+
let(:scss) { <<-SCSS }
|
|
95
|
+
p {
|
|
96
|
+
border: 1px solid $my-color;
|
|
97
|
+
}
|
|
98
|
+
SCSS
|
|
99
|
+
|
|
100
|
+
it { should_not report_lint }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
context 'when a property contains "transparent"' do
|
|
104
|
+
let(:scss) { <<-SCSS }
|
|
105
|
+
p {
|
|
106
|
+
border: 1px solid transparent;
|
|
107
|
+
}
|
|
108
|
+
SCSS
|
|
109
|
+
|
|
110
|
+
it { should_not report_lint }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context 'when a property with function calls contains "transparent"' do
|
|
114
|
+
let(:scss) { <<-SCSS }
|
|
115
|
+
p {
|
|
116
|
+
border: 1px solid some-func(transparent);
|
|
117
|
+
}
|
|
118
|
+
SCSS
|
|
119
|
+
|
|
120
|
+
it { should_not report_lint }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
context 'when a color literal is used in the special rgba shorthand helper' do
|
|
124
|
+
let(:scss) { <<-SCSS }
|
|
125
|
+
p {
|
|
126
|
+
color: rgba(#fff, .5);
|
|
127
|
+
}
|
|
128
|
+
SCSS
|
|
129
|
+
|
|
130
|
+
it { should_not report_lint }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
context 'when a color literal is used in a map declaration' do
|
|
134
|
+
let(:scss) { <<-SCSS }
|
|
135
|
+
$shades-of-gray: (
|
|
136
|
+
darker: #4c4c4c,
|
|
137
|
+
dark: #626262,
|
|
138
|
+
light: #7d7d7d,
|
|
139
|
+
lighter: #979797
|
|
140
|
+
);
|
|
141
|
+
SCSS
|
|
142
|
+
|
|
143
|
+
it { should_not report_lint }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
context 'when a string with a color name is used in a function call' do
|
|
147
|
+
let(:scss) { <<-SCSS }
|
|
148
|
+
p {
|
|
149
|
+
color: my-func('blue');
|
|
150
|
+
}
|
|
151
|
+
SCSS
|
|
152
|
+
|
|
153
|
+
it { should_not report_lint }
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::Comment do
|
|
4
|
+
context 'when no comments exist' do
|
|
5
|
+
let(:scss) { <<-SCSS }
|
|
6
|
+
p {
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
SCSS
|
|
10
|
+
|
|
11
|
+
it { should_not report_lint }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when comment is a single line comment' do
|
|
15
|
+
let(:scss) { '// Single line comment' }
|
|
16
|
+
|
|
17
|
+
it { should_not report_lint }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'when comment is a single line comment at the end of a line' do
|
|
21
|
+
let(:scss) { <<-SCSS }
|
|
22
|
+
p {
|
|
23
|
+
margin: 0; // Comment at end of line
|
|
24
|
+
}
|
|
25
|
+
SCSS
|
|
26
|
+
|
|
27
|
+
it { should_not report_lint }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'when comment is a multi-line comment' do
|
|
31
|
+
let(:scss) { <<-SCSS }
|
|
32
|
+
h1 {
|
|
33
|
+
color: #eee;
|
|
34
|
+
}
|
|
35
|
+
/*
|
|
36
|
+
* This is a multi-line comment that should report a lint
|
|
37
|
+
*/
|
|
38
|
+
p {
|
|
39
|
+
color: #DDD;
|
|
40
|
+
}
|
|
41
|
+
SCSS
|
|
42
|
+
|
|
43
|
+
it { should report_lint line: 4 }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'when multi-line-style comment is a at the end of a line' do
|
|
47
|
+
let(:scss) { <<-SCSS }
|
|
48
|
+
h1 {
|
|
49
|
+
color: #eee; /* This is a comment */
|
|
50
|
+
}
|
|
51
|
+
SCSS
|
|
52
|
+
|
|
53
|
+
it { should report_lint line: 2 }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'when multi-line comment is allowed by config' do
|
|
57
|
+
let(:linter_config) { { 'allowed' => '^[/\\* ]*Copyright' } }
|
|
58
|
+
let(:scss) { <<-SCSS }
|
|
59
|
+
/* Copyright someone. */
|
|
60
|
+
a {
|
|
61
|
+
color: #DDD;
|
|
62
|
+
}
|
|
63
|
+
SCSS
|
|
64
|
+
|
|
65
|
+
it { should_not report_lint }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'when multi-line comment is not allowed by config' do
|
|
69
|
+
let(:linter_config) { { 'allowed' => '^[/\\* ]*Copyright' } }
|
|
70
|
+
let(:scss) { <<-SCSS }
|
|
71
|
+
/* Other multiline. */
|
|
72
|
+
p {
|
|
73
|
+
color: #DDD;
|
|
74
|
+
}
|
|
75
|
+
SCSS
|
|
76
|
+
|
|
77
|
+
it { should report_lint }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SCSSLint::Linter::Compass::PropertyWithMixin do
|
|
4
|
+
context 'when a rule has a property with an equivalent Compass mixin' do
|
|
5
|
+
let(:scss) { <<-SCSS }
|
|
6
|
+
p {
|
|
7
|
+
opacity: .5;
|
|
8
|
+
}
|
|
9
|
+
SCSS
|
|
10
|
+
|
|
11
|
+
it { should report_lint line: 2 }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when a rule includes a Compass property mixin' do
|
|
15
|
+
let(:scss) { <<-SCSS }
|
|
16
|
+
p {
|
|
17
|
+
@include opacity(.5);
|
|
18
|
+
}
|
|
19
|
+
SCSS
|
|
20
|
+
|
|
21
|
+
it { should_not report_lint }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when a rule does not have a property with a corresponding Compass mixin' do
|
|
25
|
+
let(:scss) { <<-SCSS }
|
|
26
|
+
p {
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
SCSS
|
|
30
|
+
|
|
31
|
+
it { should_not report_lint }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'when a rule includes display: inline-block' do
|
|
35
|
+
let(:scss) { <<-SCSS }
|
|
36
|
+
p {
|
|
37
|
+
display: inline-block;
|
|
38
|
+
}
|
|
39
|
+
SCSS
|
|
40
|
+
|
|
41
|
+
it { should report_lint line: 2 }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'when properties are ignored' do
|
|
45
|
+
let(:linter_config) { { 'ignore' => %w[inline-block] } }
|
|
46
|
+
|
|
47
|
+
let(:scss) { <<-SCSS }
|
|
48
|
+
p {
|
|
49
|
+
display: inline-block;
|
|
50
|
+
}
|
|
51
|
+
SCSS
|
|
52
|
+
|
|
53
|
+
it { should_not report_lint }
|
|
54
|
+
end
|
|
55
|
+
end
|