scss_lint 0.55.0 → 0.56.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/scss_lint/cli.rb +1 -1
  3. data/lib/scss_lint/config.rb +7 -4
  4. data/lib/scss_lint/linter/border_zero.rb +1 -1
  5. data/lib/scss_lint/linter/color_variable.rb +2 -0
  6. data/lib/scss_lint/linter/compass/property_with_mixin.rb +1 -1
  7. data/lib/scss_lint/linter/duplicate_property.rb +1 -1
  8. data/lib/scss_lint/linter/encoding.rb +4 -0
  9. data/lib/scss_lint/linter/private_naming_convention.rb +1 -1
  10. data/lib/scss_lint/linter/property_sort_order.rb +2 -0
  11. data/lib/scss_lint/linter/property_units.rb +2 -2
  12. data/lib/scss_lint/linter/shorthand.rb +3 -3
  13. data/lib/scss_lint/linter/space_after_comment.rb +2 -2
  14. data/lib/scss_lint/linter/space_before_brace.rb +0 -1
  15. data/lib/scss_lint/linter/syntax.rb +4 -0
  16. data/lib/scss_lint/linter/transition_all.rb +1 -1
  17. data/lib/scss_lint/linter/url_format.rb +2 -2
  18. data/lib/scss_lint/linter/url_quotes.rb +3 -3
  19. data/lib/scss_lint/linter/variable_for_property.rb +2 -2
  20. data/lib/scss_lint/linter/vendor_prefix.rb +2 -2
  21. data/lib/scss_lint/location.rb +2 -2
  22. data/lib/scss_lint/reporter/config_reporter.rb +0 -1
  23. data/lib/scss_lint/reporter/default_reporter.rb +1 -1
  24. data/lib/scss_lint/reporter/json_reporter.rb +1 -1
  25. data/lib/scss_lint/reporter/tap_reporter.rb +4 -6
  26. data/lib/scss_lint/runner.rb +3 -3
  27. data/lib/scss_lint/sass/script.rb +0 -19
  28. data/lib/scss_lint/sass/tree.rb +2 -15
  29. data/lib/scss_lint/version.rb +1 -1
  30. data/spec/scss_lint/engine_spec.rb +12 -0
  31. data/spec/scss_lint/linter/space_after_comment_spec.rb +8 -0
  32. data/spec/scss_lint/linter/trailing_semicolon_spec.rb +0 -2
  33. data/spec/scss_lint/linter_spec.rb +2 -2
  34. data/spec/scss_lint/reporter/clean_files_reporter_spec.rb +2 -2
  35. data/spec/scss_lint/reporter/config_reporter_spec.rb +2 -2
  36. data/spec/scss_lint/reporter/default_reporter_spec.rb +1 -1
  37. data/spec/scss_lint/reporter/files_reporter_spec.rb +1 -1
  38. data/spec/scss_lint/reporter/json_reporter_spec.rb +1 -1
  39. data/spec/scss_lint/reporter/tap_reporter_spec.rb +4 -4
  40. data/spec/scss_lint/runner_spec.rb +39 -3
  41. data/spec/spec_helper.rb +1 -1
  42. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01a5421ff7215339318f8408e67d4b9825280594
4
- data.tar.gz: 7186bfb3c48b30597044c58f5626be8bd93bf278
3
+ metadata.gz: b39b3c7b31dc17e24974910dfff9637038a5b773
4
+ data.tar.gz: ed9774687c334aa87bbc4586c03ad93570c5bba7
5
5
  SHA512:
