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 +4 -4
- data/bin/haml-lint +1 -2
- data/lib/haml_lint/adapter/haml_5.rb +1 -1
- data/lib/haml_lint/adapter/haml_6.rb +2 -2
- data/lib/haml_lint/adapter.rb +1 -1
- data/lib/haml_lint/cli.rb +3 -2
- data/lib/haml_lint/options.rb +4 -0
- data/lib/haml_lint/rake_task.rb +1 -1
- data/lib/haml_lint/tree/root_node.rb +19 -3
- data/lib/haml_lint/version.rb +1 -1
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f37fc2b314359fb58b5209e58399fa01f53d51c977a4c60b66d9497e2acde5
|
4
|
+
data.tar.gz: afb033a6021882a269ec1fdf989d06c83c6df8047a3f60233ac83ac9f234469d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb4758509d1aca40826e598c8d1bdfb7daffbbbeb9d1955c18463e44c4799ce5102151ae34b58799198336d87ba2c4e922a699b8f9c28b13f94479d80f4607a
|
7
|
+
data.tar.gz: f585fb701da7d6ca46ab9612055a25be83c640c97da530fa19ca20684e27056955ca80714a666fef1568fb8fa4bceba5830005167b3f4a76dc575732876d125e
|
data/bin/haml-lint
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module HamlLint
|
4
4
|
class Adapter
|
5
|
-
# Adapts the Haml::Parser from Haml
|
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
|
49
|
+
# @return [Haml::Parser] the Haml 6 parser
|
50
50
|
attr_reader :parser
|
51
51
|
|
52
52
|
# The Haml code to parse
|
data/lib/haml_lint/adapter.rb
CHANGED
@@ -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
|
data/lib/haml_lint/options.rb
CHANGED
data/lib/haml_lint/rake_task.rb
CHANGED
@@ -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 :
|
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
|
-
|
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
|
data/lib/haml_lint/version.rb
CHANGED
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.
|
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-
|
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
|