2024-09-30 11:28:25 -04:00
|
|
|
#!/bin/bash -eu
|
2021-03-28 17:16:37 -07: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 11:28:25 -04:00
|
|
|
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
|
2021-03-28 17:16:37 -07:00
|
|
|
|
2024-09-30 11:28:25 -04: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'
|
|
|
|
|
2024-10-26 23:48:05 -04:00
|
|
|
for LINTER in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do
|
2021-03-28 17:16:37 -07:00
|
|
|
if [[ ! -x "$(command -v ${LINTER})" ]]; then
|
2024-09-30 11:28:25 -04:00
|
|
|
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}"
|
2021-03-28 17:16:37 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2021-04-28 14:50:29 -07:00
|
|
|
for SOURCE in Package.swift Sources Tests; do
|
2024-09-30 11:28:25 -04: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-28 17:16:37 -07:00
|
|
|
done
|
|
|
|
|
2024-09-30 11:28:25 -04:00
|
|
|
printf -- $'--> 📜 Bash shfmt\n'
|
2024-03-31 11:05:04 -06:00
|
|
|
shfmt \
|
|
|
|
--write \
|
|
|
|
--list \
|
|
|
|
--indent 2 \
|
|
|
|
--case-indent \
|
|
|
|
contrib/ script/
|
2021-03-28 17:16:37 -07:00
|
|
|
|
2024-09-30 11:28:25 -04:00
|
|
|
printf -- $'--> 〽️ Markdown\n'
|
|
|
|
markdownlint --config .markdownlint.json --fix .github .
|
2024-10-26 23:48:05 -04:00
|
|
|
|
|
|
|
printf -- $'--> 🖊 YAML\n'
|
|
|
|
# shellcheck disable=SC2046
|
|
|
|
prettier --write $(yamllint --list-files .)
|