haml_lint 0.50.0 → 0.52.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
  SHA256:
3
- metadata.gz: 3c9c0aec66473b6cb72108115d220aeea717f7a524e2c9853629ef17c3269f1a
4
- data.tar.gz: 8f8d0d45078fe3249d2ac88740aae782a3e08a1f5e052ca6c9eed8757485cae6
3
+ metadata.gz: 24f37fc2b314359fb58b5209e58399fa01f53d51c977a4c60b66d9497e2acde5
4
+ data.tar.gz: afb033a6021882a269ec1fdf989d06c83c6df8047a3f60233ac83ac9f234469d
5
5
  SHA512:
6
- metadata.gz: 1c3fb6e8ff1a81147eec8d1c1942759a5c19fe71419030762b26c33dbd5f93fc1f2a6c56d3adee626ad7bf22893dc2784bc45ce917d6a0fb95c5bd6f5722402b
7
- data.tar.gz: ac0762a3b27f32c55f7167323f429728bd01816d3794af9a574e4af9ceda7c0d19c6d16c7c3d676be255564d98830f41143287cc721f22f64a4562bd00b70ed3
6
+ metadata.gz: abb4758509d1aca40826e598c8d1bdfb7daffbbbeb9d1955c18463e44c4799ce5102151ae34b58799198336d87ba2c4e922a699b8f9c28b13f94479d80f4607a
7
+ data.tar.gz: f585fb701da7d6ca46ab9612055a25be83c640c97da530fa19ca20684e27056955ca80714a666fef1568fb8fa4bceba5830005167b3f4a76dc575732876d125e
data/bin/haml-lint CHANGED
@@ -4,5 +4,4 @@
4
4
  require 'haml_lint'
5
5
  require 'haml_lint/cli'
6
6
 
7
- logger = HamlLint::Logger.new($stdout)
8
- exit HamlLint::CLI.new(logger).run(ARGV)
7
+ exit HamlLint::CLI.new.run(ARGV)
@@ -46,7 +46,7 @@ module HamlLint
46
46
  # The Haml parser to adapt for HamlLint
47
47
  #
48
48
  # @api private
49
- # @return [Haml::Parser] the Haml 4 parser
49
+ # @return [Haml::Parser] the Haml 5 parser
50
50
  attr_reader :parser
51
51
 
52
52
  # The Haml code to parse
@@ -2,7 +2,7 @@
2
2
 
3
3
  module HamlLint
4
4
  class Adapter
5
- # Adapts the Haml::Parser from Haml 5 for use in HamlLint
5
+ # Adapts the Haml::Parser from Haml 6 for use in HamlLint
6
6
  # :reek:UncommunicativeModuleName
7
7
  class Haml6 < Adapter
8
8
  # Parses the specified Haml code into an abstract syntax tree
@@ -46,7 +46,7 @@ module HamlLint
46
46
  # The Haml parser to adapt for HamlLint
47
47
  #
48
48
  # @api private
49
- # @return [Haml::Parser] the Haml 4 parser
49
+ # @return [Haml::Parser] the Haml 6 parser
50
50
  attr_reader :parser
51
51
 
52
52
  # The Haml code to parse
@@ -21,7 +21,7 @@ module HamlLint
21
21
  case version
22
22
  when '~> 4.0' then HamlLint::Adapter::Haml4
23
23
  when '~> 5.0', '~> 5.1', '~> 5.2' then HamlLint::Adapter::Haml5
24
- when '~> 6.0', '~> 6.0.a', '~> 6.1' then HamlLint::Adapter::Haml6
24
+ when '~> 6.0', '~> 6.0.a', '~> 6.1', '~> 6.2', '~> 6.3' then HamlLint::Adapter::Haml6
25
25
  else fail HamlLint::Exceptions::UnknownHamlVersion, "Cannot handle Haml version: #{version}"
26
26
  end
27
27
  end
data/lib/haml_lint/cli.rb CHANGED
@@ -10,8 +10,8 @@ module HamlLint
10
10
  class CLI
11
11
  # Create a CLI that outputs to the specified logger.
12
12
  #
13
- # @param logger [HamlLint::Logger]
14
- def initialize(logger)
13
+ # @param logger [HamlLint::Logger, nil]
14
+ def initialize(logger = nil)
15
15
  @log = logger
16
16
  end
17
17
 
@@ -63,6 +63,7 @@ module HamlLint
63
63
  #
64
64
  # @return [void]
65
65
  def configure_logger(options)
66
+ @log ||= HamlLint::Logger.new(options[:stderr] ? $stderr : $stdout)
66
67
  log.color_enabled = options.fetch(:color, log.tty?)
67
68
  log.summary_enabled = options.fetch(:summary, true)
68
69
  end
@@ -69,6 +69,10 @@ module HamlLint
69
69
  @options[:autocorrect_only] = true
70
70
  @options[:autocorrect] ||= :safe
71
71
  end
72
+
73
+ parser.on('--stderr', 'Write all output to stderr') do
74
+ @options[:stderr] = true
75
+ end
72
76
  end
73
77
 
74
78
  def add_report_options(parser)
@@ -104,7 +104,7 @@ module HamlLint
104
104
  # @param task_args [Rake::TaskArguments]
105
105
  def run_cli(task_args)
106
106
  cli_args = parse_args
107
- logger = quiet ? HamlLint::Logger.silent : HamlLint::Logger.new($stdout)
107
+ logger = quiet ? HamlLint::Logger.silent : nil
108
108
  result = HamlLint::CLI.new(logger).run(Array(cli_args) + files_to_lint(task_args))
109
109
 
110
110
  fail "#{HamlLint::APP_NAME} failed with exit code #{result}" unless result == 0
@@ -16,10 +16,26 @@ module HamlLint::Tree
16
16
  #
17
17
  # @param line [Integer] the line number of the node
18
18
  # @return [HamlLint::Node]
19
- def node_for_line(line)
20
- find(-> { HamlLint::Tree::NullNode.new }) do |node|
21
- node.line_numbers.cover?(line) && node != self
19
+ def node_for_line(line) # rubocop:disable Metrics
20
+ each do |node|
21
+ return node if node.line_numbers.cover?(line) && node != self
22
22
  end
23
+
24
+ # Because HAML doesn't leave any trace in the nodes when it merges lines that
25
+ # end with a comma, it's harder to assign a node to the second line here:
26
+ # = some_call user,
27
+ # foo, bar
28
+ # So if the simple strategy (above) doesn't work, we try to see if we check if the last node
29
+ # that was before the requested line was one that could have been merged. If so, we use that one.
30
+ best_guess = nil
31
+ each do |node|
32
+ best_guess = node if node != self && node.line_numbers.end < line
33
+ end
34
+
35
+ # There are the cases were the merging without traces can happen
36
+ return best_guess if best_guess && %i[script silent_script tag].include?(best_guess.type)
37
+
38
+ HamlLint::Tree::NullNode.new
23
39
  end
24
40
  end
25
41
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.50.0'
5
+ VERSION = '0.52.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.50.0
4
+ version: 0.52.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-08-25 00:00:00.000000000 Z
11
+ date: 2023-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6.2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '4.0'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6.2'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: parallel
35
29
  requirement: !ruby/object:Gem::Requirement