feat(linter): updated rule 18 to allow "tel:"

closes #334
This commit is contained in:
Christopher Pickering 2022-08-17 07:16:29 -05:00
parent 919d03457d
commit f08e3acee3
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 5 additions and 5 deletions

View file

@ -134,15 +134,15 @@
message: (Django) Internal links should use the {% url ... %} pattern. message: (Django) Internal links should use the {% url ... %} pattern.
flags: re.DOTALL|re.I flags: re.DOTALL|re.I
patterns: patterns:
- <(?:a|div|span|input)\b[^>]*?\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:|tel:)[\w|/]+
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+
- rule: - rule:
name: J018 name: J018
message: (Jinja) Internal links should use the {{ url_for() ... }} pattern. message: (Jinja) Internal links should use the {{ url_for() ... }} pattern.
flags: re.DOTALL|re.I flags: re.DOTALL|re.I
patterns: patterns:
- <(?:a|div|span|input)\b[^>]*?\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:|tel:)[\w|/]+
- <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+ - <form\s+?[^>]*?(?:action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:|tel:)[\w|/]+
- rule: - rule:
name: H019 name: H019
message: Replace 'javascript:abc()' with on_ event and real url. message: Replace 'javascript:abc()' with on_ event and real url.

View file

@ -299,7 +299,7 @@ def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None:
# test mailto: # test mailto:
write_to_file( write_to_file(
tmp_file.name, tmp_file.name,
b'<a href="mailto:joe"></a>', b'<a href="mailto:joe"></a><a href="tel:joe"></a>',
) )
result = runner.invoke(djlint, [tmp_file.name]) result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 0 assert result.exit_code == 0