🧹 Separate format from lint

This commit is contained in:
Chris Araman 2021-03-28 17:16:37 -07:00
parent bf093082e8
commit 5df8db3fd6
No known key found for this signature in database
GPG key ID: BB4499D9E11B61E0
5 changed files with 49 additions and 7 deletions

View file

@ -9,6 +9,8 @@
# Disabled rules
--disable blankLinesAroundMark
--disable consecutiveSpaces
--disable indent
# Enabled rules (disabled by default)
--enable trailingClosures

View file

@ -23,7 +23,7 @@ We love pull requests from everyone. By participating in this project, you agree
`git checkout -b awesome-feature master`
- Please avoid working [directly on the master branch](https://softwareengineering.stackexchange.com/questions/223400/when-should-i-stop-committing-to-master-on-new-projects).
- Make commits of logical units.
- Run script/lint before committing your changes. Fix anything that isn't automatically fixed by the linters.
- Run script/format before committing your changes. Fix anything that isn't automatically fixed by the linters.
- Push your topic branch to your fork and [submit a pull request](https://github.com/mas-cli/mas/compare/master...your-username:topic-branch).
Some things that will increase the chance that your pull request is accepted:

View file

@ -1,5 +1,6 @@
# All Files
- Use `script/format` to automatically fix a number of style violations.
- Remove unnecessary whitespace from the end of lines.
- Use `script/lint` to look for these before committing.
- Note that [two trailing spaces](https://gist.github.com/shaunlebron/746476e6e7a4d698b373)

35
script/format Executable file
View file

@ -0,0 +1,35 @@
#!/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 shfmt swift-format swiftformat swiftlint; do
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run script/bootstrap."
exit 1
fi
done
echo
echo "--> 🕊️ Swift"
swiftformat .
for SOURCE in mas MasKit MasKitTests; do
swift-format format --in-place --configuration .swift-format --recursive ${SOURCE}
done
swiftlint lint --fix --strict
echo
echo "--> 📜 Bash"
shfmt -i 2 -l -w contrib/ script/
script/lint

View file

@ -5,12 +5,16 @@
#
# Linting checks for development and CI.
#
# Reports style violations without making any modifications to the code.
#
# Please keep in sync with script/format.
#
echo "==> 🚨 Linting mas"
for LINTER in swift-format swiftformat swiftlint; do
for LINTER in git swift-format swiftformat swiftlint; do
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "warning: ${LINTER} is not installed: script/bootstrap"
echo "error: ${LINTER} is not installed. Run script/bootstrap."
exit 1
fi
done
@ -20,12 +24,12 @@ git diff --check
echo
echo "--> 🕊️ Swift"
swiftformat .
swiftformat --lint .
for SOURCE in mas MasKit MasKitTests; do
swift-format format --in-place --configuration .swift-format --recursive ${SOURCE}
swift-format lint --configuration .swift-format --recursive ${SOURCE}
done
swiftlint lint --fix --strict
swiftlint lint --strict
echo
echo "--> 📜 Bash"
shfmt -i 2 -l -w contrib/ script/
shfmt -d -i 2 -l -w contrib/ script/