mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-22 03:41:51 +00:00
fixed #169, added test
This commit is contained in:
parent
fff0d5921d
commit
905923ba2b
4 changed files with 14 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ const slugifyCustom = (s) =>
|
|||
async function imageShortcode(src, alt, sizes, type='asdf', loading="lazy", decoding="async") {
|
||||
let metadata = await Image(src, {
|
||||
widths: [24, 300, 400, 500, 600, 800, 1200],
|
||||
formats: ["webp"],
|
||||
formats: ["webp", "png"],
|
||||
sharpWebpOptions: {
|
||||
options: {
|
||||
quality:70
|
||||
|
|
|
|||
|
|
@ -80,10 +80,7 @@ def lint_file(config: Config, this_file: Path) -> Dict:
|
|||
open_tags.insert(0, match)
|
||||
else:
|
||||
for i, tag in enumerate(copy.deepcopy(open_tags)):
|
||||
if (
|
||||
re.split(r"\s+", tag.group(1))[0]
|
||||
== match.group(2)[1:]
|
||||
):
|
||||
if tag.group(3) == match.group(2)[1:]:
|
||||
open_tags.pop(i)
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@
|
|||
message: Tag seems to be an orphan.
|
||||
flags: re.I|re.DOTALL
|
||||
patterns:
|
||||
- <((/?\w+)\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|[^'\">{}])*)(?<!/)>
|
||||
- <((/?(\w+))\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|[^'\">{}])*)(?<!/)>
|
||||
- rule:
|
||||
name: H026
|
||||
message: Emtpy id and class tags can be removed.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
# for a single test
|
||||
|
||||
pytest tests/test_linter.py::test_output_for_no_linebreaks --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_linter.py::test_H025 --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -484,6 +484,16 @@ def test_H025(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "H025" not in result.output
|
||||
|
||||
# fix issue #169
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"""<li{% if is_active %} class="active" {% endif %}>
|
||||
some content
|
||||
</li>""",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "H025" not in result.output
|
||||
|
||||
|
||||
def test_H026(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b'<asdf id="" >')
|
||||
|
|
|
|||
Loading…
Reference in a new issue