scss-lint-bliss 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/bin/scss-lint +6 -0
  2. data/config/default.yml +220 -0
  3. data/data/prefixed-identifiers/base.txt +107 -0
  4. data/data/prefixed-identifiers/bourbon.txt +71 -0
  5. data/data/properties.txt +477 -0
  6. data/data/property-sort-orders/concentric.txt +134 -0
  7. data/data/property-sort-orders/recess.txt +149 -0
  8. data/data/property-sort-orders/smacss.txt +137 -0
  9. data/lib/scss_lint.rb +31 -0
  10. data/lib/scss_lint/cli.rb +215 -0
  11. data/lib/scss_lint/config.rb +251 -0
  12. data/lib/scss_lint/constants.rb +8 -0
  13. data/lib/scss_lint/control_comment_processor.rb +126 -0
  14. data/lib/scss_lint/engine.rb +56 -0
  15. data/lib/scss_lint/exceptions.rb +21 -0
  16. data/lib/scss_lint/file_finder.rb +68 -0
  17. data/lib/scss_lint/lint.rb +24 -0
  18. data/lib/scss_lint/linter.rb +161 -0
  19. data/lib/scss_lint/linter/bang_format.rb +52 -0
  20. data/lib/scss_lint/linter/bliss.rb +8 -0
  21. data/lib/scss_lint/linter/bliss/module.rb +101 -0
  22. data/lib/scss_lint/linter/border_zero.rb +39 -0
  23. data/lib/scss_lint/linter/color_keyword.rb +32 -0
  24. data/lib/scss_lint/linter/color_variable.rb +49 -0
  25. data/lib/scss_lint/linter/comment.rb +21 -0
  26. data/lib/scss_lint/linter/compass.rb +7 -0
  27. data/lib/scss_lint/linter/compass/property_with_mixin.rb +47 -0
  28. data/lib/scss_lint/linter/debug_statement.rb +10 -0
  29. data/lib/scss_lint/linter/declaration_order.rb +71 -0
  30. data/lib/scss_lint/linter/duplicate_property.rb +58 -0
  31. data/lib/scss_lint/linter/else_placement.rb +48 -0
  32. data/lib/scss_lint/linter/empty_line_between_blocks.rb +85 -0
  33. data/lib/scss_lint/linter/empty_rule.rb +11 -0
  34. data/lib/scss_lint/linter/final_newline.rb +20 -0
  35. data/lib/scss_lint/linter/hex_length.rb +56 -0
  36. data/lib/scss_lint/linter/hex_notation.rb +38 -0
  37. data/lib/scss_lint/linter/hex_validation.rb +23 -0
  38. data/lib/scss_lint/linter/id_selector.rb +10 -0
  39. data/lib/scss_lint/linter/import_path.rb +62 -0
  40. data/lib/scss_lint/linter/important_rule.rb +12 -0
  41. data/lib/scss_lint/linter/indentation.rb +197 -0
  42. data/lib/scss_lint/linter/leading_zero.rb +49 -0
  43. data/lib/scss_lint/linter/mergeable_selector.rb +60 -0
  44. data/lib/scss_lint/linter/name_format.rb +117 -0
  45. data/lib/scss_lint/linter/nesting_depth.rb +24 -0
  46. data/lib/scss_lint/linter/placeholder_in_extend.rb +22 -0
  47. data/lib/scss_lint/linter/property_count.rb +44 -0
  48. data/lib/scss_lint/linter/property_sort_order.rb +189 -0
  49. data/lib/scss_lint/linter/property_spelling.rb +49 -0
  50. data/lib/scss_lint/linter/property_units.rb +59 -0
  51. data/lib/scss_lint/linter/qualifying_element.rb +42 -0
  52. data/lib/scss_lint/linter/selector_depth.rb +64 -0
  53. data/lib/scss_lint/linter/selector_format.rb +102 -0
  54. data/lib/scss_lint/linter/shorthand.rb +139 -0
  55. data/lib/scss_lint/linter/single_line_per_property.rb +59 -0
  56. data/lib/scss_lint/linter/single_line_per_selector.rb +35 -0
  57. data/lib/scss_lint/linter/space_after_comma.rb +110 -0
  58. data/lib/scss_lint/linter/space_after_property_colon.rb +84 -0
  59. data/lib/scss_lint/linter/space_after_property_name.rb +27 -0
  60. data/lib/scss_lint/linter/space_before_brace.rb +72 -0
  61. data/lib/scss_lint/linter/space_between_parens.rb +35 -0
  62. data/lib/scss_lint/linter/string_quotes.rb +94 -0
  63. data/lib/scss_lint/linter/trailing_semicolon.rb +67 -0
  64. data/lib/scss_lint/linter/trailing_zero.rb +41 -0
  65. data/lib/scss_lint/linter/unnecessary_mantissa.rb +42 -0
  66. data/lib/scss_lint/linter/unnecessary_parent_reference.rb +49 -0
  67. data/lib/scss_lint/linter/url_format.rb +56 -0
  68. data/lib/scss_lint/linter/url_quotes.rb +27 -0
  69. data/lib/scss_lint/linter/variable_for_property.rb +30 -0
  70. data/lib/scss_lint/linter/vendor_prefix.rb +64 -0
  71. data/lib/scss_lint/linter/zero_unit.rb +39 -0
  72. data/lib/scss_lint/linter_registry.rb +26 -0
  73. data/lib/scss_lint/location.rb +38 -0
  74. data/lib/scss_lint/options.rb +109 -0
  75. data/lib/scss_lint/rake_task.rb +106 -0
  76. data/lib/scss_lint/reporter.rb +18 -0
  77. data/lib/scss_lint/reporter/config_reporter.rb +26 -0
  78. data/lib/scss_lint/reporter/default_reporter.rb +27 -0
  79. data/lib/scss_lint/reporter/files_reporter.rb +8 -0
  80. data/lib/scss_lint/reporter/json_reporter.rb +30 -0
  81. data/lib/scss_lint/reporter/xml_reporter.rb +33 -0
  82. data/lib/scss_lint/runner.rb +51 -0
  83. data/lib/scss_lint/sass/script.rb +78 -0
  84. data/lib/scss_lint/sass/tree.rb +168 -0
  85. data/lib/scss_lint/selector_visitor.rb +34 -0
  86. data/lib/scss_lint/utils.rb +112 -0
  87. data/lib/scss_lint/version.rb +4 -0
  88. data/spec/scss_lint/cli_spec.rb +177 -0
  89. data/spec/scss_lint/config_spec.rb +253 -0
  90. data/spec/scss_lint/engine_spec.rb +24 -0
  91. data/spec/scss_lint/file_finder_spec.rb +134 -0
  92. data/spec/scss_lint/linter/bang_format_spec.rb +121 -0
  93. data/spec/scss_lint/linter/bliss/module_spec.rb +254 -0
  94. data/spec/scss_lint/linter/border_zero_spec.rb +118 -0
  95. data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
  96. data/spec/scss_lint/linter/color_variable_spec.rb +145 -0
  97. data/spec/scss_lint/linter/comment_spec.rb +79 -0
  98. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
  99. data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
  100. data/spec/scss_lint/linter/declaration_order_spec.rb +575 -0
  101. data/spec/scss_lint/linter/duplicate_property_spec.rb +189 -0
  102. data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
  103. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +276 -0
  104. data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
  105. data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
  106. data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
  107. data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
  108. data/spec/scss_lint/linter/hex_validation_spec.rb +40 -0
  109. data/spec/scss_lint/linter/id_selector_spec.rb +62 -0
  110. data/spec/scss_lint/linter/import_path_spec.rb +300 -0
  111. data/spec/scss_lint/linter/important_rule_spec.rb +43 -0
  112. data/spec/scss_lint/linter/indentation_spec.rb +347 -0
  113. data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
  114. data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
  115. data/spec/scss_lint/linter/name_format_spec.rb +282 -0
  116. data/spec/scss_lint/linter/nesting_depth_spec.rb +114 -0
  117. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
  118. data/spec/scss_lint/linter/property_count_spec.rb +104 -0
  119. data/spec/scss_lint/linter/property_sort_order_spec.rb +426 -0
  120. data/spec/scss_lint/linter/property_spelling_spec.rb +84 -0
  121. data/spec/scss_lint/linter/property_units_spec.rb +229 -0
  122. data/spec/scss_lint/linter/qualifying_element_spec.rb +125 -0
  123. data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
  124. data/spec/scss_lint/linter/selector_format_spec.rb +632 -0
  125. data/spec/scss_lint/linter/shorthand_spec.rb +198 -0
  126. data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
  127. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +130 -0
  128. data/spec/scss_lint/linter/space_after_comma_spec.rb +332 -0
  129. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +264 -0
  130. data/spec/scss_lint/linter/space_after_property_name_spec.rb +37 -0
  131. data/spec/scss_lint/linter/space_before_brace_spec.rb +829 -0
  132. data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
  133. data/spec/scss_lint/linter/string_quotes_spec.rb +335 -0
  134. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +304 -0
  135. data/spec/scss_lint/linter/trailing_zero_spec.rb +176 -0
  136. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
  137. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +98 -0
  138. data/spec/scss_lint/linter/url_format_spec.rb +55 -0
  139. data/spec/scss_lint/linter/url_quotes_spec.rb +73 -0
  140. data/spec/scss_lint/linter/variable_for_property_spec.rb +145 -0
  141. data/spec/scss_lint/linter/vendor_prefix_spec.rb +371 -0
  142. data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
  143. data/spec/scss_lint/linter_registry_spec.rb +50 -0
  144. data/spec/scss_lint/linter_spec.rb +292 -0
  145. data/spec/scss_lint/location_spec.rb +42 -0
  146. data/spec/scss_lint/options_spec.rb +34 -0
  147. data/spec/scss_lint/rake_task_spec.rb +43 -0
  148. data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
  149. data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
  150. data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
  151. data/spec/scss_lint/reporter/json_reporter_spec.rb +96 -0
  152. data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
  153. data/spec/scss_lint/reporter_spec.rb +11 -0
  154. data/spec/scss_lint/runner_spec.rb +123 -0
  155. data/spec/scss_lint/selector_visitor_spec.rb +264 -0
  156. data/spec/spec_helper.rb +34 -0
  157. data/spec/support/isolated_environment.rb +25 -0
  158. data/spec/support/matchers/report_lint.rb +48 -0
  159. metadata +342 -0
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::UnnecessaryMantissa do
4
+ context 'when value is zero' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ margin: 0;
8
+ padding: func(0);
9
+ top: 0em;
10
+ }
11
+ SCSS
12
+
13
+ it { should_not report_lint }
14
+ end
15
+
16
+ context 'when value contains no mantissa' do
17
+ let(:scss) { <<-SCSS }
18
+ p {
19
+ margin: 1;
20
+ padding: func(1);
21
+ top: 1em;
22
+ }
23
+ SCSS
24
+
25
+ it { should_not report_lint }
26
+ end
27
+
28
+ context 'when value contains a mantissa with a zero' do
29
+ let(:scss) { <<-SCSS }
30
+ p {
31
+ margin: 1.0;
32
+ padding: func(1.0);
33
+ top: 1.0em;
34
+ }
35
+ SCSS
36
+
37
+ it { should report_lint line: 2 }
38
+ it { should report_lint line: 3 }
39
+ it { should report_lint line: 4 }
40
+ end
41
+
42
+ context 'when value contains a mantissa with multiple zeroes' do
43
+ let(:scss) { <<-SCSS }
44
+ p {
45
+ margin: 1.000;
46
+ padding: func(1.000);
47
+ top: 1.000em;
48
+ }
49
+ SCSS
50
+
51
+ it { should report_lint line: 2 }
52
+ it { should report_lint line: 3 }
53
+ it { should report_lint line: 4 }
54
+ end
55
+
56
+ context 'when value contains a mantissa with multiple zeroes followed by a number' do
57
+ let(:scss) { <<-SCSS }
58
+ p {
59
+ margin: 1.0001;
60
+ padding: func(1.0001);
61
+ top: 1.0001em;
62
+ }
63
+ SCSS
64
+
65
+ it { should_not report_lint }
66
+ end
67
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::UnnecessaryParentReference do
4
+ context 'when an amperand precedes a direct descendant operator' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ & > a {}
8
+ }
9
+ SCSS
10
+
11
+ it { should report_lint line: 2 }
12
+ end
13
+
14
+ context 'when an amperand precedes a general child' do
15
+ let(:scss) { <<-SCSS }
16
+ p {
17
+ & a {}
18
+ }
19
+ SCSS
20
+
21
+ it { should report_lint line: 2 }
22
+ end
23
+
24
+ context 'when an amperand is chained with class' do
25
+ let(:scss) { <<-SCSS }
26
+ p {
27
+ &.foo {}
28
+ }
29
+ SCSS
30
+
31
+ it { should_not report_lint }
32
+ end
33
+
34
+ context 'when an amperand follows a direct descendant operator' do
35
+ let(:scss) { <<-SCSS }
36
+ p {
37
+ .foo > & {}
38
+ }
39
+ SCSS
40
+
41
+ it { should_not report_lint }
42
+ end
43
+
44
+ context 'when an ampersand precedes a sibling operator' do
45
+ let(:scss) { <<-SCSS }
46
+ p {
47
+ & + & {}
48
+ & ~ & {}
49
+ }
50
+ SCSS
51
+
52
+ it { should_not report_lint }
53
+ end
54
+
55
+ context 'when multiple ampersands exist with one concatenated' do
56
+ let(:scss) { <<-SCSS }
57
+ p {
58
+ & + &:hover {}
59
+ }
60
+ SCSS
61
+
62
+ it { should_not report_lint }
63
+ end
64
+
65
+ context 'when an amperand is used in a comma sequence to DRY up code' do
66
+ let(:scss) { <<-SCSS }
67
+ p {
68
+ &,
69
+ .foo,
70
+ .bar {
71
+ margin: 0;
72
+ }
73
+ }
74
+ SCSS
75
+
76
+ it { should_not report_lint }
77
+ end
78
+
79
+ context 'when an ampersand is used by itself' do
80
+ let(:scss) { <<-SCSS }
81
+ p {
82
+ & {}
83
+ }
84
+ SCSS
85
+
86
+ it { should report_lint line: 2 }
87
+ end
88
+
89
+ context 'when an ampersand is used in concatentation' do
90
+ let(:scss) { <<-SCSS }
91
+ .icon {
92
+ &-small {}
93
+ }
94
+ SCSS
95
+
96
+ it { should_not report_lint }
97
+ end
98
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::UrlFormat do
4
+ shared_examples_for 'UrlFormat linter' do
5
+ context 'when URL contains protocol' do
6
+ let(:url) { 'https://something.com/image.png' }
7
+
8
+ it { should report_lint }
9
+ end
10
+
11
+ context 'when URL contains domain with protocol-less double slashes' do
12
+ let(:url) { '//something.com/image.png' }
13
+
14
+ it { should report_lint }
15
+ end
16
+
17
+ context 'when URL contains absolute path' do
18
+ let(:url) { '/absolute/path/to/image.png' }
19
+
20
+ it { should_not report_lint }
21
+ end
22
+
23
+ context 'when URL contains relative path' do
24
+ let(:url) { 'relative/path/to/image.png' }
25
+
26
+ it { should_not report_lint }
27
+ end
28
+
29
+ context 'when URL is a data URI' do
30
+ let(:url) { 'data:image/png;base64,iVBORI=' }
31
+
32
+ it { should_not report_lint }
33
+ end
34
+ end
35
+
36
+ context 'when URL is enclosed in quotes' do
37
+ let(:scss) { <<-SCSS }
38
+ .block {
39
+ background: url('#{url}');
40
+ }
41
+ SCSS
42
+
43
+ it_should_behave_like 'UrlFormat linter'
44
+ end
45
+
46
+ context 'when URL is not enclosed in quotes' do
47
+ let(:scss) { <<-SCSS }
48
+ .block {
49
+ background: url(#{url});
50
+ }
51
+ SCSS
52
+
53
+ it_should_behave_like 'UrlFormat linter'
54
+ end
55
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::UrlQuotes do
4
+ context 'when property has a literal URL' do
5
+ let(:scss) { <<-SCSS }
6
+ p {
7
+ background: url(example.png);
8
+ }
9
+ SCSS
10
+
11
+ it { should report_lint line: 2 }
12
+ end
13
+
14
+ context 'when property has a URL enclosed in single quotes' do
15
+ let(:scss) { <<-SCSS }
16
+ p {
17
+ background: url('example.png');
18
+ }
19
+ SCSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when property has a URL enclosed in double quotes' do
25
+ let(:scss) { <<-SCSS }
26
+ p {
27
+ background: url("example.png");
28
+ }
29
+ SCSS
30
+
31
+ it { should_not report_lint }
32
+ end
33
+
34
+ context 'when property has a literal URL in a list' do
35
+ let(:scss) { <<-SCSS }
36
+ p {
37
+ background: transparent url(example.png);
38
+ }
39
+ SCSS
40
+
41
+ it { should report_lint line: 2 }
42
+ end
43
+
44
+ context 'when property has a single-quoted URL in a list' do
45
+ let(:scss) { <<-SCSS }
46
+ p {
47
+ background: transparent url('example.png');
48
+ }
49
+ SCSS
50
+
51
+ it { should_not report_lint }
52
+ end
53
+
54
+ context 'when property has a double-quoted URL in a list' do
55
+ let(:scss) { <<-SCSS }
56
+ p {
57
+ background: transparent url("example.png");
58
+ }
59
+ SCSS
60
+
61
+ it { should_not report_lint }
62
+ end
63
+
64
+ context 'when property has a data URI' do
65
+ let(:scss) { <<-SCSS }
66
+ .tracking-pixel {
67
+ background: url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==);
68
+ }
69
+ SCSS
70
+
71
+ it { should_not report_lint }
72
+ end
73
+ end
@@ -0,0 +1,145 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::VariableForProperty do
4
+ context 'when properties are specified' do
5
+ let(:linter_config) { { 'properties' => %w[color font] } }
6
+
7
+ context 'when configured property value is a variable' do
8
+ let(:scss) { <<-SCSS }
9
+ p {
10
+ color: $black;
11
+ }
12
+ SCSS
13
+
14
+ it { should_not report_lint }
15
+ end
16
+
17
+ context 'when configured property value is a hex string' do
18
+ let(:scss) { <<-SCSS }
19
+ p {
20
+ color: #000;
21
+ }
22
+ SCSS
23
+
24
+ it { should report_lint line: 2 }
25
+ end
26
+
27
+ context 'when configured property value is a color keyword' do
28
+ let(:scss) { <<-SCSS }
29
+ p {
30
+ color: red;
31
+ }
32
+ SCSS
33
+
34
+ it { should report_lint line: 2 }
35
+ end
36
+
37
+ context 'when an unspecified property value is a variable' do
38
+ let(:scss) { <<-SCSS }
39
+ p {
40
+ background-color: $black;
41
+ }
42
+ SCSS
43
+
44
+ it { should_not report_lint }
45
+ end
46
+
47
+ context 'when an unspecified property value is not a variable' do
48
+ let(:scss) { <<-SCSS }
49
+ p {
50
+ background-color: #000;
51
+ }
52
+ SCSS
53
+
54
+ it { should_not report_lint }
55
+ end
56
+
57
+ context 'when multiple configured property values are variables' do
58
+ let(:scss) { <<-SCSS }
59
+ p {
60
+ color: $black;
61
+ font: $small;
62
+ }
63
+ SCSS
64
+
65
+ it { should_not report_lint }
66
+ end
67
+
68
+ context 'when multiple configured property values are not variables' do
69
+ let(:scss) { <<-SCSS }
70
+ p {
71
+ color: #000;
72
+ font: 8px;
73
+ }
74
+ SCSS
75
+
76
+ it { should report_lint line: 2 }
77
+ it { should report_lint line: 3 }
78
+ end
79
+
80
+ context 'when configured property values are mixed' do
81
+ let(:scss) { <<-SCSS }
82
+ p {
83
+ color: $black;
84
+ font: 8px;
85
+ }
86
+ SCSS
87
+
88
+ it { should report_lint line: 3 }
89
+ end
90
+
91
+ context 'when property specifies `currentColor`' do
92
+ let(:scss) { <<-SCSS }
93
+ p {
94
+ background-color: currentColor;
95
+ }
96
+ SCSS
97
+
98
+ it { should_not report_lint }
99
+ end
100
+
101
+ context 'when property specifies `inherit`' do
102
+ let(:scss) { <<-SCSS }
103
+ p {
104
+ color: inherit;
105
+ }
106
+ SCSS
107
+
108
+ it { should_not report_lint }
109
+ end
110
+
111
+ context 'when property specifies `transparent`' do
112
+ let(:scss) { <<-SCSS }
113
+ p {
114
+ color: transparent;
115
+ }
116
+ SCSS
117
+
118
+ it { should_not report_lint }
119
+ end
120
+ end
121
+
122
+ context 'when properties are not specified' do
123
+ let(:linter_config) { { 'properties' => [] } }
124
+
125
+ context 'when property value is a variable' do
126
+ let(:scss) { <<-SCSS }
127
+ p {
128
+ color: $black;
129
+ }
130
+ SCSS
131
+
132
+ it { should_not report_lint }
133
+ end
134
+
135
+ context 'when property value is not a variable' do
136
+ let(:scss) { <<-SCSS }
137
+ p {
138
+ color: #000;
139
+ }
140
+ SCSS
141
+
142
+ it { should_not report_lint }
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,371 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::VendorPrefix do
4
+ context 'when no vendor-prefix is used' do
5
+ let(:scss) { <<-SCSS }
6
+ div {
7
+ transition: none;
8
+ }
9
+ SCSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'when a rule is empty' do
15
+ let(:scss) { <<-SCSS }
16
+ div {
17
+ }
18
+ SCSS
19
+
20
+ it { should_not report_lint }
21
+ end
22
+
23
+ # Properties
24
+
25
+ context 'when a vendor-prefixed listed property is used' do
26
+ let(:scss) { <<-SCSS }
27
+ div {
28
+ -webkit-transition: none;
29
+ }
30
+ SCSS
31
+
32
+ it { should report_lint line: 2 }
33
+ end
34
+
35
+ context 'when an unprefixed listed property is used' do
36
+ let(:scss) { <<-SCSS }
37
+ div {
38
+ transition: none;
39
+ }
40
+ SCSS
41
+
42
+ it { should_not report_lint }
43
+ end
44
+
45
+ context 'when a vendor-prefixed unlisted property is used' do
46
+ let(:scss) { <<-SCSS }
47
+ div {
48
+ -webkit-appearance: none;
49
+ }
50
+ SCSS
51
+
52
+ it { should_not report_lint }
53
+ end
54
+
55
+ context 'when a vendor-prefixed custom-listed property is used' do
56
+ let(:linter_config) { { 'identifier_list' => ['transform'] } }
57
+
58
+ let(:scss) { <<-SCSS }
59
+ div {
60
+ -webkit-transform: none;
61
+ }
62
+ SCSS
63
+
64
+ it { should report_lint line: 2 }
65
+ end
66
+
67
+ context 'when a proprietary unlisted vendor-prefixed property is used' do
68
+ let(:scss) { <<-SCSS }
69
+ div {
70
+ -moz-padding-end: 0;
71
+ }
72
+ SCSS
73
+
74
+ it { should_not report_lint }
75
+ end
76
+
77
+ context 'when a proprietary listed vendor-prefixed property is used' do
78
+ let(:linter_config) { { 'identifier_list' => ['padding-end'] } }
79
+
80
+ let(:scss) { <<-SCSS }
81
+ div {
82
+ -moz-padding-end: 0;
83
+ }
84
+ SCSS
85
+
86
+ it { should report_lint line: 2 }
87
+ end
88
+
89
+ # Selectors
90
+
91
+ context 'when a vendor-prefixed listed selector is used' do
92
+ let(:scss) { <<-SCSS }
93
+ ::-moz-placeholder {
94
+ color: red;
95
+ }
96
+ :-ms-placeholder {
97
+ color: pink;
98
+ }
99
+ :-moz-fullscreen p {
100
+ font-size: 200%;
101
+ }
102
+ SCSS
103
+
104
+ it { should report_lint line: 1 }
105
+ it { should report_lint line: 4 }
106
+ it { should report_lint line: 7 }
107
+ end
108
+
109
+ context 'when an unprefixed listed selector is used' do
110
+ let(:scss) { <<-SCSS }
111
+ ::placeholder {
112
+ color: red;
113
+ }
114
+ :fullscreen p {
115
+ font-size: 200%;
116
+ }
117
+ SCSS
118
+
119
+ it { should_not report_lint }
120
+ end
121
+
122
+ context 'when a vendor-prefixed unlisted selector is used' do
123
+ let(:linter_config) { { 'identifier_list' => ['transform'] } }
124
+
125
+ let(:scss) { <<-SCSS }
126
+ ::-moz-placeholder {
127
+ color: red;
128
+ }
129
+ SCSS
130
+
131
+ it { should_not report_lint }
132
+ end
133
+
134
+ context 'when a vendor-prefixed custom-listed selector is used' do
135
+ let(:linter_config) { { 'identifier_list' => ['placeholder'] } }
136
+
137
+ let(:scss) { <<-SCSS }
138
+ ::-moz-placeholder {
139
+ color: red;
140
+ }
141
+ SCSS
142
+
143
+ it { should report_lint line: 1 }
144
+ end
145
+
146
+ # Directives
147
+
148
+ context 'when a vendor-prefixed listed directive is used' do
149
+ let(:scss) { <<-SCSS }
150
+ @-webkit-keyframes anim {
151
+ 0% { opacity: 0; }
152
+ }
153
+ SCSS
154
+
155
+ it { should report_lint line: 1 }
156
+ end
157
+
158
+ context 'when an unprefixed listed directive is used' do
159
+ let(:scss) { <<-SCSS }
160
+ @keyframes anim {
161
+ 0% { opacity: 0; }
162
+ }
163
+ SCSS
164
+
165
+ it { should_not report_lint }
166
+ end
167
+
168
+ context 'when an vendor-prefixed unlisted directive is used' do
169
+ let(:linter_config) { { 'identifier_list' => ['placeholder'] } }
170
+
171
+ let(:scss) { <<-SCSS }
172
+ @-webkit-keyframes anim {
173
+ 0% { opacity: 0; }
174
+ }
175
+ SCSS
176
+
177
+ it { should_not report_lint }
178
+ end
179
+
180
+ context 'when an vendor-prefixed custom-listed directive is used' do
181
+ let(:linter_config) { { 'identifier_list' => ['keyframes'] } }
182
+
183
+ let(:scss) { <<-SCSS }
184
+ @-webkit-keyframes anim {
185
+ 0% { opacity: 0; }
186
+ }
187
+ SCSS
188
+
189
+ it { should report_lint line: 1 }
190
+ end
191
+
192
+ # Values
193
+
194
+ context 'when a vendor-prefixed listed value is used' do
195
+ let(:scss) { <<-SCSS }
196
+ div {
197
+ background-image: -webkit-linear-gradient(#000, #fff);
198
+ position: -moz-sticky;
199
+ }
200
+ SCSS
201
+
202
+ it { should report_lint line: 2 }
203
+ it { should report_lint line: 3 }
204
+ end
205
+
206
+ context 'when an unprefixed listed value is used' do
207
+ let(:scss) { <<-SCSS }
208
+ div {
209
+ background-image: linear-gradient(#000, #fff);
210
+ }
211
+ SCSS
212
+
213
+ it { should_not report_lint }
214
+ end
215
+
216
+ context 'when a vendor-unprefixed unlisted value is used' do
217
+ let(:linter_config) { { 'identifier_list' => ['keyframes'] } }
218
+
219
+ let(:scss) { <<-SCSS }
220
+ div {
221
+ background-image: -webkit-linear-gradient(#000, #fff);
222
+ position: -moz-sticky;
223
+ }
224
+ SCSS
225
+
226
+ it { should_not report_lint }
227
+ end
228
+
229
+ context 'when a vendor-unprefixed custom-listed value is used' do
230
+ let(:linter_config) { { 'identifier_list' => ['linear-gradient'] } }
231
+
232
+ let(:scss) { <<-SCSS }
233
+ div {
234
+ background-image: -webkit-linear-gradient(#000, #fff);
235
+ position: -moz-sticky;
236
+ }
237
+ SCSS
238
+
239
+ it { should report_lint line: 2 }
240
+ end
241
+
242
+ # Identifier lists
243
+
244
+ context 'when using non-default named identifier list' do
245
+ let(:linter_config) { { 'identifier_list' => 'bourbon' } }
246
+
247
+ context 'and a standard vendor-prefixed property is used' do
248
+ let(:scss) { <<-SCSS }
249
+ div {
250
+ background-image: -webkit-linear-gradient(#000, #fff);
251
+ }
252
+ SCSS
253
+
254
+ it { should report_lint line: 2 }
255
+ end
256
+
257
+ context 'and a list-specific vendor-prefixed property is used' do
258
+ let(:scss) { <<-SCSS }
259
+ div {
260
+ image-rendering: -moz-crisp-edges;
261
+ -webkit-appearance: none;
262
+ }
263
+ SCSS
264
+
265
+ it { should report_lint line: 2 }
266
+ it { should report_lint line: 3 }
267
+ end
268
+
269
+ context 'and a list-exempt vendor-prefixed property is used' do
270
+ let(:scss) { <<-SCSS }
271
+ div {
272
+ -webkit-mask-repeat: inherit;
273
+ }
274
+ SCSS
275
+
276
+ it { should_not report_lint }
277
+ end
278
+ end
279
+
280
+ # Excluding and Including
281
+
282
+ context 'when manually excluding identifiers' do
283
+ let(:linter_config) do
284
+ {
285
+ 'identifier_list' => 'base',
286
+ 'excluded_identifiers' => %w[transform selection],
287
+ }
288
+ end
289
+
290
+ let(:scss) { <<-SCSS }
291
+ div {
292
+ -webkit-transform: translateZ(0);
293
+ }
294
+ ::-moz-selection {
295
+ color: #000;
296
+ }
297
+ SCSS
298
+
299
+ it { should_not report_lint }
300
+ end
301
+
302
+ context 'when manually including identifiers' do
303
+ let(:linter_config) do
304
+ {
305
+ 'identifier_list' => 'base',
306
+ 'additional_identifiers' => ['padding-end'],
307
+ 'excluded_identifiers' => [],
308
+ }
309
+ end
310
+
311
+ let(:scss) { <<-SCSS }
312
+ div {
313
+ -moz-padding-end: 0;
314
+ }
315
+ SCSS
316
+
317
+ it { should report_lint line: 2 }
318
+ end
319
+
320
+ # More
321
+ context 'when dealing with many-hyphened vendor-prefixed identifiers' do
322
+ let(:scss) { <<-SCSS }
323
+ div {
324
+ -moz-animation-timing-function: ease-out;
325
+ -webkit-border-bottom-right-radius: 5px;
326
+ background: -o-repeating-radial-gradient(#000, #000 5px, #fff 5px, #fff 10px)
327
+ }
328
+ SCSS
329
+
330
+ it { should report_lint line: 2 }
331
+ it { should report_lint line: 3 }
332
+ it { should report_lint line: 4 }
333
+ end
334
+
335
+ context 'when dealing with many-hyphened unprefixed identifiers' do
336
+ let(:scss) { <<-SCSS }
337
+ div {
338
+ animation-timing-function: ease-out;
339
+ border-bottom-right-radius: 5px;
340
+ background: repeating-radial-gradient(#000, #000 5px, #fff 5px, #fff 10px)
341
+ }
342
+ SCSS
343
+
344
+ it { should_not report_lint }
345
+ end
346
+
347
+ context 'when vendor-prefixed media queries are used' do
348
+ let(:scss) { <<-SCSS }
349
+ @media
350
+ only screen and (-webkit-min-device-pixel-ratio: 1.3),
351
+ only screen and (-o-min-device-pixel-ratio: 13/10),
352
+ only screen and (min-resolution: 120dpi) {
353
+ body {
354
+ background: #fff;
355
+ }
356
+ }
357
+ SCSS
358
+
359
+ it { should_not report_lint }
360
+ end
361
+
362
+ context 'when property contains a list literal with an empty list' do
363
+ let(:scss) { <<-SCSS }
364
+ p {
365
+ content: 0 ();
366
+ }
367
+ SCSS
368
+
369
+ it { should_not report_lint }
370
+ end
371
+ end