Skip to content

Commit

Permalink
fix(linter): fixed false postive in alpinejs tags for H037
Browse files Browse the repository at this point in the history
thanks @danjac, @khink

closes #639
  • Loading branch information
christopherpickering committed May 11, 2023
1 parent cbf5796 commit 6520f63
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/rules.yaml
Expand Up @@ -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=[^>]*?>)
66 changes: 66 additions & 0 deletions tests/test_linter/test_h037.py
Expand Up @@ -67,6 +67,72 @@
([]),
id="repeating tags",
),
pytest.param(
(
'<img src="img.jpg" :src="isLoaded ? url : defaultValue" />\n'
'<tbody class="bg-white" x-data="{ open{{ item.history_id }}: false }" x-bind:class="open{{ item.history_id }} ? \'bg-gray-50\' : '
'">'
),
(
[
{
"code": "H006",
"line": "1:0",
"match": '<img src="img.jpg" :',
"message": "Img tag should have height and width attributes.",
},
{
"code": "H013",
"line": "1:0",
"match": '<img src="img.jpg" :',
"message": "Img tag should have an alt attribute.",
},
{
"code": "H025",
"line": "2:0",
"match": '<tbody class="bg-whi',
"message": "Tag seems to be an orphan.",
},
]
),
id="apline tags no match",
),
pytest.param(
(
'<img :src="img.jpg" :src="isLoaded ? url : defaultValue" />\n'
'<tbody x-bind:class="bg-white" x-data="{ open{{ item.history_id }}: false }" x-bind:class="open{{ item.history_id }} ? \'bg-gray-50\' : '
'">'
),
(
[
{
"code": "H006",
"line": "1:0",
"match": '<img :src="img.jpg" ',
"message": "Img tag should have height and width attributes.",
},
{
"code": "H013",
"line": "1:0",
"match": '<img :src="img.jpg" ',
"message": "Img tag should have an alt attribute.",
},
{
"code": "H025",
"line": "2:0",
"match": "<tbody x-bind:class=",
"message": "Tag seems to be an orphan.",
},
{
"code": "H037",
"line": "1:5",
"match": ":src",
"message": "Duplicate attribute found.",
},
]
),
id="apline tags match",
),
]


Expand Down

0 comments on commit 6520f63

Please sign in to comment.