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

[FEATURE] Add option to ignore lint errors in the html #113

Closed
christopherpickering opened this issue Oct 13, 2021 · 8 comments
Closed

[FEATURE] Add option to ignore lint errors in the html #113

christopherpickering opened this issue Oct 13, 2021 · 8 comments
Assignees
Labels
released 🚂 enhancement New feature or request

Comments

@christopherpickering
Copy link
Contributor

for example, maybe I need an inline style:

<div style="width:{{ x * 3}}px"></div>

can I ignore the H021 code with something like this?

{% djlint:ignore=H021 %}
<div style="width:{{ x * 3}}px"></div>
@christopherpickering christopherpickering added the 🚂 enhancement New feature or request label Oct 13, 2021
@christopherpickering christopherpickering self-assigned this Oct 13, 2021
@jayvdb
Copy link
Contributor

jayvdb commented Oct 15, 2021

Would {% djlint:ignore=H021 %} be followed with another bit of syntax to reset the ignore list - i.e. is this issue about ignoring specific codes for a small line range, or just the next line. ESLint has a 'eslint-disable-next-line' which auto-resets after a "line".

@carlotm
Copy link

carlotm commented Nov 4, 2021

Thank you for this amazing project, I was looking for something like this for years :)
I am lurking on this, as it is biting me.

What about this syntax:

{% djlint ignore=H021 ignore=H006 ... %}
   ...
{% enddjlint %}

TBH I am not sure if templatetags can be variadic though.

Again, kudos for this project!

@sr-verde
Copy link

sr-verde commented Jul 5, 2022

It would be wonderful to if djlint would support this. I have a Flask project that uses templates for frontend and email. And of course, I don't want to apply all rules to the email templates. Currently, I just ignore all email templates. But that is a bad solution.

@christopherpickering
Copy link
Contributor Author

christopherpickering commented Jul 5, 2022

Thanks! I think I will expand the current syntax for ignoring.

So to ignore just H025 (and H026 in the first example):

{# djlint:off H025,H026 #}
<p>
{# djlint:on #}

<!-- djlint:off H025-->
<p>
<!-- djlint:on -->

{% comment %} djlint:off H025 {% endcomment %}
<p>
{% comment %} djlint:on {% endcomment %}

{{!-- djlint:off H025 --}}
<p>
{{!-- djlint:on --}}

{{ /* djlint:off H025 */ }}
<p>
{{ /* djlint:on */ }}

christopherpickering pushed a commit that referenced this issue Jul 5, 2022
# [1.4.0](v1.3.0...v1.4.0) (2022-07-05)

### Features

* **ignore rules:** added option to ignore linter rules with inline comments ([1b3159f](1b3159f)), closes [#113](#113)
@christopherpickering
Copy link
Contributor Author

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@sr-verde
Copy link

sr-verde commented Jul 6, 2022

Wow, that was pretty fast now. Thank you!

@marty0678
Copy link

Thanks for this! I'm using 1.19.15 and the specific linting rules do not seem to be applying. For example:

            {% comment %} djlint:off H025 {% endcomment %}
            <h1 style="margin: 0">
                Welcome to My Website
            </h1>
            {% comment %} djlint:on {% endcomment %}

Turns off all rule linting for this code block, where I would expect the H021 error to still be shown. Am I doing something wrong? If not I can open a bug.

Thank you!

@christopherpickering
Copy link
Contributor Author

hey @marty0678 do you mind opening a new issue? Thanks!

@marty0678 marty0678 mentioned this issue Feb 26, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released 🚂 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants