slim_lint 0.13.0 → 0.14.0

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: fc8d22202c9f6eb2a16d57cc44a7c1ab94f80992
4
- data.tar.gz: 2bb72a9326dc5be97d7b00e41da0aed16762ac77
3
+ metadata.gz: bf8c56ea545885c5a0214e60a865a266f4459ed5
4
+ data.tar.gz: a8d108a971c36c77e507374a4aeffcbf5d188381
5
5
  SHA512:
6
- metadata.gz: 2139ed039c41a606ee6fe8674568cf46ae223ef85d8a403216369cd325c7b0fb0252347bb05f4a6312fcf4b560812c1b77dd24b5268512345697ee9da7acc8a0
7
- data.tar.gz: 1d4e203db09d82845aae1e3489cc3ae863f29f436bb5d739fb7c47f4c6bebfd2f3b64eb5a36991386a09d6c231cc0eec1acbebef541cab3446b05a0e8fa8ea20
6
+ metadata.gz: 58880962969b559714aa8c51b406d92d8854da6bdc38a65f505c1f8192e96e09847c9bb361b379d3189b4dfd964762ab62599e1a8820a54f7cb50e20c75a3154
7
+ data.tar.gz: 1cbe595ed72c75eee128580bbdcb59db30569593537b8b9a2c46f34c2c5ba2e182c25beb8df81a191fdbdecd7ec398bf0c3358aa86af3d5f55a766853493f33d
data/config/default.yml CHANGED
@@ -18,6 +18,9 @@ linters:
18
18
  EmptyControlStatement:
19
19
  enabled: true
20
20
 
21
+ EmptyLines:
22
+ enabled: true
23
+
21
24
  RedundantDiv:
22
25
  enabled: true
23
26
 
@@ -32,9 +35,11 @@ linters:
32
35
  # WARNING: If you define this list in your own .slim-lint.yml file, you'll
33
36
  # be overriding the list defined here.
34
37
  ignored_cops:
38
+ - Layout/AlignArray
35
39
  - Layout/AlignHash
36
40
  - Layout/AlignParameters
37
41
  - Layout/FirstParameterIndentation
42
+ - Layout/IndentArray
38
43
  - Layout/IndentationConsistency
39
44
  - Layout/IndentationWidth
40
45
  - Layout/MultilineArrayBraceLayout
@@ -50,9 +55,9 @@ linters:
50
55
  - Lint/EndAlignment
51
56
  - Lint/Void
52
57
  - Metrics/BlockLength
58
+ - Metrics/BlockNesting
53
59
  - Metrics/LineLength
54
- - Style/BlockNesting
55
- - Style/FileName
60
+ - Naming/FileName
56
61
  - Style/FrozenStringLiteralComment
57
62
  - Style/IfUnlessModifier
58
63
  - Style/Next
@@ -64,5 +69,8 @@ linters:
64
69
  TagCase:
65
70
  enabled: true
66
71
 
72
+ TrailingBlankLines:
73
+ enabled: true
74
+
67
75
  TrailingWhitespace:
68
76
  enabled: true
data/lib/slim_lint/cli.rb CHANGED
@@ -21,7 +21,7 @@ module SlimLint
21
21
  def run(args)
22
22
  options = SlimLint::Options.new.parse(args)
23
23
  act_on_options(options)
24
- rescue => ex
24
+ rescue StandardError => ex
25
25
  handle_exception(ex)
26
26
  end
27
27
 
@@ -96,7 +96,7 @@ module SlimLint
96
96
  # Ensure `include` and `exclude` options for linters are arrays
97
97
  # (since users can specify a single string glob pattern for convenience)
98
98
  def ensure_linter_include_exclude_arrays_exist
99
- @hash['linters'].keys.each do |linter_name|
99
+ @hash['linters'].each_key do |linter_name|
100
100
  %w[include exclude].each do |option|
101
101
  linter_config = @hash['linters'][linter_name]
102
102
  linter_config[option] = Array(linter_config[option])
@@ -0,0 +1,24 @@
1
+ module SlimLint
2
+ # This linter checks for two or more consecutive blank lines
3
+ # and for the first blank line in file.
4
+ class Linter::EmptyLines < Linter
5
+ include LinterRegistry
6
+
7
+ on_start do |_sexp|
8
+ dummy_node = Struct.new(:line)
9
+
10
+ was_empty = true
11
+ document.source.lines.each_with_index do |line, i|
12
+ if line.blank?
13
+ if was_empty
14
+ report_lint(dummy_node.new(i + 1),
15
+ 'Extra empty line detected')
16
+ end
17
+ was_empty = true
18
+ else
19
+ was_empty = false
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module SlimLint
2
+ # This linter looks for trailing blank lines and a final newline.
3
+ class Linter::TrailingBlankLines < Linter
4
+ include LinterRegistry
5
+
6
+ on_start do |_sexp|
7
+ dummy_node = Struct.new(:line)
8
+
9
+ if !document.source.end_with?("\n")
10
+ report_lint(dummy_node.new(document.source_lines.size),
11
+ 'No blank line in the end of file')
12
+ elsif document.source.lines.last.blank?
13
+ report_lint(dummy_node.new(document.source.lines.size),
14
+ 'Multiple empty lines in the end of file')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SlimLint
5
- VERSION = '0.13.0'.freeze
5
+ VERSION = '0.14.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-26 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slim
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.49.0
53
+ version: 0.50.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.49.0
60
+ version: 0.50.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: sysexits
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -132,11 +132,13 @@ files:
132
132
  - lib/slim_lint/linter/comment_control_statement.rb
133
133
  - lib/slim_lint/linter/consecutive_control_statements.rb
134
134
  - lib/slim_lint/linter/empty_control_statement.rb
135
+ - lib/slim_lint/linter/empty_lines.rb
135
136
  - lib/slim_lint/linter/line_length.rb
136
137
  - lib/slim_lint/linter/redundant_div.rb
137
138
  - lib/slim_lint/linter/rubocop.rb
138
139
  - lib/slim_lint/linter/tab.rb
139
140
  - lib/slim_lint/linter/tag_case.rb
141
+ - lib/slim_lint/linter/trailing_blank_lines.rb
140
142
  - lib/slim_lint/linter/trailing_whitespace.rb
141
143
  - lib/slim_lint/linter_registry.rb
142
144
  - lib/slim_lint/linter_selector.rb
@@ -180,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
182
  version: '0'
181
183
  requirements: []
182
184
  rubyforge_project:
183
- rubygems_version: 2.6.11
185
+ rubygems_version: 2.6.13
184
186
  signing_key:
185
187
  specification_version: 4
186
188
  summary: Slim template linting tool