mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-03 22:20:29 +00:00
parent
c709efd658
commit
f38328c829
4 changed files with 14 additions and 5 deletions
|
|
@ -112,7 +112,6 @@ def lint_file(config: Config, this_file: Path) -> Dict:
|
|||
}
|
||||
)
|
||||
else:
|
||||
|
||||
for match in re.finditer(
|
||||
re.compile(
|
||||
pattern, flags=build_flags(rule.get("flags", "re.DOTALL"))
|
||||
|
|
|
|||
|
|
@ -11,14 +11,15 @@
|
|||
- '{%-[^\s]+'
|
||||
- '{%[^\s|\-]+'
|
||||
# handlebars
|
||||
- '[^{]{#[^\s]+|^{#[^\s]+'
|
||||
- '[^{]{#[^\s-]+|^{#[^\s-]+'
|
||||
- '[^{]{#-[^\s]+|^{#-[^\s]+'
|
||||
- '[^{]{\/[^\s]+|^{\/[^\s]+'
|
||||
- '[^{]{\@[^\s]+|^{\@[^\s]+'
|
||||
# close
|
||||
- '[^(\s|^|\-)]+[}|%|#]}'
|
||||
- '[^(\s|^)]+\-[}|%|#]}'
|
||||
- \s{2,}[}|%|#]}
|
||||
- '{[{|%|#]\s{2,}'
|
||||
- '{[{|%|#]-?\s{2,}'
|
||||
- rule:
|
||||
name: T002
|
||||
message: Double quotes should be used in tags.
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ class Config:
|
|||
| {\#\s*djlint\:\s*off\s*\#}.*?(?={\#\s*djlint\:\s*on\s*\#})
|
||||
| {%\s*comment\s*%\}\s*djlint\:off\s*\{%\s*endcomment\s*%\}.*?(?={%\s*comment\s*%\}\s*djlint\:on\s*\{%\s*endcomment\s*%\})
|
||||
# inline jinja comments
|
||||
| {\#(?!\s*djlint\:\s*(?:off|on)).*?\#}
|
||||
# | {\#(?!\s*djlint\:\s*(?:off|on)).*?\#}
|
||||
# handlebars
|
||||
| {{!--\s*djlint\:off\s*--}}.*?(?={{!--\s*djlint\:on\s*--}})
|
||||
# golang
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
# for a single test
|
||||
|
||||
pytest tests/test_linter/test_linter.py::test_DJ018
|
||||
pytest tests/test_linter/test_linter.py::test_T001
|
||||
|
||||
"""
|
||||
# pylint: disable=C0116,C0103
|
||||
|
|
@ -41,6 +41,15 @@ def test_T001(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "nunjucks"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
# this test will pass, because the jinja comment is an ignored block
|
||||
write_to_file(tmp_file.name, b"{#-test -#}")
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
write_to_file(tmp_file.name, b"{#- test -#}")
|
||||
result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_T002(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"{% extends 'this' %}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue