haml_lint 0.72.0 → 0.74.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/default.yml +9 -4
- data/lib/haml_lint/cli.rb +5 -1
- data/lib/haml_lint/document.rb +0 -5
- data/lib/haml_lint/linter/class_attribute_with_static_value.rb +51 -11
- data/lib/haml_lint/linter/classes_before_ids.rb +16 -1
- data/lib/haml_lint/linter/consecutive_comments.rb +20 -1
- data/lib/haml_lint/linter/empty_object_reference.rb +16 -1
- data/lib/haml_lint/linter/empty_script.rb +31 -1
- data/lib/haml_lint/linter/final_newline.rb +31 -7
- data/lib/haml_lint/linter/implicit_div.rb +14 -1
- data/lib/haml_lint/linter/leading_comment_space.rb +13 -1
- data/lib/haml_lint/linter/multiline_script.rb +65 -5
- data/lib/haml_lint/linter/rubocop.rb +5 -17
- data/lib/haml_lint/linter/ruby_comments.rb +13 -3
- data/lib/haml_lint/linter/space_before_script.rb +36 -3
- data/lib/haml_lint/linter/space_inside_hash_attributes.rb +41 -3
- data/lib/haml_lint/linter/tag_name.rb +14 -1
- data/lib/haml_lint/linter/trailing_empty_lines.rb +13 -1
- data/lib/haml_lint/linter/trailing_whitespace.rb +15 -2
- data/lib/haml_lint/linter/unescaped_html.rb +27 -0
- data/lib/haml_lint/linter/unnecessary_interpolation.rb +30 -3
- data/lib/haml_lint/linter/unnecessary_string_output.rb +34 -2
- data/lib/haml_lint/linter.rb +111 -0
- data/lib/haml_lint/reporter/disabled_config_reporter.rb +26 -5
- data/lib/haml_lint/reporter/github_reporter.rb +26 -8
- data/lib/haml_lint/ruby_extraction/chunk_extractor.rb +27 -3
- data/lib/haml_lint/runner.rb +17 -3
- data/lib/haml_lint/source.rb +2 -6
- data/lib/haml_lint/tree/filter_node.rb +13 -0
- data/lib/haml_lint/tree/tag_node.rb +55 -23
- data/lib/haml_lint/version.rb +1 -1
- metadata +5 -4
|
@@ -33,6 +33,16 @@ module HamlLint::Tree
|
|
|
33
33
|
@value[:parse] && !@value[:value].strip.empty?
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# Whether this tag outputs unescaped HTML via a `!` marker, e.g. `%tag!=` or
|
|
37
|
+
# `%tag!~`.
|
|
38
|
+
#
|
|
39
|
+
# @return [true,false]
|
|
40
|
+
def unescape_html?
|
|
41
|
+
return false unless contains_script?
|
|
42
|
+
|
|
43
|
+
/\A\s*[<>]*\s*!/.match?(inline_marker_source)
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
# Returns whether this tag has a specified attribute.
|
|
37
47
|
#
|
|
38
48
|
# @return [true,false]
|
|
@@ -94,30 +104,18 @@ module HamlLint::Tree
|
|
|
94
104
|
#
|
|
95
105
|
# @return [Hash]
|
|
96
106
|
def attributes_source
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_explicit_tag, static_attrs, rest =
|
|
100
|
-
source_code.scan(/\A\s*(%[-:\w]+)?([-:\w.\#]*)(.*)/m)[0]
|
|
101
|
-
|
|
102
|
-
attr_types = {
|
|
103
|
-
'{' => [:hash, %w[{ }]],
|
|
104
|
-
'(' => [:html, %w[( )]],
|
|
105
|
-
'[' => [:object_ref, %w[[ ]]],
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
attr_source = { static: static_attrs }
|
|
109
|
-
while rest
|
|
110
|
-
type, chars = attr_types[rest[0]]
|
|
111
|
-
break unless type # Not an attribute opening character, so we're done
|
|
112
|
-
|
|
113
|
-
# Can't define multiple of the same attribute type (e.g. two {...})
|
|
114
|
-
break if attr_source[type]
|
|
115
|
-
|
|
116
|
-
attr_source[type], rest = Haml::Util.balance(rest, *chars)
|
|
117
|
-
end
|
|
107
|
+
parsed_attributes_source[:attributes]
|
|
108
|
+
end
|
|
118
109
|
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
# Source that follows the tag name and attributes. It begins with the
|
|
111
|
+
# content marker (e.g. `=`, `!=`, `~`, `!~`, or plain text).
|
|
112
|
+
#
|
|
113
|
+
# @example For `%tag.class!= foo`, this returns:
|
|
114
|
+
# '!= foo'
|
|
115
|
+
#
|
|
116
|
+
# @return [String]
|
|
117
|
+
def inline_marker_source
|
|
118
|
+
parsed_attributes_source[:marker]
|
|
121
119
|
end
|
|
122
120
|
|
|
123
121
|
# Whether this tag node has a set of hash attributes defined via the
|
|
@@ -229,6 +227,40 @@ module HamlLint::Tree
|
|
|
229
227
|
|
|
230
228
|
private
|
|
231
229
|
|
|
230
|
+
# Parses the source code following the tag name once into its attribute
|
|
231
|
+
# sources and the remaining inline content marker.
|
|
232
|
+
#
|
|
233
|
+
# @return [Hash{Symbol => Object}] `:attributes` source hash (keyed by
|
|
234
|
+
# `:static`/`:hash`/`:html`/`:object_ref`) and the `:marker` string
|
|
235
|
+
def parsed_attributes_source
|
|
236
|
+
@parsed_attributes_source ||=
|
|
237
|
+
begin
|
|
238
|
+
_explicit_tag, static_attrs, rest =
|
|
239
|
+
source_code.scan(/\A\s*(%[-:\w]+)?([-:\w.\#]*)(.*)/m)[0]
|
|
240
|
+
|
|
241
|
+
attr_types = {
|
|
242
|
+
'{' => [:hash, %w[{ }]],
|
|
243
|
+
'(' => [:html, %w[( )]],
|
|
244
|
+
'[' => [:object_ref, %w[[ ]]],
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
attr_source = { static: static_attrs }
|
|
248
|
+
while rest
|
|
249
|
+
type, chars = attr_types[rest[0]]
|
|
250
|
+
break unless type # Not an attribute opening character, so we're done
|
|
251
|
+
|
|
252
|
+
# Can't define multiple of the same attribute type (e.g. two {...})
|
|
253
|
+
break if attr_source[type]
|
|
254
|
+
|
|
255
|
+
attr_source[type], rest = Haml::Util.balance(rest, *chars)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Whatever remains after the tag name and attributes begins with the
|
|
259
|
+
# content marker (e.g. `=`, `!=`, `~`, `!~`, or plain text).
|
|
260
|
+
{ attributes: attr_source, marker: rest.to_s }
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
232
264
|
def existing_attributes
|
|
233
265
|
parsed_attrs = parsed_attributes
|
|
234
266
|
return {} unless parsed_attrs.respond_to?(:children)
|
data/lib/haml_lint/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: haml_lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.74.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
@@ -27,14 +27,14 @@ dependencies:
|
|
|
27
27
|
name: parallel
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '1.10'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- - "
|
|
37
|
+
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '1.10'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
@@ -138,6 +138,7 @@ files:
|
|
|
138
138
|
- lib/haml_lint/linter/tag_name.rb
|
|
139
139
|
- lib/haml_lint/linter/trailing_empty_lines.rb
|
|
140
140
|
- lib/haml_lint/linter/trailing_whitespace.rb
|
|
141
|
+
- lib/haml_lint/linter/unescaped_html.rb
|
|
141
142
|
- lib/haml_lint/linter/unnecessary_interpolation.rb
|
|
142
143
|
- lib/haml_lint/linter/unnecessary_string_output.rb
|
|
143
144
|
- lib/haml_lint/linter/view_length.rb
|
|
@@ -218,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
218
219
|
- !ruby/object:Gem::Version
|
|
219
220
|
version: '0'
|
|
220
221
|
requirements: []
|
|
221
|
-
rubygems_version:
|
|
222
|
+
rubygems_version: 4.0.10
|
|
222
223
|
specification_version: 4
|
|
223
224
|
summary: HAML lint tool
|
|
224
225
|
test_files: []
|