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] [Linter] Jinja2 comments are recognised as variables with extra whitespace #292

Closed
3 tasks done
jace opened this issue Jul 14, 2022 · 2 comments · Fixed by #296
Closed
3 tasks done

[BUG] [Linter] Jinja2 comments are recognised as variables with extra whitespace #292

jace opened this issue Jul 14, 2022 · 2 comments · Fixed by #296
Labels
🔍 linter 🦠 bug Something isn't working released

Comments

@jace
Copy link

jace commented Jul 14, 2022

System Info

  • OS: macOS 12.4
  • Python Version: 3.9.13
  • djLint Version 1.7.0
  • template language: jinja2

Issue

Jinja2 comments can be written as {# comment #} or {#- comment -#}, where the - is standard Jinja2 syntax for trimming whitespace. However, djLint flags {#- as a variable with extra whitespace. The closing -#} is accepted. Changing the opening to {# resolves the problem:

T001 27:3 Variables should be wrapped in a single whitespace. {#-
T001 30:3 Variables should be wrapped in a single whitespace. {#-
T001 499:23 Variables should be wrapped in a single whitespace. {#-

How To Reproduce

{#- This will be flagged -#}
{#- This will also be flagged #}
{# This is okay -#}
{# This is also okay. #}
@jace jace added 🔍 linter 🦠 bug Something isn't working labels Jul 14, 2022
@christopherpickering
Copy link
Contributor

Thanks, I'll put out a fix for this that will not flag {#-. Unfortunately it will not catch items without a space as this is one of the ignored block patterns.

christopherpickering pushed a commit that referenced this issue Jul 22, 2022
## [1.7.1](v1.7.0...v1.7.1) (2022-07-22)

### Bug Fixes

* **linter:** fix false positive on rule T001 ([f38328c](f38328c)), closes [#292](#292)
* **twig:** fixed indent issue with comments. Added test ([47ef81f](47ef81f)), closes [#290](#290)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 linter 🦠 bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants