mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-18 10:01:06 +00:00
added rule H029, closes #125
This commit is contained in:
parent
19acc02cda
commit
7c7cac916f
4 changed files with 24 additions and 1 deletions
|
|
@ -4,6 +4,8 @@ Changelog
|
|||
next_release
|
||||
------------
|
||||
- Added rule T027 to check for unclosed in template syntax
|
||||
- Added rule T028 to check for missing spaceless tags in attributes
|
||||
- Added rule H029 to check for lowercase form method
|
||||
|
||||
0.5.9a
|
||||
------
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ Codes
|
|||
+--------+-------------------------------------------------------------------------+
|
||||
| T028 | Consider using spaceless tags inside attribute values. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
|
||||
| H029 | Consider using lowercase form method values. |
|
||||
+--------+-------------------------------------------------------------------------+
|
||||
|
||||
|
||||
Adding Rules
|
||||
|
|
|
|||
|
|
@ -205,3 +205,8 @@
|
|||
patterns:
|
||||
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?({%|{{)[^-])
|
||||
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?[^-](%}|}}))
|
||||
- rule:
|
||||
name: H029
|
||||
message: Consider using lowercase form method values.
|
||||
patterns:
|
||||
- <[fF][oO][rR][mM]\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*([mM][eE][tT][hH][oO][dD])=(([\"'])[a-zA-Z]*?[A-Z][a-zA-Z]*?\3)
|
||||
|
|
|
|||
|
|
@ -483,6 +483,21 @@ def test_T028(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
assert "T028" not in result.output
|
||||
|
||||
|
||||
def test_H029(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
write_to_file(tmp_file.name, b'<forM method="Post">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 1
|
||||
assert "H029" in result.output
|
||||
|
||||
write_to_file(tmp_file.name, b'<forM method="post">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "H029" not in result.output
|
||||
|
||||
write_to_file(tmp_file.name, b'<a method="post">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert "H029" not in result.output
|
||||
|
||||
|
||||
def test_rules_not_matched_in_ignored_block(
|
||||
runner: CliRunner, tmp_file: TextIO
|
||||
) -> None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue