From 20e814077f19b1cd497835356bed17ac4d9e007a Mon Sep 17 00:00:00 2001 From: danmx Date: Thu, 30 Apr 2020 17:36:42 +0200 Subject: [PATCH] add(lint,args): shell linters and args support Signed-off-by: danmx --- .editconfig | 10 ++++++++++ .pre-commit-config.yaml | 5 +++++ README.md | 4 ++++ hooks/kapitan-compile.sh | 8 ++++---- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .editconfig diff --git a/.editconfig b/.editconfig new file mode 100644 index 0000000..ad03f88 --- /dev/null +++ b/.editconfig @@ -0,0 +1,10 @@ +[*.sh] +# like -i=4 +indent_style = space +indent_size = 4 + +shell_variant = posix # like -ln=posix +binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +keep_padding = true # like -kp diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bf90b4..26be947 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,3 +5,8 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml +- repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 2.0.1 + hooks: + - id: shellcheck + - id: shfmt diff --git a/README.md b/README.md index 3448191..5123b3e 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,7 @@ A collection of pre-commit hooks for [https://github.com/pre-commit/pre-commit]( - **kapitan-compile**: Compiles [Kapitan](https://kapitan.dev) templates +## Development dependencies + +- [shellcheck](https://www.shellcheck.net/) +- [shfmt](https://github.com/mvdan/sh) diff --git a/hooks/kapitan-compile.sh b/hooks/kapitan-compile.sh index db8698c..603667a 100755 --- a/hooks/kapitan-compile.sh +++ b/hooks/kapitan-compile.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh -set -e - -docker run -t --rm -v "$(pwd)":/src:delegated deepmind/kapitan:0.27.2 compile +set -eu +# shellcheck disable=SC2068 +docker run -t --rm -v "${PWD}":/src:delegated deepmind/kapitan:0.27.2 compile $@