haml_lint 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93d2cec8a3ce45f370d5e8d055ed8f9dc5a988e2c56e8e145f50710f04f40a3f
4
- data.tar.gz: 59a2d93bd2ab520c4fb1288cf85f784d3d20955293b6167f046bffba3f198cac
3
+ metadata.gz: 0411721c82b95f3662c12b9bb3eeff8013a81dbef095d1b5756baf529f121fd9
4
+ data.tar.gz: 2ab1affd25ac7b27278a35bc56a883aeb8626573e082b3ac4a2e725bdff1a90f
5
5
  SHA512:
6
- metadata.gz: be4b59ae43a2cab51fd4148e843177b939da14ee7b0dc40a8ed0d9dd7bbcd12d39d674c1d9c7f19f0a524d912e27fc82b882f6412083eda143c5cf60e218c397
7
- data.tar.gz: 28075057ee4c955a4966d2561ff77680b9d90c24e647dc83386dab4ebfabc404cbcb22913836f987896cc506244a4f612f74e131d8838c91f1e0db027d0f8cdd
6
+ metadata.gz: 431cc4b6f6dec7e6d910e7406a76fa58a9224fd689446636e02a7cb895137c33090a3fd845ffbeda941650549da069b8ce056eb979494d6442b348939da32ba5
7
+ data.tar.gz: 9c491a34546d7b437ee53ba5ec4059f8019bcd45dae564c90d230d8faaf69c7e4ec5f07585afc61bd5e0f903b1678567b727d9d82b3a30723e0aa1c8767923a6
data/config/default.yml CHANGED
@@ -105,6 +105,9 @@ linters:
105
105
  TagName:
106
106
  enabled: true
107
107
 
108
+ TrailingEmptyLines:
109
+ enabled: true
110
+
108
111
  TrailingWhitespace:
109
112
  enabled: true
110
113
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HamlLint
4
+ # Checks for trailing empty lines.
5
+ class Linter::TrailingEmptyLines < Linter
6
+ include LinterRegistry
7
+
8
+ DummyNode = Struct.new(:line)
9
+
10
+ def visit_root(root)
11
+ return if document.source.empty?
12
+ line_number = document.last_non_empty_line
13
+
14
+ node = root.node_for_line(line_number)
15
+ return if node.disabled?(self)
16
+
17
+ return unless document.source.end_with?("\n\n")
18
+
19
+ record_lint(line_number, 'Files should not end with trailing empty lines')
20
+ end
21
+ end
22
+ end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'rubocop'
4
4
  require 'rubocop/ast/builder'
5
- require 'parser/current'
6
5
 
7
6
  module HamlLint
8
7
  # Parser for the Ruby language.
@@ -14,10 +13,21 @@ module HamlLint
14
13
  class RubyParser
15
14
  # Creates a reusable parser.
16
15
  def initialize
16
+ require_parser
17
17
  @builder = ::RuboCop::AST::Builder.new
18
18
  @parser = ::Parser::CurrentRuby.new(@builder)
19
19
  end
20
20
 
21
+ # Require the current parser version while suppressing the
22
+ # compliancy warning for minor version differences.
23
+ def require_parser
24
+ prev = $VERBOSE
25
+ $VERBOSE = nil
26
+ require 'parser/current'
27
+ ensure
28
+ $VERBOSE = prev
29
+ end
30
+
21
31
  # Parse the given Ruby source into an abstract syntax tree.
22
32
  #
23
33
  # @param source [String] Ruby source code
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.48.0'
5
+ VERSION = '0.49.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.48.0
4
+ version: 0.49.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: 2023-07-09 00:00:00.000000000 Z
11
+ date: 2023-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -143,6 +143,7 @@ files:
143
143
  - lib/haml_lint/linter/space_inside_hash_attributes.rb
144
144
  - lib/haml_lint/linter/syntax.rb
145
145
  - lib/haml_lint/linter/tag_name.rb
146
+ - lib/haml_lint/linter/trailing_empty_lines.rb
146
147
  - lib/haml_lint/linter/trailing_whitespace.rb
147
148
  - lib/haml_lint/linter/unnecessary_interpolation.rb
148
149
  - lib/haml_lint/linter/unnecessary_string_output.rb
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  - !ruby/object:Gem::Version
221
222
  version: '0'
222
223
  requirements: []
223
- rubygems_version: 3.1.6
224
+ rubygems_version: 3.0.3.1
224
225
  signing_key:
225
226
  specification_version: 4
226
227
  summary: HAML lint tool