mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
fix(linter): disabling linter rules should not disable formatting
closes #316
This commit is contained in:
parent
f0e9a02655
commit
69ef16afa8
3 changed files with 30 additions and 5 deletions
|
|
@ -355,8 +355,8 @@ class Config:
|
|||
| <\?php
|
||||
| <script
|
||||
| <!--
|
||||
| [^\{]{\#(?!\s*djlint\:\s*on)
|
||||
| ^{\#(?!\s*djlint\:\s*on)
|
||||
| [^\{]{\#(?!\s*djlint\:\s*(?:on|off))
|
||||
| ^{\#(?!\s*djlint\:\s*(?:on|off))
|
||||
| <pre
|
||||
| <textarea
|
||||
| {%[ ]*?blocktrans(?:late)?[^(?:%})]*?%}
|
||||
|
|
|
|||
7
tests/test_config/test_ignores/html_two.html
Normal file
7
tests/test_config/test_ignores/html_two.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{# djlint:off H021 #}
|
||||
<div>
|
||||
<div>
|
||||
{{ test }}
|
||||
</div>
|
||||
</div>
|
||||
{# djlint:on #}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
run::
|
||||
|
||||
pytest tests/test_config.py --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_config/test_ignores/test_config.py --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
for a single test, run::
|
||||
|
||||
pytest tests/test_config.py::test_custom_html --cov=src/djlint \
|
||||
pytest tests/test_config/test_ignores/test_config.py::test_custom_html --cov=src/djlint \
|
||||
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -20,6 +20,24 @@ from src.djlint import main as djlint
|
|||
|
||||
|
||||
def test_ignores(runner: CliRunner) -> None:
|
||||
result = runner.invoke(djlint, ["tests/test_config/test_ignores"])
|
||||
result = runner.invoke(djlint, ["tests/test_config/test_ignores/html.html"])
|
||||
assert """Linted 1 file, found 0 errors.""" in result.output
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_ignored_rule_does_not_disable_formatting(runner: CliRunner) -> None:
|
||||
result = runner.invoke(
|
||||
djlint, ["tests/test_config/test_ignores/html_two.html", "--check"]
|
||||
)
|
||||
print(result.output)
|
||||
assert (
|
||||
""" {# djlint:off H021 #}
|
||||
<div>
|
||||
-<div>
|
||||
-{{ test }}
|
||||
-</div>
|
||||
+ <div>{{ test }}</div>
|
||||
</div>
|
||||
{# djlint:on #}"""
|
||||
in result.output
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue