From 815ba27bee0a12cdf5a0ba0c81d067078c3812ec Mon Sep 17 00:00:00 2001 From: slowy07 Date: Thu, 13 Jun 2024 08:47:49 +0700 Subject: [PATCH] chore: introduce pre-commit Signed-off-by: slowy07 --- .pre-commit-config.yaml | 32 ++++++++++++++++++++++++++++++++ ruff.toml | 10 ++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 ruff.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3240cb98 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-executables-have-shebangs + # check toml files + - id: check-toml + # check yaml files + - id: check-yaml + # fixing empty or blank of end file + - id: end-of-file-fixer + types: [python] + # check trailing whitespace on file + - id: trailing-whitespace + # sort the entries of package on requirements.txt + - id: requirements-txt-fixer + + # ruff formatter and linter + # replace black and flake8 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.3 + hooks: + - id: ruff + - id: ruff-format + + # mirror of prettier + # beautify of toml and yaml files + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v4.0.0-alpha.8" + hooks: + - id: prettier + types_or: [toml, yaml] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..8842a230 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,10 @@ +line-length = 88 + +# ignore specific error from lint with ruff +[lint] +ignore = ["F541", "F841", "E711", "E721", "F541", "E741", "F401", "F403", "E712", "E731", "F811"] + + +[format] +# according PEP8 python, double quotes for strings. +quote-style = "double"