scss-lint 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +19 -1
- data/data/properties.txt +4 -0
- data/lib/scss_lint.rb +1 -0
- data/lib/scss_lint/cli.rb +4 -42
- data/lib/scss_lint/config.rb +1 -45
- data/lib/scss_lint/control_comment_processor.rb +47 -15
- data/lib/scss_lint/file_finder.rb +57 -0
- data/lib/scss_lint/linter/bang_format.rb +1 -1
- data/lib/scss_lint/linter/border_zero.rb +25 -9
- data/lib/scss_lint/linter/color_keyword.rb +3 -13
- data/lib/scss_lint/linter/color_variable.rb +36 -0
- data/lib/scss_lint/linter/declaration_order.rb +2 -2
- data/lib/scss_lint/linter/important_rule.rb +12 -0
- data/lib/scss_lint/linter/indentation.rb +7 -1
- data/lib/scss_lint/linter/property_count.rb +44 -0
- data/lib/scss_lint/linter/property_sort_order.rb +73 -19
- data/lib/scss_lint/linter/string_quotes.rb +9 -0
- data/lib/scss_lint/linter/variable_for_property.rb +20 -0
- data/lib/scss_lint/linter/vendor_prefixes.rb +3 -3
- data/lib/scss_lint/runner.rb +5 -7
- data/lib/scss_lint/utils.rb +34 -0
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +1 -1
- data/spec/scss_lint/config_spec.rb +4 -203
- data/spec/scss_lint/engine_spec.rb +4 -4
- data/spec/scss_lint/file_finder_spec.rb +110 -0
- data/spec/scss_lint/linter/bang_format_spec.rb +28 -18
- data/spec/scss_lint/linter/border_zero_spec.rb +50 -16
- data/spec/scss_lint/linter/color_keyword_spec.rb +16 -16
- data/spec/scss_lint/linter/color_variable_spec.rb +102 -0
- data/spec/scss_lint/linter/comment_spec.rb +9 -9
- data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +10 -10
- data/spec/scss_lint/linter/debug_statement_spec.rb +4 -4
- data/spec/scss_lint/linter/declaration_order_spec.rb +80 -80
- data/spec/scss_lint/linter/duplicate_property_spec.rb +30 -30
- data/spec/scss_lint/linter/else_placement_spec.rb +16 -16
- data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +38 -38
- data/spec/scss_lint/linter/empty_rule_spec.rb +4 -4
- data/spec/scss_lint/linter/final_newline_spec.rb +6 -6
- data/spec/scss_lint/linter/hex_length_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_notation_spec.rb +16 -16
- data/spec/scss_lint/linter/hex_validation_spec.rb +6 -6
- data/spec/scss_lint/linter/id_selector_spec.rb +10 -10
- data/spec/scss_lint/linter/import_path_spec.rb +45 -45
- data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
- data/spec/scss_lint/linter/indentation_spec.rb +103 -43
- data/spec/scss_lint/linter/leading_zero_spec.rb +45 -45
- data/spec/scss_lint/linter/mergeable_selector_spec.rb +32 -32
- data/spec/scss_lint/linter/name_format_spec.rb +75 -41
- data/spec/scss_lint/linter/nesting_depth_spec.rb +14 -14
- data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +12 -12
- data/spec/scss_lint/linter/property_count_spec.rb +104 -0
- data/spec/scss_lint/linter/property_sort_order_spec.rb +138 -48
- data/spec/scss_lint/linter/property_spelling_spec.rb +14 -14
- data/spec/scss_lint/linter/qualifying_element_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_depth_spec.rb +26 -26
- data/spec/scss_lint/linter/selector_format_spec.rb +114 -114
- data/spec/scss_lint/linter/shorthand_spec.rb +32 -32
- data/spec/scss_lint/linter/single_line_per_property_spec.rb +10 -10
- data/spec/scss_lint/linter/single_line_per_selector_spec.rb +24 -24
- data/spec/scss_lint/linter/space_after_comma_spec.rb +60 -60
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +44 -44
- data/spec/scss_lint/linter/space_after_property_name_spec.rb +6 -6
- data/spec/scss_lint/linter/space_before_brace_spec.rb +119 -119
- data/spec/scss_lint/linter/space_between_parens_spec.rb +48 -48
- data/spec/scss_lint/linter/string_quotes_spec.rb +74 -62
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +53 -54
- data/spec/scss_lint/linter/trailing_zero_spec.rb +34 -34
- data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +10 -10
- data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +18 -18
- data/spec/scss_lint/linter/url_format_spec.rb +4 -4
- data/spec/scss_lint/linter/url_quotes_spec.rb +14 -14
- data/spec/scss_lint/linter/variable_for_property_spec.rb +115 -0
- data/spec/scss_lint/linter/vendor_prefixes_spec.rb +66 -56
- data/spec/scss_lint/linter/zero_unit_spec.rb +22 -22
- data/spec/scss_lint/linter_spec.rb +72 -28
- data/spec/scss_lint/runner_spec.rb +0 -1
- data/spec/scss_lint/selector_visitor_spec.rb +23 -23
- data/spec/spec_helper.rb +2 -2
- metadata +27 -12
@@ -2,31 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::PropertySpelling do
|
4
4
|
context 'with a regular property' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
p {
|
7
7
|
margin: 5px;
|
8
8
|
}
|
9
|
-
|
9
|
+
SCSS
|
10
10
|
|
11
11
|
it { should_not report_lint }
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'with a property containing interpolation' do
|
15
|
-
let(:
|
15
|
+
let(:scss) { <<-SCSS }
|
16
16
|
p {
|
17
17
|
\#{$property-name}: 5px;
|
18
18
|
}
|
19
|
-
|
19
|
+
SCSS
|
20
20
|
|
21
21
|
it { should_not report_lint }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with a non-existent property' do
|
25
|
-
let(:
|
25
|
+
let(:scss) { <<-SCSS }
|
26
26
|
p {
|
27
27
|
peanut-butter: jelly-time;
|
28
28
|
}
|
29
|
-
|
29
|
+
SCSS
|
30
30
|
|
31
31
|
it { should report_lint }
|
32
32
|
end
|
@@ -35,48 +35,48 @@ describe SCSSLint::Linter::PropertySpelling do
|
|
35
35
|
let(:linter_config) { { 'extra_properties' => ['made-up-property'] } }
|
36
36
|
|
37
37
|
context 'with a non-existent property' do
|
38
|
-
let(:
|
38
|
+
let(:scss) { <<-SCSS }
|
39
39
|
p {
|
40
40
|
peanut-butter: jelly-time;
|
41
41
|
}
|
42
|
-
|
42
|
+
SCSS
|
43
43
|
|
44
44
|
it { should report_lint }
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'with a property listed as an extra property' do
|
48
|
-
let(:
|
48
|
+
let(:scss) { <<-SCSS }
|
49
49
|
p {
|
50
50
|
made-up-property: value;
|
51
51
|
}
|
52
|
-
|
52
|
+
SCSS
|
53
53
|
|
54
54
|
it { should_not report_lint }
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'with valid nested properties' do
|
59
|
-
let(:
|
59
|
+
let(:scss) { <<-SCSS }
|
60
60
|
p {
|
61
61
|
text: {
|
62
62
|
align: center;
|
63
63
|
transform: uppercase;
|
64
64
|
}
|
65
65
|
}
|
66
|
-
|
66
|
+
SCSS
|
67
67
|
|
68
68
|
it { should_not report_lint }
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'with invalid nested properties' do
|
72
|
-
let(:
|
72
|
+
let(:scss) { <<-SCSS }
|
73
73
|
p {
|
74
74
|
text: {
|
75
75
|
aligned: center;
|
76
76
|
transformed: uppercase;
|
77
77
|
}
|
78
78
|
}
|
79
|
-
|
79
|
+
SCSS
|
80
80
|
|
81
81
|
it { should report_lint line: 3 }
|
82
82
|
it { should report_lint line: 4 }
|
@@ -2,84 +2,84 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::QualifyingElement do
|
4
4
|
context 'when selector does not include an element' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
.foo {}
|
7
7
|
#bar {}
|
8
8
|
[foobar] {}
|
9
9
|
.foo .bar {}
|
10
10
|
#bar > .foo {}
|
11
11
|
[foobar] #bar .foo {}
|
12
|
-
|
12
|
+
SCSS
|
13
13
|
|
14
14
|
it { should_not report_lint }
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'when selector includes an element' do
|
18
18
|
context 'and element does not qualify' do
|
19
|
-
let(:
|
19
|
+
let(:scss) { <<-SCSS }
|
20
20
|
ul {}
|
21
|
-
|
21
|
+
SCSS
|
22
22
|
|
23
23
|
it { should_not report_lint }
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'and element qualifies class' do
|
27
|
-
let(:
|
27
|
+
let(:scss) { <<-SCSS }
|
28
28
|
ul.list {}
|
29
|
-
|
29
|
+
SCSS
|
30
30
|
|
31
31
|
it { should report_lint line: 1 }
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'and element qualifies attribute' do
|
35
|
-
let(:
|
35
|
+
let(:scss) { <<-SCSS }
|
36
36
|
a[href] {}
|
37
|
-
|
37
|
+
SCSS
|
38
38
|
|
39
39
|
it { should report_lint line: 1 }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'and element qualifies id' do
|
43
|
-
let(:
|
43
|
+
let(:scss) { <<-SCSS }
|
44
44
|
ul#list {}
|
45
|
-
|
45
|
+
SCSS
|
46
46
|
|
47
47
|
it { should report_lint line: 1 }
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'and selector is in a group' do
|
51
51
|
context 'and element does not qualify' do
|
52
|
-
let(:
|
52
|
+
let(:scss) { <<-SCSS }
|
53
53
|
.list li,
|
54
54
|
.item > span {}
|
55
|
-
|
55
|
+
SCSS
|
56
56
|
|
57
57
|
it { should_not report_lint }
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'and element qualifies class' do
|
61
|
-
let(:
|
61
|
+
let(:scss) { <<-SCSS }
|
62
62
|
.item span,
|
63
63
|
ul > li.item {}
|
64
|
-
|
64
|
+
SCSS
|
65
65
|
|
66
66
|
it { should report_lint line: 1 }
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'and element qualifies attribute' do
|
70
|
-
let(:
|
70
|
+
let(:scss) { <<-SCSS }
|
71
71
|
.item + span,
|
72
72
|
li a[href] {}
|
73
|
-
|
73
|
+
SCSS
|
74
74
|
|
75
75
|
it { should report_lint line: 1 }
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'and element qualifies id' do
|
79
|
-
let(:
|
79
|
+
let(:scss) { <<-SCSS }
|
80
80
|
#foo,
|
81
81
|
li#item + li {}
|
82
|
-
|
82
|
+
SCSS
|
83
83
|
|
84
84
|
it { should report_lint line: 1 }
|
85
85
|
end
|
@@ -87,36 +87,36 @@ describe SCSSLint::Linter::QualifyingElement do
|
|
87
87
|
|
88
88
|
context 'and selector involves a combinator' do
|
89
89
|
context 'and element does not qualify' do
|
90
|
-
let(:
|
90
|
+
let(:scss) { <<-SCSS }
|
91
91
|
.list li {}
|
92
92
|
.list > li {}
|
93
93
|
.item + li {}
|
94
94
|
.item ~ li {}
|
95
|
-
|
95
|
+
SCSS
|
96
96
|
|
97
97
|
it { should_not report_lint }
|
98
98
|
end
|
99
99
|
|
100
100
|
context 'and element qualifies class' do
|
101
|
-
let(:
|
101
|
+
let(:scss) { <<-SCSS }
|
102
102
|
ul > li.item {}
|
103
|
-
|
103
|
+
SCSS
|
104
104
|
|
105
105
|
it { should report_lint line: 1 }
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'and element qualifies attribute' do
|
109
|
-
let(:
|
109
|
+
let(:scss) { <<-SCSS }
|
110
110
|
li a[href] {}
|
111
|
-
|
111
|
+
SCSS
|
112
112
|
|
113
113
|
it { should report_lint line: 1 }
|
114
114
|
end
|
115
115
|
|
116
116
|
context 'and element qualifies id' do
|
117
|
-
let(:
|
117
|
+
let(:scss) { <<-SCSS }
|
118
118
|
li#item + li {}
|
119
|
-
|
119
|
+
SCSS
|
120
120
|
|
121
121
|
it { should report_lint line: 1 }
|
122
122
|
end
|
@@ -2,30 +2,30 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::SelectorDepth do
|
4
4
|
context 'when sequence has a depth of one' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { 'p {}' }
|
6
6
|
|
7
7
|
it { should_not report_lint }
|
8
8
|
end
|
9
9
|
|
10
10
|
context 'when sequence has a depth of three' do
|
11
|
-
let(:
|
11
|
+
let(:scss) { 'body article p {}' }
|
12
12
|
|
13
13
|
it { should_not report_lint }
|
14
14
|
|
15
15
|
context 'and contains a nested selector' do
|
16
|
-
let(:
|
16
|
+
let(:scss) { <<-SCSS }
|
17
17
|
body article p {
|
18
18
|
i {
|
19
19
|
font-style: italic;
|
20
20
|
}
|
21
21
|
}
|
22
|
-
|
22
|
+
SCSS
|
23
23
|
|
24
24
|
it { should report_lint line: 2 }
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'and contains multiple nested selectors' do
|
28
|
-
let(:
|
28
|
+
let(:scss) { <<-SCSS }
|
29
29
|
body article p {
|
30
30
|
b {
|
31
31
|
font-weight: bold;
|
@@ -34,7 +34,7 @@ describe SCSSLint::Linter::SelectorDepth do
|
|
34
34
|
font-style: italic;
|
35
35
|
}
|
36
36
|
}
|
37
|
-
|
37
|
+
SCSS
|
38
38
|
|
39
39
|
it { should report_lint line: 2 }
|
40
40
|
it { should report_lint line: 5 }
|
@@ -42,99 +42,99 @@ describe SCSSLint::Linter::SelectorDepth do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'when sequence has a depth of four' do
|
45
|
-
let(:
|
45
|
+
let(:scss) { 'body article p i {}' }
|
46
46
|
|
47
47
|
it { should report_lint line: 1 }
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when sequence is made up of adjacent sibling combinators' do
|
51
|
-
let(:
|
51
|
+
let(:scss) { '.one + .two + .three + .four {}' }
|
52
52
|
|
53
53
|
it { should_not report_lint }
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'when sequence is made up of general sibling combinators' do
|
57
|
-
let(:
|
57
|
+
let(:scss) { '.one .two ~ .three ~ .four {}' }
|
58
58
|
|
59
59
|
it { should_not report_lint }
|
60
60
|
end
|
61
61
|
|
62
62
|
context 'when sequence contains interpolation' do
|
63
|
-
let(:
|
63
|
+
let(:scss) { '.one #{$interpolated-string} .two .three {}' }
|
64
64
|
|
65
65
|
it { should_not report_lint }
|
66
66
|
end
|
67
67
|
|
68
68
|
context 'when comma sequence contains no sequences exceeding depth limit' do
|
69
|
-
let(:
|
69
|
+
let(:scss) { <<-SCSS }
|
70
70
|
p,
|
71
71
|
.one .two .three,
|
72
72
|
ul > li {
|
73
73
|
}
|
74
|
-
|
74
|
+
SCSS
|
75
75
|
|
76
76
|
it { should_not report_lint }
|
77
77
|
|
78
78
|
context 'and a nested selector causes one of the sequences to exceed the limit' do
|
79
|
-
let(:
|
79
|
+
let(:scss) { <<-SCSS }
|
80
80
|
p,
|
81
81
|
.one .two .three,
|
82
82
|
ul > li {
|
83
83
|
.four {}
|
84
84
|
}
|
85
|
-
|
85
|
+
SCSS
|
86
86
|
|
87
87
|
it { should report_lint line: 4 }
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
context 'when comma sequence contains a sequence exceeding the depth limit' do
|
92
|
-
let(:
|
92
|
+
let(:scss) { <<-SCSS }
|
93
93
|
p,
|
94
94
|
.one .two .three .four,
|
95
95
|
ul > li {
|
96
96
|
}
|
97
|
-
|
97
|
+
SCSS
|
98
98
|
|
99
99
|
it { should report_lint line: 1 }
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'when sequence contains a nested selector with a parent selector' do
|
103
103
|
context 'which does not exceed the depth limit' do
|
104
|
-
let(:
|
104
|
+
let(:scss) { <<-SCSS }
|
105
105
|
.one .two {
|
106
106
|
.three & {}
|
107
107
|
}
|
108
|
-
|
108
|
+
SCSS
|
109
109
|
|
110
110
|
it { should_not report_lint }
|
111
111
|
|
112
112
|
context 'and the parent selector is chained' do
|
113
|
-
let(:
|
113
|
+
let(:scss) { <<-SCSS }
|
114
114
|
.one .two .three {
|
115
115
|
&.chained {}
|
116
116
|
}
|
117
|
-
|
117
|
+
SCSS
|
118
118
|
|
119
119
|
it { should_not report_lint }
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
context 'which does exceed the depth limit' do
|
124
|
-
let(:
|
124
|
+
let(:scss) { <<-SCSS }
|
125
125
|
.one .two {
|
126
126
|
.three & & .four {}
|
127
127
|
}
|
128
|
-
|
128
|
+
SCSS
|
129
129
|
|
130
130
|
it { should report_lint line: 2 }
|
131
131
|
|
132
132
|
context 'and the parent selector is chained' do
|
133
|
-
let(:
|
133
|
+
let(:scss) { <<-SCSS }
|
134
134
|
.one .two .three > .four {
|
135
135
|
&.chained {}
|
136
136
|
}
|
137
|
-
|
137
|
+
SCSS
|
138
138
|
|
139
139
|
it { should report_lint line: 2 }
|
140
140
|
end
|
@@ -142,7 +142,7 @@ describe SCSSLint::Linter::SelectorDepth do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
context 'when sequence contains a @keyframe' do
|
145
|
-
let(:
|
145
|
+
let(:scss) { <<-SCSS }
|
146
146
|
@keyframe my-keyframe {
|
147
147
|
0% {
|
148
148
|
background: #000;
|
@@ -152,7 +152,7 @@ describe SCSSLint::Linter::SelectorDepth do
|
|
152
152
|
background: #fff;
|
153
153
|
}
|
154
154
|
}
|
155
|
-
|
155
|
+
SCSS
|
156
156
|
|
157
157
|
it { should_not report_lint }
|
158
158
|
end
|
@@ -2,82 +2,82 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SCSSLint::Linter::SelectorFormat do
|
4
4
|
context 'when class has alphanumeric chars and is separated by hyphens' do
|
5
|
-
let(:
|
5
|
+
let(:scss) { <<-SCSS }
|
6
6
|
.foo-bar-77 {
|
7
7
|
}
|
8
|
-
|
8
|
+
SCSS
|
9
9
|
|
10
10
|
it { should_not report_lint }
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when id has alphanumeric chars and is separated by hyphens' do
|
14
|
-
let(:
|
14
|
+
let(:scss) { <<-SCSS }
|
15
15
|
#foo-bar-77 {
|
16
16
|
}
|
17
|
-
|
17
|
+
SCSS
|
18
18
|
|
19
19
|
it { should_not report_lint }
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'when element has alphanumeric chars and is separated by hyphens' do
|
23
|
-
let(:
|
23
|
+
let(:scss) { <<-SCSS }
|
24
24
|
foo-bar-77 {
|
25
25
|
}
|
26
|
-
|
26
|
+
SCSS
|
27
27
|
|
28
28
|
it { should_not report_lint }
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'when placeholder has alphanumeric chars and is separated by hyphens' do
|
32
|
-
let(:
|
32
|
+
let(:scss) { <<-SCSS }
|
33
33
|
%foo-bar-77 {
|
34
34
|
}
|
35
|
-
|
35
|
+
SCSS
|
36
36
|
|
37
37
|
it { should_not report_lint }
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when selector has alphanumeric chars and is separated by underscores' do
|
41
|
-
let(:
|
41
|
+
let(:scss) { <<-SCSS }
|
42
42
|
.foo_bar {
|
43
43
|
}
|
44
|
-
|
44
|
+
SCSS
|
45
45
|
|
46
46
|
it { should report_lint line: 1 }
|
47
47
|
end
|
48
48
|
|
49
|
-
context 'when selector
|
50
|
-
let(:
|
49
|
+
context 'when selector is camelCase' do
|
50
|
+
let(:scss) { <<-SCSS }
|
51
51
|
fooBar77 {
|
52
52
|
}
|
53
|
-
|
53
|
+
SCSS
|
54
54
|
|
55
55
|
it { should report_lint line: 1 }
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'when placeholder has alphanumeric chars and is separated by underscores' do
|
59
|
-
let(:
|
59
|
+
let(:scss) { <<-SCSS }
|
60
60
|
%foo_bar {
|
61
61
|
}
|
62
|
-
|
62
|
+
SCSS
|
63
63
|
|
64
64
|
it { should report_lint line: 1 }
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'when attribute has alphanumeric chars and is separated by underscores' do
|
68
|
-
let(:
|
68
|
+
let(:scss) { <<-SCSS }
|
69
69
|
[data_text] {
|
70
70
|
}
|
71
|
-
|
71
|
+
SCSS
|
72
72
|
|
73
73
|
it { should report_lint line: 1 }
|
74
74
|
end
|
75
75
|
|
76
76
|
context 'when attribute selector has alphanumeric chars and is separated by underscores' do
|
77
|
-
let(:
|
77
|
+
let(:scss) { <<-SCSS }
|
78
78
|
[data-text=some_text] {
|
79
79
|
}
|
80
|
-
|
80
|
+
SCSS
|
81
81
|
|
82
82
|
it { should_not report_lint }
|
83
83
|
end
|
@@ -86,28 +86,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
86
86
|
let(:linter_config) { { 'convention' => 'snake_case' } }
|
87
87
|
|
88
88
|
context 'when selector has alphanumeric chars and is separated by underscores' do
|
89
|
-
let(:
|
89
|
+
let(:scss) { <<-SCSS }
|
90
90
|
.foo_bar_77 {
|
91
91
|
}
|
92
|
-
|
92
|
+
SCSS
|
93
93
|
|
94
94
|
it { should_not report_lint }
|
95
95
|
end
|
96
96
|
|
97
97
|
context 'when selector has alphanumeric chars and is separated by hyphens' do
|
98
|
-
let(:
|
98
|
+
let(:scss) { <<-SCSS }
|
99
99
|
.foo-bar-77 {
|
100
100
|
}
|
101
|
-
|
101
|
+
SCSS
|
102
102
|
|
103
103
|
it { should report_lint line: 1 }
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'when selector is in camelCase' do
|
107
|
-
let(:
|
107
|
+
let(:scss) { <<-SCSS }
|
108
108
|
.fooBar77 {
|
109
109
|
}
|
110
|
-
|
110
|
+
SCSS
|
111
111
|
|
112
112
|
it { should report_lint line: 1 }
|
113
113
|
end
|
@@ -116,38 +116,38 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
116
116
|
context 'when convention is set to camel_case' do
|
117
117
|
let(:linter_config) { { 'convention' => 'camel_case' } }
|
118
118
|
|
119
|
-
context 'when selector
|
120
|
-
let(:
|
119
|
+
context 'when selector is camelCase' do
|
120
|
+
let(:scss) { <<-SCSS }
|
121
121
|
.fooBar77 {
|
122
122
|
}
|
123
|
-
|
123
|
+
SCSS
|
124
124
|
|
125
125
|
it { should_not report_lint }
|
126
126
|
end
|
127
127
|
|
128
128
|
context 'when selector capitalizes first word' do
|
129
|
-
let(:
|
129
|
+
let(:scss) { <<-SCSS }
|
130
130
|
.FooBar77 {
|
131
131
|
}
|
132
|
-
|
132
|
+
SCSS
|
133
133
|
|
134
134
|
it { should report_lint line: 1 }
|
135
135
|
end
|
136
136
|
|
137
137
|
context 'when selector has alphanumeric chars and is separated by underscores' do
|
138
|
-
let(:
|
138
|
+
let(:scss) { <<-SCSS }
|
139
139
|
.foo_bar_77 {
|
140
140
|
}
|
141
|
-
|
141
|
+
SCSS
|
142
142
|
|
143
143
|
it { should report_lint line: 1 }
|
144
144
|
end
|
145
145
|
|
146
146
|
context 'when selector has alphanumeric chars and is separated by hyphens' do
|
147
|
-
let(:
|
147
|
+
let(:scss) { <<-SCSS }
|
148
148
|
.foo-bar-77 {
|
149
149
|
}
|
150
|
-
|
150
|
+
SCSS
|
151
151
|
|
152
152
|
it { should report_lint line: 1 }
|
153
153
|
end
|
@@ -157,19 +157,19 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
157
157
|
let(:linter_config) { { 'convention' => /^[0-9]*$/ } }
|
158
158
|
|
159
159
|
context 'when selector uses regex properly' do
|
160
|
-
let(:
|
160
|
+
let(:scss) { <<-SCSS }
|
161
161
|
.1337 {
|
162
162
|
}
|
163
|
-
|
163
|
+
SCSS
|
164
164
|
|
165
165
|
it { should_not report_lint }
|
166
166
|
end
|
167
167
|
|
168
168
|
context 'when selector does not use regex properly' do
|
169
|
-
let(:
|
169
|
+
let(:scss) { <<-SCSS }
|
170
170
|
.leet {
|
171
171
|
}
|
172
|
-
|
172
|
+
SCSS
|
173
173
|
|
174
174
|
it { should report_lint line: 1 }
|
175
175
|
end
|
@@ -179,10 +179,10 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
179
179
|
let(:linter_config) { { 'ignored_names' => ['fooBar'] } }
|
180
180
|
|
181
181
|
context 'it ignores exact string matches' do
|
182
|
-
let(:
|
182
|
+
let(:scss) { <<-SCSS }
|
183
183
|
fooBar {
|
184
184
|
}
|
185
|
-
|
185
|
+
SCSS
|
186
186
|
|
187
187
|
it { should_not report_lint }
|
188
188
|
end
|
@@ -192,10 +192,10 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
192
192
|
let(:linter_config) { { 'ignored_types' => ['class'] } }
|
193
193
|
|
194
194
|
context 'it ignores all invalid classes' do
|
195
|
-
let(:
|
195
|
+
let(:scss) { <<-SCSS }
|
196
196
|
.fooBar {
|
197
197
|
}
|
198
|
-
|
198
|
+
SCSS
|
199
199
|
|
200
200
|
it { should_not report_lint }
|
201
201
|
end
|
@@ -207,37 +207,37 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
207
207
|
end
|
208
208
|
|
209
209
|
context 'it ignores all invalid ids' do
|
210
|
-
let(:
|
210
|
+
let(:scss) { <<-SCSS }
|
211
211
|
#fooBar {
|
212
212
|
}
|
213
|
-
|
213
|
+
SCSS
|
214
214
|
|
215
215
|
it { should_not report_lint }
|
216
216
|
end
|
217
217
|
|
218
218
|
context 'it ignores all invalid elements' do
|
219
|
-
let(:
|
219
|
+
let(:scss) { <<-SCSS }
|
220
220
|
fooBar {
|
221
221
|
}
|
222
|
-
|
222
|
+
SCSS
|
223
223
|
|
224
224
|
it { should_not report_lint }
|
225
225
|
end
|
226
226
|
|
227
227
|
context 'it ignores all invalid placeholders' do
|
228
|
-
let(:
|
228
|
+
let(:scss) { <<-SCSS }
|
229
229
|
%fooBar {
|
230
230
|
}
|
231
|
-
|
231
|
+
SCSS
|
232
232
|
|
233
233
|
it { should_not report_lint }
|
234
234
|
end
|
235
235
|
|
236
236
|
context 'it ignores all invalid attributes' do
|
237
|
-
let(:
|
237
|
+
let(:scss) { <<-SCSS }
|
238
238
|
[fooBar=fooBar] {
|
239
239
|
}
|
240
|
-
|
240
|
+
SCSS
|
241
241
|
|
242
242
|
it { should_not report_lint }
|
243
243
|
end
|
@@ -247,28 +247,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
247
247
|
let(:linter_config) { { 'id_convention' => 'snake_case' } }
|
248
248
|
|
249
249
|
context 'and actual id is correct' do
|
250
|
-
let(:
|
250
|
+
let(:scss) { <<-SCSS }
|
251
251
|
.hyphenated-lowercase {}
|
252
252
|
#snake_case {}
|
253
|
-
|
253
|
+
SCSS
|
254
254
|
|
255
255
|
it { should_not report_lint }
|
256
256
|
end
|
257
257
|
|
258
258
|
context 'and actual id is incorrect' do
|
259
|
-
let(:
|
259
|
+
let(:scss) { <<-SCSS }
|
260
260
|
.hyphenated-lowercase {}
|
261
261
|
#hyphenated-lowercase {}
|
262
|
-
|
262
|
+
SCSS
|
263
263
|
|
264
264
|
it { should report_lint line: 2 }
|
265
265
|
end
|
266
266
|
|
267
267
|
context 'and something else uses the `id_convention`' do
|
268
|
-
let(:
|
268
|
+
let(:scss) { <<-SCSS }
|
269
269
|
.snake_case {}
|
270
270
|
#hyphenated-lowercase {}
|
271
|
-
|
271
|
+
SCSS
|
272
272
|
|
273
273
|
it { should report_lint line: 1 }
|
274
274
|
end
|
@@ -278,28 +278,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
278
278
|
let(:linter_config) { { 'class_convention' => 'camel_case' } }
|
279
279
|
|
280
280
|
context 'and actual class is correct' do
|
281
|
-
let(:
|
281
|
+
let(:scss) { <<-SCSS }
|
282
282
|
.camelCase {}
|
283
283
|
#hyphenated-lowercase {}
|
284
|
-
|
284
|
+
SCSS
|
285
285
|
|
286
286
|
it { should_not report_lint }
|
287
287
|
end
|
288
288
|
|
289
289
|
context 'and actual class is incorrect' do
|
290
|
-
let(:
|
290
|
+
let(:scss) { <<-SCSS }
|
291
291
|
.hyphenated-lowercase {}
|
292
292
|
#hyphenated-lowercase {}
|
293
|
-
|
293
|
+
SCSS
|
294
294
|
|
295
295
|
it { should report_lint line: 1 }
|
296
296
|
end
|
297
297
|
|
298
298
|
context 'and something else uses the `class_convention`' do
|
299
|
-
let(:
|
299
|
+
let(:scss) { <<-SCSS }
|
300
300
|
.hyphenated-lowercase {}
|
301
301
|
#camelCase {}
|
302
|
-
|
302
|
+
SCSS
|
303
303
|
|
304
304
|
it { should report_lint line: 2 }
|
305
305
|
end
|
@@ -309,28 +309,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
309
309
|
let(:linter_config) { { 'placeholder_convention' => 'snake_case' } }
|
310
310
|
|
311
311
|
context 'and actual placeholder is correct' do
|
312
|
-
let(:
|
312
|
+
let(:scss) { <<-SCSS }
|
313
313
|
.hyphenated-lowercase {}
|
314
314
|
%snake_case {}
|
315
|
-
|
315
|
+
SCSS
|
316
316
|
|
317
317
|
it { should_not report_lint }
|
318
318
|
end
|
319
319
|
|
320
320
|
context 'and actual placeholder is incorrect' do
|
321
|
-
let(:
|
321
|
+
let(:scss) { <<-SCSS }
|
322
322
|
.hyphenated-lowercase {}
|
323
323
|
%hyphenated-lowercase {}
|
324
|
-
|
324
|
+
SCSS
|
325
325
|
|
326
326
|
it { should report_lint line: 2 }
|
327
327
|
end
|
328
328
|
|
329
329
|
context 'and something else uses the `placeholder_convention`' do
|
330
|
-
let(:
|
330
|
+
let(:scss) { <<-SCSS }
|
331
331
|
.snake_case {}
|
332
332
|
%snake_case {}
|
333
|
-
|
333
|
+
SCSS
|
334
334
|
|
335
335
|
it { should report_lint line: 1 }
|
336
336
|
end
|
@@ -345,28 +345,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
345
345
|
end
|
346
346
|
|
347
347
|
context 'and actual element is correct' do
|
348
|
-
let(:
|
348
|
+
let(:scss) { <<-SCSS }
|
349
349
|
hyphenated-lowercase {}
|
350
350
|
#camelCase {}
|
351
|
-
|
351
|
+
SCSS
|
352
352
|
|
353
353
|
it { should_not report_lint }
|
354
354
|
end
|
355
355
|
|
356
356
|
context 'and actual element is incorrect' do
|
357
|
-
let(:
|
357
|
+
let(:scss) { <<-SCSS }
|
358
358
|
camelCase {}
|
359
359
|
#camelCase {}
|
360
|
-
|
360
|
+
SCSS
|
361
361
|
|
362
362
|
it { should report_lint line: 1 }
|
363
363
|
end
|
364
364
|
|
365
365
|
context 'and something else uses the `element_convention`' do
|
366
|
-
let(:
|
366
|
+
let(:scss) { <<-SCSS }
|
367
367
|
hyphenated-lowercase {}
|
368
368
|
#hyphenated-lowercase {}
|
369
|
-
|
369
|
+
SCSS
|
370
370
|
|
371
371
|
it { should report_lint line: 2 }
|
372
372
|
end
|
@@ -381,28 +381,28 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
381
381
|
end
|
382
382
|
|
383
383
|
context 'and actual attribute is correct' do
|
384
|
-
let(:
|
384
|
+
let(:scss) { <<-SCSS }
|
385
385
|
[hyphenated-lowercase] {}
|
386
386
|
#camelCase {}
|
387
|
-
|
387
|
+
SCSS
|
388
388
|
|
389
389
|
it { should_not report_lint }
|
390
390
|
end
|
391
391
|
|
392
392
|
context 'and actual attribute is incorrect' do
|
393
|
-
let(:
|
393
|
+
let(:scss) { <<-SCSS }
|
394
394
|
[camelCase] {}
|
395
395
|
#camelCase {}
|
396
|
-
|
396
|
+
SCSS
|
397
397
|
|
398
398
|
it { should report_lint line: 1 }
|
399
399
|
end
|
400
400
|
|
401
401
|
context 'and something else uses the `attribute_convention`' do
|
402
|
-
let(:
|
402
|
+
let(:scss) { <<-SCSS }
|
403
403
|
[hyphenated-lowercase] {}
|
404
404
|
#hyphenated-lowercase {}
|
405
|
-
|
405
|
+
SCSS
|
406
406
|
|
407
407
|
it { should report_lint line: 2 }
|
408
408
|
end
|
@@ -419,35 +419,35 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
419
419
|
end
|
420
420
|
|
421
421
|
context 'and everything is correct' do
|
422
|
-
let(:
|
422
|
+
let(:scss) { <<-SCSS }
|
423
423
|
#camelCase {}
|
424
424
|
hyphenated-lowercase {}
|
425
425
|
[snake_case] {}
|
426
426
|
.foo--bar {}
|
427
|
-
|
427
|
+
SCSS
|
428
428
|
|
429
429
|
it { should_not report_lint }
|
430
430
|
end
|
431
431
|
|
432
432
|
context 'some things are not correct' do
|
433
|
-
let(:
|
433
|
+
let(:scss) { <<-SCSS }
|
434
434
|
#camelCase {}
|
435
435
|
camelCase {}
|
436
436
|
[snake_case] {}
|
437
437
|
.fooBar {}
|
438
|
-
|
438
|
+
SCSS
|
439
439
|
|
440
440
|
it { should report_lint line: 2 }
|
441
441
|
it { should report_lint line: 4 }
|
442
442
|
end
|
443
443
|
|
444
444
|
context 'other things are not correct' do
|
445
|
-
let(:
|
445
|
+
let(:scss) { <<-SCSS }
|
446
446
|
#snake_case {}
|
447
447
|
hyphenated-lowercase {}
|
448
448
|
[camelCase] {}
|
449
449
|
.foo--bar {}
|
450
|
-
|
450
|
+
SCSS
|
451
451
|
|
452
452
|
it { should report_lint line: 1 }
|
453
453
|
it { should report_lint line: 3 }
|
@@ -458,79 +458,79 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
458
458
|
let(:linter_config) { { 'convention' => 'BEM' } }
|
459
459
|
|
460
460
|
context 'when a name contains no underscores or hyphens' do
|
461
|
-
let(:
|
461
|
+
let(:scss) { '.block {}' }
|
462
462
|
|
463
463
|
it { should_not report_lint }
|
464
464
|
end
|
465
465
|
|
466
466
|
context 'when a name contains single hyphen' do
|
467
|
-
let(:
|
467
|
+
let(:scss) { '.b-block {}' }
|
468
468
|
|
469
469
|
it { should_not report_lint }
|
470
470
|
end
|
471
471
|
|
472
472
|
context 'when a name contains multiple hyphens' do
|
473
|
-
let(:
|
473
|
+
let(:scss) { '.b-block-name {}' }
|
474
474
|
|
475
475
|
it { should_not report_lint }
|
476
476
|
end
|
477
477
|
|
478
478
|
context 'when a name contains multiple hyphens in a row' do
|
479
|
-
let(:
|
479
|
+
let(:scss) { '.b-block--modifier {}' }
|
480
480
|
|
481
481
|
it { should report_lint }
|
482
482
|
end
|
483
483
|
|
484
484
|
context 'when a name contains a single underscore' do
|
485
|
-
let(:
|
485
|
+
let(:scss) { '.block_modifier {}' }
|
486
486
|
|
487
487
|
it { should report_lint }
|
488
488
|
end
|
489
489
|
|
490
490
|
context 'when a block has name-value modifier' do
|
491
|
-
let(:
|
491
|
+
let(:scss) { '.block_modifier_value {}' }
|
492
492
|
|
493
493
|
it { should_not report_lint }
|
494
494
|
end
|
495
495
|
|
496
496
|
context 'when a block has name-value modifier with lots of hyphens' do
|
497
|
-
let(:
|
497
|
+
let(:scss) { '.b-block-name_modifier-name-here_value-name-here {}' }
|
498
498
|
|
499
499
|
it { should_not report_lint }
|
500
500
|
end
|
501
501
|
|
502
502
|
context 'when a name has double underscores' do
|
503
|
-
let(:
|
503
|
+
let(:scss) { '.b-block__element {}' }
|
504
504
|
|
505
505
|
it { should_not report_lint }
|
506
506
|
end
|
507
507
|
|
508
508
|
context 'when element goes after block with modifier' do
|
509
|
-
let(:
|
509
|
+
let(:scss) { '.block_modifier_value__element {}' }
|
510
510
|
|
511
511
|
it { should report_lint }
|
512
512
|
end
|
513
513
|
|
514
514
|
context 'when element has modifier' do
|
515
|
-
let(:
|
515
|
+
let(:scss) { '.block__element_modifier_value {}' }
|
516
516
|
|
517
517
|
it { should_not report_lint }
|
518
518
|
end
|
519
519
|
|
520
520
|
context 'when element has not paired modifier' do
|
521
|
-
let(:
|
521
|
+
let(:scss) { '.block__element_modifier {}' }
|
522
522
|
|
523
523
|
it { should report_lint }
|
524
524
|
end
|
525
525
|
|
526
526
|
context 'when element has hypenated modifier' do
|
527
|
-
let(:
|
527
|
+
let(:scss) { '.block__element--modifier {}' }
|
528
528
|
|
529
529
|
it { should report_lint }
|
530
530
|
end
|
531
531
|
|
532
532
|
context 'when element has hypenated paired modifier' do
|
533
|
-
let(:
|
533
|
+
let(:scss) { '.block__element--modifier_value {}' }
|
534
534
|
|
535
535
|
it { should report_lint }
|
536
536
|
end
|
@@ -540,91 +540,91 @@ describe SCSSLint::Linter::SelectorFormat do
|
|
540
540
|
let(:linter_config) { { 'convention' => 'hyphenated_BEM' } }
|
541
541
|
|
542
542
|
context 'when a name contains no underscores or hyphens' do
|
543
|
-
let(:
|
543
|
+
let(:scss) { '.block {}' }
|
544
544
|
|
545
545
|
it { should_not report_lint }
|
546
546
|
end
|
547
547
|
|
548
548
|
context 'when a name contains single hyphen' do
|
549
|
-
let(:
|
549
|
+
let(:scss) { '.b-block {}' }
|
550
550
|
|
551
551
|
it { should_not report_lint }
|
552
552
|
end
|
553
553
|
|
554
554
|
context 'when a name contains multiple hyphens' do
|
555
|
-
let(:
|
555
|
+
let(:scss) { '.b-block-name {}' }
|
556
556
|
|
557
557
|
it { should_not report_lint }
|
558
558
|
end
|
559
559
|
|
560
560
|
context 'when a name contains multiple hyphens in a row' do
|
561
|
-
let(:
|
561
|
+
let(:scss) { '.b-block--modifier {}' }
|
562
562
|
|
563
563
|
it { should_not report_lint }
|
564
564
|
end
|
565
565
|
|
566
566
|
context 'when a name contains a single underscore' do
|
567
|
-
let(:
|
567
|
+
let(:scss) { '.block_modifier {}' }
|
568
568
|
|
569
569
|
it { should report_lint }
|
570
570
|
end
|
571
571
|
|
572
572
|
context 'when a block has name-value modifier' do
|
573
|
-
let(:
|
573
|
+
let(:scss) { '.block--modifier-value {}' }
|
574
574
|
|
575
575
|
it { should_not report_lint }
|
576
576
|
end
|
577
577
|
|
578
578
|
context 'when a block has name-value modifier with lots of hyphens' do
|
579
|
-
let(:
|
579
|
+
let(:scss) { '.b-block-name--modifier-name-here-value-name-here {}' }
|
580
580
|
|
581
581
|
it { should_not report_lint }
|
582
582
|
end
|
583
583
|
|
584
584
|
context 'when a name has double underscores' do
|
585
|
-
let(:
|
585
|
+
let(:scss) { '.b-block__element {}' }
|
586
586
|
|
587
587
|
it { should_not report_lint }
|
588
588
|
end
|
589
589
|
|
590
590
|
context 'when element goes after block with modifier' do
|
591
|
-
let(:
|
591
|
+
let(:scss) { '.block--modifier-value__element {}' }
|
592
592
|
|
593
593
|
it { should_not report_lint }
|
594
594
|
end
|
595
595
|
|
596
596
|
context 'when element has modifier' do
|
597
|
-
let(:
|
597
|
+
let(:scss) { '.block__element--modifier-value {}' }
|
598
598
|
|
599
599
|
it { should_not report_lint }
|
600
600
|
end
|
601
601
|
|
602
602
|
context 'when element has hypenated modifier' do
|
603
|
-
let(:
|
603
|
+
let(:scss) { '.block__element--modifier {}' }
|
604
604
|
|
605
605
|
it { should_not report_lint }
|
606
606
|
end
|
607
607
|
|
608
608
|
context 'when element has hypenated paired modifier' do
|
609
|
-
let(:
|
609
|
+
let(:scss) { '.block__element--modifier-value {}' }
|
610
610
|
|
611
611
|
it { should_not report_lint }
|
612
612
|
end
|
613
613
|
|
614
614
|
context 'when a block contains an underscore' do
|
615
|
-
let(:
|
615
|
+
let(:scss) { '.a_block__element--modifier {}' }
|
616
616
|
|
617
617
|
it { should report_lint }
|
618
618
|
end
|
619
619
|
|
620
620
|
context 'when an element contains an underscore' do
|
621
|
-
let(:
|
621
|
+
let(:scss) { '.block__an_element--modifier {}' }
|
622
622
|
|
623
623
|
it { should report_lint }
|
624
624
|
end
|
625
625
|
|
626
626
|
context 'when a modifier contains an underscore' do
|
627
|
-
let(:
|
627
|
+
let(:scss) { '.block__element--a_modifier {}' }
|
628
628
|
|
629
629
|
it { should report_lint }
|
630
630
|
end
|