From a9b2b1cf86c6d985337e23566b8de98e10c60fa4 Mon Sep 17 00:00:00 2001 From: AJ Livingston Date: Wed, 6 Jul 2022 13:35:53 -0400 Subject: [PATCH 1/2] Update H026 regex to ignore hyphens before and after class/id Avoids matching
]*?\b(class|id)\b=(\"\"|'') - - <\w+\b[^(?:{(?:%|{|#))>]*?\b(class|id)\b[^=\"] + - <\w+\b[^(?:{(?:%|{|#))>-]*?\b(class|id)\b[^=\"-] - rule: name: T027 message: Unclosed string found in template syntax. From 611b1fa57a130ac9cb7153c85df4f0eaabff8503 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Wed, 6 Jul 2022 12:50:15 -0500 Subject: [PATCH 2/2] fix(h026): fixes rule H026 for cases where id/class are part of another string closes #281 --- tests/test_linter/test_linter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_linter/test_linter.py b/tests/test_linter/test_linter.py index f02412b..2ed0e47 100644 --- a/tests/test_linter/test_linter.py +++ b/tests/test_linter/test_linter.py @@ -549,6 +549,10 @@ def test_H026(runner: CliRunner, tmp_file: TextIO) -> None: assert result.exit_code == 0 assert "H026" not in result.output + write_to_file(tmp_file.name, b"
") + result = runner.invoke(djlint, [tmp_file.name]) + assert "H026" not in result.output + def test_T027(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b"{% blah 'asdf %}")