diff --git a/docs/djlint/rules.rst b/docs/djlint/rules.rst index f11fd3f..9878a55 100644 --- a/docs/djlint/rules.rst +++ b/docs/djlint/rules.rst @@ -48,6 +48,8 @@ Warning Codes +--------+----------------------------------------------------------------+ | W017 | Tag should be self closing. | +--------+----------------------------------------------------------------+ +| W018 | Internal links should use the {% url ... %} pattern. | ++--------+----------------------------------------------------------------+ Adding Rules ------------ diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index 737e30e..8cd3f05 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -44,7 +44,9 @@ message: Img tag should have alt, height and width attributes. flags: re.DOTALL|re.I patterns: - - + - + - + - - rule: name: W007 message: should be present before the html tag. @@ -71,10 +73,10 @@ - (?:CLASS|ID|SRC|WIDTH|HEIGHT|ALT|STYLE|LANG|TITLE)= - rule: name: W011 - message: Attirbute values should be quoted. + message: Attribute values should be quoted. flags: re.DOTALL|re.I patterns: - - "[^(?:\"|')](?:class|id|src|width|height|alt|style|lang|title)=[a-zA-Z]+" + - "[^(?:\"|')]\\s+?(?:class|id|src|width|height|alt|style|lang|title|href|action|method)=[a-zA-Z]+" - rule: name: W012 message: There should be no spaces around attribute =. @@ -117,5 +119,5 @@ message: Internal links should use the {% url ... %} pattern. flags: re.DOTALL|re.I patterns: - - ]*?(?:href|data-url)=[\"|'](?!https?://)[\w|/]+ + - <(?:a|div|span|input)\s+?[^>]*?(?:href|data-url|data-ajax)=[\"|'](?!https?://)[\w|/]+ - ]*?(?:action)=[\"|'](?!https?://)[\w|/]+