Skip to content

Commit

Permalink
fix(t002): fixed false positive in t002. Added test
Browse files Browse the repository at this point in the history
closes #399
  • Loading branch information
christopherpickering committed Sep 21, 2022
1 parent 90f023d commit e23ee46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/rules.yaml
Expand Up @@ -26,7 +26,7 @@
message: Double quotes should be used in tags.
flags: re.DOTALL
patterns:
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)?[ \t]+?(?:[^']+?=)?'[^']*?'(?:(?!%}).)*?%}"
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)[\\s]+?(?:[^']+?=)?'[^']*?'(?:(?!%}).)*?%}"
- rule:
name: T003
message: 'Endblock should have name. Ex: {% endblock body %}.'
Expand Down
11 changes: 11 additions & 0 deletions tests/test_linter/test_linter.py
Expand Up @@ -113,6 +113,17 @@ 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 regex doesn't match other stuff
write_to_file(
tmp_file.name,
b"""{% if form.action_url %}
='stuff'
{% endif %}
""",
)
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
assert "T002" not in result.output


def test_T003(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"{% endblock %}")
Expand Down

0 comments on commit e23ee46

Please sign in to comment.