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] Linter fails with D018 on url parameter with name = "action" #755

Closed
3 tasks done
danigm opened this issue Sep 15, 2023 · 4 comments
Closed
3 tasks done
Labels
🔍 linter 🦠 bug Something isn't working released

Comments

@danigm
Copy link

danigm commented Sep 15, 2023

System Info

  • OS: openSUSE Tumbleweed (20230910)
  • Python Version (python --version): python 3.11.5
  • djLint Version (djlint --version): 1.32.1
  • template language: django

Issue

The Linter complains with an error D018 1:0 (Django) Internal links should use the {% url ... %} pattern. if a form has a django url with a parameter named "action".

How To Reproduce

Lint the following file:

  <form method="post" class="header-form" action="{% url "web:profile_action" action="token_revoke" %}">

Contents of .djlintrc/pyproject.toml [tool.djlint]

profile="django"
max_line_length = 120
@danigm danigm added 🔍 linter 🦠 bug Something isn't working labels Sep 15, 2023
@welcome
Copy link

welcome bot commented Sep 15, 2023

Thanks for opening your first issue here!

danigm added a commit to danigm/djLint that referenced this issue Sep 15, 2023
@danigm
Copy link
Author

danigm commented Sep 15, 2023

I've a branch adding this issue to the tests: danigm@016b7c9

I've been trying to improve the regex, but I think it's not easy to detect this condition with just a regular expression...

@christopherpickering
Copy link
Contributor

Thanks for those tests, I'll update the regex to make them pass. The regex is not foolproof, but will pass the tests, which is what we need :)

One day all the rules should be converted to python and use the template and attribute parser packages for finding things. Wish someone from ruff would do it 😀

christopherpickering pushed a commit that referenced this issue Sep 18, 2023
# [1.33.0](v1.32.1...v1.33.0) (2023-09-18)

### Bug Fixes

* **formatter:** fixed extra breaks added around html tags inside template tags ([6091ffb](6091ffb)), closes [#742](#742)
* **formatter:** fixed extra indend in script tags ([9d04d51](9d04d51)), closes [#733](#733)
* **formatter:** fixed formatting on functions that used python keywords as the param name ([183a7c0](183a7c0)), closes [#756](#756)
* **h033:** fix rull to not match data-action ([f6881e0](f6881e0))
* **linter:** fixed false positive on DJ018 ([78d81dc](78d81dc)), closes [#755](#755)

### Features

* **formatter:** added support for nunjucks async loop tags ([5a32bb3](5a32bb3))
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.33.0 🎉

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

No branches or pull requests

2 participants