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,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::EmptyRule do
|
4
|
+
context 'when rule is empty' do
|
5
|
+
let(:scss) { <<-SCSS }
|
6
|
+
p {
|
7
|
+
}
|
8
|
+
SCSS
|
9
|
+
|
10
|
+
it { should report_lint line: 1 }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when rule contains an empty nested rule' do
|
14
|
+
let(:scss) { <<-SCSS }
|
15
|
+
p {
|
16
|
+
background: #000;
|
17
|
+
display: none;
|
18
|
+
margin: 5px;
|
19
|
+
padding: 10px;
|
20
|
+
a {
|
21
|
+
}
|
22
|
+
}
|
23
|
+
SCSS
|
24
|
+
|
25
|
+
it { should report_lint line: 6 }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::FinalNewline do
|
4
|
+
let(:linter_config) { { 'present' => present } }
|
5
|
+
|
6
|
+
context 'when trailing newline is preferred' do
|
7
|
+
let(:present) { true }
|
8
|
+
|
9
|
+
context 'when the file is empty' do
|
10
|
+
let(:scss) { '' }
|
11
|
+
|
12
|
+
it { should_not report_lint }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when the file ends with a newline' do
|
16
|
+
let(:scss) { "p {}\n" }
|
17
|
+
|
18
|
+
it { should_not report_lint }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the file does not end with a newline' do
|
22
|
+
let(:scss) { 'p {}' }
|
23
|
+
|
24
|
+
it { should report_lint }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when no trailing newline is preferred' do
|
29
|
+
let(:present) { false }
|
30
|
+
|
31
|
+
context 'when the file is empty' do
|
32
|
+
let(:scss) { '' }
|
33
|
+
|
34
|
+
it { should_not report_lint }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the file ends with a newline' do
|
38
|
+
let(:scss) { "p {}\n" }
|
39
|
+
|
40
|
+
it { should report_lint }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when the file does not end with a newline' do
|
44
|
+
let(:scss) { 'p {}' }
|
45
|
+
|
46
|
+
it { should_not report_lint }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::HexLength do
|
4
|
+
let(:linter_config) { { 'style' => style } }
|
5
|
+
let(:style) { 'short' }
|
6
|
+
|
7
|
+
context 'when rule is empty' do
|
8
|
+
let(:scss) { <<-SCSS }
|
9
|
+
p {
|
10
|
+
}
|
11
|
+
SCSS
|
12
|
+
|
13
|
+
it { should_not report_lint }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule contains properties with valid hex code' do
|
17
|
+
let(:scss) { <<-SCSS }
|
18
|
+
p {
|
19
|
+
color: #1234ab;
|
20
|
+
}
|
21
|
+
SCSS
|
22
|
+
|
23
|
+
it { should_not report_lint }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when ID selector starts with a hex code' do
|
27
|
+
let(:scss) { <<-SCSS }
|
28
|
+
#aabbcc {
|
29
|
+
}
|
30
|
+
SCSS
|
31
|
+
|
32
|
+
it { should_not report_lint }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when color is specified as a color keyword' do
|
36
|
+
let(:scss) { <<-SCSS }
|
37
|
+
p {
|
38
|
+
@include box-shadow(0 0 1px 1px gold);
|
39
|
+
}
|
40
|
+
SCSS
|
41
|
+
|
42
|
+
it { should_not report_lint }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when short style is preferred' do
|
46
|
+
let(:style) { 'short' }
|
47
|
+
|
48
|
+
context 'with short hex code' do
|
49
|
+
let(:scss) { <<-SCSS }
|
50
|
+
p {
|
51
|
+
background: #ccc;
|
52
|
+
background: #CCC;
|
53
|
+
@include crazy-color(#fff);
|
54
|
+
}
|
55
|
+
SCSS
|
56
|
+
|
57
|
+
it { should_not report_lint }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with long hex code that could be condensed to 3 digits' do
|
61
|
+
let(:scss) { <<-SCSS }
|
62
|
+
p {
|
63
|
+
background: #cccccc;
|
64
|
+
background: #CCCCCC;
|
65
|
+
@include crazy-color(#ffffff);
|
66
|
+
}
|
67
|
+
SCSS
|
68
|
+
|
69
|
+
it { should report_lint line: 2 }
|
70
|
+
it { should report_lint line: 3 }
|
71
|
+
it { should report_lint line: 4 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when long style is preferred' do
|
76
|
+
let(:style) { 'long' }
|
77
|
+
|
78
|
+
context 'with long hex code that could be condensed to 3 digits' do
|
79
|
+
let(:scss) { <<-SCSS }
|
80
|
+
p {
|
81
|
+
background: #cccccc;
|
82
|
+
background: #CCCCCC;
|
83
|
+
@include crazy-color(#ffffff);
|
84
|
+
}
|
85
|
+
SCSS
|
86
|
+
|
87
|
+
it { should_not report_lint }
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'with short hex code' do
|
91
|
+
let(:scss) { <<-SCSS }
|
92
|
+
p {
|
93
|
+
background: #ccc;
|
94
|
+
background: #CCC;
|
95
|
+
@include crazy-color(#fff);
|
96
|
+
}
|
97
|
+
SCSS
|
98
|
+
|
99
|
+
it { should report_lint line: 2 }
|
100
|
+
it { should report_lint line: 3 }
|
101
|
+
it { should report_lint line: 4 }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::HexNotation do
|
4
|
+
let(:linter_config) { { 'style' => style } }
|
5
|
+
let(:style) { nil }
|
6
|
+
|
7
|
+
context 'when rule is empty' do
|
8
|
+
let(:scss) { <<-SCSS }
|
9
|
+
p {
|
10
|
+
}
|
11
|
+
SCSS
|
12
|
+
|
13
|
+
it { should_not report_lint }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule contains color keyword' do
|
17
|
+
let(:scss) { <<-SCSS }
|
18
|
+
p {
|
19
|
+
border-color: red;
|
20
|
+
}
|
21
|
+
SCSS
|
22
|
+
|
23
|
+
it { should_not report_lint }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'lowercase style' do
|
27
|
+
let(:style) { 'lowercase' }
|
28
|
+
|
29
|
+
context 'when rule contains properties with lowercase hex code' do
|
30
|
+
let(:scss) { <<-SCSS }
|
31
|
+
p {
|
32
|
+
background: #ccc;
|
33
|
+
color: #cccccc;
|
34
|
+
@include crazy-color(#fff);
|
35
|
+
}
|
36
|
+
SCSS
|
37
|
+
|
38
|
+
it { should_not report_lint }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with uppercase hex codes' do
|
42
|
+
let(:scss) { <<-SCSS }
|
43
|
+
p {
|
44
|
+
background: #CCC;
|
45
|
+
color: #CCCCCC;
|
46
|
+
@include crazy-color(#FFF);
|
47
|
+
}
|
48
|
+
SCSS
|
49
|
+
|
50
|
+
it { should report_lint line: 2 }
|
51
|
+
it { should report_lint line: 3 }
|
52
|
+
it { should report_lint line: 4 }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'uppercase style' do
|
57
|
+
let(:style) { 'uppercase' }
|
58
|
+
|
59
|
+
context 'with uppercase hex codes' do
|
60
|
+
let(:scss) { <<-SCSS }
|
61
|
+
p {
|
62
|
+
background: #CCC;
|
63
|
+
color: #CCCCCC;
|
64
|
+
@include crazy-color(#FFF);
|
65
|
+
}
|
66
|
+
SCSS
|
67
|
+
|
68
|
+
it { should_not report_lint }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when rule contains properties with lowercase hex code' do
|
72
|
+
let(:scss) { <<-SCSS }
|
73
|
+
p {
|
74
|
+
background: #ccc;
|
75
|
+
color: #cccccc;
|
76
|
+
@include crazy-color(#fff);
|
77
|
+
}
|
78
|
+
SCSS
|
79
|
+
|
80
|
+
it { should report_lint line: 2 }
|
81
|
+
it { should report_lint line: 3 }
|
82
|
+
it { should report_lint line: 4 }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when ID selector starts with a hex code' do
|
87
|
+
let(:scss) { <<-SCSS }
|
88
|
+
#aabbcc {
|
89
|
+
}
|
90
|
+
SCSS
|
91
|
+
|
92
|
+
it { should_not report_lint }
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when color is specified as a color keyword' do
|
96
|
+
let(:scss) { <<-SCSS }
|
97
|
+
p {
|
98
|
+
@include box-shadow(0 0 1px 1px gold);
|
99
|
+
}
|
100
|
+
SCSS
|
101
|
+
|
102
|
+
it { should_not report_lint }
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::HexValidation 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 valid hex codes or color keyword' do
|
14
|
+
gradient_css = 'progid:DXImageTransform.Microsoft.gradient' \
|
15
|
+
'(startColorstr=#99000000, endColorstr=#99000000)'
|
16
|
+
|
17
|
+
let(:scss) { <<-SCSS }
|
18
|
+
p {
|
19
|
+
background: #000;
|
20
|
+
color: #FFFFFF;
|
21
|
+
border-color: red;
|
22
|
+
filter: #{gradient_css};
|
23
|
+
}
|
24
|
+
SCSS
|
25
|
+
|
26
|
+
it { should_not report_lint }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when rule contains invalid hex codes' do
|
30
|
+
let(:scss) { <<-SCSS }
|
31
|
+
p {
|
32
|
+
background: #dd;
|
33
|
+
color: #dddd;
|
34
|
+
}
|
35
|
+
SCSS
|
36
|
+
|
37
|
+
it { should report_lint line: 2 }
|
38
|
+
it { should report_lint line: 3 }
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::IdSelector do
|
4
|
+
context 'when rule is a type' do
|
5
|
+
let(:scss) { 'p {}' }
|
6
|
+
|
7
|
+
it { should_not report_lint }
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when rule is an ID' do
|
11
|
+
let(:scss) { '#identifier {}' }
|
12
|
+
|
13
|
+
it { should report_lint line: 1 }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when rule is a class' do
|
17
|
+
let(:scss) { '.class {}' }
|
18
|
+
|
19
|
+
it { should_not report_lint }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when rule is a type with a class' do
|
23
|
+
let(:scss) { 'a.class {}' }
|
24
|
+
|
25
|
+
it { should_not report_lint }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when rule is a type with an ID' do
|
29
|
+
let(:scss) { 'a#identifier {}' }
|
30
|
+
|
31
|
+
it { should report_lint line: 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when rule is an ID with a pseudo-selector' do
|
35
|
+
let(:scss) { '#identifier:active {}' }
|
36
|
+
|
37
|
+
it { should report_lint line: 1 }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when rule contains a nested rule with type and ID' do
|
41
|
+
let(:scss) { <<-SCSS }
|
42
|
+
p {
|
43
|
+
a#identifier {}
|
44
|
+
}
|
45
|
+
SCSS
|
46
|
+
|
47
|
+
it { should report_lint line: 2 }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when rule contains multiple selectors' do
|
51
|
+
context 'when all of the selectors are just IDs, classes, or types' do
|
52
|
+
let(:scss) { <<-SCSS }
|
53
|
+
#identifier,
|
54
|
+
.class,
|
55
|
+
a {
|
56
|
+
}
|
57
|
+
SCSS
|
58
|
+
|
59
|
+
it { should report_lint line: 1 }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,300 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SCSSLint::Linter::ImportPath do
|
4
|
+
context 'when the path includes no directories' do
|
5
|
+
context 'and the filename has no leading underscore or filename extension' do
|
6
|
+
let(:scss) { '@import "filename";' }
|
7
|
+
|
8
|
+
it { should_not report_lint }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'and the filename has a leading underscore' do
|
12
|
+
let(:scss) { '@import "_filename";' }
|
13
|
+
|
14
|
+
it { should report_lint line: 1 }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'and the filename has a filename extension' do
|
18
|
+
let(:scss) { '@import "filename.scss";' }
|
19
|
+
|
20
|
+
it { should report_lint line: 1 }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
24
|
+
let(:scss) { '@import "_filename.scss";' }
|
25
|
+
|
26
|
+
it { should report_lint line: 1 }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'and multiple files are @imported' do
|
30
|
+
context 'and neither have leading underscores or filename extensions' do
|
31
|
+
let(:scss) { '@import "foo", "bar";' }
|
32
|
+
|
33
|
+
it { should_not report_lint }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'and the second has a leading underscore' do
|
37
|
+
let(:scss) { '@import "foo", "_bar";' }
|
38
|
+
|
39
|
+
it { should report_lint line: 1 }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'and the first has a filename extension' do
|
43
|
+
let(:scss) { '@import "foo.scss", "bar";' }
|
44
|
+
|
45
|
+
it { should report_lint line: 1 }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when the path includes directories' do
|
51
|
+
context 'and the filename has no leading underscore or filename extension' do
|
52
|
+
let(:scss) { '@import "path/to/filename";' }
|
53
|
+
|
54
|
+
it { should_not report_lint }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'and the filename has a leading underscore' do
|
58
|
+
let(:scss) { '@import "../to/_filename";' }
|
59
|
+
|
60
|
+
it { should report_lint line: 1 }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and the filename has a filename extension' do
|
64
|
+
let(:scss) { '@import "/path/to/filename.scss";' }
|
65
|
+
|
66
|
+
it { should report_lint line: 1 }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
70
|
+
let(:scss) { '@import "path/to/_filename.scss";' }
|
71
|
+
|
72
|
+
it { should report_lint line: 1 }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'and multiple files are @imported' do
|
76
|
+
context 'and neither have leading underscores or filename extensions' do
|
77
|
+
let(:scss) { '@import "path/to/foo", "../../bar";' }
|
78
|
+
|
79
|
+
it { should_not report_lint }
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'and the second has a leading underscore' do
|
83
|
+
let(:scss) { '@import "path/to/foo", "../../_bar";' }
|
84
|
+
|
85
|
+
it { should report_lint line: 1 }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'and the first has a filename extension' do
|
89
|
+
let(:scss) { '@import "path/to/foo.scss", "../../bar";' }
|
90
|
+
|
91
|
+
it { should report_lint line: 1 }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when option `leading_underscore` is true' do
|
97
|
+
let(:linter_config) { { 'leading_underscore' => true } }
|
98
|
+
|
99
|
+
context 'and the filename has no leading underscore or filename extension' do
|
100
|
+
let(:scss) { '@import "path/to/filename";' }
|
101
|
+
|
102
|
+
it { should report_lint line: 1 }
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'and the filename has a leading underscore' do
|
106
|
+
let(:scss) { '@import "../to/_filename";' }
|
107
|
+
|
108
|
+
it { should_not report_lint }
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'and the filename has a filename extension' do
|
112
|
+
let(:scss) { '@import "/path/to/filename.scss";' }
|
113
|
+
|
114
|
+
it { should report_lint line: 1 }
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
118
|
+
let(:scss) { '@import "path/to/_filename.scss";' }
|
119
|
+
|
120
|
+
it { should report_lint line: 1 }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'and multiple files are @imported' do
|
124
|
+
context 'and neither have leading underscores or filename extensions' do
|
125
|
+
let(:scss) { '@import "path/to/foo", "../../bar";' }
|
126
|
+
|
127
|
+
it { should report_lint line: 1 }
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'and both have a leading underscore' do
|
131
|
+
let(:scss) { '@import "path/to/_foo", "../../_bar";' }
|
132
|
+
|
133
|
+
it { should_not report_lint }
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'and only one has a leading underscore' do
|
137
|
+
let(:scss) { '@import "path/to/foo.scss", "../../_bar";' }
|
138
|
+
|
139
|
+
it { should report_lint line: 1 }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when option `filename_extension` is true' do
|
145
|
+
let(:linter_config) { { 'filename_extension' => true } }
|
146
|
+
|
147
|
+
context 'and the filename has no leading underscore or filename extension' do
|
148
|
+
let(:scss) { '@import "path/to/filename";' }
|
149
|
+
|
150
|
+
it { should report_lint line: 1 }
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'and the filename has a leading underscore' do
|
154
|
+
let(:scss) { '@import "../to/_filename";' }
|
155
|
+
|
156
|
+
it { should report_lint line: 1 }
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'and the filename has a filename extension' do
|
160
|
+
let(:scss) { '@import "/path/to/filename.scss";' }
|
161
|
+
|
162
|
+
it { should_not report_lint }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
166
|
+
let(:scss) { '@import "path/to/_filename.scss";' }
|
167
|
+
|
168
|
+
it { should report_lint line: 1 }
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'and multiple files are @imported' do
|
172
|
+
context 'and neither have leading underscores or filename extensions' do
|
173
|
+
let(:scss) { '@import "path/to/foo", "../../bar";' }
|
174
|
+
|
175
|
+
it { should report_lint line: 1 }
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'and both have filename extensions' do
|
179
|
+
let(:scss) { '@import "path/to/foo.scss", "../../bar.scss";' }
|
180
|
+
|
181
|
+
it { should_not report_lint }
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'and only one has a filename extensions' do
|
185
|
+
let(:scss) { '@import "path/to/foo.scss", "../../bar";' }
|
186
|
+
|
187
|
+
it { should report_lint line: 1 }
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context 'when options `leading_underscore` and `filename_extension` are true' do
|
193
|
+
let(:linter_config) { { 'leading_underscore' => true, 'filename_extension' => true } }
|
194
|
+
|
195
|
+
context 'and the filename has no leading underscore or filename extension' do
|
196
|
+
let(:scss) { '@import "path/to/filename";' }
|
197
|
+
|
198
|
+
it { should report_lint line: 1 }
|
199
|
+
end
|
200
|
+
|
201
|
+
context 'and the filename has a leading underscore' do
|
202
|
+
let(:scss) { '@import "../to/_filename";' }
|
203
|
+
|
204
|
+
it { should report_lint line: 1 }
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'and the filename has a filename extension' do
|
208
|
+
let(:scss) { '@import "/path/to/filename.scss";' }
|
209
|
+
|
210
|
+
it { should report_lint line: 1 }
|
211
|
+
end
|
212
|
+
|
213
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
214
|
+
let(:scss) { '@import "path/to/_filename.scss";' }
|
215
|
+
|
216
|
+
it { should_not report_lint }
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'and multiple files are @imported' do
|
220
|
+
context 'and neither have leading underscores or filename extensions' do
|
221
|
+
let(:scss) { '@import "path/to/foo", "../../bar";' }
|
222
|
+
|
223
|
+
it { should report_lint line: 1 }
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'and both have filename extensions and leading underscores' do
|
227
|
+
let(:scss) { '@import "path/to/_foo.scss", "../../_bar.scss";' }
|
228
|
+
|
229
|
+
it { should_not report_lint }
|
230
|
+
end
|
231
|
+
|
232
|
+
context 'and only one has both a filename extension and a leading underscore' do
|
233
|
+
let(:scss) { '@import "path/to/_foo.scss", "../../bar.scss";' }
|
234
|
+
|
235
|
+
it { should report_lint line: 1 }
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'when the @import directive compiles directly to a CSS @import rule' do
|
241
|
+
context 'and the @import is a CSS file' do
|
242
|
+
let(:scss) { '@import "_foo.css";' }
|
243
|
+
|
244
|
+
it { should_not report_lint }
|
245
|
+
end
|
246
|
+
|
247
|
+
context 'and the @import contains a protocol' do
|
248
|
+
let(:scss) { '@import "http://foo.com/_bar.css";' }
|
249
|
+
|
250
|
+
it { should_not report_lint }
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'and the @import contains a media query' do
|
254
|
+
let(:scss) { '@import "_foo.css" screen;' }
|
255
|
+
|
256
|
+
it { should_not report_lint }
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'and the @import is a URL' do
|
260
|
+
let(:scss) { '@import url(_foo.css);' }
|
261
|
+
|
262
|
+
it { should_not report_lint }
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'and the @import contains interpolation' do
|
266
|
+
let(:scss) { <<-SCSS }
|
267
|
+
$family: unquote("Droid+Sans");
|
268
|
+
@import url("http://fonts.googleapis.com/css?family=\#{$family}");
|
269
|
+
SCSS
|
270
|
+
|
271
|
+
it { should_not report_lint }
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'when the partial has the same name as its directory' do
|
276
|
+
context 'and the filename has no leading underscore or filename extension' do
|
277
|
+
let(:scss) { '@import "foo/foo";' }
|
278
|
+
|
279
|
+
it { should_not report_lint }
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'and the filename has a leading underscore' do
|
283
|
+
let(:scss) { '@import "_foo/_foo";' }
|
284
|
+
|
285
|
+
it { should report_lint line: 1 }
|
286
|
+
end
|
287
|
+
|
288
|
+
context 'and the filename has a filename extension' do
|
289
|
+
let(:scss) { '@import "foo/foo.scss";' }
|
290
|
+
|
291
|
+
it { should report_lint line: 1 }
|
292
|
+
end
|
293
|
+
|
294
|
+
context 'and the filename has a leading underscore and a filename extension' do
|
295
|
+
let(:scss) { '@import "_foo/_foo.scss";' }
|
296
|
+
|
297
|
+
it { should report_lint line: 1 }
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|