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

Invalid test usage in Jinja2 isn't caught by linter #153

Open
miketheman opened this issue Apr 20, 2023 · 0 comments
Open

Invalid test usage in Jinja2 isn't caught by linter #153

miketheman opened this issue Apr 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@miketheman
Copy link

Describe the bug

When writing a Jinja2 template, using the expression if foo is None: does not trigger a linter error, so we only find out about it during runtime, aka TemplateRuntimeError

Ref: https://jinja.palletsprojects.com/en/3.1.x/api/#jinja2.TemplateRuntimeError

Writing Python, it's common to use the if foo is None: syntax, and sadly curlylint didn't catch this before I deployed to prd and learned the hard way.

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

is None

Environment

curlylint 0.13.1, running in either macOS or Linux.
I don't know if prior versions detected this, as it's new code we wrote and linted with the current version.

Steps to reproduce

  1. First, create an HTML template with the following content:
{% if foo is None: %}
foo is None!
{% endif %}
  1. Then, run curlylint against that file

Expected behavior

I would have expected that the linter would fail, and hopefully suggest that I use the valid lowercase none is the right way to use this comparison.

Actual behavior

Passes with no errors:

$ curlylint broken.html
All done! ✨ 🍰 ✨

Reproducible demo

See steps above for file content that demonstrates issue.

Other

I found this while using None, but the same would apply for True and False.

Some links:

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

No branches or pull requests

1 participant