mas/script/format

44 lines
1 KiB
Text
Raw Normal View History

2021-03-28 17:16:37 -07:00
#!/bin/bash -e
#
# script/format
# mas
#
# Linting checks for development and CI.
#
# Automatically formats and fixes style violations using various tools.
# Additionally runs `lint` to report any remaining style violations.
#
# Please keep in sync with script/lint.
#
echo "==> 🚨 Formatting mas"
for LINTER in markdownlint prettier shfmt swiftformat swiftlint yamllint; do
2021-03-28 17:16:37 -07:00
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'."
2021-03-28 17:16:37 -07:00
exit 1
fi
done
echo "--> 🕊️ Swift"
2021-04-28 14:50:29 -07:00
for SOURCE in Package.swift Sources Tests; do
swiftformat ${SOURCE}
swift run swift-format format --in-place --recursive ${SOURCE}
2021-04-28 14:50:29 -07:00
swiftlint lint --fix --strict ${SOURCE}
2021-03-28 17:16:37 -07:00
done
echo "--> 〽️ Markdown"
markdownlint --config .markdownlint.json --fix .github .
echo "--> 🖊 YAML"
# shellcheck disable=SC2046
prettier --write $(yamllint --list-files .)
2021-03-28 17:16:37 -07:00
echo "--> 📜 Bash"
2024-03-31 11:05:04 -06:00
shfmt \
--write \
--list \
--indent 2 \
--case-indent \
contrib/ script/