mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
parent
228a3809e1
commit
67e8c64762
2 changed files with 15 additions and 3 deletions
|
|
@ -26,7 +26,7 @@
|
|||
message: Double quotes should be used in tags.
|
||||
flags: re.DOTALL
|
||||
patterns:
|
||||
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)[\\s]+?(?:[^']+?=)?'[^']*?'(?:(?!%}).)*?%}"
|
||||
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)[\\s]+?(?:(?:(?!%}|').)+?=)?'(?:(?!%}|').)*?'(?:(?!%}).)*?%}"
|
||||
- rule:
|
||||
name: T003
|
||||
message: 'Endblock should have name. Ex: {% endblock body %}.'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ run::
|
|||
pytest tests/test_linter/test_linter.py::test_T034
|
||||
|
||||
"""
|
||||
# pylint: disable=C0116,C0103
|
||||
# pylint: disable=C0116,C0103,C0302
|
||||
|
||||
from typing import TextIO
|
||||
|
||||
|
|
@ -108,7 +108,9 @@ def test_T002(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"""{% extends "layout.h" %}
|
||||
<div class="card" data-list='{"name": "blah"}'>""",
|
||||
<div class="card" data-list='{"name": "blah"}'>
|
||||
{% include "template.html" %}
|
||||
<div {% fpr %} data-{{ name }}='{{ value }}'{% endfor %}/>""",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert "T002" not in result.output
|
||||
|
|
@ -124,6 +126,16 @@ def test_T002(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert "T002" not in result.output
|
||||
|
||||
# verify correct line is returned
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"""{% include "template.html" %}
|
||||
{% include "template.html" with type='mono' %}""",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert result.exit_code == 1
|
||||
assert "T002 2:" in result.output
|
||||
|
||||
|
||||
def test_T003(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"{% endblock %}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue