diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d3bf43 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..732b74e --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..85b8083 --- /dev/null +++ b/Makefile @@ -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 diff --git a/setup.cfg b/setup.cfg index 0205935..53108ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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