mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-23 06:24:46 +00:00
added more rules.
This commit is contained in:
parent
40d8562033
commit
04b8e99b4f
5 changed files with 94 additions and 2 deletions
|
|
@ -1,3 +1,7 @@
|
|||
# 0.0.8
|
||||
|
||||
Added rules.
|
||||
|
||||
# 0.0.1
|
||||
|
||||
Initial release.
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -37,3 +37,15 @@ djlint <file or path>
|
|||
|------|--------------------------------------------------------------|
|
||||
| W003 | Endblock should have name. Ex: {% endblock body %}. |
|
||||
| W004 | Status urls should follow {% static path/to/file %} pattern. |
|
||||
| W005 | Html tag should have lang attribute. |
|
||||
| W006 | Img tag should have alt, height and width attributes. |
|
||||
| W007 | \<!DOCTYPE ... > should be present before the html tag. |
|
||||
| W008 | Attributes should be double quoted. |
|
||||
| W009 | Tag names should be lowercase. |
|
||||
| W010 | Attribute names should be lowercase. |
|
||||
| W011 | Attirbute values should be quoted. |
|
||||
| W012 | There should be no spaces around attribute =. |
|
||||
| W013 | Line is longer than 99 chars. |
|
||||
| W014 | More than 2 blank lines. |
|
||||
| W015 | Follow h tags with a blank line. |
|
||||
| W016 | Missging title tag in html. |
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ def lint_file(this_file: Path):
|
|||
{
|
||||
"code": rule["name"],
|
||||
"line": get_line(match.start()),
|
||||
"match": match.group(),
|
||||
"match": match.group()[:20].strip(),
|
||||
"message": rule["message"],
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,3 +22,64 @@
|
|||
# this should be using the static path from django settings
|
||||
patterns:
|
||||
- <(?:link|img|script)\s[^\>]*?(?:href|src)=[\"\']/?static/?
|
||||
- rule:
|
||||
name: W005
|
||||
message: Html tag should have lang attribute.
|
||||
patterns:
|
||||
- <html\s(?:(?!lang).)*>
|
||||
- rule:
|
||||
name: W006
|
||||
message: Img tag should have alt, height and width attributes.
|
||||
patterns:
|
||||
- <img\s(?:(?!(?:alt|width|height)).)*>
|
||||
- rule:
|
||||
name: W007
|
||||
message: <!DOCTYPE ... > should be present before the html tag.
|
||||
patterns:
|
||||
- ^<html
|
||||
- rule:
|
||||
name: W008
|
||||
message: Attributes should be double quoted.
|
||||
patterns:
|
||||
- (?:class|id|src|width|height|alt|style|lang|title)=\'[^\']*'
|
||||
- rule:
|
||||
name: W009
|
||||
message: Tag names should be lowercase.
|
||||
patterns:
|
||||
- (?<=<)(?:HTML|BODY|DIV|P|SPAN|TABLE|TR|TD|TH|THEAD|TBODY|CODE|UL|OL|LI|H1|H2|H3|H4|H5|H6)
|
||||
- rule:
|
||||
name: W010
|
||||
message: Attribute names should be lowercase.
|
||||
patterns:
|
||||
- (?:CLASS|ID|SRC|WIDTH|HEIGHT|ALT|STYLE|LANG|TITLE)=
|
||||
- rule:
|
||||
name: W011
|
||||
message: Attirbute values should be quoted.
|
||||
patterns:
|
||||
- (?:class|id|src|width|height|alt|style|lang|title)=[a-zA-Z]+
|
||||
- rule:
|
||||
name: W012
|
||||
message: There should be no spaces around attribute =.
|
||||
patterns:
|
||||
- <(?:(?!\{[%|{|#])[^\n])*\s+=
|
||||
- <(?:(?!\{[%|{|#])[^\n])*=\s
|
||||
- rule:
|
||||
name: W013
|
||||
message: Line is longer than 99 chars.
|
||||
patterns:
|
||||
- "[^\n]{99,}"
|
||||
- rule:
|
||||
name: W014
|
||||
message: More than 2 blank lines.
|
||||
patterns:
|
||||
- "[^\n]{,10}\n{3,}"
|
||||
- rule:
|
||||
name: W015
|
||||
message: Follow h tags with a blank line.
|
||||
patterns:
|
||||
- </h\d?>(?:(?!(.+\r?\n){1,}).)*<[a-zA-Z]+\d?
|
||||
- rule:
|
||||
name: W016
|
||||
message: Missging title tag in html.
|
||||
patterns:
|
||||
- <html[^>]*?>(?:(?!<title>).)*</html>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,23 @@
|
|||
{%this%}
|
||||
{{ is}}
|
||||
|
||||
<a src="/junk"></a>
|
||||
<a href="/junk"></a>
|
||||
|
||||
<footer class="ft">
|
||||
© {% now "Y" %} - {{settings.ORG_NAME }}
|
||||
</footer>
|
||||
|
||||
<BODY>
|
||||
<P>This is a paragraph.</P>
|
||||
|
||||
|
||||
<a HREF="https://www.w3schools.com/html/">Visit our HTML tutorial</a>
|
||||
|
||||
<table class=striped></table>
|
||||
|
||||
</BODY>
|
||||
|
||||
<img src="html5.gif">
|
||||
<link rel = "stylesheet" href = "styles.css">
|
||||
|
||||
<div class="this is a really line long of random stuff... how long can we make it? hopefully over 99 chars long!"><p>close that div out!</p></div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue