From 84a182595c2a9dc46cd7a461451ad13dd985915d Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Thu, 14 Oct 2021 13:37:21 +0300 Subject: [PATCH] fixed #110, added test --- src/djlint/lint.py | 1 - src/djlint/rules.yaml | 2 +- tests/test_linter.py | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/djlint/lint.py b/src/djlint/lint.py index fb90539..95ac45a 100644 --- a/src/djlint/lint.py +++ b/src/djlint/lint.py @@ -69,7 +69,6 @@ def lint_file(config: Config, this_file: Path) -> Dict: ), html, ): - if match.group(1) and not re.match( re.compile( fr"^/?{config.always_self_closing_html_tags}", re.I | re.X diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index c647659..922f9cf 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -184,7 +184,7 @@ message: Tag seems to be an orphan. flags: re.I|re.DOTALL patterns: - - <(/?(?:\w+)(?:\s?(?:(?:{%[^(?:%}]*?%})|(?:{{[^(?:}})]*?}})|[^<>])*[^/])?)> + - <(/?(?:\w+)\b(\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*)> - rule: name: H026 message: Emtpy id and class tags can be removed. diff --git a/tests/test_linter.py b/tests/test_linter.py index 93ac66d..8457693 100644 --- a/tests/test_linter.py +++ b/tests/test_linter.py @@ -397,6 +397,11 @@ def test_H025(runner: CliRunner, tmp_file: TextIO) -> None: assert "H025 1:" in result.output assert "H025 2:" not in result.output + # test tags inside attibutes + write_to_file(tmp_file.name, b'Foo') + result = runner.invoke(djlint, [tmp_file.name]) + assert "H025" not in result.output + def test_H026(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b'')