sds / haml-lint Goto Github PK
View Code? Open in Web Editor NEWTool for writing clean and consistent HAML
License: MIT License
Tool for writing clean and consistent HAML
License: MIT License
comparison of Array with Array failed
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/report.rb:7:in `sort_by'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/report.rb:7:in `initialize'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/runner.rb:26:in `new'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/runner.rb:26:in `run'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/cli.rb:55:in `scan_for_lints'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/cli.rb:50:in `act_on_options'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/cli.rb:22:in `run'
/Users/karolis/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/bin/haml-lint:7:in `<top (required)>'
/Users/karolis/.rbenv/versions/2.1.2/bin/haml-lint:23:in `load'
/Users/karolis/.rbenv/versions/2.1.2/bin/haml-lint:23:in `<main>'
This error is being thrown out when I try to run haml-lint without specifying config file.
config file. (named: config.haml-lint.yml)
linters:
LineLength:
enabled: true
max: 130
RuboCop:
enabled: false
The following HAML is incorrectly reported:
%p
My text content |
= my_variable
Hey all,
I think there's a problem with the UnnecessaryStringOutput linter.
When dealing with nested values, if there's interpolation, Haml treats it like a script tag, triggering a false positive.
The following spec illustrates the problem.
context 'when tag contains nested text with interpolation' do
let(:haml) { <<-'HAML' }
%tag
Some #{interpolation} text
HAML
it { should_not report_lint }
end
Unfortunately, fixing this by checking for interpolation breaks the following spec:
context 'when script outputs literal string in double quotes' do
let(:haml) { '= "hello #{world}"' }
it { should report_lint }
end
As Haml parses each of these as a script node. You might be able to get around it by checking for a space before the quote as that would give you some indication that an equals sign was present, but that would depend on the SpaceBeforeScript linter to ensure all the matches.
Anyone have any ideas?
% cat haml_lint_bug.html.haml
%p= @foo.bar
% haml-lint -i SpaceBeforeScript haml_lint_bug.html.haml
/home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/linter/space_before_script.rb:73:in `next_node': undefined method `children' for nil:NilClass (NoMethodError)
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/linter/space_before_script.rb:80:in `next_node'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/linter/space_before_script.rb:58:in `tag_with_inline_text'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/linter/space_before_script.rb:13:in `visit_tag'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/haml_visitor.rb:16:in `visit'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/haml_visitor.rb:25:in `block in visit_children'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/haml_visitor.rb:25:in `each'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/haml_visitor.rb:25:in `visit_children'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/haml_visitor.rb:21:in `visit'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/linter.rb:13:in `run'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:39:in `block in find_lints'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:38:in `each'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:38:in `find_lints'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:27:in `block in run'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:26:in `each'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/runner.rb:26:in `run'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/lib/haml_lint/cli.rb:59:in `run'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/bin/haml-lint:8:in `block in <top (required)>'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/bin/haml-lint:6:in `tap'
from /home/mde/.gem/ruby/2.1.2/gems/haml-lint-0.5.2/bin/haml-lint:6:in `<top (required)>'
from /home/mde/.gem/ruby/2.1.2/bin/haml-lint:23:in `load'
from /home/mde/.gem/ruby/2.1.2/bin/haml-lint:23:in `<main>'
Not sure if it's intentional, but we get a LeadingCommentSpace
violation when we have comments like:
-# the start of the comment
-# continuing the comment
show an error after upgrade to 0.7.0 version
lib/haml_lint/ruby_parser.rb:1:in `require': cannot load such file -- astrolabe/builder (LoadError)
For example:
= 'user'.pluralize(@users.count)
I found haml-lint would crash on my codebase. I've narrowed it down to a simplifed test-case
%ul
- case foo
- when bar
%li= one
- when baz
%li= two
It crashes with the following message:
space_before_script.rb:73:in `next_node': undefined method `children' for nil:NilClass (NoMethodError)
It's worth noting that the following is fine:
%ul
- case foo
- when bar
%li one
- when baz
%li two
i.e. with the %li=
changed to a plain %li
.
/var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:73:in `next_node': undefined method `children' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:80:in `next_node'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:80:in `next_node'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:80:in `next_node'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:58:in `tag_with_inline_text'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter/space_before_script.rb:13:in `visit_tag'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:16:in `visit'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `block in visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `each'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:21:in `visit'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `block in visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `each'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:21:in `visit'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `block in visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `each'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:25:in `visit_children'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/haml_visitor.rb:21:in `visit'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/linter.rb:13:in `run'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:39:in `block in find_lints'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:38:in `each'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:38:in `find_lints'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:27:in `block in run'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:26:in `each'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/runner.rb:26:in `run'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/lib/haml_lint/cli.rb:59:in `run'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/bin/haml-lint:8:in `block in <top (required)>'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/bin/haml-lint:6:in `tap'
from /var/lib/gems/1.9.1/gems/haml-lint-0.5.0/bin/haml-lint:6:in `<top (required)>'
from /usr/local/bin/haml-lint:19:in `load'
from /usr/local/bin/haml-lint:19:in `<main>'
I have rubocop running and can run haml-lint from the command line.
Is it possible to have haml-lint run when rubycop runs? I haven't been able to figure out how to do this.
In one of our HAML templates (which still mostly is a click dummy), we have the following construct:
%p
Freue dich auf einen erfolgreichen Workshop! Alkoholische Getränke sind
zu Übungszwecken bereitgestellt und im Preis enthalten.
https://gist.github.com/oliverklee/cd3ae86204661cb83847
This causes the following warning in haml-lint:
app/views/home/index.html.haml:2 [W] RuboCop: Style/AsciiComments: Use only ascii symbols in comments.
It looks like haml-lint passes the contents of the p tag as a Ruby comment to RuboCop.
I have some rubocop rules disabled, but they're turning up in my haml-lint output. Any idea what I'm doing wrong? Specifically, I'm seeing the following complaints:
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Use the new Ruby 1.9 hash syntax.
I ran the command from the root of our rails app with haml-lint app/views/
bundle exec haml-lint app/views
undefined method `-' for nil:NilClass
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/linter/space_before_script.rb:29:in `visit_tag'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/haml_visitor.rb:18:in `visit'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/haml_visitor.rb:27:in `block in visit_children'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/haml_visitor.rb:27:in `each'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/haml_visitor.rb:27:in `visit_children'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/haml_visitor.rb:23:in `visit'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/linter.rb:17:in `run'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:63:in `block in find_lints'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:62:in `each'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:62:in `find_lints'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:22:in `block in run'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:21:in `each'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/runner.rb:21:in `run'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/cli.rb:73:in `scan_for_lints'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/cli.rb:47:in `act_on_options'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/lib/haml_lint/cli.rb:22:in `run'
/Users/stereodenis/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/haml-lint-0.13.0/bin/haml-lint:7:in `<top (required)>'
/Users/stereodenis/.rbenv/versions/2.2.0/bin/haml-lint:23:in `load'
/Users/stereodenis/.rbenv/versions/2.2.0/bin/haml-lint:23:in `<main>'
The UnnecessaryInterpolation linter uses this to determine if a line is only interpolation:
def only_interpolation?(content)
content.lstrip.start_with?('"#{')
end
Thus lines like this
%tag #{some}/partially/#{interpolated}/#{value}
Raise when they shouldn't. My first thought would be to try to gsub out all the interpolation via regex then check to see if anything's left, but that seems error-prone and expensive. Any better ideas?
I have this code:
%em.text-muted
- if group.sequential?
Routed to Multiple Recipients
- elsif group.all_at_once?
Alternate Emails Uploaded
And I'm getting this message from haml-lint
:
[W] RuboCop: Favor the ternary operator (?:) over if/then/else/end constructs.
The same code represented in pure ruby passes rubocop, so it seems like an issue in haml-lint
.
With 0.3.0, haml-lint --show-linters
fails because print_linters
is not defined anywhere.
haml-lint ignores some rubocop cops (https://github.com/brigade/haml-lint/blob/master/config/default.yml#L56-L70)
Let's say I didn't want it to...
I tried figuring out how to configure haml-lint to enable those cops but couldn't quite figure it out. Is it possible?
Thanks!
haml-lint always uses 80 as the line length limit independent of the configured value:
klee@gonzales:~/eclipse/justworkshops$ haml-lint app/views/
app/views/devise/confirmations/new.html.haml:3 [W] Line is too long. [108/80]
This is my .haml-lint.yml (in the current working directory):
linters:
LineLength:
max: 400
This happens with haml-lint 0.6.0 and rubocop 0.25.0. I think one of the recent rubocop upgrades has caused this. IIRC, Rubocop has renamed/moved the parameter for their line length parameter. It has moved to Metrics/LineLength: Max.
Hi. In my project I use unobstrusive javascript with Ruby on Rails. While linting *.js.haml files, they give constant "UnnecessaryStringOutput" errors.
Is there a way to exclude this filetype from being linted at all?
Currently tried to use exclude next way in my .haml-lint.yml:
UnnecessaryStringOutput:
enabled: true
exclude:
- *.js.haml (or /*.js.haml/, or '*.js.haml', or this exclude right under 'skip_frontmatter' parameter)
None of those tries gave a positive result.
Please help me to solve this issue.
Thanks
Putting the following test in the class_attribute_with_static_value_spec.rb and Haml-Lint will crash horribly and provide no feedback as to what caused it to happen.
context 'given an incorrectly structured hash' do
let(:haml) { <<-HAML }
%th{:class: value}
HAML
it { should_not report_lint }
end
Haml-Lint also crashes when running it against a code base that has something similar.
It would be nice if this error could perhaps be caught and display to the user what node caused it to crash, which would make debugging it a lot easier.
Running haml-lint on:
:ruby
if true
# noop
else
# noop
end
...produces the following stacktrace:
/home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:105:in `*': negative argument (ArgumentError)
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:105:in `add_line'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:89:in `block in visit_filter'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:88:in `each'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:88:in `each_with_index'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:88:in `visit_filter'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:16:in `visit'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:25:in `block in visit_children'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:25:in `each'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:25:in `visit_children'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:12:in `block in visit'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:41:in `visit_root'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/haml_visitor.rb:16:in `visit'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/script_extractor.rb:32:in `extract'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/linter/ruby_script.rb:16:in `run'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:39:in `block in find_lints'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:38:in `each'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:38:in `find_lints'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:27:in `block in run'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:26:in `each'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/runner.rb:26:in `run'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/lib/haml_lint/cli.rb:59:in `run'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/bin/haml-lint:7:in `block in <top (required)>'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/bin/haml-lint:5:in `tap'
from /home/tom/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/haml-lint-0.2.0/bin/haml-lint:5:in `<top (required)>'
from /home/tom/.rbenv/versions/2.0.0-p195/bin/haml-lint:23:in `load'
from /home/tom/.rbenv/versions/2.0.0-p195/bin/haml-lint:23:in `<main>'
Hi,
if you have a multiline if statement in haml, for example:
- if false ||
- true
Wheee!
haml-lint outputs a bogus
foo.haml:1 [W] RuboCop: Syntax: unexpected token kEND
(In some cases it's $end
instead of kEND
.)
It's probably in RuboCop but since I can't figure out what actually gets passed to rubocop (the --debug output doesn't trigger it), I'm making an issue here.
Any thoughs please?
If I have the following haml, I expect haml-lint to give me an ImplicitDiv
warning, which it currently does.
%div.supervisor-page
However if I have the following haml, I would expect it to not raise an ImplicitDiv
warning.
%div{id: leaderboard.code}
Yet it does, and the suggestion that it offers isn't quite right either.
[W] ImplicitDiv: `%div` can be written as `.code}` since `%div` is implicit
It seems to think that my method call anywhere after %div
is supposed to be the class that I'm using on the div.
The following code creates warnings in haml-lint:
- if controller_name != 'sessions'
= link_to 'Sign in',
new_session_path(resource_name)
%br
- if controller_name != 'registrations'
= link_to 'Sign up',
new_registration_path(resource_name)
%br
- if controller_name != 'passwords' && controller_name != 'registrations'
= link_to 'Forgot your password?',
new_password_path(resource_name)
%br
- if controller_name != 'confirmations'
= link_to 'Didn\'t receive confirmation instructions?',
new_confirmation_path(resource_name)
%br
- if controller_name != 'unlocks'
= link_to 'Didn\'t receive unlock instructions?',
new_unlock_path(resource_name)
%br
This is the warning:
app/views/devise/shared/_links.html.haml:1 [W] ConsecutiveSilentScripts: 5 consecutive Ruby scripts can be merged into a single `:ruby` filter
However, the template isn't pure Ruby - it contains the %br tags. haml-lint should recognize that this.
Has anybody tried to port this to slim?
How easy would it be for this project to support both?
haml-lint seems to use Utils#haml_file? to determine whether or not it should process a file. I'm using a kind of rickety asset pipeline preprocessor that requires a .ractivehaml
extension to process the file via haml and then Ractive. The files are valid haml, but I can't rename them to .ractive.haml
or anything like that because of some special processing that is a little different than the standard haml
preprocessor. Any chance it would be possible to add a setting to .haml-lint.yml
to allow additional file extensions?
haml-lint 0.7.0 is reporting a problem from ObjectReferenceAttributes on the first line of the following haml:
%h3 Test
%p hi
Have you considered adding some basic accessibility assertions to your rules (i.e. presence of alt
attributes, label
association on form elements)?
I'd like to work on some PRs for accessibility rules, starting with looking for missing alt
attributes. Would you be open to that?
This problem might related to issue #25. It occurs with haml-lint 0.6.0 and rubocop 0.25.0.
For testing the issue, I have set the maximum line length to 200 both in my rubocop configuration as well as my haml-lint configuration. I get this error for the following HAML lines:
klee@gonzales:~/eclipse/justworkshops$ haml-lint app/views/
app/views/home/admin.html.haml:118 [W] Line is too long. [358/200]
This is the corresponding piece of HAML code:
%p!= t 'views.home.admin.statisticsText1Html',
users: number_with_delimiter(5_392, delimiter: t('views.thousandsSeperator')),
attendees: number_with_delimiter(4_966, delimiter: t('views.thousandsSeperator')),
offerers: number_with_delimiter(554, delimiter: t('views.thousandsSeperator')),
admins: number_with_delimiter(4, delimiter: t('views.thousandsSeperator'))
It seems that HAML (or RuboCop?) check the length of the logical line (consisting of 5 screen lines) instead of the lengths of the individual screen lines.
Hi. Thanks for this tool. It's really helpful.
I just upgraded to haml-lint 0.8.0 and now I'm getting a bunch of false positives for the LeadingCommentSpace
error in files that do not have any comments at all. It appears that every single haml file is reporting this issue, and not a single one has a comment.
For example:
https://github.com/codeforamerica/ohana-api/blob/master/app/views/admin/contacts/_form.html.haml
Based on the line number in the error report, what appears to be triggering this is the newline at the end of each file, which is required per the Ruby Style Guide.
I'm on OS X 10.9.5 with Ruby 2.1.3 and Rails 4.1.8.
With a tag definition with hash attributes spanning multiple lines, TagNode#hash_attributes? incorrectly returns false, and TagNode#hash_attributes_source incorrectly returns nil.
Haml source:
%tag{ one: 1,
two: 2,
three: 3 }
Observed behavior:
(byebug) node.first_line_source
"%tag{ one: 1,"
(byebug) node.hash_attributes?
false
(byebug) node.hash_attributes_source
nil
(byebug) node.dynamic_attributes_source
{:hash=>nil}
Expected behavior (shown via a single-line tag definition):
(byebug) node.first_line_source
"%tag{ one: 1, two: 2, three: 3}"
(byebug) node.hash_attributes?
true
(byebug) node.hash_attributes_source
"{ one: 1, two: 2, three: 3}"
(byebug) node.dynamic_attributes_source
{:hash=>"{ one: 1, two: 2, three: 3}"}
The following haml generates a lint from the space before script linter:
.div
.another= key
.again= array[something_with_the_word_key_in_it]
It seems to pick up the variable name from the previous line, only when it is indented just like this, and gets confused.
Have a bug on fresh project. Ruby 2.2.0 / Rails: 4.2.1
undefined method `type' for nil:NilClass
/lib/haml_lint/linter/unnecessary_string_output.rb:34:in `outputs_string_literal?'
Stack trace: https://gist.github.com/KODerFunk/66f09d0a2fd63e2565ff
Hi!
I would like ask that are you planning to add an optional rubocop-like json output format?
We have a bot, which checks pull requests with rubocop.
I would like to add support for the haml
files with haml-lint, but I need JSON as output.
Thanks!
If i use conditions containing only CSS, i got the following warning:
[W] RuboCop: Style/EmptyElse: Redundant empty `else`-clause.
- if Rails.env == 'development'
:css
.jw-non-functional {
box-shadow: 0 0 6px 4px rgba(255, 127, 80, .6);
}
- else
:css
.jw-non-functional {
display: none;
}
I've created a gist: https://gist.github.com/michsch/c876a01e576fb7e1de63
Expected result: no warning
Current result: [W] RuboCop: Style/EmptyElse: Redundant empty else
-clause.
Our work around at the moment in haml-lint.yml
:
RuboCop:
ignored_cops:
- Style/EmptyElse
It would be nice to have the rubocop cop name in the output as well, so when we need to disable them we can quickly add it to the config file.
The "good" example for the ConsecutiveComments linter has 3 spaces for all lines after the first. In practice this doesn't appear possible to do. Take the following partial snippet:
-# The email partial displays the email icon and address.
e.g. [icon] admin@example.com
- if email.present?
%section.email
…
With 3 spaces present for the second line of the comment, the page fails with a Haml::SyntaxError
error of Inconsistent indentation: 2 spaces used for indentation, but the rest of the document was indented using 3 spaces.
.
A correctly functioning example instead uses 2 spaces for the lines after the first:
-# The email partial displays the email icon and address.
e.g. [icon] admin@example.com
- if email.present?
%section.email
…
Is there a recommended format that left-aligns all pertinent comment lines, something like the following for example?
-# |
The email partial displays the email icon and address.
e.g. [icon] admin@example.com
The current version restriction of haml-lint
on colorize 0.5.8 (strictly that version) prevents users of capistrano
3 from using haml-lint
, as capistrano
depends on sshkit
and sshkit
depends on colorize 0.6.0+ (currently implicitly, but I expect this will be made explicit shortly (capistrano/sshkit#151)).
From the colorize
changelog I don't see any reason to expect this wouldn't work.
Hi,
First, thanks a lot for this linter. It works flawlessly !
I have a feature request :
It would be really great to be able to configure haml-lint the same way rubocop does with inherit_from
.
This would allow to have global overrides in ~/.haml-lint.yml
and your local project overrides in ./haml-lint.yml
.
Hope you will consider this !
Cheers !
The following code fails Style/AlignHash
%div{ 'item-A' => 'valA',
'item-B' => 'valB' }
related: #49
Hello,
I am trying to work with rubocop and haml-lint and testing on haml files
Rubocop detect trailing whitespaces, haml-lint not !
Is it a configuration tip or is it a feature not yet ready on haml-lint ?
I don't understand also how rubocop and haml-lint work together
Hi, I've got RuboCop configured to require a trailing blank line at the end of each file. Even though my haml files do have the trailing blank line, I'm still getting this for every file:
app/views/thing/show.html.haml:0 [W] RuboCop: Style/TrailingBlankLines: Trailing blank line missing.
Hi. Thanks for this great gem. I'd love to keep my HAML lines under 80 characters, but the problem is I haven't found a syntax highlighter for Sublime Text that supports attributes on multiple lines.
For example, if I do this:
= link_to('Code for America', 'http://codeforamerica.org',
target: '_blank', title: 'Code for America')
the second line is not highlighted properly.
I find it harder to read when it's not highlighted properly, so I stick with the longer lines unfortunately.
How do you deal with this? Have you found a syntax highlighter that works?
I'm not sure if this is a bug in haml-lint or RuboCop, but haml-lint 0.7.0 and rubocop 0.26.1, I get a problem on line 1 of the following haml file:
- things = [1, 2]
- things.each do |thing|
= thing
RuboCop: Useless assignment to variable =
things
I am the author of the linter-haml package that provides haml-lint integration with Atom. Unfortunately, I've run into an issue that I don't believe can be solved without support from haml-lint
to allow specifying a config location to rubocop.
The nature of the problem is that files are written to a temporary directory before being linted and so rubocop is unable to automatically determine the correct .rubocop.yml
file to use and needs to told where it is located. More details can be found at AtomLinter/linter-haml#2.
Is it possible to get haml-lint to support specifying a location for .rubocop.yml
?
Right now any lints found in interpolation within a HAML filter are reported with a line number that is the first line of that filter. It should instead report on the actual line of the problem.
For example:
:preserve
#{Module::method} # Rubocop ColonMethodCall reported on line 1 instead of line 2
There might be some difficulties and edge cases here (for example interpolation that spans multiple lines) but we should be able to get somewhere with it.
The code in https://gist.github.com/oliverklee/1fdfaa5b4d699cfd31d9 creates the following warning with haml-lint 0.7.0:
app/views/devise/unlocks/new.html.haml:14 [W] ImplicitDiv: `%div` can be written as `.submit` since `%div` is implicit
This is the corresponding line:
%div= f.submit 'Resend unlock instructions'
The warning is incorrect because the code after the div isn't a ".submit class", but a "f.submit tag".
It would be great if haml-lint had a switch to activate rubocop --auto-correct
to fix eg. hash syntax in haml templates to 1.9 syntax.
Simply using the -h
switch throws an error:
haml-lint -h
Usage: haml-lint [options] [file1, file2, ...]
-i, --include-linter linter,... Specify which linters you want to run
-x, --exclude-linter linter,... Specify which linters you don't want to run
-c, --config config-file Specify which configuration file you want to use
-e, --exclude file,... List of file names to exclude
--show-linters Display available linters
-h, --help Display help documentation
-v, --version Display version
uninitialized constant HamlLint::CLI::SysExits
/Users/matthew/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/cli.rb:42:in `act_on_options'
/Users/matthew/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/lib/haml_lint/cli.rb:22:in `run'
/Users/matthew/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/haml-lint-0.6.0/bin/haml-lint:7:in `<top (required)>'
/Users/matthew/.rbenv/versions/2.1.1/bin/haml-lint:23:in `load'
/Users/matthew/.rbenv/versions/2.1.1/bin/haml-lint:23:in `<main>'
Report this bug at https://github.com/causes/haml-lint/issues
But others do not:
haml-lint -v
haml-lint 0.6.0
I'm getting this error when I try to run haml-lint:
$ haml-lint app/views/
/home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/lib/haml_lint/cli.rb:78:in `sort_by': comparison of Array with Array failed (ArgumentError)
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/lib/haml_lint/cli.rb:78:in `report_lints'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/lib/haml_lint/cli.rb:60:in `run'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/bin/haml-lint:7:in `block in <top (required)>'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/bin/haml-lint:5:in `tap'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/gems/haml-lint-0.4.1/bin/haml-lint:5:in `<top (required)>'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/bin/haml-lint:23:in `load'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/bin/haml-lint:23:in `<main>'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
from /home/fletch/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.