updated regex to require a tag name before looking for attribute =. Closes #46

This commit is contained in:
Christopher Pickering 2021-10-04 13:11:12 +02:00
parent 9ab51a115a
commit d01f866a29
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 12 additions and 3 deletions

View file

@ -215,8 +215,8 @@
message: There should be no spaces around attribute =.
flags: re.DOTALL
patterns:
- <(?:(?!\{[%|{|#])[^\n|>])*\s+=
- <(?:(?!\{[%|{|#])[^\n|>])*=\s
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*\s+=
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*=\s
- rule:
name: H014
message: More than 2 blank lines.

View file

@ -140,12 +140,21 @@ def test_H012(runner: CliRunner, tmp_file: TextIO) -> None:
assert result.exit_code == 1
assert "H012 1:" in result.output
# test for not matching random "="" in text
# test for not matching random "=" in text
write_to_file(tmp_file.name, b"<h3>#= title #</h3>")
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 0
assert "H012 1:" not in result.output
# test for not matching "=" in template condition
write_to_file(
tmp_file.name,
b"<p>{% if activity.reporting_groups|length <= 0 %}<h3>{% trans 'General' %}</h3>{% endif %}</p>",
)
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 0
assert "H012 1:" not in result.output
def test_H014(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"</div>\n\n\n<p>")