Skip to content

Commit c596959

Browse files
format-code: enable beautysh
beautysh is a code formatter for bash/sh/zsh. Signed-off-by: Patrick Williams <[email protected]> Change-Id: I0ebd5da9e78d84a98940fb3e6618b12cf8eb0fc7
1 parent b08ddf7 commit c596959

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

scripts/build-unit-test-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ RUN apt-get update && apt-get dist-upgrade -yy
845845
"""
846846

847847
dockerfile_base += """
848+
RUN pip3 install beautysh
848849
RUN pip3 install codespell
849850
RUN pip3 install flake8
850851
RUN pip3 install gitlint

scripts/format-code.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function display_help()
2727
LINTERS_ALL=( \
2828
commit_gitlint \
2929
commit_spelling \
30+
beautysh \
31+
beautysh_sh \
3032
clang_format \
3133
eslint \
3234
flake8 \
@@ -158,6 +160,22 @@ function do_commit_gitlint() {
158160
--config "${CONFIG_PATH}/.gitlint"
159161
}
160162

163+
# We need different function style for bash/zsh vs plain sh, so beautysh is
164+
# split into two linters. "function foo()" is not traditionally accepted
165+
# POSIX-shell syntax, so shellcheck barfs on it.
166+
LINTER_REQUIRE+=([beautysh]="beautysh")
167+
LINTER_IGNORE+=([beautysh]=".beautysh-ignore")
168+
LINTER_TYPES+=([beautysh]="bash;zsh")
169+
function do_beautysh() {
170+
beautysh --force-function-style fnpar "$@"
171+
}
172+
LINTER_REQUIRE+=([beautysh_sh]="beautysh")
173+
LINTER_IGNORE+=([beautysh_sh]=".beautysh-ignore")
174+
LINTER_TYPES+=([beautysh_sh]="sh")
175+
function do_beautysh_sh() {
176+
beautysh --force-function-style paronly "$@"
177+
}
178+
161179
LINTER_REQUIRE+=([eslint]="eslint;.eslintrc.json;${CONFIG_PATH}/eslint-global-config.json")
162180
LINTER_IGNORE+=([eslint]=".eslintignore")
163181
LINTER_TYPES+=([eslint]="json")

0 commit comments

Comments
 (0)