diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index 79035659..8f40b0d9 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -276,4 +276,4 @@ message: Duplicate attribute found. flags: re.I patterns: - - <\w[^>]*?\s\K([a-z][a-z-]*?)(?==[^>]+?\1=[^>]*?>) + - <\w[^>]*?\s\K([a-z-][a-z-]*?)(?==[^>]+?[^-]\1=[^>]*?>) diff --git a/tests/test_linter/test_django_linter.py b/tests/test_linter/test_django_linter.py index ce083a1b..17946246 100644 --- a/tests/test_linter/test_django_linter.py +++ b/tests/test_linter/test_django_linter.py @@ -276,16 +276,7 @@ ), pytest.param( ('
'), - ( - [ - { - "code": "H037", - "line": "1:6", - "match": "action", - "message": "Duplicate attribute found.", - } - ] - ), + ([]), id="DJ018_data_action", ), pytest.param( diff --git a/tests/test_linter/test_h037.py b/tests/test_linter/test_h037.py index c6ae2db7..3ccb33f6 100644 --- a/tests/test_linter/test_h037.py +++ b/tests/test_linter/test_h037.py @@ -41,6 +41,25 @@ ([]), id="mismatch names", ), + pytest.param( + (''), + ( + [ + { + "code": "H037", + "line": "1:5", + "match": "-width", + "message": "Duplicate attribute found.", + } + ] + ), + id="leading hyphen names", + ), + pytest.param( + (''), + ([]), + id="mismatch hyphen names", + ), pytest.param( ( ''