diff --git a/docs/djlint/changelog.rst b/docs/djlint/changelog.rst index 92f8554..56bf15d 100644 --- a/docs/djlint/changelog.rst +++ b/docs/djlint/changelog.rst @@ -4,6 +4,7 @@ Changelog next release ----------- - Added require_pragma option +- Updated DJ018 to catch ``data-src`` and ``action`` on inputs 0.5.7 ----- diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index 52f4466..dcbbcba 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)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+ + - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+ - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\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)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+ + - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+ - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:)[\w|/]+ - rule: name: H019 diff --git a/tests/test_linter.py b/tests/test_linter.py index fa4aaa5..6a6412e 100644 --- a/tests/test_linter.py +++ b/tests/test_linter.py @@ -254,6 +254,16 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None: result = runner.invoke(djlint, [tmp_file.name]) assert result.exit_code == 0 + # test data-src + write_to_file( + tmp_file.name, + b'
', + ) + result = runner.invoke(djlint, [tmp_file.name]) + assert result.exit_code == 1 + assert "D018 1:" in result.output + assert "J018 1:" in result.output + def test_H019(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b"asdf")