From 79618a5bfbdbfa4c600dad1a4e8f3672bc4d5dcd Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Mon, 22 Aug 2022 08:49:46 -0500 Subject: [PATCH] fix(linter): fixed false postive on rule H008 closes #339 --- requirements.txt | 42 ++++++++++++++++---------------- src/djlint/rules.yaml | 2 +- tests/test_linter/test_linter.py | 15 ++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/requirements.txt b/requirements.txt index c7da797a..edec3ece 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,47 +1,47 @@ -astroid==2.12.2; python_full_version >= "3.7.2" -atomicwrites==1.4.1; python_version >= "3.7" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.7" and python_full_version >= "3.4.0" +astroid==2.11.7; python_full_version >= "3.7.2" +atomicwrites==1.4.0; python_version >= "3.7" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.7" and python_full_version >= "3.4.0" attrs==21.4.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" -black==22.6.0; python_full_version >= "3.6.2" -click==8.1.3; python_version >= "3.6" +black==22.1.0; python_full_version >= "3.6.2" +click==8.0.3; python_version >= "3.6" colorama==0.4.5; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -coverage==6.4.4; python_version >= "3.7" -cssbeautifier==1.14.6 +coverage==6.4.2; python_version >= "3.7" +cssbeautifier==1.14.4 dill==0.3.5.1; python_full_version >= "3.7.2" editorconfig==0.12.3 execnet==1.9.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -flake8==4.0.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" +flake8==3.9.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" html-tag-names==0.1.2; python_version >= "3.7" and python_version < "4.0" html-void-elements==0.1.0; python_version >= "3.7" and python_version < "4.0" -importlib-metadata==4.12.0; python_version >= "3.7" +importlib-metadata==4.11.0; python_version >= "3.7" iniconfig==1.1.1; python_version >= "3.7" isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0" -jsbeautifier==1.14.6 +jsbeautifier==1.14.4 lazy-object-proxy==1.7.1; python_version >= "3.6" and python_full_version >= "3.7.2" -mccabe==0.7.0; python_full_version >= "3.7.2" +mccabe==0.6.1; python_full_version >= "3.7.2" mypy-extensions==0.4.3; python_full_version >= "3.6.2" and python_version >= "3.6" mypy==0.971; python_version >= "3.6" packaging==21.3; python_version >= "3.7" pathspec==0.9.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -pep8-naming==0.13.2 -platformdirs==2.5.2; python_version >= "3.7" and python_full_version >= "3.7.2" +pep8-naming==0.13.1 +platformdirs==2.5.0; python_version >= "3.7" and python_full_version >= "3.7.2" pluggy==1.0.0; python_version >= "3.7" py==1.11.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" -pycodestyle==2.9.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -pyflakes==2.5.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" +pycodestyle==2.7.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" +pyflakes==2.3.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" pylint==2.14.5; python_full_version >= "3.7.2" -pyparsing==3.0.9; python_version >= "3.7" +pyparsing==3.0.7; python_version >= "3.7" pytest-cov==3.0.0; python_version >= "3.6" pytest-forked==1.4.0; python_version >= "3.6" pytest-xdist==2.5.0; python_version >= "3.6" pytest==7.1.2; python_version >= "3.7" pyyaml==6.0; python_version >= "3.6" -regex==2022.8.17 +regex==2022.1.18 six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" tomli==2.0.1; python_version >= "3.7" and python_full_version >= "3.7.2" and python_full_version <= "3.11.0a6" and python_version < "3.11" or python_version < "3.11" -tomlkit==0.11.4; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.7.2" -tqdm==4.64.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") -typed-ast==1.5.4; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.7.2" and python_version >= "3.6" +tomlkit==0.11.1; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.7.2" +tqdm==4.62.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") +typed-ast==1.4.3; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.7.2" and python_version >= "3.6" types-pyyaml==6.0.11 -typing-extensions==4.3.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.7.2" +typing-extensions==4.1.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.7.2" wrapt==1.14.1; python_full_version >= "3.7.2" -zipp==3.8.1; python_version < "3.8" and python_version >= "3.7" +zipp==3.7.0; python_version < "3.8" and python_version >= "3.7" diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index 9638a299..d1d2f5c9 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -70,7 +70,7 @@ message: Attributes should be double quoted. flags: re.DOTALL|re.I patterns: - - (?:class|id|src|width|height|alt|style|lang|title|srcset|media)=\'[^\']*' + - <(?:\w+)\b(\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}])*(?:class|id|src|width|height|alt|style|lang|title|srcset|media)=\'[^\']*' - rule: name: H009 message: Tag names should be lowercase. diff --git a/tests/test_linter/test_linter.py b/tests/test_linter/test_linter.py index 83f25cff..b9dbeb1d 100644 --- a/tests/test_linter/test_linter.py +++ b/tests/test_linter/test_linter.py @@ -105,6 +105,21 @@ def test_H008(runner: CliRunner, tmp_file: TextIO) -> None: assert result.exit_code == 1 assert "H008 1:" in result.output + write_to_file( + tmp_file.name, + b"""""", + ) + result = runner.invoke(djlint, [tmp_file.name]) + assert result.exit_code == 1 + assert "H008 1:" in result.output + + write_to_file( + tmp_file.name, + b"""""", + ) + result = runner.invoke(djlint, [tmp_file.name]) + assert "H008 1:" not in result.output + def test_H009(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b"

")