haml_lint 0.56.0 → 0.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/haml_lint/linter/empty_script.rb +1 -1
- data/lib/haml_lint/linter/id_names.rb +1 -1
- data/lib/haml_lint/linter/indentation.rb +1 -1
- data/lib/haml_lint/linter/leading_comment_space.rb +1 -1
- data/lib/haml_lint/linter/space_inside_hash_attributes.rb +2 -2
- data/lib/haml_lint/linter/tag_name.rb +1 -1
- data/lib/haml_lint/linter/trailing_whitespace.rb +1 -1
- data/lib/haml_lint/linter/unnecessary_string_output.rb +1 -1
- data/lib/haml_lint/linter.rb +2 -2
- data/lib/haml_lint/reporter/github_reporter.rb +32 -0
- data/lib/haml_lint/ruby_extraction/chunk_extractor.rb +7 -3
- data/lib/haml_lint/ruby_extraction/non_ruby_filter_chunk.rb +1 -1
- data/lib/haml_lint/ruby_extraction/ruby_filter_chunk.rb +1 -1
- data/lib/haml_lint/ruby_extraction/script_chunk.rb +1 -1
- data/lib/haml_lint/spec/shared_rubocop_autocorrect_context.rb +1 -1
- data/lib/haml_lint/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6962d4b0d9f7f60b473641303f1ef1b8962797bf7abdeb8db4e57b36df65f7d3
|
4
|
+
data.tar.gz: 214c0ccb902d9c742af8df5f4e65fc221f6ae9bec572b7a535df0ee682b5dfac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b161dc044d6a5a22be918384f7cde7b0fd9b20dc2f4408f4a535ae72ed0b7fab75b96f885db83e92ae4cce769b811118978412bbba819e6f38178fb261f040f1
|
7
|
+
data.tar.gz: fb2af5b891147f8588cf9ffcd17fccc7ef0674bf11127327addbca55c9a8c094c6e53f8f268550dc160955d4c1c889948d7285fc39027287781d3abba7f66873
|
@@ -24,7 +24,7 @@ module HamlLint
|
|
24
24
|
|
25
25
|
style = config['style'] || 'lisp_case'
|
26
26
|
matcher = STYLES[style]
|
27
|
-
record_lint(node, "`id` attribute must be in #{STYLIZED_NAMES[style]}") unless id
|
27
|
+
record_lint(node, "`id` attribute must be in #{STYLIZED_NAMES[style]}") unless id&.match?(matcher)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -30,7 +30,7 @@ module HamlLint
|
|
30
30
|
dummy_node = Struct.new(:line)
|
31
31
|
|
32
32
|
document.source_lines.each_with_index do |line, index|
|
33
|
-
next if line
|
33
|
+
next if line&.match?(regex)
|
34
34
|
|
35
35
|
unless root.node_for_line(index).disabled?(self)
|
36
36
|
record_lint dummy_node.new(index + 1), "Line contains #{wrong_characters} in indentation"
|
@@ -8,7 +8,7 @@ module HamlLint
|
|
8
8
|
def visit_haml_comment(node)
|
9
9
|
# Skip if the node spans multiple lines starting on the second line,
|
10
10
|
# or starts with a space
|
11
|
-
return if
|
11
|
+
return if /\A#*(\s*|\s+\S.*)$/.match?(node.text)
|
12
12
|
|
13
13
|
record_lint(node, 'Comment should have a space after the `#`')
|
14
14
|
end
|
@@ -27,8 +27,8 @@ module HamlLint
|
|
27
27
|
style = STYLE[config['style'] == 'no_space' ? 'no_space' : 'space']
|
28
28
|
source = node.hash_attributes_source
|
29
29
|
|
30
|
-
record_lint(node, style[:start_message]) unless source
|
31
|
-
record_lint(node, style[:end_message]) unless source
|
30
|
+
record_lint(node, style[:start_message]) unless source&.match?(style[:start_regex])
|
31
|
+
record_lint(node, style[:end_message]) unless source&.match?(style[:end_regex])
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -22,7 +22,7 @@ module HamlLint
|
|
22
22
|
def visit_script(node)
|
23
23
|
# Some script nodes created by the HAML parser aren't actually script
|
24
24
|
# nodes declared via the `=` marker. Check for it.
|
25
|
-
return
|
25
|
+
return unless /\A\s*=/.match?(node.source_code)
|
26
26
|
|
27
27
|
if outputs_string_literal?(node)
|
28
28
|
record_lint(node, MESSAGE)
|
data/lib/haml_lint/linter.rb
CHANGED
@@ -37,7 +37,7 @@ module HamlLint
|
|
37
37
|
:error
|
38
38
|
)
|
39
39
|
rescue StandardError => e
|
40
|
-
msg = "Couldn't process the file"
|
40
|
+
msg = +"Couldn't process the file"
|
41
41
|
if @autocorrect
|
42
42
|
# Those lints related to auto-correction were not saved, so don't display them
|
43
43
|
@lints = []
|
@@ -231,7 +231,7 @@ module HamlLint
|
|
231
231
|
# excess whitespace
|
232
232
|
@document.source_lines[(tag_node.line - 1)...(following_node_line(tag_node) - 1)]
|
233
233
|
.map do |line|
|
234
|
-
line.strip.
|
234
|
+
line.strip.delete_suffix('|').rstrip
|
235
235
|
end.join(' ')
|
236
236
|
end
|
237
237
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
module HamlLint
|
4
|
+
# Outputs GitHub workflow commands for GitHub check annotations when run within GitHub actions.
|
5
|
+
class Reporter::GithubReporter < Reporter
|
6
|
+
ESCAPE_MAP = { '%' => '%25', "\n" => '%0A', "\r" => '%0D' }.freeze
|
7
|
+
|
8
|
+
include Reporter::Utils
|
9
|
+
|
10
|
+
def added_lint(lint, report)
|
11
|
+
if lint.severity >= report.fail_level
|
12
|
+
print_workflow_command(lint: lint)
|
13
|
+
else
|
14
|
+
print_workflow_command(severity: 'warning', lint: lint)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def display_report(report)
|
19
|
+
print_summary(report)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def print_workflow_command(lint:, severity: 'error')
|
25
|
+
log.log "::#{severity} file=#{lint.filename},line=#{lint.line}::#{github_escape(lint.message)}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def github_escape(string)
|
29
|
+
string.gsub(Regexp.union(ESCAPE_MAP.keys), ESCAPE_MAP)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -17,6 +17,10 @@ module HamlLint::RubyExtraction
|
|
17
17
|
::Haml::Parser.new('', {})
|
18
18
|
end
|
19
19
|
|
20
|
+
# HAML strips newlines when handling multi-line statements (using pipes or trailing comma)
|
21
|
+
# We don't. So the regex must be fixed to correctly detect the start of the string.
|
22
|
+
BLOCK_KEYWORD_REGEX = Regexp.new(Haml::Parser::BLOCK_KEYWORD_REGEX.source.sub('^', '\A'))
|
23
|
+
|
20
24
|
def initialize(document, script_output_prefix:)
|
21
25
|
@document = document
|
22
26
|
@script_output_prefix = script_output_prefix
|
@@ -390,7 +394,7 @@ module HamlLint::RubyExtraction
|
|
390
394
|
# is indented by 0.
|
391
395
|
lines = node.text.split("\n")
|
392
396
|
lines.map! do |line|
|
393
|
-
if line
|
397
|
+
if !/\S/.match?(line)
|
394
398
|
# whitespace or empty
|
395
399
|
''
|
396
400
|
else
|
@@ -546,7 +550,7 @@ module HamlLint::RubyExtraction
|
|
546
550
|
joined_lines = lines.join("\n")
|
547
551
|
|
548
552
|
if haml_processed_ruby_code.include?("\n")
|
549
|
-
haml_processed_ruby_code = haml_processed_ruby_code.
|
553
|
+
haml_processed_ruby_code = haml_processed_ruby_code.tr("\n", ' ')
|
550
554
|
end
|
551
555
|
|
552
556
|
haml_processed_ruby_code.split(/[, ]/)
|
@@ -692,7 +696,7 @@ module HamlLint::RubyExtraction
|
|
692
696
|
return keyword
|
693
697
|
end
|
694
698
|
|
695
|
-
return unless keyword = code.scan(
|
699
|
+
return unless keyword = code.scan(BLOCK_KEYWORD_REGEX)[0]
|
696
700
|
keyword[0] || keyword[1]
|
697
701
|
end
|
698
702
|
end
|
@@ -19,7 +19,7 @@ module HamlLint::RubyExtraction
|
|
19
19
|
haml_lines[@haml_line_index - 1] = HamlLint::Utils.indent(haml_lines[@haml_line_index - 1], delta_indent)
|
20
20
|
|
21
21
|
to_haml_lines = to_ruby_lines.map do |line|
|
22
|
-
if line
|
22
|
+
if !/\S/.match?(line)
|
23
23
|
# whitespace or empty
|
24
24
|
''
|
25
25
|
else
|
@@ -113,7 +113,7 @@ module HamlLint::RubyExtraction
|
|
113
113
|
line_start_indexes_that_need_pipes = []
|
114
114
|
haml_output_prefix = first_output_haml_prefix
|
115
115
|
to_haml_lines = to_ruby_lines.map.with_index do |line, i| # rubocop:disable Metrics/BlockLength
|
116
|
-
if line
|
116
|
+
if !/\S/.match?(line)
|
117
117
|
# whitespace or empty lines, we don't want any indentation
|
118
118
|
''
|
119
119
|
elsif statement_start_line_indexes.include?(i)
|
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.58.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: 2024-
|
11
|
+
date: 2024-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- lib/haml_lint/reporter/checkstyle_reporter.rb
|
154
154
|
- lib/haml_lint/reporter/default_reporter.rb
|
155
155
|
- lib/haml_lint/reporter/disabled_config_reporter.rb
|
156
|
+
- lib/haml_lint/reporter/github_reporter.rb
|
156
157
|
- lib/haml_lint/reporter/hash_reporter.rb
|
157
158
|
- lib/haml_lint/reporter/hooks.rb
|
158
159
|
- lib/haml_lint/reporter/json_reporter.rb
|
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
216
|
- !ruby/object:Gem::Version
|
216
217
|
version: '0'
|
217
218
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.5.9
|
219
220
|
signing_key:
|
220
221
|
specification_version: 4
|
221
222
|
summary: HAML lint tool
|