Skip to content

Commit

Permalink
fix(linter): fixed false positive on H037
Browse files Browse the repository at this point in the history
thanks @kai687

closes #633
  • Loading branch information
christopherpickering committed May 10, 2023
1 parent 5cf1e1c commit e65558c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
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=[^>]*?>)
11 changes: 1 addition & 10 deletions tests/test_linter/test_django_linter.py
Expand Up @@ -276,16 +276,7 @@
),
pytest.param(
('<form action="{% url \'something\' %}" data-action="xxx"></form>'),
(
[
{
"code": "H037",
"line": "1:6",
"match": "action",
"message": "Duplicate attribute found.",
}
]
),
([]),
id="DJ018_data_action",
),
pytest.param(
Expand Down
19 changes: 19 additions & 0 deletions tests/test_linter/test_h037.py
Expand Up @@ -41,6 +41,25 @@
([]),
id="mismatch names",
),
pytest.param(
('<svg -width="16" -width="2"></svg>'),
(
[
{
"code": "H037",
"line": "1:5",
"match": "-width",
"message": "Duplicate attribute found.",
}
]
),
id="leading hyphen names",
),
pytest.param(
('<svg width="16" stroke-width="2"></svg>'),
([]),
id="mismatch hyphen names",
),
pytest.param(
(
'<a href="" ></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a>'
Expand Down

0 comments on commit e65558c

Please sign in to comment.