6
- metadata.gz: 8a58456b3a1dc059e1b03ad9066a5ce6d3efa3be4f313d982dc5dbe3d5b9ab20b9fa1733097f3ae23579b50aa01bb1d1e4707220de6fe67f60563c4a88d1fb8e
7
- data.tar.gz: cdd7914be549c8c39a1ed144bb52d23d5c6141f3d345eb02fce248929502591ac22674f703adba17ffa94c38c3543e950023040287bf2ca7de4652a48c4b51a2
6
+ metadata.gz: eb91473219f23fd58ceb69363b5b1f081bbc7bd04baaea668f60666a2ac2bdcfabeb24c50aacdfad823b374b873a2008652343a1518d1a85c4db561ac6ac70a7
7
+ data.tar.gz: a05b44b216ee1060a788ebbcf44dd5cd5184d02286b292d357cb18ef1d7cac36f6072e71d198bae06b7e52fb3055ae49fd344251c2764ae93f6061fb0c630856
@@ -31,7 +31,7 @@ module SCSSLint
31
31
  def run(args)
32
32
  options = SCSSLint::Options.new.parse(args)
33
33
  act_on_options(options)
34
- rescue => ex
34
+ rescue StandardError => ex
35
35
  handle_runtime_exception(ex, options)
36
36
  end
37
37
 
@@ -64,7 +64,7 @@ module SCSSLint
64
64
  else
65
65
  {}
66
66
  end
67
- rescue => ex
67
+ rescue StandardError => ex
68
68
  raise SCSSLint::Exceptions::InvalidConfiguration,
69
69
  "Invalid configuration: #{ex.message}"
70
70
  end
@@ -95,12 +95,15 @@ module SCSSLint
95
95
  def merge_wildcard_linter_options(options)
96
96
  options = options.dup
97
97
 
98
+ # rubocop:disable Performance/HashEachMethods (FALSE POSITIVE)
99
+ # Cannot use `each_key` because the cycle adds new keys during iteration
98
100
  options.fetch('linters', {}).keys.each do |class_name|
99
101
  next unless class_name.include?('*')
100
102
 
101
103
  wildcard_options = options['linters'].delete(class_name)
102
104
  apply_options_to_matching_linters(class_name, options, wildcard_options)
103
105
  end
106
+ # rubocop:enable Performance/HashEachMethods
104
107
 
105
108
  options
106
109
  end
@@ -124,7 +127,7 @@ module SCSSLint
124
127
 
125
128
  options['linters'] ||= {}
126
129
 
127
- options['linters'].keys.each do |linter_name|
130
+ options['linters'].each_key do |linter_name|
128
131
  options['linters'][linter_name] =
129
132
  ensure_exclude_paths_are_absolute(options['linters'][linter_name], original_file)
130
133
  end
@@ -264,7 +267,7 @@ module SCSSLint
264
267
  end
265
268
 
266
269
  def disable_all_linters
267
- @options['linters'].values.each do |linter_config|
270
+ @options['linters'].each_value do |linter_config|
268
271
  linter_config['enabled'] = false
269
272
  end
270
273
  end
@@ -316,7 +319,7 @@ module SCSSLint
316
319
  def validate_linters
317
320
  return unless linters = @options['linters']
318
321
 
319
- linters.keys.each do |name|
322
+ linters.each_key do |name|
320
323
  begin
321
324
  Linter.const_get(name)
322
325
  rescue NameError
@@ -27,7 +27,7 @@ module SCSSLint
27
27
 
28
28
  def visit_prop(node)
29
29
  return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
30
- check_border(node, node.name.first.to_s, node.value.to_sass.strip)
30
+ check_border(node, node.name.first.to_s, node.value.first.to_sass.strip)
31
31
  end
32
32
 
33
33
  private
@@ -19,10 +19,12 @@ module SCSSLint
19
19
  def visit_script_string(node)
20
20
  return if literal_string?(node)
21
21
 
22
+ # rubocop:disable Performance/HashEachMethods (FALSE POSITIVE v0.50.0)
22
23
  remove_quoted_strings(node.value)
