Lint rules¶
By default djangofmt runs every stable rule.
Override that with select and ignore, either on the command line (--select, --ignore) or under [tool.djangofmt.lint] in pyproject.toml.
[tool.djangofmt.lint]
select = ["category:all"]
ignore = ["category:style", "missing-img-alt"]
preview = true
A selector is either:
- single rule name (e.g.
missing-img-alt) - a group prefixed with
category:(e.g.category:all,category:style, ...)
Preview rules are off by default. Enable them with --preview or preview = true.
Correctness¶
| Name | Message | Fix |
|---|---|---|
| invalid-attr-value | Invalid value '{}' for attribute '{}'. | None |
| untrimmed-blocktranslate | {% blocktranslate %} should declare trimmed to avoid leaking indentation into translation strings. |
Always |
| duplicate-block-name | Duplicate {{% block %}} name {}. |
None |
Suspicious¶
| Name | Message | Fix |
|---|---|---|
| django-static-url | Hardcoded static path in {}. |
None |
| django-url-pattern | Hardcoded internal URL in {}. |
None |
| javascript-url | Avoid javascript: URLs in {}. |
None |
| duplicate-attr | Duplicate attribute {}. |
None |
| use-https | Avoid http:// URLs in {}. |
Always |
| empty-tag-pair | Empty <{}> tag pair. |
None |
Style¶
| Name | Message | Fix |
|---|---|---|
| empty-attr-value | Empty {} attribute can be removed. |
Always |
| redundant-type-attr | Redundant type="{}" on <{}> tag. | Always |
| uppercase-form-method | Form method {} should be lowercase. |
Always |
| form-action-whitespace | Extra whitespace found in form action. |
Always |
| missing-doctype | Missing <!DOCTYPE html> declaration. |
None |
Accessibility¶
| Name | Message | Fix |
|---|---|---|
| missing-html-lang | <html> tag should declare a lang attribute. |
None |
| missing-title | Missing or empty <title> in <head>. |
None |
| missing-img-alt | <img> tag should declare an alt attribute. |
None |
| missing-img-dimensions | <img> tag should declare both height and width attributes. |
None |
| table-header-missing-scope | Missing or empty scope attribute on <th>. |
None |