Skip to content

Commit

Permalink
fix(linter): fixed golang false positive on T027
Browse files Browse the repository at this point in the history
closes #712
  • Loading branch information
christopherpickering committed Jul 17, 2023
1 parent a25cf0c commit 232f4bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/djlint/settings.py
Expand Up @@ -789,6 +789,8 @@ def __init__(
| {{!--\s*djlint\:off\s*--}}(?:(?!{{!--\s*djlint\:on\s*--}}).)*
# golang
| {{-?\s*/\*\s*djlint\:off\s*\*/\s*-?}}(?:(?!{{-?\s*/\*\s*djlint\:on\s*\*/\s*-?}}).)*
# inline golang comments
| {{-?\s*/\*(?!\s*djlint\:\s*(?:off|on)).*?\*/\s*-?}}
| <!--.*?-->
| <\?php.*?\?>
| {%[ ]*?blocktranslate\b(?:(?!%}|\btrimmed\b).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
Expand All @@ -810,6 +812,8 @@ def __init__(
| {{!--\s*djlint\:off\s*--}}.*?(?={{!--\s*djlint\:on\s*--}})
# golang
| {{-?\s*/\*\s*djlint\:off\s*\*/\s*-?}}.*?(?={{-?\s*/\*\s*djlint\:on\s*\*/\s*-?}})
# inline golang comments
| {{-?\s*/\*(?!\s*djlint\:\s*(?:off|on)).*?\*/\s*-?}}
| <!--.*?-->
| <\?php.*?\?>
| {%[ ]*?blocktranslate\b(?:(?!%}|\btrimmed\b).)*?%}.*?{%[ ]*?endblocktranslate[ ]*?%}
Expand Down
9 changes: 6 additions & 3 deletions tests/test_linter/test_django_linter.py
Expand Up @@ -318,9 +318,12 @@
id="T027_trans",
),
pytest.param(
(
"{% macro rendersubmit(buttons=[], class=\"\", index='', url='', that=\"\" , test='') -%}"
),
('{% trans "Check box if you\'re interested in this location." %}'),
([]),
id="T027_golang comment",
),
pytest.param(
("{{/* can't */}}"),
([]),
id="T027_mixed_quotes",
),
Expand Down

0 comments on commit 232f4bc

Please sign in to comment.