Skip to content

Commit

Permalink
Clean up AltText linter
Browse files Browse the repository at this point in the history
There were a few Rubocop warnings to be fixed.

Change-Id: I1db6543a3b6149e44902360b72a9ccf1a5db6066
Reviewed-on: http://gerrit.causes.com/48347
Tested-by: jenkins <[email protected]>
Reviewed-by: Shane da Silva <[email protected]>
  • Loading branch information
sds committed Mar 28, 2015
1 parent fe37a4c commit 275fcab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
containing `if`/`else` blocks containing only HAML filters
* Add `MultilineScript` linter to report scripts with trailing operators that
should be merged with the following line
* Add `AltText` linter to report missing `alt` attributes on `img` tags

## 0.11.0

Expand Down
3 changes: 2 additions & 1 deletion lib/haml_lint/linter/alt_text.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module HamlLint
# Checks for missing `alt` attributes on `img` tags.
class Linter::AltText < Linter
include LinterRegistry

def visit_tag(node)
if node.tag_name == 'img' && !node.has_hash_attribute?(:alt)
add_lint(node, "`img` tags must include alt text.")
add_lint(node, '`img` tags must include alt text')
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/haml_lint/tree/tag_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def contains_script?
@value[:parse] && !@value[:value].strip.empty?
end

# Returns whether this tag has a specified attribute
# `=`).
# Returns whether this tag has a specified attribute.
#
# @return [true,false]
def has_hash_attribute?(attribute)
Expand Down

0 comments on commit 275fcab

Please sign in to comment.