From 31a28e177c435f398ad9a099095f6fe7f6a73d5e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 5 Nov 2021 16:03:30 +0100 Subject: [PATCH] pre-commit: setup pre-commit config to run prettier on YAML files --- .pre-commit-config.yaml | 19 +++++++++++++++++++ .prettierignore | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierignore diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..e3938d08d8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# pre-commit is a tool to perform a predefined set of tasks manually and/or +# automatically before git commits are made. +# +# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level +# +# Common tasks +# +# - Run on all files: pre-commit run --all-files +# - Register git hooks: pre-commit install --install-hooks +# +repos: + # FIXME: Consider adding more, for example by looking at those configured for + # TLJH in https://github.com/jupyterhub/the-littlest-jupyterhub/blob/main/.pre-commit-config.yaml + + # Autoformat: markdown, yaml + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.4.1 + hooks: + - id: prettier diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..44c0355a81 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +# Helm chart's templates aren't pure YAML files +**/templates/ + +# It would be trouble if we had two automatic formatters on the same files. This +# could happen if we would auto-format the sops generated files with prettier. +secrets/**/* +**/secrets.yaml +!secrets/config/hubs/schema.yaml + +# To create a minimal change suggestion, prettier was introduced to auto-format +# the YAML files only. It is absolutely reasonable to auto-format markdown files +# and json files as well, but for now, let's make prettier only auto-format +# YAML. +**/*.md +**/*.json