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.
flags: re.DOTALL|re.I
patterns:
- <(?:a|div|span|input)\b[^>]*?\s(?:href|data-url|data-src|action)=[\"|'](?!(?:https?://)|javascript:|on\w+:|mailto:)[\w|/]+
- <form\s+?[^>]*?(?: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:|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|/]+
- <form\s+?[^>]*?(?: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:|tel:)[\w|/]+
- rule:
name: H019
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:
write_to_file(
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])
assert result.exit_code == 0