Skip to content

Commit

Permalink
fix(linter): fixed false positive on T032 with jinja multi line set
Browse files Browse the repository at this point in the history
closes #342
  • Loading branch information
christopherpickering committed Aug 22, 2022
1 parent af3eb04 commit f9dac86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/djlint/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@
name: T032
message: Extra whitespace found in template tags.
patterns:
- "{%(([\"|'](?:(?!'|\"|%}).)*?[\"|'])|[^(?:%}|'|\")])*?\\s{2,}"
- "{{(([\"|'](?:(?!'|\"|}}).)*?[\"|'])|[^(?:}}|'|\")])*?\\s{2,}"
- "{%(([\"|'](?:(?!'|\"|%}).)*?[\"|'])|[^(?:%}|'|\"|\n)])*?[ \t]{2,}"
- "{{(([\"|'](?:(?!'|\"|}}).)*?[\"|'])|[^(?:}}|'|\"|\n)])*?[ \t]{2,}"
- rule:
name: H033
message: Extra whitespace found in form action.
Expand Down
18 changes: 18 additions & 0 deletions tests/test_linter/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,24 @@ def test_T032(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
assert "T032" not in result.output

write_to_file(
tmp_file.name,
b"""{# [INFO] Simple example #}
{% set kira = [
'Goddess', 'Genius'
] %}
{# [INFO] Real example #}
{% set kira_online_scaners = [
('https://quttera.com/sitescan/', 'SashaButtonLightSkyBlue', 'Quttera'),
('https://sitecheck.sucuri.net/results/', 'SashaButtonLimeGreen', 'Sucuri'),
('https://www.isithacked.com/check/', 'SashaButtonPlum', 'Is It Hacked?'),
] %}
""",
)
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
assert "T032" not in result.output


def test_H033(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(
Expand Down

0 comments on commit f9dac86

Please sign in to comment.