Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

image_alt rule fails to find missing alt tag inside django block #72

Open
360cid opened this issue Mar 23, 2021 · 1 comment
Open

image_alt rule fails to find missing alt tag inside django block #72

360cid opened this issue Mar 23, 2021 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@360cid
Copy link

360cid commented Mar 23, 2021

Describe the bug

The image_alt rule does not seem to work inside Django template blocks. This seems very similar to #28, but since it's a different rule I wanted to open a separate ticket.

Which terms did you search for in the documentation and issue tracker?

Image_alt, image, alt tag, django

Environment

$ curlylint --version
curlylint, version 0.12.2

MacOS Catalina 10.15.7

Steps to reproduce

  1. Create the following template.html:
{% block content %}
    <img src="/path/static/image.png">
{% endblock %}
  1. Run curlylint with image_alt enabled:
curlylint --rule 'image_alt: true' template.html

Expected behavior

$ curlylint --rule 'image_alt: true' template.html
template.html
3:5	The `<img>` tag must have a `alt` attribute, either with meaningful text, or an empty string for decorative images	image_alt

Oh no! 💥 💔 💥
1 error reported

Actual behavior

$ curlylint --rule 'image_alt: true' template.html
All done! ✨ 🍰 ✨

The missing alt attribute is reported correctly when the img tag is moved out of the block.

@360cid 360cid added the bug Something isn't working label Mar 23, 2021
@thibaudcolas
Copy link
Owner

thibaudcolas commented Mar 24, 2021

Thank you @360cid, I wouldn’t be surprised if this was indeed the same issue as #28. Currently it’s not ideal that each rule implements its own parsing of the template’s AST, so it leads to issues like this.

If you want to help fixing this, the first step will be to add a test case for this in https://github.com/thibaudcolas/curlylint/blob/main/curlylint/rules/image_alt/image_alt_test.json.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants