mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-27 02:30:27 +00:00
parent
e906b3e30a
commit
f63cc4d8ea
2 changed files with 13 additions and 4 deletions
|
|
@ -133,14 +133,14 @@
|
|||
message: (Django) Internal links should use the {% url ... %} pattern.
|
||||
flags: re.DOTALL|re.I
|
||||
patterns:
|
||||
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- rule:
|
||||
name: J018
|
||||
message: (Jinja) Internal links should use the {{ url_for() ... }} pattern.
|
||||
flags: re.DOTALL|re.I
|
||||
patterns:
|
||||
- <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
|
||||
- rule:
|
||||
name: H019
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ run::
|
|||
|
||||
# for a single test
|
||||
|
||||
pytest tests/test_linter.py::test_H021 --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
pytest tests/test_linter/test_linter.py::test_DJ018
|
||||
|
||||
"""
|
||||
# pylint: disable=C0116,C0103
|
||||
|
|
@ -296,6 +295,16 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
|
||||
# test attribute names
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b'<div data-row-selection-action="highlight"></div>',
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_H019(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"<a href='javascript:abc()'>asdf</a>")
|
||||
|
|
|
|||
Loading…
Reference in a new issue