-
Notifications
You must be signed in to change notification settings - Fork 281
/
Copy pathlint
executable file
·67 lines (55 loc) · 2.08 KB
/
lint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/zsh -Ndfgku
#
# script/lint
# mas
#
# Linting checks for development and CI.
#
# Reports style violations without making any modifications to the code.
#
# Please keep in sync with script/format.
#
. "${0:a:h}/_setup_script"
printf $'==> 🚨 Linting mas %s\n' "$(script/version)"
script/generate_package_swift lint
for linter in git markdownlint periphery shellcheck swift-format swiftformat swiftlint yamllint; do
if ! command -v "${linter}" >/dev/null; then
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2
exit 1
fi
done
exit_code=0
for source in Package.swift Sources Tests; do
printf -- $'--> 🦅 %s swift-format\n' "${source}"
swift-format lint --strict --recursive "${source}"
((exit_code |= ${?}))
printf -- $'--> 🦅 %s swiftformat\n' "${source}"
script -q /dev/null swiftformat --lint --strict "${source}" |
(grep -vxE '(?:\^D\x08{2})?Running SwiftFormat\.{3}\r|\(lint mode - no files will be changed\.\)\r|Reading (?:config|swift-version) file at .*|\x1b\[32mSwiftFormat completed in \d+(?:\.\d+)?s\.\x1b\[0m\r|0/\d+ files require formatting\.\r' || true)
((exit_code |= ${?}))
printf -- $'--> 🦅 %s swiftlint\n' "${source}"
swiftlint --strict --quiet "${source}"
((exit_code |= ${?}))
done
printf -- $'--> 🐚 ShellCheck\n'
shellcheck -s bash -o all -e SC1088,SC1102,SC2066,SC2296,SC2299,SC2300,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.)
((exit_code |= ${?}))
printf -- $'--> 💤 zsh syntax\n'
for script in script/**/*(.); do
/bin/zsh -n "${script}"
((exit_code |= ${?}))
done
printf -- $'--> 〽️ Markdown\n'
markdownlint --config .markdownlint.json . docs
((exit_code |= ${?}))
printf -- $'--> 📝 YAML\n'
yamllint .
((exit_code |= ${?}))
printf -- $'--> 🌳 Git\n'
git diff --check
((exit_code |= ${?}))
printf -- $'--> 🌀 Periphery\n'
script -q /dev/null periphery scan --strict --quiet --disable-update-check |
(grep -vxE '(?:\x1b\[0;1;32m|\^D\x08{2})\* (?:\x1b\[0;0m\x1b\[0;1m)?No unused code detected\.(?:\x1b\[0;0m)?\r' || true)
((exit_code |= ${?}))
exit "${exit_code}"