2024-09-30 15:28:25 +00:00
|
|
|
#!/bin/bash -eu
|
2021-03-29 00:16:37 +00:00
|
|
|
#
|
|
|
|
# script/format
|
|
|
|
# mas
|
|
|
|
#
|
|
|
|
# Linting checks for development and CI.
|
|
|
|
#
|
|
|
|
# Automatically formats and fixes style violations using various tools.
|
|
|
|
#
|
|
|
|
# Please keep in sync with script/lint.
|
|
|
|
#
|
|
|
|
|
2024-09-30 15:28:25 +00:00
|
|
|
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
|
2021-03-29 00:16:37 +00:00
|
|
|
|
2024-09-30 15:28:25 +00:00
|
|
|
if ! cd -- "${mas_dir}"; then
|
|
|
|
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf $'==> 🚨 Formatting mas\n'
|
|
|
|
|
|
|
|
for LINTER in markdownlint shfmt swift-format swiftformat swiftlint; do
|
2021-03-29 00:16:37 +00:00
|
|
|
if [[ ! -x "$(command -v ${LINTER})" ]]; then
|
2024-09-30 15:28:25 +00:00
|
|
|
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}"
|
2021-03-29 00:16:37 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2021-04-28 21:50:29 +00:00
|
|
|
for SOURCE in Package.swift Sources Tests; do
|
2024-09-30 15:28:25 +00:00
|
|
|
printf -- $'--> 🕊 %s swift-format\n' "${SOURCE}"
|
|
|
|
swift-format format --in-place --recursive "${SOURCE}"
|
|
|
|
printf -- $'--> 🕊 %s swiftformat\n' "${SOURCE}"
|
|
|
|
swiftformat "${SOURCE}"
|
|
|
|
printf -- $'--> 🕊 %s swiftlint\n' "${SOURCE}"
|
|
|
|
swiftlint --fix --strict "${SOURCE}"
|
2021-03-29 00:16:37 +00:00
|
|
|
done
|
|
|
|
|
2024-09-30 15:28:25 +00:00
|
|
|
printf -- $'--> 📜 Bash shfmt\n'
|
|
|
|
shfmt \
|
|
|
|
--write \
|
|
|
|
--list \
|
|
|
|
--indent 2 \
|
|
|
|
--case-indent \
|
|
|
|
contrib/ script/
|
2021-03-29 00:16:37 +00:00
|
|
|
|
2024-09-30 15:28:25 +00:00
|
|
|
printf -- $'--> 〽️ Markdown\n'
|
|
|
|
markdownlint --config .markdownlint.json --fix .github .
|