scss_lint 0.47.0 → 0.47.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 220e8895bebf7c06f86e7fd713590d1a000f39a5
4
- data.tar.gz: 2ba553b10d57c144b4d70872969be373973f0d77
3
+ metadata.gz: e0ac6b15087b8dec70d1bdde62a549b7257d06a5
4
+ data.tar.gz: 1c82559401919e75e12460d080b0f1744d9b1ba4
5
5
  SHA512:
6
- metadata.gz: 9f1c249c6885cedd4d7f33355e4b97206b0f2e84296d0cdd588016a3598d32af9f68920db045b85c8824c6ef1790297701c6430795f892f292291f591e88ebfa
7
- data.tar.gz: f8f7e66b89debe64c3ae32d69212e1f9513e32dad3288ef69c203be65b130d65a2238d884708fda84c5571107c6ccb44233c2eaca9051147607753182f89d067
6
+ metadata.gz: f02fc63d1f4f277c8193ec256303ca9f483fcc413554049b1c02f1fc9227d431b7b5a30d4cc982e89673c739ea5e50045c733af488ba0456a7924d6b25129336
7
+ data.tar.gz: a590c19d6d195d590a7a4189f0678fd265df38a0a704d90383f09cc02dc89c9105a8be588a81917d8205346dd591f01003ae51661b01219b132a9bb4007c6114
data/lib/scss_lint/cli.rb CHANGED
@@ -182,7 +182,7 @@ module SCSSLint
182
182
 
183
183
  # @param options [Hash]
184
184
  # @param lints [Array<Lint>]
185
- # @param files [Array<String>]
185
+ # @param files [Array<Hash>]
186
186
  def report_lints(options, lints, files)
187
187
  sorted_lints = lints.sort_by { |l| [l.filename, l.location] }
188
188
  options.fetch(:reporters).each do |reporter, output|
@@ -42,7 +42,7 @@ module SCSSLint
42
42
  # for purposes of uniqueness.
43
43
  def property_key(prop)
44
44
  prop_key = prop.name.join
45
- prop_value = property_value(prop)
45
+ prop_value = value_as_string(prop.value)
46
46
 
47
47
  # Differentiate between values for different vendor prefixes
48
48
  prop_value.to_s.scan(/^(-[^-]+-.+)/) do |vendor_keyword|
@@ -52,15 +52,17 @@ module SCSSLint
52
52
  prop_key
53
53
  end
54
54
 
55
- def property_value(prop)
56
- case prop.value
55
+ def value_as_string(value)
56
+ case value
57
57
  when Sass::Script::Funcall
58
- prop.value.name
58
+ value.name
59
59
  when Sass::Script::String
60
60
  when Sass::Script::Tree::Literal
61
- prop.value.value
61
+ value.value
62
+ when Sass::Script::Tree::ListLiteral
63
+ value.elements.map { |e| value_as_string(e) }.join(' ')
62
64
  else
63
- prop.value.to_s
65
+ value.to_s
64
66
  end
65
67
  end
66
68
 
@@ -14,7 +14,7 @@ module SCSSLint
14
14
 
15
15
  private
16
16
 
17
- # @param files [Array<String>]
17
+ # @param files [Array<Hash>]
18
18
  # @param lints [Array<SCSSLint::Lint>]
19
19
  # @return [String]
20
20
  def format_plan(files, lints)
@@ -24,15 +24,15 @@ module SCSSLint
24
24
  "1..#{files.count + extra_lines}#{comment}"
25
25
  end
26
26
 
27
- # @param files [Array<String>]
27
+ # @param files [Array<Hash>]
28
28
  # @param lints [Array<SCSSLint::Lint>]
29
29
  # @return [Array<String>] one item per ok file or not ok lint
30
30
  def format_files(files, lints)
31
31
  unless lints.any?
32
32
  # There are no lints, so we can take a shortcut and just output an ok
33
33
  # test line for every file.
34
- return files.map.with_index do |filename, index|
35
- format_ok(filename, index + 1)
34
+ return files.map.with_index do |file, index|
35
+ format_ok(file, index + 1)
36
36
  end
37
37
  end
38
38
 
@@ -45,17 +45,17 @@ module SCSSLint
45
45
  grouped_lints = group_lints_by_filename(lints)
46
46
 
47
47
  test_number = 1
48
- files.map do |filename|
49
- if grouped_lints.key?(filename)
48
+ files.map do |file|
49
+ if grouped_lints.key?(file[:path])
50
50
  # This file has lints, so we want to generate a "not ok" test line for
51
51
  # each failing lint.
52
- grouped_lints[filename].map do |lint|
52
+ grouped_lints[file[:path]].map do |lint|
53
53
  formatted = format_not_ok(lint, test_number)
54
54
  test_number += 1
55
55
  formatted
56
56
  end
57
57
  else
58
- formatted = format_ok(filename, test_number)
58
+ formatted = format_ok(file, test_number)
59
59
  test_number += 1
