haml_lint 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +4 -0
- data/lib/haml_lint/adapter.rb +1 -0
- data/lib/haml_lint/linter/class_attribute_with_static_value.rb +1 -1
- data/lib/haml_lint/linter/consecutive_comments.rb +1 -0
- data/lib/haml_lint/linter/inline_styles.rb +14 -0
- data/lib/haml_lint/linter/rubocop.rb +1 -1
- data/lib/haml_lint/linter/trailing_whitespace.rb +3 -1
- data/lib/haml_lint/linter/unnecessary_string_output.rb +1 -1
- data/lib/haml_lint/options.rb +3 -3
- data/lib/haml_lint/report.rb +1 -1
- data/lib/haml_lint/tree/tag_node.rb +12 -1
- data/lib/haml_lint/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec594ab38cde43b4bfc77c30d2d01cdaa8efcce
|
4
|
+
data.tar.gz: 91068f84316b31511721b023a677609085796314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d852491b8757d078d5285d18a54017d70589fc98cc4d68e30e6d73be239e704dcf5fd0575fd7756bbfb4807fa68abdfe4fb361636e712423ad4614b9964e8df
|
7
|
+
data.tar.gz: 775dc9d01056561a235508e7d4dee8af74fff6484424270796ecb2ab1fb2c0e17d61917d3ad6c2d8358b9688d88e84851e7e71678476d42f0ccad7c7e76f7d31
|
data/config/default.yml
CHANGED
@@ -22,6 +22,7 @@ linters:
|
|
22
22
|
|
23
23
|
ConsecutiveComments:
|
24
24
|
enabled: true
|
25
|
+
max_consecutive: 1
|
25
26
|
|
26
27
|
ConsecutiveSilentScripts:
|
27
28
|
enabled: true
|
@@ -52,6 +53,9 @@ linters:
|
|
52
53
|
character: space # or tab
|
53
54
|
width: 2 # ignored if character == tab
|
54
55
|
|
56
|
+
InlineStyles:
|
57
|
+
enabled: true
|
58
|
+
|
55
59
|
InstanceVariables:
|
56
60
|
enabled: true
|
57
61
|
file_types: partials
|
data/lib/haml_lint/adapter.rb
CHANGED
@@ -17,6 +17,7 @@ module HamlLint
|
|
17
17
|
version = haml_version
|
18
18
|
case version
|
19
19
|
when '~> 4.0' then HamlLint::Adapter::Haml4
|
20
|
+
when '~> 4.1' then HamlLint::Adapter::Haml4
|
20
21
|
when '~> 5.0' then HamlLint::Adapter::Haml5
|
21
22
|
else fail HamlLint::Exceptions::UnknownHamlVersion, "Cannot handle Haml version: #{version}"
|
22
23
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module HamlLint
|
2
|
+
# Detects use of inline `style` attributes on any tag
|
3
|
+
class Linter::InlineStyles < Linter
|
4
|
+
include LinterRegistry
|
5
|
+
|
6
|
+
MESSAGE = 'Do not use inline style attributes'.freeze
|
7
|
+
|
8
|
+
def visit_tag(node)
|
9
|
+
if node.has_hash_attribute?(:style)
|
10
|
+
record_lint(node, MESSAGE)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -51,7 +51,7 @@ module HamlLint
|
|
51
51
|
def extract_lints_from_offenses(offenses, source_map)
|
52
52
|
dummy_node = Struct.new(:line)
|
53
53
|
|
54
|
-
offenses.
|
54
|
+
offenses.reject { |offense| Array(config['ignored_cops']).include?(offense.cop_name) }
|
55
55
|
.each do |offense|
|
56
56
|
record_lint(dummy_node.new(source_map[offense.line]), offense.message)
|
57
57
|
end
|
@@ -3,13 +3,15 @@ module HamlLint
|
|
3
3
|
class Linter::TrailingWhitespace < Linter
|
4
4
|
include LinterRegistry
|
5
5
|
|
6
|
+
DummyNode = Struct.new(:line)
|
7
|
+
|
6
8
|
def visit_root(root)
|
7
9
|
document.source_lines.each_with_index do |line, index|
|
8
10
|
next unless line =~ /\s+$/
|
9
11
|
|
10
12
|
node = root.node_for_line(index + 1)
|
11
13
|
unless node.disabled?(self)
|
12
|
-
record_lint
|
14
|
+
record_lint DummyNode.new(index + 1), 'Line contains trailing whitespace'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -33,7 +33,7 @@ module HamlLint
|
|
33
33
|
|
34
34
|
def outputs_string_literal?(script_node)
|
35
35
|
return unless tree = parse_ruby(script_node.script)
|
36
|
-
[
|
36
|
+
%i[str dstr].include?(tree.type) &&
|
37
37
|
!starts_with_reserved_character?(tree.children.first)
|
38
38
|
rescue ::Parser::SyntaxError # rubocop:disable Lint/HandleExceptions
|
39
39
|
# Gracefully ignore syntax errors, as that's managed by a different linter
|
data/lib/haml_lint/options.rb
CHANGED
@@ -21,7 +21,7 @@ module HamlLint
|
|
21
21
|
end.parse!(args)
|
22
22
|
|
23
23
|
# Any remaining arguments are assumed to be files
|
24
|
-
@options[:files] = args.empty? ? [
|
24
|
+
@options[:files] = args.empty? ? ['.'] : args
|
25
25
|
|
26
26
|
@options
|
27
27
|
rescue OptionParser::InvalidOption => ex
|
@@ -56,12 +56,12 @@ module HamlLint
|
|
56
56
|
@options[:reporter] = load_reporter_class(reporter.capitalize)
|
57
57
|
end
|
58
58
|
|
59
|
-
parser.on('--fail-fast', 'Fail after the first file with lint above the fail level') do
|
59
|
+
parser.on('--fail-fast', 'Fail after the first file with lint at or above the fail level') do
|
60
60
|
@options[:fail_fast] = true
|
61
61
|
end
|
62
62
|
|
63
63
|
parser.on('--fail-level fail_level', String,
|
64
|
-
'Specify which level you want the suite to fail') do |fail_level|
|
64
|
+
'Specify which level (warning or error) you want the suite to fail') do |fail_level|
|
65
65
|
@options[:fail_level] = HamlLint::Severity.new(fail_level.to_sym)
|
66
66
|
end
|
67
67
|
end
|
data/lib/haml_lint/report.rb
CHANGED
@@ -7,9 +7,20 @@ module HamlLint::Tree
|
|
7
7
|
# different attribute setting syntaxes (`{...}`/`(...)`), converted into
|
8
8
|
# Ruby code.
|
9
9
|
#
|
10
|
+
# @note This has to be memoized because of a design decision in Haml 5. When
|
11
|
+
# calling `DynamicAttributes#to_literal`, they mutate the "old" parameter using
|
12
|
+
# `String#sub!` instead of returning a new string. This means that any subsequent
|
13
|
+
# calls can return a nil instead of a string for that attribute, which causes
|
14
|
+
# any subsequent calls to the method to raise an error.
|
15
|
+
#
|
10
16
|
# @return [Array<String>]
|
11
17
|
def dynamic_attributes_sources
|
12
|
-
@
|
18
|
+
@dynamic_attributes_sources ||=
|
19
|
+
if Gem::Version.new(Haml::VERSION) < Gem::Version.new('5')
|
20
|
+
@value[:attributes_hashes]
|
21
|
+
else
|
22
|
+
Array(@value[:dynamic_attributes].to_literal).reject(&:empty?)
|
23
|
+
end
|
13
24
|
end
|
14
25
|
|
15
26
|
# Returns whether this tag contains executable script (e.g. is followed by a
|
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.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/haml_lint/linter/id_names.rb
|
134
134
|
- lib/haml_lint/linter/implicit_div.rb
|
135
135
|
- lib/haml_lint/linter/indentation.rb
|
136
|
+
- lib/haml_lint/linter/inline_styles.rb
|
136
137
|
- lib/haml_lint/linter/instance_variables.rb
|
137
138
|
- lib/haml_lint/linter/leading_comment_space.rb
|
138
139
|
- lib/haml_lint/linter/line_length.rb
|
@@ -203,9 +204,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
204
|
version: '0'
|
204
205
|
requirements: []
|
205
206
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.
|
207
|
+
rubygems_version: 2.5.2
|
207
208
|
signing_key:
|
208
209
|
specification_version: 4
|
209
210
|
summary: HAML lint tool
|
210
211
|
test_files: []
|
211
|
-
has_rdoc:
|