23
24
  .scan(/(^|\s)(#[a-f0-9]+|[a-z]+)(?=\s|$)/i)
24
25
  .select { |_, word| color?(word) }
25
26
  .each { |_, color| record_lint(node, color) }
27
+ # rubocop:enable Performance/HashEachMethods
26
28
  end
27
29
 
28
30
  def visit_script_funcall(node)
@@ -33,7 +33,7 @@ module SCSSLint
33
33
  def check_for_inline_block(node)
34
34
  prop_name = node.name.join
35
35
  return unless prop_name == 'display' &&
36
- node.value.to_sass == 'inline-block' &&
36
+ node.value.first.to_sass == 'inline-block' &&
37
37
  !ignore_compass_mixin?('inline-block')
38
38
 
39
39
  add_lint node,
@@ -43,7 +43,7 @@ module SCSSLint
43
43
  # for purposes of uniqueness.
44
44
  def property_key(prop)
45
45
  prop_key = prop.name.join
46
- prop_value = value_as_string(prop.value)
46
+ prop_value = value_as_string(prop.value.first)
47
47
 
48
48
  # Differentiate between values for different vendor prefixes
49
49
  prop_value.to_s.scan(/^(-[^-]+-.+)/) do |vendor_keyword|
@@ -0,0 +1,4 @@
1
+ module SCSSLint
2
+ class Linter::Encoding < Linter
3
+ end
4
+ end
@@ -132,7 +132,7 @@ module SCSSLint
132
132
  def after_visit_all
133
133
  return unless @private_definitions
134
134
 
135
- @private_definitions.each do |_, nodes|
135
+ @private_definitions.each_value do |nodes|
136
136
  nodes.each do |node_text, node_info|
137
137
  next if node_info[:times_used] > 0
138
138
  node_type = humanize_node_class(node_info[:node])
@@ -38,6 +38,7 @@ module SCSSLint
38
38
  alias visit_rule check_order
39
39
  alias visit_prop check_order
40
40
 
41
+ # rubocop:disable Lint/DuplicateMethods (FALSE POSITIVE v0.50.0)
41
42
  def visit_prop(node, &block)
42
43
  # Handle nested properties by appending the parent property they are
43
44
  # nested under to the name
@@ -45,6 +46,7 @@ module SCSSLint
45
46
  check_order(node, &block)
46
47
  @nested_under = nil
47
48
  end
49
+ # rubocop:enable Lint/DuplicateMethods
48
50
 
49
51
  def visit_if(node, &block)
50
52
  check_order(node, &block)
@@ -32,8 +32,8 @@ module SCSSLint
32
32
  property = "#{@nested_under}-#{property}"
33
33
  end
34
34
 
35
- if node.value.respond_to?(:value)
36
- node.value.value.to_s.scan(NUMBER_WITH_UNITS_REGEX).each do |matches|
35
+ if node.value.first.respond_to?(:value)
36
+ node.value.first.value.to_s.scan(NUMBER_WITH_UNITS_REGEX).each do |matches|
37
37
  is_quoted_value = !matches[0].nil?
38
38
  next if is_quoted_value
39
39
  units = matches[1]
@@ -22,11 +22,11 @@ module SCSSLint
22
22
 
23
23
  end
24
24
 
25
- case node.value
25
+ case node.value.first
26
26
  when Sass::Script::Tree::Literal
27
- check_script_literal(property_name, node.value)
27
+ check_script_literal(property_name, node.value.first)
28
28
  when Sass::Script::Tree::ListLiteral
29
- check_script_list(property_name, node.value)
29
+ check_script_list(property_name, node.value.first)
30
30
  end
31
31
  end
32
32
 
@@ -58,8 +58,8 @@ module SCSSLint
58
58
  def whitespace_after_comment(source, offset)
59
59
  whitespace = 0
60
60
 
61
- # Allow for comments that start with `/// `.
62
- offset += 1 if source[offset] == '/'
61
+ offset += 1 if source[offset] == '/' # Allow for triple-slash comments
62
+ offset += 1 if source[offset] == '/' # Allow for quadruple-slash comments
63
63
 
64
64
  while [' ', "\t"].include? source[offset]
65
65
  whitespace += 1
@@ -19,7 +19,6 @@ module SCSSLint
19
19
  check_node(node.else, &block) if node.else
20
20
  end
21
21
 
22
- alias visit_function check_node
23
22
  alias visit_each check_node
24
23
  alias visit_for check_node
25
24
  alias visit_function check_node
@@ -0,0 +1,4 @@
1
+ module SCSSLint
2
+ class Linter::Syntax < Linter
3
+ end
4
+ end
@@ -12,7 +12,7 @@ module SCSSLint
12
12
  property = node.name.first.to_s
13
13
  return unless TRANSITION_PROPERTIES.include?(property)
14
14
 
15
- check_transition(node, property, node.value.to_sass)
15
+ check_transition(node, property, node.value.first.to_sass)
16
16
  end
17
17
 
18
18
  private
@@ -17,8 +17,8 @@ module SCSSLint
17
17
  end
18
18
 
19
19
  def visit_prop(node)
20
- if url_literal?(node.value)
21
- url = node.value.to_sass.sub(/^url\((.*)\)$/, '\\1')
20
+ if url_literal?(node.value.first)
21
+ url = node.value.first.to_sass.sub(/^url\((.*)\)$/, '\\1')
22
22
  check_url(url, node)
23
23
  end
24
24
 
@@ -4,11 +4,11 @@ module SCSSLint
4
4
  include LinterRegistry
5
5
 
6
6
  def visit_prop(node)
7
- case node.value
7
+ case node.value.first
8
8
  when Sass::Script::Tree::Literal
9
- check(node, node.value.value.to_s)
9
+ check(node, node.value.first.value.to_s)
10
10
  when Sass::Script::Tree::ListLiteral
11
- node.value
11
+ node.value.first
12
12
  .children
13
13
  .select { |child| child.is_a?(Sass::Script::Tree::Literal) }
14
14
  .each { |child| check(node, child.value.to_s) }
@@ -13,9 +13,9 @@ module SCSSLint
13
13
  def visit_prop(node)
14
14
  property_name = node.name.join
15
15
  return unless @properties.include?(property_name)
16
- return if ignored_value?(node.value)
16
+ return if ignored_value?(node.value.first)
17
17
  return if node.children.first.is_a?(Sass::Script::Tree::Variable)
18
- return if variable_property_with_important?(node.value)
18
+ return if variable_property_with_important?(node.value.first)
19
19
 
20
20
  add_lint(node, "Property #{property_name} should use " \
21
21
  'a variable rather than a literal value')
@@ -16,8 +16,8 @@ module SCSSLint
16
16
  check_identifier(node, name.sub(/^@/, ''))
17
17
 
18
18
  # Check for values
19
- return unless node.respond_to?(:value) && node.value.respond_to?(:source_range)
20
- check_identifier(node, source_from_range(node.value.source_range))
19
+ return unless node.respond_to?(:value) && node.value.first.respond_to?(:source_range)
20
+ check_identifier(node, source_from_range(node.value.first.source_range))
21
21
  end
22
22
 
23
23
  alias visit_prop check_node
@@ -19,7 +19,7 @@ module SCSSLint
19
19
  end
20
20
 
21
21
  def ==(other)
22
- [:line, :column, :length].all? do |attr|
22
+ %i[line column length].all? do |attr|
23
23
  send(attr) == other.send(attr)
24
24
  end
25
25
  end
@@ -27,7 +27,7 @@ module SCSSLint
27
27
  alias eql? ==
28
28
 
29
29
  def <=>(other)
30
- [:line, :column, :length].each do |attr|
30
+ %i[line column length].each do |attr|
31
31
  result = send(attr) <=> other.send(attr)
32
32
  return result unless result == 0
33
33
  end
@@ -19,7 +19,6 @@ module SCSSLint
19
19
  end
20
20
 
21
21
  def linter_name(linter)
22
- return unless linter
23
22
  linter.class.to_s.split('::').last
24
23
  end
25
24
  end
@@ -24,7 +24,7 @@ module SCSSLint
24
24
  end
25
25
 
26
26
  def message(lint)
27
- linter_name = log.green("#{lint.linter.name}: ") if lint.linter
27
+ linter_name = log.green("#{lint.linter.name}: ")
28
28
  "#{linter_name}#{lint.description}"
29
29
  end
30
30
  end
@@ -23,7 +23,7 @@ module SCSSLint
23
23
  'severity' => lint.severity,
24
24
  'reason' => lint.description,
25
25
  }.tap do |hash|
26
- hash['linter'] = lint.linter.name if lint.linter
26
+ hash['linter'] = lint.linter.name
27
27
  end
28
28
  end
29
29
  end
@@ -95,18 +95,16 @@ module SCSSLint
95
95
  'column' => lint.location.column,
96
96
  }
