From a65fb774ba1ef37fa5b87e57dcc92dd010162677 Mon Sep 17 00:00:00 2001 From: ddieulivol <ddieulivol@gitlab.com> Date: Wed, 8 Jun 2022 11:51:47 +0200 Subject: [PATCH] Add yamllint to lefthook --- lefthook.yml | 5 +++++ scripts/lint-yaml.sh | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100755 scripts/lint-yaml.sh diff --git a/lefthook.yml b/lefthook.yml index ff57725dac684..161ce0b515556 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -18,6 +18,11 @@ pre-push: files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD glob: 'doc/*.md' run: yarn markdownlint {files} + yamllint: + tags: backend style + files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD + glob: '*.{yml,yaml}' + run: scripts/lint-yaml.sh {files} stylelint: tags: stylesheet css style files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD diff --git a/scripts/lint-yaml.sh b/scripts/lint-yaml.sh new file mode 100755 index 0000000000000..c3bd7f2817e11 --- /dev/null +++ b/scripts/lint-yaml.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if ! command -v yamllint > /dev/null; then + echo "ERROR: yamllint is not installed. For more information, see https://yamllint.readthedocs.io/en/stable/index.html." + exit 1 +fi + +yamllint --strict -f colored "$@" -- GitLab