fix(linter): fixes false positive on D018

closes #501
This commit is contained in:
Christopher Pickering 2023-01-04 09:03:24 -06:00
parent d43513a8e5
commit ebd099f011
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 10 additions and 1 deletions

View file

@ -136,7 +136,7 @@
flags: re.DOTALL|re.I
patterns:
- <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:|data:)[\w|/]+
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+
- <form\b[^>]*?(?:\saction)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+
- rule:
name: J018
message: (Jinja) Internal links should use the {{ url_for() ... }} pattern.

View file

@ -451,6 +451,15 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
assert result.exit_code == 0
# test data-actions
write_to_file(
tmp_file.name,
b"""<form action="{% url 'something' %}" data-action="xxx"></form>""",
)
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
assert "D018" not in result.output
def test_H019(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"<a href='javascript:abc()'>asdf</a>")