60
60
  [formatted]
61
61
  end
@@ -73,30 +73,38 @@ module SCSSLint
73
73
  grouped_lints
74
74
  end
75
75
 
76
- # @param filename [String]
76
+ # @param file [Hash]
77
77
  # @param test_number [Number]
78
78
  # @return [String]
79
- def format_ok(filename, test_number)
80
- "ok #{test_number} - #{filename}"
79
+ def format_ok(file, test_number)
80
+ "ok #{test_number} - #{file[:path]}"
81
81
  end
82
82
 
83
83
  # @param lint [SCSSLint::Lint]
84
84
  # @param test_number [Number]
85
85
  # @return [String]
86
- def format_not_ok(lint, test_number)
86
+ def format_not_ok(lint, test_number) # rubocop:disable Metrics/AbcSize
87
87
  location = lint.location
88
88
  test_line_description = "#{lint.filename}:#{location.line}:#{location.column}"
89
- test_line_description += " #{lint.linter.name}" if lint.linter
89
+
90
+ data = {
91
+ 'message' => lint.description,
92
+ 'severity' => lint.severity.to_s,
93
+ 'file' => lint.filename,
94
+ 'line' => lint.location.line,
95
+ 'column' => lint.location.column,
96
+ }
97
+
98
+ if lint.linter
99
+ test_line_description += " #{lint.linter.name}" if lint.linter
100
+ data['name'] = lint.linter.name
101
+ end
102
+
103
+ data_yaml = data.to_yaml.strip.gsub(/^/, ' ')
90
104
 
91
105
  <<-EOS.strip
92
106
  not ok #{test_number} - #{test_line_description}
93
- ---
94
- message: #{lint.description}
95
- severity: #{lint.severity}
96
- data:
97
- file: #{lint.filename}
98
- line: #{lint.location.line}
99
- column: #{lint.location.column}
107
+ #{data_yaml}
100
108
  ...
101
109
  EOS
102
110
  end
@@ -8,7 +8,7 @@ module SCSSLint
8
8
  end
9
9
 
10
10
  # @param lints [List<Lint>] a list of Lints sorted by file and line number
11
- # @param files [List<String>] a list of the files that were linted
11
+ # @param files [List<Hash>] a list of the files that were linted
12
12
  # @param logger [SCSSLint::Logger]
13
13
  def initialize(lints, files, logger)
14
14
  @lints = lints
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SCSSLint
5
- VERSION = '0.47.0'.freeze
5
+ VERSION = '0.47.1'.freeze
6
6
  end
@@ -76,6 +76,7 @@ describe SCSSLint::Linter::DuplicateProperty do
76
76
  @mixin cursor-grabbing($num) {
77
77
  cursor: -moz-grabbing;
78
78
  cursor: -webkit-grabbing;
79
+ cursor: -foo-grabbing unquote('!important');
79
80
  cursor: grabbing;
80
81
  }
81
82
  SCSS
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe SCSSLint::Reporter::TAPReporter do
4
4
  let(:logger) { SCSSLint::Logger.new($stdout) }
5
- subject { described_class.new(lints, filenames, logger) }
5
+ let(:files) { filenames.map { |filename| { path: filename } } }
6
+ subject { described_class.new(lints, files, logger) }
6
7
 
7
8
  describe '#report_lints' do
8
9
  context 'when there are no files' do
@@ -66,28 +67,28 @@ not ok 2 - not-ok1.scss:123:10 SCSSLint::Linter::PrivateNamingConvention
66
67
  ---
67
68
  message: Description of lint 1
68
69
  severity: warning
69
- data:
70
- file: not-ok1.scss
71
- line: 123
72
- column: 10
70
+ file: not-ok1.scss
71
+ line: 123
72
+ column: 10
73
+ name: SCSSLint::Linter::PrivateNamingConvention
73
74
  ...
74
75
  not ok 3 - not-ok2.scss:20:2 SCSSLint::Linter::PrivateNamingConvention
75
76
  ---
76
77
  message: Description of lint 2
77
78
  severity: error
78
- data:
79
- file: not-ok2.scss
80
- line: 20
81
- column: 2
79
+ file: not-ok2.scss
80
+ line: 20
81
+ column: 2
82
+ name: SCSSLint::Linter::PrivateNamingConvention
82
83
  ...
83
84
  not ok 4 - not-ok2.scss:21:3 SCSSLint::Linter::PrivateNamingConvention
84
85
  ---
85
86
  message: Description of lint 3
86
87
  severity: warning
87
- data:
88
- file: not-ok2.scss
89
- line: 21
90
- column: 3
88
+ file: not-ok2.scss
89
+ line: 21
90
+ column: 3
91
+ name: SCSSLint::Linter::PrivateNamingConvention
91
92
  ...
92
93
  ok 5 - ok2.scss
93
94
  EOS
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.47.0
4
+ version: 0.47.1
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: 2016-02-23 00:00:00.000000000 Z
12
+ date: 2016-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake