From f08e3acee311cc41600c1fdef10890e12273780c Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Wed, 17 Aug 2022 07:16:29 -0500 Subject: [PATCH] feat(linter): updated rule 18 to allow "tel:" closes #334 --- src/djlint/rules.yaml | 8 ++++---- tests/test_linter/test_linter.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index 11ab245..39eab2f 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -134,15 +134,15 @@ message: (Django) Internal links should use the {% url ... %} pattern. flags: re.DOTALL|re.I patterns: - - <(?: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|/]+ + - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ + - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ - rule: name: J018 message: (Jinja) Internal links should use the {{ url_for() ... }} pattern. flags: re.DOTALL|re.I patterns: - - <(?: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|/]+ + - <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ + - ]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+ - rule: name: H019 message: Replace 'javascript:abc()' with on_ event and real url. diff --git a/tests/test_linter/test_linter.py b/tests/test_linter/test_linter.py index 7168b40..daf0a6f 100644 --- a/tests/test_linter/test_linter.py +++ b/tests/test_linter/test_linter.py @@ -299,7 +299,7 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None: # test mailto: write_to_file( tmp_file.name, - b'', + b'', ) result = runner.invoke(djlint, [tmp_file.name]) assert result.exit_code == 0