fix(linter): fixed false positive on T032 with jinja multi line set

closes #342
This commit is contained in:
Christopher Pickering 2022-08-22 08:42:55 -05:00
parent af3eb04387
commit f9dac86b1a
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 20 additions and 2 deletions

View file

@ -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.

View file

@ -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(