scss-lint 0.25.1 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +10 -1
  3. data/data/property-sort-orders/concentric.txt +99 -0
  4. data/lib/scss_lint.rb +1 -0
  5. data/lib/scss_lint/cli.rb +9 -3
  6. data/lib/scss_lint/exceptions.rb +4 -0
  7. data/lib/scss_lint/linter.rb +10 -1
  8. data/lib/scss_lint/linter/capitalization_in_selector.rb +14 -6
  9. data/lib/scss_lint/linter/compass/property_with_mixin.rb +9 -2
  10. data/lib/scss_lint/linter/indentation.rb +28 -6
  11. data/lib/scss_lint/linter/property_sort_order.rb +61 -9
  12. data/lib/scss_lint/linter/single_line_per_property.rb +53 -0
  13. data/lib/scss_lint/linter/single_line_per_selector.rb +6 -1
  14. data/lib/scss_lint/linter/space_after_comma.rb +27 -19
  15. data/lib/scss_lint/linter/space_before_brace.rb +5 -4
  16. data/lib/scss_lint/linter/trailing_semicolon.rb +53 -0
  17. data/lib/scss_lint/linter/unnecessary_parent_reference.rb +36 -0
  18. data/lib/scss_lint/reporter/default_reporter.rb +7 -2
  19. data/lib/scss_lint/reporter/xml_reporter.rb +2 -1
  20. data/lib/scss_lint/runner.rb +7 -3
  21. data/lib/scss_lint/version.rb +1 -1
  22. data/spec/scss_lint/cli_spec.rb +314 -0
  23. data/spec/scss_lint/config_spec.rb +439 -0
  24. data/spec/scss_lint/engine_spec.rb +24 -0
  25. data/spec/scss_lint/linter/border_zero_spec.rb +84 -0
  26. data/spec/scss_lint/linter/capitalization_in_selector_spec.rb +71 -0
  27. data/spec/scss_lint/linter/color_keyword_spec.rb +83 -0
  28. data/spec/scss_lint/linter/comment_spec.rb +55 -0
  29. data/spec/scss_lint/linter/compass/property_with_mixin_spec.rb +55 -0
  30. data/spec/scss_lint/linter/debug_statement_spec.rb +21 -0
  31. data/spec/scss_lint/linter/declaration_order_spec.rb +94 -0
  32. data/spec/scss_lint/linter/duplicate_property_spec.rb +176 -0
  33. data/spec/scss_lint/linter/else_placement_spec.rb +106 -0
  34. data/spec/scss_lint/linter/empty_line_between_blocks_spec.rb +263 -0
  35. data/spec/scss_lint/linter/empty_rule_spec.rb +27 -0
  36. data/spec/scss_lint/linter/final_newline_spec.rb +49 -0
  37. data/spec/scss_lint/linter/hex_length_spec.rb +104 -0
  38. data/spec/scss_lint/linter/hex_notation_spec.rb +104 -0
  39. data/spec/scss_lint/linter/hex_validation_spec.rb +36 -0
  40. data/spec/scss_lint/linter/id_with_extraneous_selector_spec.rb +139 -0
  41. data/spec/scss_lint/linter/indentation_spec.rb +242 -0
  42. data/spec/scss_lint/linter/leading_zero_spec.rb +233 -0
  43. data/spec/scss_lint/linter/mergeable_selector_spec.rb +283 -0
  44. data/spec/scss_lint/linter/name_format_spec.rb +206 -0
  45. data/spec/scss_lint/linter/placeholder_in_extend_spec.rb +63 -0
  46. data/spec/scss_lint/linter/property_sort_order_spec.rb +246 -0
  47. data/spec/scss_lint/linter/property_spelling_spec.rb +57 -0
  48. data/spec/scss_lint/linter/selector_depth_spec.rb +159 -0
  49. data/spec/scss_lint/linter/shorthand_spec.rb +172 -0
  50. data/spec/scss_lint/linter/single_line_per_property_spec.rb +73 -0
  51. data/spec/scss_lint/linter/single_line_per_selector_spec.rb +121 -0
  52. data/spec/scss_lint/linter/space_after_comma_spec.rb +315 -0
  53. data/spec/scss_lint/linter/space_after_property_colon_spec.rb +238 -0
  54. data/spec/scss_lint/linter/space_after_property_name_spec.rb +23 -0
  55. data/spec/scss_lint/linter/space_before_brace_spec.rb +447 -0
  56. data/spec/scss_lint/linter/space_between_parens_spec.rb +263 -0
  57. data/spec/scss_lint/linter/string_quotes_spec.rb +303 -0
  58. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +188 -0
  59. data/spec/scss_lint/linter/unnecessary_mantissa_spec.rb +67 -0
  60. data/spec/scss_lint/linter/unnecessary_parent_reference_spec.rb +67 -0
  61. data/spec/scss_lint/linter/url_format_spec.rb +55 -0
  62. data/spec/scss_lint/linter/url_quotes_spec.rb +63 -0
  63. data/spec/scss_lint/linter/zero_unit_spec.rb +113 -0
  64. data/spec/scss_lint/linter_registry_spec.rb +50 -0
  65. data/spec/scss_lint/location_spec.rb +42 -0
  66. data/spec/scss_lint/reporter/config_reporter_spec.rb +42 -0
  67. data/spec/scss_lint/reporter/default_reporter_spec.rb +73 -0
  68. data/spec/scss_lint/reporter/files_reporter_spec.rb +38 -0
  69. data/spec/scss_lint/reporter/xml_reporter_spec.rb +103 -0
  70. data/spec/scss_lint/reporter_spec.rb +11 -0
  71. data/spec/scss_lint/runner_spec.rb +132 -0
  72. data/spec/scss_lint/selector_visitor_spec.rb +264 -0
  73. data/spec/spec_helper.rb +34 -0
  74. data/spec/support/isolated_environment.rb +25 -0
  75. data/spec/support/matchers/report_lint.rb +48 -0
  76. metadata +126 -8
  77. data/lib/scss_lint/linter/trailing_semicolon_after_property_value.rb +0 -40
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::EmptyRule do
4
+ context 'when rule is empty' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ }
8
+ CSS
9
+
10
+ it { should report_lint line: 1 }
11
+ end
12
+
13
+ context 'when rule contains an empty nested rule' do
14
+ let(:css) { <<-CSS }
15
+ p {
16
+ background: #000;
17
+ display: none;
18
+ margin: 5px;
19
+ padding: 10px;
20
+ a {
21
+ }
22
+ }
23
+ CSS
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(:css) { '' }
11
+
12
+ it { should_not report_lint }
13
+ end
14
+
15
+ context 'when the file ends with a newline' do
16
+ let(:css) { "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(:css) { '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(:css) { '' }
33
+
34
+ it { should_not report_lint }
35
+ end
36
+
37
+ context 'when the file ends with a newline' do
38
+ let(:css) { "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(:css) { '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(:css) { <<-CSS }
9
+ p {
10
+ }
11
+ CSS
12
+
13
+ it { should_not report_lint }
14
+ end
15
+
16
+ context 'when rule contains properties with valid hex code' do
17
+ let(:css) { <<-CSS }
18
+ p {
19
+ color: #1234ab;
20
+ }
21
+ CSS
22
+
23
+ it { should_not report_lint }
24
+ end
25
+
26
+ context 'when ID selector starts with a hex code' do
27
+ let(:css) { <<-CSS }
28
+ #aabbcc {
29
+ }
30
+ CSS
31
+
32
+ it { should_not report_lint }
33
+ end
34
+
35
+ context 'when color is specified as a color keyword' do
36
+ let(:css) { <<-CSS }
37
+ p {
38
+ @include box-shadow(0 0 1px 1px gold);
39
+ }
40
+ CSS
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(:css) { <<-CSS }
50
+ p {
51
+ background: #ccc;
52
+ background: #CCC;
53
+ @include crazy-color(#fff);
54
+ }
55
+ CSS
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(:css) { <<-CSS }
62
+ p {
63
+ background: #cccccc;
64
+ background: #CCCCCC;
65
+ @include crazy-color(#ffffff);
66
+ }
67
+ CSS
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(:css) { <<-CSS }
80
+ p {
81
+ background: #cccccc;
82
+ background: #CCCCCC;
83
+ @include crazy-color(#ffffff);
84
+ }
85
+ CSS
86
+
87
+ it { should_not report_lint }
88
+ end
89
+
90
+ context 'with short hex code' do
91
+ let(:css) { <<-CSS }
92
+ p {
93
+ background: #ccc;
94
+ background: #CCC;
95
+ @include crazy-color(#fff);
96
+ }
97
+ CSS
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(:css) { <<-CSS }
9
+ p {
10
+ }
11
+ CSS
12
+
13
+ it { should_not report_lint }
14
+ end
15
+
16
+ context 'when rule contains color keyword' do
17
+ let(:css) { <<-CSS }
18
+ p {
19
+ border-color: red;
20
+ }
21
+ CSS
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(:css) { <<-CSS }
31
+ p {
32
+ background: #ccc;
33
+ color: #cccccc;
34
+ @include crazy-color(#fff);
35
+ }
36
+ CSS
37
+
38
+ it { should_not report_lint }
39
+ end
40
+
41
+ context 'with uppercase hex codes' do
42
+ let(:css) { <<-CSS }
43
+ p {
44
+ background: #CCC;
45
+ color: #CCCCCC;
46
+ @include crazy-color(#FFF);
47
+ }
48
+ CSS
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(:css) { <<-CSS }
61
+ p {
62
+ background: #CCC;
63
+ color: #CCCCCC;
64
+ @include crazy-color(#FFF);
65
+ }
66
+ CSS
67
+
68
+ it { should_not report_lint }
69
+ end
70
+
71
+ context 'when rule contains properties with lowercase hex code' do
72
+ let(:css) { <<-CSS }
73
+ p {
74
+ background: #ccc;
75
+ color: #cccccc;
76
+ @include crazy-color(#fff);
77
+ }
78
+ CSS
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(:css) { <<-CSS }
88
+ #aabbcc {
89
+ }
90
+ CSS
91
+
92
+ it { should_not report_lint }
93
+ end
94
+
95
+ context 'when color is specified as a color keyword' do
96
+ let(:css) { <<-CSS }
97
+ p {
98
+ @include box-shadow(0 0 1px 1px gold);
99
+ }
100
+ CSS
101
+
102
+ it { should_not report_lint }
103
+ end
104
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::HexValidation do
4
+ context 'when rule is empty' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ }
8
+ CSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when rule contains valid hex codes or color keyword' do
14
+ let(:css) { <<-CSS }
15
+ p {
16
+ background: #000;
17
+ color: #FFFFFF;
18
+ border-color: red;
19
+ }
20
+ CSS
21
+
22
+ it { should_not report_lint }
23
+ end
24
+
25
+ context 'when rule contains invalid hex codes' do
26
+ let(:css) { <<-CSS }
27
+ p {
28
+ background: #dd;
29
+ color: #dddd;
30
+ }
31
+ CSS
32
+
33
+ it { should report_lint line: 2 }
34
+ it { should report_lint line: 3 }
35
+ end
36
+ end
@@ -0,0 +1,139 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::IdWithExtraneousSelector do
4
+ context 'when rule is just a type' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ }
8
+ CSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when rule is just an ID' do
14
+ let(:css) { <<-CSS }
15
+ #identifier {
16
+ }
17
+ CSS
18
+
19
+ it { should_not report_lint }
20
+ end
21
+
22
+ context 'when rule is just a class' do
23
+ let(:css) { <<-CSS }
24
+ .class {
25
+ }
26
+ CSS
27
+
28
+ it { should_not report_lint }
29
+ end
30
+
31
+ context 'when rule is a type with a class' do
32
+ let(:css) { <<-CSS }
33
+ a.class {
34
+ }
35
+ CSS
36
+
37
+ it { should_not report_lint }
38
+ end
39
+
40
+ context 'when rule is a type with an ID' do
41
+ let(:css) { <<-CSS }
42
+ a#identifier {
43
+ }
44
+ CSS
45
+
46
+ it { should report_lint line: 1 }
47
+ end
48
+
49
+ context 'when rule is an ID with a pseudo' do
50
+ let(:css) { <<-CSS }
51
+ #identifier:active {
52
+ }
53
+ CSS
54
+
55
+ it { should_not report_lint }
56
+ end
57
+
58
+ context 'when rule is a type with an ID with a pseudo' do
59
+ let(:css) { <<-CSS }
60
+ a#identifier:active {
61
+ }
62
+ CSS
63
+
64
+ it { should report_lint line: 1 }
65
+ end
66
+
67
+ context 'when rule contains multiple selectors' do
68
+ context 'when all of the selectors are just IDs, classes, or types' do
69
+ let(:css) { <<-CSS }
70
+ #identifier,
71
+ .class,
72
+ a {
73
+ }
74
+ CSS
75
+
76
+ it { should_not report_lint }
77
+ end
78
+
79
+ context 'when one of the rules is an ID with a pseudo' do
80
+ let(:css) { <<-CSS }
81
+ #identifier:active,
82
+ .class {
83
+ }
84
+ CSS
85
+
86
+ it { should_not report_lint }
87
+ end
88
+
89
+ context 'when one of the rules is a type with an ID with a pseudo' do
90
+ let(:css) { <<-CSS }
91
+ a#identifier:active,
92
+ .class {
93
+ }
94
+ CSS
95
+
96
+ it { should report_lint line: 1 }
97
+ end
98
+
99
+ context 'when one of the selectors is a type and class' do
100
+ let(:css) { <<-CSS }
101
+ #identifier,
102
+ a.class {
103
+ }
104
+ CSS
105
+
106
+ it { should_not report_lint }
107
+ end
108
+
109
+ context 'when one of the selectors is a type and ID' do
110
+ let(:css) { <<-CSS }
111
+ #identifier,
112
+ a#my-id {
113
+ }
114
+ CSS
115
+
116
+ it { should report_lint line: 1 }
117
+ end
118
+ end
119
+
120
+ context 'when rule contains a nested rule with type and ID' do
121
+ let(:css) { <<-CSS }
122
+ p {
123
+ a#identifier {
124
+ }
125
+ }
126
+ CSS
127
+
128
+ it { should report_lint line: 2 }
129
+ end
130
+
131
+ context 'when selector contains a class and ID' do
132
+ let(:css) { <<-CSS }
133
+ #id.class {
134
+ }
135
+ CSS
136
+
137
+ it { should report_lint line: 1 }
138
+ end
139
+ end