mas/script/format

40 lines
903 B
Text
Raw Normal View History

2021-03-29 00:16:37 +00: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 shfmt swiftformat swiftlint; do
2021-03-29 00:16:37 +00:00
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'."
2021-03-29 00:16:37 +00:00
exit 1
fi
done
2021-05-03 20:42:10 +00:00
echo
echo "--> 🖊 Markdown"
markdownlint --config .markdownlint.json --fix .github .
2021-03-29 00:16:37 +00:00
echo
echo "--> 🕊️ Swift"
2021-04-28 21:50:29 +00:00
for SOURCE in Package.swift Sources Tests; do
swiftformat ${SOURCE}
swift run swift-format format --in-place --recursive ${SOURCE}
2021-04-28 21:50:29 +00:00
swiftlint lint --fix --strict ${SOURCE}
2021-03-29 00:16:37 +00:00
done
echo
echo "--> 📜 Bash"
shfmt -i 2 -l -w contrib/ script/
script/lint