Update and add linting config to better match Wagtail

pull/352/head
Sage Abdullah 2022-07-26 10:18:47 +07:00 zatwierdzone przez Karl Hobley
rodzic 7cf07d4072
commit b45934ce83
4 zmienionych plików z 79 dodań i 2 usunięć

27
.editorconfig 100644
Wyświetl plik

@ -0,0 +1,27 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
[Makefile]
indent_style = tab
[*.py]
charset = utf-8
indent_size = 4
max_line_length = 120
[*.js]
charset = utf-8
[*.{html,rst,md}]
indent_size = 4
[*.{js,ts,tsx,json,yml,yaml,css,scss}]
indent_size = 2
[*.md]
trim_trailing_whitespace = false

Wyświetl plik

@ -0,0 +1,27 @@
default_language_version:
node: system
python: python3
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
args: ["--target-version", "py37"]
- repo: https://github.com/timothycrosley/isort
# isort config is in setup.cfg
rev: 5.6.4
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
# flake8 config is in setup.cfg
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-comprehensions
- flake8-assertive
- repo: https://github.com/rtts/djhtml
rev: v1.4.13
hooks:
- id: djhtml

17
Makefile 100644
Wyświetl plik

@ -0,0 +1,17 @@
.PHONY: lint format
help:
@echo "lint - check style with black, flake8, sort python with isort, and indent html"
@echo "format - enforce a consistent code style across the codebase and sort python files with isort"
lint:
black --target-version py37 --check --diff .
flake8
isort --check-only --diff .
curlylint --parse-only bakerydemo
git ls-files '*.html' | xargs djhtml --check
format:
black --target-version py37 .
isort .
git ls-files '*.html' | xargs djhtml -i

Wyświetl plik

@ -1,4 +1,10 @@
[flake8]
max-line-length=120
exclude=migrations
ignore=F405,W503
exclude=venv,.venv,bakerydemo/settings/local.py
ignore=E501,F405,W503
[isort]
profile=black
skip=migrations,.git,__pycache__,LC_MESSAGES,venv,.venv
blocked_extensions=rst,html,js,svg,txt,css,scss,png,snap,ts,tsx
default_section=THIRDPARTY