mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-21 13:44:42 +00:00
fixes #143, added test
This commit is contained in:
parent
3af4517ce7
commit
d2a42f2be0
2 changed files with 9 additions and 1 deletions
|
|
@ -206,6 +206,8 @@
|
|||
- rule:
|
||||
name: T028
|
||||
message: Consider using spaceless tags inside attribute values. {%- if/for -%}
|
||||
exclude:
|
||||
- django
|
||||
patterns:
|
||||
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?({%)[^-])\s*?(?:if|for|else|end)
|
||||
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?{%(?:(?!%}).)*(?:if|else|for|end)(?:(?!%}).)*[^-](%}))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
# for a single test
|
||||
|
||||
pytest tests/test_linter.py::test_H017 --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_linter.py::test_T028 --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -476,6 +476,12 @@ def test_T028(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert result.exit_code == 1
|
||||
assert "T028" in result.output
|
||||
|
||||
# django should not trigger
|
||||
write_to_file(tmp_file.name, b"<a href=\"{%- if 'asdf' %}\">")
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert result.exit_code == 1
|
||||
assert "T028" not in result.output
|
||||
|
||||
write_to_file(tmp_file.name, b"<a href=\"{{- blah 'asdf' }}\">")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "T028" not in result.output
|
||||
|
|
|
|||
Loading…
Reference in a new issue