mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-15 16:43:12 +00:00
added rule T027. closes #134
This commit is contained in:
parent
5eddca90fe
commit
c39693c7df
5 changed files with 32 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
next_release
|
||||
------------
|
||||
- Added rule T027 to check for unclosed in template syntax
|
||||
|
||||
0.5.9a
|
||||
------
|
||||
- Added test support for python 3.10
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ Codes
|
|||
+--------+-------------------------------------------------------------------------+
|
||||
| H026 | Emtpy id and class tags can be removed. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| T027 | Unclosed string found in template syntax. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
|
||||
|
||||
Adding Rules
|
||||
------------
|
||||
|
|
|
|||
|
|
@ -192,3 +192,10 @@
|
|||
patterns:
|
||||
- <\w+\b[^(?:{(?:%|{|#))>]*?\b(class|id)\b=(\"\"|'')
|
||||
- <\w+\b[^(?:{(?:%|{|#))>]*?\b(class|id)\b[^=\"]
|
||||
- rule:
|
||||
name: T027
|
||||
message: Unclosed string found in template syntax.
|
||||
flags: re.I
|
||||
patterns:
|
||||
- "{%(?:(?!'|\"|%}).)*((?:'|\")(?:(?!'|\"|%}).)*(?:'|\")(?:(?!'|\"|%}).)*)*(?:'|\")(?:(?!'|\"|%}).)*%}"
|
||||
- "{{(?:(?!'|\"|}}).)*((?:'|\")(?:(?!'|\"|}}).)*(?:'|\")(?:(?!'|\"|}}).)*)*(?:'|\")(?:(?!'|\"|}}).)*}}"
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ class Config:
|
|||
| {{-?\s*/\*\s*djlint\:off\s*\*/\s*-?}}.*?{{-?\s*/\*\s*djlint\:on\s*\*/\s*-?}}
|
||||
| <!--.*?-->
|
||||
| <\?php.*?\?>
|
||||
| {\%[ ]trans[ ][^}]*?\%}
|
||||
# | {\%[ ]trans[ ][^}]*?\%}
|
||||
| {%[ ]+?comment[ ]+?[^(?:%})]*?%}.*?{%[ ]+?endcomment[ ]+?%}
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
# for a single test
|
||||
|
||||
pytest tests/test_linter.py::test_output_order --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_linter.py::test_T027 --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -433,6 +433,22 @@ def test_H026(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert "H026" not in result.output
|
||||
|
||||
|
||||
def test_T027(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"{% blah 'asdf %}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 1
|
||||
assert "T027" in result.output
|
||||
|
||||
write_to_file(tmp_file.name, b"{% blah 'asdf' %}{{ blah \"asdf\" }}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "T027" not in result.output
|
||||
|
||||
write_to_file(tmp_file.name, b"{% blah 'asdf' 'blah %}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 1
|
||||
assert "T027" in result.output
|
||||
|
||||
|
||||
def test_rules_not_matched_in_ignored_block(
|
||||
runner: CliRunner, tmp_file: TextIO
|
||||
) -> None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue