This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment).
-# example.haml
- name ='James Brown'
- unused_variable =42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml configuration:
AllCops:
DisplayCopNames:true
HamlLint/LineLength
Option
Description
max
Maximum number of columns a single line can have. (default 80)
Wrap lines at 80 characters. You can configure this amount via the max
option on the linter, e.g. by adding the following to your .haml-lint.yml:
linters:
LineLength:
max:100
Long lines are harder to read and usually indicative of complexity. You can
avoid them by splitting long attribute hashes on a comma, for example:
%tag{attr1:1,
attr2:2,
attr3:3}
This significantly improves readability.
HamlLint/LineLength
Option
Description
max
Maximum number of columns a single line can have. (default 80)
Wrap lines at 80 characters. You can configure this amount via the max
option on the linter, e.g. by adding the following to your .haml-lint.yml:
linters:
LineLength:
max:100
Long lines are harder to read and usually indicative of complexity. You can
avoid them by splitting long attribute hashes on a comma, for example:
%tag{attr1:1,
attr2:2,
attr3:3}
This significantly improves readability.
HamlLint/UnnecessaryStringOutput
Avoid outputting string expressions in Ruby when static text will suffice.
Badhaml
%tag= "Some #{interpolated} string"
Good: more concisehaml
%tag Some #{interpolated} string
HAML gracefully handles string interpolation in static text, so you don't need
to work with Ruby strings in order to use interpolation.
HamlLint/RuboCop
Option
Description
ignored_cops
Array of RuboCop cops to ignore.
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment).
-# example.haml
- name ='James Brown'
- unused_variable =42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml configuration:
AllCops:
DisplayCopNames:true
HamlLint/RuboCop
Option
Description
ignored_cops
Array of RuboCop cops to ignore.
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment).
-# example.haml
- name ='James Brown'
- unused_variable =42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml configuration:
AllCops:
DisplayCopNames:true
HamlLint/RuboCop
Option
Description
ignored_cops
Array of RuboCop cops to ignore.
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment).
-# example.haml
- name ='James Brown'
- unused_variable =42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml configuration: