format-code: enable beautysh
beautysh is a code formatter for bash/sh/zsh.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I0ebd5da9e78d84a98940fb3e6618b12cf8eb0fc7
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index 1de8f8b..2aa4c50 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -845,6 +845,7 @@
"""
dockerfile_base += """
+RUN pip3 install beautysh
RUN pip3 install codespell
RUN pip3 install flake8
RUN pip3 install gitlint
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index 77e8df0..17a6d1e 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -27,6 +27,8 @@
LINTERS_ALL=( \
commit_gitlint \
commit_spelling \
+ beautysh \
+ beautysh_sh \
clang_format \
eslint \
flake8 \
@@ -158,6 +160,22 @@
--config "${CONFIG_PATH}/.gitlint"
}
+# We need different function style for bash/zsh vs plain sh, so beautysh is
+# split into two linters. "function foo()" is not traditionally accepted
+# POSIX-shell syntax, so shellcheck barfs on it.
+LINTER_REQUIRE+=([beautysh]="beautysh")
+LINTER_IGNORE+=([beautysh]=".beautysh-ignore")
+LINTER_TYPES+=([beautysh]="bash;zsh")
+function do_beautysh() {
+ beautysh --force-function-style fnpar "$@"
+}
+LINTER_REQUIRE+=([beautysh_sh]="beautysh")
+LINTER_IGNORE+=([beautysh_sh]=".beautysh-ignore")
+LINTER_TYPES+=([beautysh_sh]="sh")
+function do_beautysh_sh() {
+ beautysh --force-function-style paronly "$@"
+}
+
LINTER_REQUIRE+=([eslint]="eslint;.eslintrc.json;${CONFIG_PATH}/eslint-global-config.json")
LINTER_IGNORE+=([eslint]=".eslintignore")
LINTER_TYPES+=([eslint]="json")