mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
fix(linter): t002
Fixed bad match on t002.
This commit is contained in:
parent
223200fe57
commit
190ad01ff3
2 changed files with 12 additions and 3 deletions
|
|
@ -26,7 +26,7 @@
|
|||
message: Double quotes should be used in tags.
|
||||
flags: re.DOTALL
|
||||
patterns:
|
||||
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)?[ \t]+?(?:[^']+?=)?'[^']*'"
|
||||
- "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)?[ \t]+?(?:[^']+?=)?'[^']*?'(?:(?!%}).)*?%}"
|
||||
- rule:
|
||||
name: T003
|
||||
message: 'Endblock should have name. Ex: {% endblock body %}.'
|
||||
|
|
@ -203,12 +203,12 @@
|
|||
# for single quotes
|
||||
- "{%((?:(?!'|%}).)*?(')(?:(?!\\2|%}).)*?\\2(?:(?!\\2|%}).)*?)*\\2(?:(?!\\2|%}).)*?%}"
|
||||
# for double quotes
|
||||
- "{%((?:(?!\"|%}).)*?(\")(?:(?!\\2|%}).)*?\\2(?:(?!\\2|%}).)*?)*\\2(?:(?!\\2|%}).)*?%}"
|
||||
- '{%((?:(?!"|%}).)*?(")(?:(?!\2|%}).)*?\2(?:(?!\2|%}).)*?)*\2(?:(?!\2|%}).)*?%}'
|
||||
|
||||
# for single quotes
|
||||
- "{{((?:(?!'|}}).)*?(')(?:(?!\\2|}}).)*?\\2(?:(?!\\2|}}).)*?)*\\2(?:(?!\\2|}}).)*?}}"
|
||||
# for double quotes
|
||||
- "{{((?:(?!\"|}}).)*?(\")(?:(?!\\2|}}).)*?\\2(?:(?!\\2|}}).)*?)*\\2(?:(?!\\2|}}).)*?}}"
|
||||
- '{{((?:(?!"|}}).)*?(")(?:(?!\2|}}).)*?\2(?:(?!\2|}}).)*?)*\2(?:(?!\2|}}).)*?}}'
|
||||
|
||||
# for tags with a single quote
|
||||
- "{%((?:(?!'|\"|%}).)*?('|\")(?:(?!\\2|%}).)*?)%}"
|
||||
|
|
|
|||
|
|
@ -104,6 +104,15 @@ def test_T002(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert result.exit_code == 1
|
||||
assert "T002" in result.output
|
||||
|
||||
# verify regex doesn't over grab
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"""{% extends "layout.h" %}
|
||||
<div class="card" data-list='{"name": "blah"}'>""",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"])
|
||||
assert "T002" not in result.output
|
||||
|
||||
|
||||
def test_T003(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"{% endblock %}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue