Add jinjalint linter for Django templates, allowing errors for now

pull/5265/head
Thibaud Colas 2019-04-23 12:58:58 +01:00
rodzic 8407245207
commit a51631c306
5 zmienionych plików z 22 dodań i 0 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ jobs:
key: pip-package-v1-{{ .Branch }}
- run: pipenv run flake8 wagtail
- run: pipenv run isort --check-only --diff --recursive wagtail
- run: pipenv run jinjalint --parse-only wagtail || true
- run: DATABASE_NAME=wagtail.db pipenv run python -u runtests.py
frontend:

Wyświetl plik

@ -18,6 +18,7 @@ develop: clean-pyc
lint:
flake8 wagtail
isort --check-only --diff --recursive wagtail
jinjalint --parse-only wagtail || true
npm run lint:css --silent
npm run lint:js --silent

Wyświetl plik

@ -0,0 +1,16 @@
HTML coding guidelines
======================
We use `Django templates <https://docs.djangoproject.com/en/stable/ref/templates/language/>`_ to author HTML.
Linting HTML
~~~~~~~~~~~~
We use `jinjalint <https://github.com/motet-a/jinjalint>`_ to lint templates. If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``.
Principles
~~~~~~~~~~
* Write `valid HTML <https://validator.w3.org/nu/>`_. We target the HTML5 doctype.
* Attach JavaScript behavior with ``data-`` attributes, rather than classes or IDs.
* For comments, use Django templates syntax instead of HTML.

Wyświetl plik

@ -60,6 +60,7 @@ More information
styleguide
general_guidelines
python_guidelines
html_guidelines
css_guidelines
javascript_guidelines
release_process

Wyświetl plik

@ -53,6 +53,9 @@ testing_extras = [
'isort==4.2.5',
'flake8-blind-except==0.1.1',
'flake8-print==2.0.2',
# For templates linting
'jinjalint>=0.5',
]
# Documentation dependencies