mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-17 05:50:24 +00:00
fix(h012): prevent H012 from matching the contents of tags or attributes
closes #348
This commit is contained in:
parent
a5d96e7a2d
commit
4480cff832
2 changed files with 12 additions and 2 deletions
|
|
@ -96,8 +96,8 @@
|
|||
message: There should be no spaces around attribute =.
|
||||
flags: re.DOTALL
|
||||
patterns:
|
||||
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*\s+=
|
||||
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*=\s
|
||||
- <\w+?(\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}])*\s+=
|
||||
- <\w+?(\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}])*=\s
|
||||
- rule:
|
||||
name: H013
|
||||
message: Img tag should have an alt attribute.
|
||||
|
|
|
|||
|
|
@ -219,6 +219,16 @@ def test_H012(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert result.exit_code == 0
|
||||
assert "H012 1:" not in result.output
|
||||
|
||||
# space allowed inside attributes.
|
||||
write_to_file(
|
||||
tmp_file.name,
|
||||
b"""<button x-on:click="myVariable = {{ myObj.id }}" class="text-red-600 hover:text-red-800">
|
||||
<span x-text="showSource == true ? 'Hide source' : 'Show source'"></span>
|
||||
<button x-on:click="open = !open" class="flex items-center mt-2">""",
|
||||
)
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "H012" not in result.output
|
||||
|
||||
|
||||
def test_H013(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b'<img height="12" width="12"/>')
|
||||
|
|
|
|||
Loading…
Reference in a new issue