Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bug(H006): not possible to ignore if use HTML comment syntax or ignoring comments inside a tag #344

Closed
3 tasks done
Kristinita opened this issue Aug 20, 2022 · 6 comments
Closed
3 tasks done
Labels

Comments

@Kristinita
Copy link

#333 — possibly related issue

1. Summary

I can’t ignore H006 error if:

  1. I use <!-- HTML comments syntax -->.
  2. Or if my ignoring comments inside a tag.

2. MCVE

2.1. Files to check

Content of my KiraH006 folder:

  1. KiraDJLint__Ignore-specific-by-HTML-comments--H006.html:

    <!-- djlint:off T027,H017,H006 -->
    
    {% if "<img alt=\"" in kira_article %}
    	<script src="KiraJS.js" defer></script>
    {% endif %}
    
    <!-- djlint:on -->
    
  2. KiraDJLint__Ignore-all-by-HTML-comments--H006.html:

    <!-- djlint:off -->
    
    {% if "<img alt=\"" in kira_article %}
    	<script src="KiraJS.js" defer></script>
    {% endif %}
    
    <!-- djlint:on -->
    
  3. KiraDJLint__Ignore-H006-inside-div--H006.html:

    <div>
    
    		{# djlint:off H006 #}
    
    		<img src="{{ kira_variable }}.webp" alt="Kira Goddess!" />
    
    		{# djlint:on #}
    
    </div>
    
  4. KiraDJLint__Ignore-all-inside-div--H006.html:

    <div>
    
    		{# djlint:off #}
    
    		<img src="{{ kira_variable }}.webp" alt="Kira Goddess!" />
    
    		{# djlint:on #}
    
    </div>
    

2.2. Desired behavior

No errors

2.3. Current behavior

D:\SashaDebugging\KiraDJLintDebuging>djlint --profile=jinja --lint KiraH006

Linting 4/4 files ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00


SashaDebugging\KiraDJLintDebuging\KiraH006\KiraDJLint__Ignore-H006-inside-div--H006.html
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── H006 5:2 Img tag should have height and width attributes. <img src="{{ kira_va

SashaDebugging\KiraDJLintDebuging\KiraH006\KiraDJLint__Ignore-all-by-HTML-comments--H006.html
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── H006 3:7 Img tag should have height and width attributes. <img alt=\"" in kira

SashaDebugging\KiraDJLintDebuging\KiraH006\KiraDJLint__Ignore-all-inside-div--H006.html
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── H006 5:2 Img tag should have height and width attributes. <img src="{{ kira_va

SashaDebugging\KiraDJLintDebuging\KiraH006\KiraDJLint__Ignore-specific-by-HTML-comments--H006.html
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── H006 3:7 Img tag should have height and width attributes. <img alt=\"" in kira

Linted 4 files, found 4 errors.

3. Environment

  1. Microsoft Windows [Version 10.0.19041.1415]
  2. Python 3.10.6
  3. djlint, version 1.11.0
  4. Template language — Jinja

4. Checkbox

  1. I’m on the latest version of djLint
  2. I’ve searched the issues
  3. I’ve read the docs

Thanks.

@christopherpickering
Copy link
Contributor

@Kristinita Thanks, I can't get this to reproduce. I tested with Windows 10, Python 3.10, and djlint 1.11.1. I also try with ubuntu + python3.8 + djlint 3.11.1 and osx with py 3.9 + djlint 1.11.1.

@aleprovencio

Can either of you help with more debugging?

Specifically, I'm interesting in what is going on in lint.py on lines 124 when the inside_ignored_rule is called.

On line 122 can you add print(inside_ignored_rule(config, html, match,rule["name"])) ?

In helpers.py on line 143 can you add print(rule_regex) and try to find which regex is not matching but should be? From the examples in this issue, it sounds like none of them are matching..

Thanks!

@Kristinita
Copy link
Author

Status: Partially fixed 🌔

1. Summary

@christopherpickering , for djLint 1.11.1 I can’t reproduce problems in examples 1, 2 and 4. Thanks!

But I still get H006 error for the example 3 on my machine.

2. Circle CI Ubuntu testing

I reproduce the problem on the Circle CI Ubuntu.

2.1. Configuration

You can see this configuration on the KiraDJLintH006 branch of my demo/debugging repository.

  • config.yml

     version: 2.1
    
     jobs:
       build:
         machine:
           image: ubuntu-2204:current
         steps:
         - checkout
         - run: pyenv global 3.10.5
         - run: pip install djlint
         - run: djlint --profile=jinja KiraDJLint__Ignore-H006-inside-div--H006.html
    

2.2. Build

Build, result of executing djLint command:

djlint --profile=jinja KiraDJLint__Ignore-H006-inside-div--H006.html

100% 1/1 [00:00<?, ?it/s]


KiraDJLint__Ignore-H006-inside-div--H006.html

H006 5:2 Img tag should have height and width attributes. <img src="{{ kira_va

Linted 1 file, found 1 error.

2.3. Environment

  1. Ubuntu 22.04 (Jammy Jellyfish)
  2. Python 3.10.5
  3. djLint 1.1.1

Thanks.

@christopherpickering
Copy link
Contributor

Thanks! I was able to reproduce it in ubuntu docker + py 3.10.. so I switched back on the Mac and tested out w/ py.3.10 there and was able to reproduce it as well.. Must be something different in how 3.10 works. I will check it out!

@christopherpickering
Copy link
Contributor

But on more testing, I'm able to reproduce in py 3.9 now :D Something must have changed when I copy/paste yesterday.

christopherpickering pushed a commit that referenced this issue Aug 24, 2022
# [1.12.0](v1.11.1...v1.12.0) (2022-08-24)

### Bug Fixes

* **h006:** prevented false positives on H006 ([215bd23](215bd23)), closes [#344](#344) [#333](#333)
* **h012:** prevent H012 from matching the contents of tags or attributes ([4480cff](4480cff)), closes [#348](#348)
* **t001:** fixed false positive on multiline template tags ([ea76672](ea76672)), closes [#350](#350)

### Features

* **h021:** allow inline styles that contain template syntax ([f1a39ed](f1a39ed)), closes [#351](#351)
* **t002:** allow variables names to be used in the {% extends tag ([a5d96e7](a5d96e7)), closes [#349](#349)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Kristinita
Copy link
Author

Status: FIXED ✔️ for me for djLint 1.12.0. Also, fixed on Circle CI Ubuntu.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants