From b7e456a9473548ae52ecaa69a03fb8c7b5a6a363 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Wed, 6 Oct 2021 08:43:06 +0200 Subject: [PATCH] added rule H020. closes #64 --- docs/djlint/changelog.rst | 4 ++++ docs/djlint/rules.rst | 2 ++ src/djlint/rules.yaml | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/docs/djlint/changelog.rst b/docs/djlint/changelog.rst index c0ba0b1..67d0fde 100644 --- a/docs/djlint/changelog.rst +++ b/docs/djlint/changelog.rst @@ -1,6 +1,10 @@ Changelog ========= +Next Release +------------ +- Added rule H020 to find empty tag pairs + 0.5.3 ----- - Change stdout for ``--reformat/check`` options to only print new html when using stdin as the input diff --git a/docs/djlint/rules.rst b/docs/djlint/rules.rst index 698f7f7..7643f4e 100644 --- a/docs/djlint/rules.rst +++ b/docs/djlint/rules.rst @@ -49,6 +49,8 @@ Codes +--------+-------------------------------------------------------------------------+ | H019 | Replace 'javascript:abc()' with on_ event and real url. | +--------+-------------------------------------------------------------------------+ +| H020 | Empty tag pair found. Consider removing. | ++--------+-------------------------------------------------------------------------+ Adding Rules ------------ diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index dabcaf5..569c44d 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -269,3 +269,9 @@ patterns: - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url)=[\"|']javascript:[\w|/]+ - ]*?(?:action)=[\"|']javascript:[\w|/]+ +- rule: + name: H020 + message: Empty tag pair found. Consider removing. + flags: re.DOTALL|re.I + patterns: + - <(\w+)\s*?>\s*?<\/\1>