97
97
 
98
- if lint.linter
99
- test_line_description += " #{lint.linter.name}" if lint.linter
100
- data['name'] = lint.linter.name
101
- end
98
+ test_line_description += " #{lint.linter.name}"
99
+ data['name'] = lint.linter.name
102
100
 
103
101
  data_yaml = data.to_yaml.strip.gsub(/^/, ' ')
104
102
 
105
- <<-EOS.strip
103
+ <<-LINES.strip
106
104
  not ok #{test_number} - #{test_line_description}
107
105
  #{data_yaml}
108
106
  ...
109
- EOS
107
+ LINES
110
108
  end
111
109
 
112
110
  # @param output [Array<String>]
@@ -33,7 +33,7 @@ module SCSSLint
33
33
  @linters.each do |linter|
34
34
  begin
35
35
  run_linter(linter, engine, file[:path])
36
- rescue => error
36
+ rescue StandardError => error
37
37
  raise SCSSLint::Exceptions::LinterError,
38
38
  "#{linter.class} raised unexpected error linting file #{file[:path]}: " \
39
39
  "'#{error.message}'",
@@ -41,10 +41,10 @@ module SCSSLint
41
41
  end
42
42
  end
43
43
  rescue Sass::SyntaxError => ex
44
- @lints << Lint.new(nil, ex.sass_filename, Location.new(ex.sass_line),
44
+ @lints << Lint.new(Linter::Syntax.new, ex.sass_filename, Location.new(ex.sass_line),
45
45
  "Syntax Error: #{ex}", :error)
46
46
  rescue FileEncodingError => ex
47
- @lints << Lint.new(nil, file[:path], Location.new, ex.to_s, :error)
47
+ @lints << Lint.new(Linter::Encoding.new, file[:path], Location.new, ex.to_s, :error)
48
48
  end
49
49
 
50
50
  # For stubbing in tests.
@@ -74,24 +74,5 @@ module Sass::Script
74
74
  [value]
75
75
  end
76
76
  end
77
-
78
- # This monkey patch can be removed once scss-lint depends on a minimum
79
- # version of the sass gem that includes a fix for
80
- # https://github.com/sass/sass/issues/1799
81
- class ListLiteral
82
- def source_range
83
- return @source_range if @elements.empty?
84
- @source_range.end_pos = @elements.last.source_range.end_pos
85
- @source_range
86
- end
87
- end
88
-
89
- class MapLiteral
90
- def source_range
91
- return @source_range if @pairs.empty?
92
- @source_range.end_pos = @pairs.last.last.source_range.end_pos
93
- @source_range
94
- end
95
- end
96
77
  end
97
78
  end
@@ -11,15 +11,6 @@ module Sass::Tree
11
11
  # Stores node for which this node is a direct child
12
12
  attr_accessor :node_parent
13
13
 
14
- # The `args` field of some Sass::Tree::Node classes returns
15
- # Sass::Script::Variable nodes with no line numbers. This adds the line
16
- # numbers back in so lint reporting works for those nodes.
17
- def add_line_numbers_to_args(arg_list)
18
- arg_list.each do |variable, _default_expr|
19
- add_line_number(variable)
20
- end
21
- end
22
-
23
14
  # The Sass parser sometimes doesn't assign line numbers in cases where it
24
15
  # should. This is a helper to easily correct that.
25
16
  def add_line_number(node)
@@ -96,8 +87,6 @@ module Sass::Tree
96
87
 
97
88
  class FunctionNode
98
89
  def children
99
- add_line_numbers_to_args(args)
100
-
101
90
  concat_expr_lists super, args, splat
102
91
  end
103
92
  end
@@ -110,16 +99,12 @@ module Sass::Tree
110
99
 
111
100
  class MixinDefNode
112
101
  def children
113
- add_line_numbers_to_args(args)
114
-
115
102
  concat_expr_lists super, args, splat
116
103
  end
117
104
  end
118
105
 
119
106
  class MixinNode
120
107
  def children
121
- add_line_numbers_to_args(args)
122
-
123
108
  # Keyword mapping is String -> Expr, so convert the string to a variable
124
109
  # node that supports lint reporting
125
110
  if keywords.any?
@@ -134,6 +119,8 @@ module Sass::Tree
134
119
 
135
120
  class PropNode
136
121
  def children
122
+ # TODO: fix custom properties
123
+ return [] if custom_property?
137
124
  concat_expr_lists super, extract_script_nodes(name), add_line_number(value)
138
125
  end
139
126
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SCSSLint
5
- VERSION = '0.55.0'.freeze
5
+ VERSION = '0.56.0'.freeze
6
6
  end
@@ -14,6 +14,18 @@ describe SCSSLint::Engine do
14
14
  end
15
15
  end
16
16
 
17
+ context 'when a custom property is present' do
18
+ let(:scss) { <<-SCSS }
19
+ :root {
20
+ --my-font-family: Helvetica;
21
+ }
22
+ SCSS
23
+
24
+ it 'has a parse tree' do
25
+ engine.tree.should_not be_nil
26
+ end
27
+ end
28
+
17
29
  context 'when the file being linted has an invalid byte sequence' do
18
30
  let(:scss) { "\xC0\u0001" }
19
31
 
@@ -46,6 +46,14 @@ describe SCSSLint::Linter::SpaceAfterComment do
46
46
  it { should_not report_lint }
47
47
  end
48
48
 
49
+ context 'when silent four-slash comment' do
50
+ let(:scss) { <<-SCSS }
51
+ //// File-level annotations
52
+ SCSS
53
+
54
+ it { should_not report_lint }
55
+ end
56
+
49
57
  context 'when inline silent comment and no space' do
50
58
  let(:scss) { <<-SCSS }
51
59
  p {
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe SCSSLint::Linter::TrailingSemicolon do
@@ -13,7 +13,7 @@ describe SCSSLint::Linter do
13
13
  end
14
14
 
15
15
  def visit_prop(node)
16
- return unless node.value.to_sass.strip == 'fail1'
16
+ return unless node.value.first.to_sass.strip == 'fail1'
17
17
  add_lint(node, 'everything offends me')
18
18
  end
19
19
 
@@ -29,7 +29,7 @@ describe SCSSLint::Linter do
29
29
  .select { |child| child.is_a?(Sass::Tree::PropNode) }
30
30
  .reject { |prop| prop.name.any? { |item| item.is_a?(Sass::Script::Node) } }
31
31
  .each do |prop|
32
- add_lint(prop, 'everything offends me 2') if prop.value.to_sass.strip == 'fail2'
32
+ add_lint(prop, 'everything offends me 2') if prop.value.first.to_sass.strip == 'fail2'
33
33
  end
34
34
 
35
35
  yield
@@ -39,7 +39,7 @@ describe SCSSLint::Reporter::CleanFilesReporter do
39
39
 
40
40
  let(:lints) do
41
41
  dirty_files.map do |file|
42
- SCSSLint::Lint.new(nil, file, SCSSLint::Location.new, '')
42
+ SCSSLint::Lint.new(SCSSLint::Linter::Comment.new, file, SCSSLint::Location.new, '')
43
43
  end
44
44
  end
45
45
 
@@ -61,7 +61,7 @@ describe SCSSLint::Reporter::CleanFilesReporter do
61
61
 
62
62
  let(:lints) do
63
63
  files.map do |file|
64
- SCSSLint::Lint.new(nil, file, SCSSLint::Location.new, '')
64
+ SCSSLint::Lint.new(SCSSLint::Linter::Comment.new, file, SCSSLint::Location.new, '')
65
65
  end
66
66
  end
67
67
 
@@ -16,11 +16,11 @@ describe SCSSLint::Reporter::ConfigReporter do
16
16
  context 'when there are lints' do
17
17
  let(:linters) do
18
18
  [SCSSLint::Linter::FinalNewline, SCSSLint::Linter::BorderZero,
19
- SCSSLint::Linter::BorderZero, nil]
19
+ SCSSLint::Linter::BorderZero]
20
20
  end
21
21
  let(:lints) do
22
22
  linters.each.map do |linter|
23
- SCSSLint::Lint.new(linter ? linter.new : nil, '',
23
+ SCSSLint::Lint.new(linter.new, '',
24
24
  SCSSLint::Location.new, '')
25
25
  end
26
26
  end
@@ -22,7 +22,7 @@ describe SCSSLint::Reporter::DefaultReporter do
22
22
  filenames.each_with_index.map do |filename, index|
23
23
  line, column = locations[index]
24
24
  location = SCSSLint::Location.new(line, column, 10)
25
- SCSSLint::Lint.new(nil, filename, location, descriptions[index],
25
+ SCSSLint::Lint.new(SCSSLint::Linter::Comment, filename, location, descriptions[index],
26
26
  severities[index])
27
27
  end
28
28
  end
@@ -17,7 +17,7 @@ describe SCSSLint::Reporter::FilesReporter do
17
17
 
18
18
  let(:lints) do
19
19
  filenames.map do |filename|
20
- SCSSLint::Lint.new(nil, filename, SCSSLint::Location.new, '')
20
+ SCSSLint::Lint.new(SCSSLint::Linter::Comment.new, filename, SCSSLint::Location.new, '')
21
21
  end
22
22
  end
23
23
 
@@ -35,7 +35,7 @@ describe SCSSLint::Reporter::JSONReporter do
35
35
 
36
36
  let(:lints) do
37
37
  filenames.each_with_index.map do |filename, index|
38
- SCSSLint::Lint.new(nil, filename, locations[index],
38
+ SCSSLint::Lint.new(SCSSLint::LinterRegistry.linters.sample, filename, locations[index],
39
39
  descriptions[index], severities[index])
40
40
  end
41
41
  end
@@ -20,12 +20,12 @@ describe SCSSLint::Reporter::TAPReporter do
20
20
  let(:lints) { [] }
21
21
 
22
22
  it 'returns the TAP version, plan, and ok test lines' do
23
- subject.report_lints.should eq(<<-EOS)
23
+ subject.report_lints.should eq(<<-LINES)
24
24
  TAP version 13
25
25
  1..2
26
26
  ok 1 - file.scss
27
27
  ok 2 - another-file.scss
28
- EOS
28
+ LINES
29
29
  end
30
30
  end
31
31
 
@@ -59,7 +59,7 @@ ok 2 - another-file.scss
59
59
  end
60
60
 
61
61
  it 'returns the TAP version, plan, and correct test lines' do
62
- subject.report_lints.should eq(<<-EOS)
62
+ subject.report_lints.should eq(<<-LINES)
63
63
  TAP version 13
64
64
  1..5
65
65
  ok 1 - ok1.scss
@@ -91,7 +91,7 @@ not ok 4 - not-ok2.scss:21:3 SCSSLint::Linter::PrivateNamingConvention
91
91
  name: SCSSLint::Linter::PrivateNamingConvention
92
92
  ...
93
93
  ok 5 - ok2.scss
94
- EOS
94
+ LINES
95
95
  end
96
96
  end
97
97
  end
@@ -59,15 +59,51 @@ describe SCSSLint::Runner do
59
59
 
60
60
  context 'when the engine raises a FileEncodingError' do
61
61
  let(:error) do
62
- SCSSLint::FileEncodingError.new('Some error message')
62
+ SCSSLint::FileEncodingError.new('File encoding error!')
63
63
  end
64
64
 
65
65
  before do
66
66
  SCSSLint::Engine.stub(:new).and_raise(error)
67
+ subject
67
68
  end
68
69
 
69
- it 'records the error as a lint' do
70
- subject.count.should == 2
70
+ it 'records the error as an Encoding lint' do
71
+ expect(runner.lints).to(
72
+ be_all { |lint| lint.linter.is_a?(SCSSLint::Linter::Encoding) }
73
+ )
74
+ end
75
+
76
+ it 'records the error with the error message' do
77
+ expect(runner.lints).to(
78
+ be_all { |lint| lint.description == error.message }
79
+ )
80
+ end
81
+ end
82
+
83
+ context 'when the engine raises a Sass::SyntaxError' do
84
+ let(:error) do
85
+ Sass::SyntaxError.new('Syntax error!', line: 42)
86
+ end
87
+
88
+ before do
89
+ SCSSLint::Engine.stub(:new).and_raise(error)
90
+ subject
91
+ end
92
+
93
+ it 'records the error as a Syntax lint' do
94
+ expect(runner.lints).to(
95
+ be_all { |lint| lint.linter.is_a?(SCSSLint::Linter::Syntax) }
96
+ )
97
+ end
98
+
99
+ it 'records the error with the error message' do
100
+ expect(runner.lints).to(
101
+ be_all { |lint| lint.description == "Syntax Error: #{error.message}" }
102
+ )
103
+ end
104
+
105
+ it 'records the error with the line number' do
106
+ expect(runner.lints).to(be_all { |lint| lint.location.line == 42 })
71
107
  end
72
108
  end
73
109
 
@@ -14,7 +14,7 @@ Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
14
14
 
15
15
  RSpec.configure do |config|
16
16
  config.expect_with :rspec do |c|
17
- c.syntax = [:expect, :should]
17
+ c.syntax = %i[expect should]
18
18
  end
19
19
 
20
20
  config.mock_with :rspec do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scss_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.55.0
4
+ version: 0.56.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-10 00:00:00.000000000 Z
12
+ date: 2017-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -37,18 +37,18 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.4.20
40
+ version: 3.5.3
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.4.20
47
+ version: 3.5.3
48
48
  description: Configurable tool for writing clean and consistent SCSS
49
49
  email:
50
50
  - eng@brigade.com
51
- - shane.dasilva@brigade.com
51
+ - shane@dasilva.io
52
52
  executables:
53
53
  - scss-lint
54
54
  extensions: []
@@ -90,6 +90,7 @@ files:
90
90
  - lib/scss_lint/linter/else_placement.rb
91
91
  - lib/scss_lint/linter/empty_line_between_blocks.rb
92
92
  - lib/scss_lint/linter/empty_rule.rb
93
+ - lib/scss_lint/linter/encoding.rb
93
94
  - lib/scss_lint/linter/extend_directive.rb
94
95
  - lib/scss_lint/linter/final_newline.rb
95
96
  - lib/scss_lint/linter/hex_length.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/scss_lint/linter/space_before_brace.rb
128
129
  - lib/scss_lint/linter/space_between_parens.rb
129
130
  - lib/scss_lint/linter/string_quotes.rb
131
+ - lib/scss_lint/linter/syntax.rb
130
132
  - lib/scss_lint/linter/trailing_semicolon.rb
131
133
  - lib/scss_lint/linter/trailing_whitespace.rb
132
134
  - lib/scss_lint/linter/trailing_zero.rb