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,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::BorderZero do
4
+ context 'when a 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 a property' do
14
+ context 'contains a normal border' do
15
+ let(:css) { <<-CSS }
16
+ p {
17
+ border: 1px solid #000;
18
+ }
19
+ CSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'has a border of 0' do
25
+ let(:css) { <<-CSS }
26
+ p {
27
+ border: 0;
28
+ }
29
+ CSS
30
+
31
+ it { should_not report_lint }
32
+ end
33
+
34
+ context 'has a border of none' do
35
+ let(:css) { <<-CSS }
36
+ p {
37
+ border: none;
38
+ }
39
+ CSS
40
+
41
+ it { should report_lint line: 2 }
42
+ end
43
+
44
+ context 'has a border-top of none' do
45
+ let(:css) { <<-CSS }
46
+ p {
47
+ border-top: none;
48
+ }
49
+ CSS
50
+
51
+ it { should report_lint line: 2 }
52
+ end
53
+
54
+ context 'has a border-right of none' do
55
+ let(:css) { <<-CSS }
56
+ p {
57
+ border-right: none;
58
+ }
59
+ CSS
60
+
61
+ it { should report_lint line: 2 }
62
+ end
63
+
64
+ context 'has a border-bottom of none' do
65
+ let(:css) { <<-CSS }
66
+ p {
67
+ border-bottom: none;
68
+ }
69
+ CSS
70
+
71
+ it { should report_lint line: 2 }
72
+ end
73
+
74
+ context 'has a border-left of none' do
75
+ let(:css) { <<-CSS }
76
+ p {
77
+ border-left: none;
78
+ }
79
+ CSS
80
+
81
+ it { should report_lint line: 2 }
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::CapitalizationInSelector do
4
+ context 'when selector is all lowercase' do
5
+ let(:css) { <<-CSS }
6
+ span {
7
+ }
8
+ CSS
9
+
10
+ it { should_not report_lint }
11
+ end
12
+
13
+ context 'when selector is lowercase with non-alphabetic characters' do
14
+ let(:css) { <<-CSS }
15
+ .foo-bar {
16
+ }
17
+ CSS
18
+
19
+ it { should_not report_lint }
20
+ end
21
+
22
+ context 'when selector is camelCase' do
23
+ let(:css) { <<-CSS }
24
+ .fooBar {
25
+ }
26
+ CSS
27
+
28
+ it { should report_lint line: 1 }
29
+ end
30
+
31
+ context 'when selector is UPPER CASE' do
32
+ let(:css) { <<-CSS }
33
+ SPAN {
34
+ }
35
+ CSS
36
+
37
+ it { should report_lint line: 1 }
38
+ end
39
+
40
+ context 'when attribute selector has attribute containing uppercase letters' do
41
+ let(:css) { <<-CSS }
42
+ [dataText] {
43
+ }
44
+ CSS
45
+
46
+ it { should report_lint line: 1 }
47
+ end
48
+
49
+ context 'when attribute selector has value containing uppercase letters' do
50
+ let(:css) { <<-CSS }
51
+ [data-text=someText] {
52
+ }
53
+ CSS
54
+
55
+ it { should_not report_lint }
56
+ end
57
+
58
+ context 'when a selector name is whitelisted' do
59
+ let(:linter_config) { { 'ignored_names' => %w[Foo] } }
60
+ let(:css) { '.Foo {}' }
61
+
62
+ it { should_not report_lint }
63
+ end
64
+
65
+ context 'when a certain type of selector is ignored' do
66
+ let(:linter_config) { { 'ignored_types' => %w[class] } }
67
+ let(:css) { '.Foo {}' }
68
+
69
+ it { should_not report_lint }
70
+ end
71
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::ColorKeyword do
4
+ context 'when a color is specified as a hex' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ color: #fff;
8
+ }
9
+ CSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'when a color is specified as a keyword' do
15
+ let(:css) { <<-CSS }
16
+ p {
17
+ color: white;
18
+ }
19
+ CSS
20
+
21
+ it { should report_lint line: 2 }
22
+ end
23
+
24
+ context 'when a color keyword exists in a shorthand property' do
25
+ let(:css) { <<-CSS }
26
+ p {
27
+ border: 1px solid black;
28
+ }
29
+ CSS
30
+
31
+ it { should report_lint line: 2 }
32
+ end
33
+
34
+ context 'when a property contains a color keyword as a string' do
35
+ let(:css) { <<-CSS }
36
+ p {
37
+ content: 'white';
38
+ }
39
+ CSS
40
+
41
+ it { should_not report_lint }
42
+ end
43
+
44
+ context 'when a function call contains a color keyword' do
45
+ let(:css) { <<-CSS }
46
+ p {
47
+ color: function(red);
48
+ }
49
+ CSS
50
+
51
+ it { should report_lint line: 2 }
52
+ end
53
+
54
+ context 'when a mixin include contains a color keyword' do
55
+ let(:css) { <<-CSS }
56
+ p {
57
+ @include some-mixin(red);
58
+ }
59
+ CSS
60
+
61
+ it { should report_lint line: 2 }
62
+ end
63
+
64
+ context 'when the "transparent" color keyword is used' do
65
+ let(:css) { <<-CSS }
66
+ p {
67
+ @include mixin(transparent);
68
+ }
69
+ CSS
70
+
71
+ it { should_not report_lint }
72
+ end
73
+
74
+ context 'when color keyword appears in a string identifier' do
75
+ let(:css) { <<-CSS }
76
+ p {
77
+ content: content-with-blue-in-name;
78
+ }
79
+ CSS
80
+
81
+ it { should_not report_lint }
82
+ end
83
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::Comment do
4
+ context 'when no comments exist' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ margin: 0;
8
+ }
9
+ CSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'when comment is a single line comment' do
15
+ let(:css) { '// Single line comment' }
16
+
17
+ it { should_not report_lint }
18
+ end
19
+
20
+ context 'when comment is a single line comment at the end of a line' do
21
+ let(:css) { <<-CSS }
22
+ p {
23
+ margin: 0; // Comment at end of line
24
+ }
25
+ CSS
26
+
27
+ it { should_not report_lint }
28
+ end
29
+
30
+ context 'when comment is a multi-line comment' do
31
+ let(:css) { <<-CSS }
32
+ h1 {
33
+ color: #eee;
34
+ }
35
+ /*
36
+ * This is a multi-line comment that should report a lint
37
+ */
38
+ p {
39
+ color: #DDD;
40
+ }
41
+ CSS
42
+
43
+ it { should report_lint line: 4 }
44
+ end
45
+
46
+ context 'when multi-line-style comment is a at the end of a line' do
47
+ let(:css) { <<-CSS }
48
+ h1 {
49
+ color: #eee; /* This is a comment */
50
+ }
51
+ CSS
52
+
53
+ it { should report_lint line: 2 }
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::Compass::PropertyWithMixin do
4
+ context 'when a rule has a property with an equivalent Compass mixin' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ opacity: .5;
8
+ }
9
+ CSS
10
+
11
+ it { should report_lint line: 2 }
12
+ end
13
+
14
+ context 'when a rule includes a Compass property mixin' do
15
+ let(:css) { <<-CSS }
16
+ p {
17
+ @include opacity(.5);
18
+ }
19
+ CSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when a rule does not have a property with a corresponding Compass mixin' do
25
+ let(:css) { <<-CSS }
26
+ p {
27
+ margin: 0;
28
+ }
29
+ CSS
30
+
31
+ it { should_not report_lint }
32
+ end
33
+
34
+ context 'when a rule includes display: inline-block' do
35
+ let(:css) { <<-CSS }
36
+ p {
37
+ display: inline-block;
38
+ }
39
+ CSS
40
+
41
+ it { should report_lint line: 2 }
42
+ end
43
+
44
+ context 'when properties are ignored' do
45
+ let(:linter_config) { { 'ignore' => %w[inline-block] } }
46
+
47
+ let(:css) { <<-CSS }
48
+ p {
49
+ display: inline-block;
50
+ }
51
+ CSS
52
+
53
+ it { should_not report_lint }
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::DebugStatement do
4
+ context 'when no debug statements are present' do
5
+ let(:css) { <<-CSS }
6
+ p {
7
+ color: #fff;
8
+ }
9
+ CSS
10
+
11
+ it { should_not report_lint }
12
+ end
13
+
14
+ context 'when a debug statement is present' do
15
+ let(:css) { <<-CSS }
16
+ @debug 'This is a debug statement';
17
+ CSS
18
+
19
+ it { should report_lint line: 1 }
20
+ end
21
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe SCSSLint::Linter::DeclarationOrder 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 only properties' do
14
+ let(:css) { <<-CSS }
15
+ p {
16
+ background: #000;
17
+ margin: 5px;
18
+ }
19
+ CSS
20
+
21
+ it { should_not report_lint }
22
+ end
23
+
24
+ context 'when rule contains only mixins' do
25
+ let(:css) { <<-CSS }
26
+ p {
27
+ @include border-radius(5px);
28
+ @include box-shadow(5px);
29
+ }
30
+ CSS
31
+
32
+ it { should_not report_lint }
33
+ end
34
+
35
+ context 'when rule contains no mixins or properties' do
36
+ let(:css) { <<-CSS }
37
+ p {
38
+ a {
39
+ color: #f00;
40
+ }
41
+ }
42
+ CSS
43
+
44
+ it { should_not report_lint }
45
+ end
46
+
47
+ context 'when rule contains properties after nested rules' do
48
+ let(:css) { <<-CSS }
49
+ p {
50
+ a {
51
+ color: #f00;
52
+ }
53
+ color: #f00;
54
+ margin: 5px;
55
+ }
56
+ CSS
57
+
58
+ it { should report_lint }
59
+ end
60
+
61
+ context 'when @extend appears before any properties or rules' do
62
+ let(:css) { <<-CSS }
63
+ .warn {
64
+ font-weight: bold;
65
+ }
66
+ .error {
67
+ @extend .warn;
68
+ color: #f00;
69
+ a {
70
+ color: #ccc;
71
+ }
72
+ }
73
+ CSS
74
+
75
+ it { should_not report_lint }
76
+ end
77
+
78
+ context 'when @extend appears after a property' do
79
+ let(:css) { <<-CSS }
80
+ .warn {
81
+ font-weight: bold;
82
+ }
83
+ .error {
84
+ color: #f00;
85
+ @extend .warn;
86
+ a {
87
+ color: #ccc;
88
+ }
89
+ }
90
+ CSS
91
+
92
+ it { should report_lint }
93
+ end
94
+ end