diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index cbd6f56..67f33fb 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -133,14 +133,14 @@ message: (Django) Internal links should use the {% url ... %} pattern. flags: re.DOTALL|re.I patterns: - - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ + - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - rule: name: J018 message: (Jinja) Internal links should use the {{ url_for() ... }} pattern. flags: re.DOTALL|re.I patterns: - - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ + - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - rule: name: H019 diff --git a/tests/test_linter/test_linter.py b/tests/test_linter/test_linter.py index b9a9428..9b91e34 100644 --- a/tests/test_linter/test_linter.py +++ b/tests/test_linter/test_linter.py @@ -7,8 +7,7 @@ run:: # for a single test - pytest tests/test_linter.py::test_H021 --cov=src/djlint --cov-branch \ - --cov-report xml:coverage.xml --cov-report term-missing + pytest tests/test_linter/test_linter.py::test_DJ018 """ # pylint: disable=C0116,C0103 @@ -296,6 +295,16 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None: result = runner.invoke(djlint, [tmp_file.name]) assert result.exit_code == 0 + # test attribute names + write_to_file( + tmp_file.name, + b'
', + ) + result = runner.invoke(djlint, [tmp_file.name, "--profile", "django"]) + assert result.exit_code == 0 + result = runner.invoke(djlint, [tmp_file.name, "--profile", "jinja"]) + assert result.exit_code == 0 + def test_H019(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b"asdf")