mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-15 00:23:10 +00:00
split alt from H006 to H013, closes #47
This commit is contained in:
parent
b24cc81875
commit
07a812ee1d
4 changed files with 24 additions and 4 deletions
|
|
@ -1,6 +1,10 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
Next Release
|
||||
------------
|
||||
- Split ``alt`` requirement from H006 to H013
|
||||
|
||||
0.5.1
|
||||
-----
|
||||
- Added rule H019
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Codes
|
|||
+--------+-------------------------------------------------------------------------+
|
||||
| H005 | Html tag should have lang attribute. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| H006 | Img tag should have alt, height and width attributes. |
|
||||
| H006 | Img tag should have height and width attributes. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| H007 | <!DOCTYPE ... > should be present before the html tag. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
|
|
@ -33,6 +33,8 @@ Codes
|
|||
+--------+-------------------------------------------------------------------------+
|
||||
| H012 | There should be no spaces around attribute =. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| H013 | Img tag should have alt attributes. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| H014 | More than 2 blank lines. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
| H015 | Follow h tags with a line break. |
|
||||
|
|
|
|||
|
|
@ -52,12 +52,11 @@
|
|||
- <html\s*(?:(?!lang).)*>
|
||||
- rule:
|
||||
name: H006
|
||||
message: Img tag should have alt, height and width attributes.
|
||||
message: Img tag should have height and width attributes.
|
||||
flags: re.DOTALL|re.I
|
||||
patterns:
|
||||
- <img\s(?:(?!(?:height)=).)*/?>
|
||||
- <img\s(?:(?!(?:width)=).)*/?>
|
||||
- <img\s(?:(?!(?:alt)=).)*/?>
|
||||
- rule:
|
||||
name: H007
|
||||
message: <!DOCTYPE ... > should be present before the html tag.
|
||||
|
|
@ -217,6 +216,12 @@
|
|||
patterns:
|
||||
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*\s+=
|
||||
- <\w+?(?:(?!\{[%|{|#])[^\n|>])*=\s
|
||||
- rule:
|
||||
name: H013
|
||||
message: Img tag should have an alt attribute.
|
||||
flags: re.DOTALL|re.I
|
||||
patterns:
|
||||
- <img\s(?:(?!(?:alt)=).)*/?>
|
||||
- rule:
|
||||
name: H014
|
||||
message: More than 2 blank lines.
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ def test_H005(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
|
||||
|
||||
def test_H006(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"<img />")
|
||||
write_to_file(tmp_file.name, b'<img alt="test"/>')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 1
|
||||
assert "H006 1:" in result.output
|
||||
|
|
@ -156,6 +156,15 @@ def test_H012(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert "H012 1:" 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"/>')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 1
|
||||
assert "H013 1:" in result.output
|
||||
print(result.output)
|
||||
assert "found 1 error" in result.output
|
||||
|
||||
|
||||
def test_H014(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b"</div>\n\n\n<p>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
|
|
|
|||
Loading…
Reference in a new issue