closes #89. added tests

This commit is contained in:
Christopher Pickering 2021-10-11 13:34:28 +03:00
parent edcf3506aa
commit d634ce61fa
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 8 additions and 2 deletions

View file

@ -190,4 +190,5 @@
message: Emtpy id and class tags can be removed.
flags: re.I
patterns:
- <(?:\w+)(?:\s(?:(?:{%[^(?:%})]*?%})|(?:{{[^(?:}})]*?}})|[^<>])*)(id|class)(?:(?:=(?:\"{2})|(?:'{2}))|\s)
- <\w+\b[^(?:{(?:%|{|#))>]*?\b(class|id)\b=(\"\"|'')
- <\w+\b[^(?:{(?:%|{|#))>]*?\b(class|id)\b[^=]

View file

@ -7,7 +7,7 @@ run::
# for a single test
pytest tests/test_linter.py::test_H025 --cov=src/djlint --cov-branch \
pytest tests/test_linter.py::test_H026 --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
"""
@ -396,6 +396,11 @@ def test_H026(runner: CliRunner, tmp_file: TextIO) -> None:
assert result.exit_code == 1
assert "H026" in result.output
write_to_file(tmp_file.name, b'<asdf {% class="" %}></asdf>')
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 0
assert "H026" not in result.output
def test_rules_not_matched_in_ignored_block(
runner: CliRunner, tmp_file: TextIO