haml_lint 0.58.0 → 0.60.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 +4 -4
- data/config/forced_rubocop_config.yml +12 -0
- data/lib/haml_lint/adapter.rb +3 -3
- data/lib/haml_lint/cli.rb +2 -2
- data/lib/haml_lint/document.rb +1 -1
- data/lib/haml_lint/extensions/haml_util_unescape_interpolation_tracking.rb +1 -1
- data/lib/haml_lint/linter/instance_variables.rb +27 -2
- data/lib/haml_lint/linter/rubocop.rb +1 -1
- data/lib/haml_lint/options.rb +9 -1
- data/lib/haml_lint/rake_task.rb +3 -2
- data/lib/haml_lint/reporter/default_reporter.rb +1 -1
- data/lib/haml_lint/reporter/disabled_config_reporter.rb +1 -1
- data/lib/haml_lint/reporter/json_reporter.rb +1 -1
- data/lib/haml_lint/reporter/progress_reporter.rb +2 -1
- data/lib/haml_lint/reporter/utils.rb +2 -2
- data/lib/haml_lint/reporter.rb +1 -1
- data/lib/haml_lint/ruby_extraction/base_chunk.rb +1 -1
- data/lib/haml_lint/ruby_extraction/chunk_extractor.rb +1 -1
- data/lib/haml_lint/runner.rb +1 -0
- data/lib/haml_lint/spec.rb +4 -4
- data/lib/haml_lint/tree/haml_comment_node.rb +1 -1
- data/lib/haml_lint/tree/node.rb +1 -1
- data/lib/haml_lint/tree/root_node.rb +2 -2
- data/lib/haml_lint/tree/script_node.rb +1 -1
- data/lib/haml_lint/utils.rb +1 -1
- data/lib/haml_lint/version.rb +1 -1
- data/lib/haml_lint.rb +23 -23
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bf4b2b435129bea13f5c1b32aabf202f5e8731264df179e3e7a9c16017b8654
|
4
|
+
data.tar.gz: 34a95aa1ac68c54a513d9431be449f5a53963d77e7d451cfa532c60ff08fe08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65d869de4f21555cc165baccae390ae09202de3d6aea707404806d0ee40bdd1d5916d7ab3ae9a7b4a0d35c1a4a5a8c89da3cb317389877460e03f48b5577c54
|
7
|
+
data.tar.gz: 84ccd1349eb889e3b516f42e4919eb0003566f01ba62a01b05cce28aeb801138c6f725eac054c23073997f0e67e452765ac78c03bfe710639c9742828b85521d
|
@@ -45,6 +45,18 @@ Layout/EndAlignment:
|
|
45
45
|
Layout/EndOfLine:
|
46
46
|
Enabled: false
|
47
47
|
|
48
|
+
# Complying with this lint requires the use of pipes which causes a conflict with MultilinePipe.
|
49
|
+
Layout/FirstArrayElementLineBreak:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Complying with this lint requires the use of pipes which causes a conflict with MultilinePipe.
|
53
|
+
Layout/FirstHashElementLineBreak:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Complying with this lint requires the use of pipes which causes a conflict with MultilinePipe.
|
57
|
+
Layout/FirstMethodArgumentLineBreak:
|
58
|
+
Enabled: false
|
59
|
+
|
48
60
|
# Turning this cop on can turn
|
49
61
|
# = content_tag(:span) do
|
50
62
|
# - foo
|
data/lib/haml_lint/adapter.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative 'adapter/haml_5'
|
4
|
+
require_relative 'adapter/haml_6'
|
5
|
+
require_relative 'exceptions'
|
6
6
|
|
7
7
|
module HamlLint
|
8
8
|
# Determines the adapter to use for the current Haml version
|
data/lib/haml_lint/cli.rb
CHANGED
data/lib/haml_lint/document.rb
CHANGED
@@ -14,7 +14,7 @@ module Haml::Util
|
|
14
14
|
Thread.current[:haml_lint_unescape_interpolation_to_original_cache] ||= {}
|
15
15
|
end
|
16
16
|
|
17
|
-
# As soon as a HamlLint::Document has finished processing a HAML
|
17
|
+
# As soon as a HamlLint::Document has finished processing a HAML source, this gets called to
|
18
18
|
# get a copy of this cache and clear up for the next HAML processing
|
19
19
|
def self.unescape_interpolation_to_original_cache_take_and_wipe
|
20
20
|
value = unescape_interpolation_to_original_cache.dup
|
@@ -21,7 +21,7 @@ module HamlLint
|
|
21
21
|
return unless enabled?
|
22
22
|
|
23
23
|
if node.parsed_script.contains_instance_variables?
|
24
|
-
record_lint(node,
|
24
|
+
record_lint(node, failure_message)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -41,10 +41,27 @@ module HamlLint
|
|
41
41
|
|
42
42
|
visit_script(node) ||
|
43
43
|
if node.parsed_attributes.contains_instance_variables?
|
44
|
-
record_lint(node,
|
44
|
+
record_lint(node, failure_message)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
# Checks for instance variables in :ruby filters when the linter is enabled.
|
49
|
+
#
|
50
|
+
# @param [HamlLint::Tree::FilterNode]
|
51
|
+
# @return [void]
|
52
|
+
def visit_filter(node)
|
53
|
+
return unless enabled?
|
54
|
+
return unless node.filter_type == 'ruby'
|
55
|
+
return unless ast = parse_ruby(node.text)
|
56
|
+
|
57
|
+
ast.each_node do |i|
|
58
|
+
if i.type == :ivar
|
59
|
+
record_lint(node, failure_message)
|
60
|
+
break
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
48
65
|
private
|
49
66
|
|
50
67
|
# Tracks whether the linter is enabled for the file.
|
@@ -75,5 +92,13 @@ module HamlLint
|
|
75
92
|
def matcher
|
76
93
|
@matcher ||= Regexp.new(config['matchers'][file_types] || '\A_.*\.haml\z')
|
77
94
|
end
|
95
|
+
|
96
|
+
# The error message when an ivar is found
|
97
|
+
#
|
98
|
+
# @api private
|
99
|
+
# @return [String]
|
100
|
+
def failure_message
|
101
|
+
"Avoid using instance variables in #{file_types} views"
|
102
|
+
end
|
78
103
|
end
|
79
104
|
end
|
@@ -117,7 +117,7 @@ module HamlLint
|
|
117
117
|
# so the lints will be recorded then.
|
118
118
|
@lints = []
|
119
119
|
|
120
|
-
msg = "Corrections couldn't be
|
120
|
+
msg = "Corrections couldn't be transferred: #{e.message} - Consider linting the file " \
|
121
121
|
'without auto-correct and doing the changes manually.'
|
122
122
|
if ENV['HAML_LINT_DEBUG'] == 'true'
|
123
123
|
msg = "#{msg} DEBUG: Rubocop corrected Ruby code follows:\n#{new_ruby_code}\n------"
|
data/lib/haml_lint/options.rb
CHANGED
@@ -10,7 +10,7 @@ module HamlLint
|
|
10
10
|
# @param args [Array<String>] arguments passed via the command line
|
11
11
|
# @return [Hash] parsed options
|
12
12
|
def parse(args)
|
13
|
-
@options =
|
13
|
+
@options = default_options
|
14
14
|
|
15
15
|
OptionParser.new do |parser|
|
16
16
|
parser.banner = "Usage: #{APP_NAME} [options] [file1, file2, ...]"
|
@@ -32,6 +32,10 @@ module HamlLint
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
+
def default_options
|
36
|
+
{ parallel: true }
|
37
|
+
end
|
38
|
+
|
35
39
|
def add_linter_options(parser) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
36
40
|
parser.on('--auto-gen-config', 'Generate a configuration file acting as a TODO list') do
|
37
41
|
@options[:auto_gen_config] = true
|
@@ -56,6 +60,10 @@ module HamlLint
|
|
56
60
|
@options[:parallel] = true
|
57
61
|
end
|
58
62
|
|
63
|
+
parser.on('--no-parallel', 'Disable parallel linter runs') do
|
64
|
+
@options[:parallel] = false
|
65
|
+
end
|
66
|
+
|
59
67
|
parser.on('-a', '--auto-correct', 'Auto-correct offenses (only when it’s safe)') do
|
60
68
|
@options[:autocorrect] = :safe
|
61
69
|
end
|
data/lib/haml_lint/rake_task.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'rake'
|
4
4
|
require 'rake/tasklib'
|
5
|
-
|
5
|
+
|
6
|
+
require_relative 'constants'
|
6
7
|
|
7
8
|
module HamlLint
|
8
9
|
# Rake task interface for haml-lint command line interface.
|
@@ -93,7 +94,7 @@ module HamlLint
|
|
93
94
|
|
94
95
|
task(name, [:files]) do |_task, task_args|
|
95
96
|
# Lazy-load so task doesn't affect Rakefile load time
|
96
|
-
|
97
|
+
require_relative 'cli'
|
97
98
|
|
98
99
|
run_cli(task_args)
|
99
100
|
end
|
@@ -96,7 +96,7 @@ module HamlLint
|
|
96
96
|
# Prints a summary of the number of lints found in a report.
|
97
97
|
#
|
98
98
|
# @param report [HamlLint::Report] the report to print
|
99
|
-
# @param is_append [Boolean] if this is appending to a line. Will
|
99
|
+
# @param is_append [Boolean] if this is appending to a line. Will prefix with ", ".
|
100
100
|
# @return [void]
|
101
101
|
def print_summary_lints(report, is_append:)
|
102
102
|
log.log ', ', false if is_append
|
@@ -114,7 +114,7 @@ module HamlLint
|
|
114
114
|
# Prints a summary of the number of lints corrected in a report.
|
115
115
|
#
|
116
116
|
# @param report [HamlLint::Report] the report to print
|
117
|
-
# @param is_append [Boolean] if this is appending to a line. Will
|
117
|
+
# @param is_append [Boolean] if this is appending to a line. Will prefix with ", ".
|
118
118
|
# @return [void]
|
119
119
|
def print_summary_corrected_lints(report, is_append:)
|
120
120
|
lint_count = report.lints.count(&:corrected)
|
data/lib/haml_lint/reporter.rb
CHANGED
@@ -63,7 +63,7 @@ module HamlLint::RubyExtraction
|
|
63
63
|
transfer_correction_logic(coordinator, to_ruby_lines, haml_lines)
|
64
64
|
end
|
65
65
|
|
66
|
-
# To be
|
66
|
+
# To be overridden by subclasses.
|
67
67
|
#
|
68
68
|
# Logic to transfer the corrections that turned from_ruby_lines into to_ruby_lines.
|
69
69
|
#
|
@@ -678,7 +678,7 @@ module HamlLint::RubyExtraction
|
|
678
678
|
|
679
679
|
def self.anonymous_block?(code)
|
680
680
|
# Don't start with a comment and end with a `do`
|
681
|
-
#
|
681
|
+
# Definitely not perfect for the comment handling, but otherwise a more advanced parsing system is needed.
|
682
682
|
# Move the comment to its own line if it's annoying.
|
683
683
|
code !~ /\A\s*#/ &&
|
684
684
|
code =~ /\bdo\s*(\|[^|]*\|\s*)?(#.*)?\z/
|
data/lib/haml_lint/runner.rb
CHANGED
data/lib/haml_lint/spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'spec/normalize_indent'
|
4
|
+
require_relative 'spec/shared_linter_context'
|
5
|
+
require_relative 'spec/shared_rubocop_autocorrect_context'
|
6
|
+
require_relative 'spec/matchers/report_lint'
|
data/lib/haml_lint/tree/node.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'null_node'
|
4
4
|
|
5
5
|
module HamlLint::Tree
|
6
6
|
# Represents the root node of a HAML document that contains all other nodes.
|
7
7
|
class RootNode < Node
|
8
|
-
# The name
|
8
|
+
# The name of the file parsed to build this tree.
|
9
9
|
#
|
10
10
|
# @return [String] a file name
|
11
11
|
def file
|
data/lib/haml_lint/utils.rb
CHANGED
@@ -116,7 +116,7 @@ module HamlLint
|
|
116
116
|
|
117
117
|
# Returns indexes of all occurrences of a substring within a string.
|
118
118
|
#
|
119
|
-
# Note, this will not return
|
119
|
+
# Note, this will not return overlapping substrings, so searching for "aa"
|
120
120
|
# in "aaa" will only find one substring, not two.
|
121
121
|
#
|
122
122
|
# @param text [String] the text to search
|
data/lib/haml_lint/version.rb
CHANGED
data/lib/haml_lint.rb
CHANGED
@@ -3,26 +3,26 @@
|
|
3
3
|
# Need to load haml before we can reference some Haml modules in our code
|
4
4
|
require 'haml'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
6
|
+
require_relative 'haml_lint/constants'
|
7
|
+
require_relative 'haml_lint/exceptions'
|
8
|
+
require_relative 'haml_lint/configuration'
|
9
|
+
require_relative 'haml_lint/configuration_loader'
|
10
|
+
require_relative 'haml_lint/document'
|
11
|
+
require_relative 'haml_lint/haml_visitor'
|
12
|
+
require_relative 'haml_lint/lint'
|
13
|
+
require_relative 'haml_lint/linter_registry'
|
14
|
+
require_relative 'haml_lint/ruby_parser'
|
15
|
+
require_relative 'haml_lint/linter'
|
16
|
+
require_relative 'haml_lint/logger'
|
17
|
+
require_relative 'haml_lint/reporter'
|
18
|
+
require_relative 'haml_lint/report'
|
19
|
+
require_relative 'haml_lint/linter_selector'
|
20
|
+
require_relative 'haml_lint/file_finder'
|
21
|
+
require_relative 'haml_lint/runner'
|
22
|
+
require_relative 'haml_lint/utils'
|
23
|
+
require_relative 'haml_lint/version'
|
24
|
+
require_relative 'haml_lint/version_comparer'
|
25
|
+
require_relative 'haml_lint/severity'
|
26
26
|
|
27
27
|
# Lead all extensions to external source code
|
28
28
|
Dir[File.expand_path('haml_lint/extensions/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
@@ -30,8 +30,8 @@ Dir[File.expand_path('haml_lint/extensions/*.rb', File.dirname(__FILE__))].sort.
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Load all parse tree node classes
|
33
|
-
|
34
|
-
|
33
|
+
require_relative 'haml_lint/tree/node'
|
34
|
+
require_relative 'haml_lint/node_transformer'
|
35
35
|
Dir[File.expand_path('haml_lint/tree/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
36
36
|
require file
|
37
37
|
end
|
@@ -47,7 +47,7 @@ Dir[File.expand_path('haml_lint/reporter/*.rb', File.dirname(__FILE__))].sort.ea
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Load all the chunks for RubyExtraction
|
50
|
-
|
50
|
+
require_relative 'haml_lint/ruby_extraction/base_chunk'
|
51
51
|
Dir[File.expand_path('haml_lint/ruby_extraction/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
52
52
|
require file
|
53
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.60.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: haml
|
@@ -201,7 +200,6 @@ homepage: https://github.com/sds/haml-lint
|
|
201
200
|
licenses:
|
202
201
|
- MIT
|
203
202
|
metadata: {}
|
204
|
-
post_install_message:
|
205
203
|
rdoc_options: []
|
206
204
|
require_paths:
|
207
205
|
- lib
|
@@ -216,8 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
214
|
- !ruby/object:Gem::Version
|
217
215
|
version: '0'
|
218
216
|
requirements: []
|
219
|
-
rubygems_version: 3.
|
220
|
-
signing_key:
|
217
|
+
rubygems_version: 3.6.2
|
221
218
|
specification_version: 4
|
222
219
|
summary: HAML lint tool
|
223
220
|
test_files: []
|