Skip to content

Commit b5fbe9e

Browse files
committed
Add typo checking on pre-commit
This will use https://github.com/crate-ci/typos to warn on new typos before committing using bin/pre-commit.
1 parent 02a1023 commit b5fbe9e

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

.typos.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[default]
2+
extend-ignore-re = [
3+
# ns alias
4+
":as [0-9a-z]*\\]"
5+
]
6+
7+
[default.extend-words]
8+
Blance = "Blance"
9+
edn = "edn"
10+
juxt = "juxt"
11+
12+
[type.gpg]
13+
extend-glob = ["*.gpg"]
14+
check-file = false
15+
16+
[type.min-js]
17+
extend-glob = ["*.min.js"]
18+
check-file = false

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ tag-release:
3434
test:
3535
./bin/kaocha
3636

37+
.PHONY: typos
38+
typos:
39+
./bin/typos
40+
3741
.PHONY: uberjar
3842
uberjar:
3943
clojure -T:build uberjar

bin/pre-commit

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Make sure I'm not about to introduce more kondo linting errors/warnings
3+
# Make sure I'm not about to introduce more kondo linting errors/warnings or typos
44

55
# get just the clj/cljs files from the git changeset
66
changed_clj="$(git diff --cached --name-only | grep -E 'cljs?$')"
@@ -18,3 +18,10 @@ if [ -n "${changed_clj}" ] ; then
1818
git add "$f"
1919
done
2020
fi
21+
22+
changed_files="$(git diff --cached --name-only)"
23+
if [ -n "${changed_files}" ]; then
24+
if ! ./bin/typos $changed_files; then
25+
exit 1
26+
fi
27+
fi

bin/typos

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
# Self-extracting typos shim. Sourced releases from GitHub.
3+
4+
set -euo pipefail
5+
6+
TYPOS_VERSION="v1.22.9"
7+
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd)
8+
9+
function ensure_typos() {
10+
# Doesn't take args, simply reads variables set above.
11+
VERSION=$TYPOS_VERSION
12+
PLATFORM="$(uname -s)"
13+
ARCH="$(uname -m)"
14+
PATH_SUFFIX=""
15+
16+
if [ "${PLATFORM}" == "Darwin" ]; then
17+
if [ "${ARCH}" == "x86_64" ]; then
18+
PATH_SUFFIX="x86_64-apple-darwin"
19+
elif [ "${ARCH}" == "arm64" ]; then
20+
PATH_SUFFIX="aarch64-apple-darwin"
21+
fi
22+
elif [ "${PLATFORM}" == "Linux" ]; then
23+
if [ "${ARCH}" == "x86_64" ]; then
24+
PATH_SUFFIX="x86_64-unknown-linux-musl"
25+
fi
26+
fi
27+
28+
if [ -z "$PATH_SUFFIX" ]; then
29+
echo "Platform ${PLATFORM} and ${ARCH} combination is currently not supported" >&2 && exit 1
30+
fi
31+
32+
ARCHIVE="typos-${VERSION}-${PATH_SUFFIX}.tar.gz"
33+
CACHE_DIR="$ROOT/bin/.cache/typos-${VERSION}"
34+
if ! [ -f "${CACHE_DIR}/BOOTSTRAPPED" ]; then
35+
echo "Missing typos binary for version [${VERSION}] -- will download." >&2
36+
PACKAGE_FULL_URL="https://github.com/crate-ci/typos/releases/download/${VERSION}/${ARCHIVE}"
37+
mkdir -p "$ROOT/bin/.cache"
38+
pushd "$ROOT/bin/.cache" >/dev/null 2>&1 || exit 1
39+
echo "Downloading ${PACKAGE_FULL_URL}..." >&2
40+
curl -#L -O "${PACKAGE_FULL_URL}" ||
41+
(echo "Failed to download ${PACKAGE_FULL_URL}." && exit 1)
42+
43+
(rm -rf "$CACHE_DIR" &&
44+
mkdir "$CACHE_DIR" &&
45+
tar --extract --directory="$CACHE_DIR" -f "${ARCHIVE}") >&2 ||
46+
(echo "Failed to extract ${PACKAGE_FULL_URL}." && exit 1)
47+
rm -rf "${ARCHIVE}"
48+
touch "${CACHE_DIR}/BOOTSTRAPPED"
49+
popd >/dev/null 2>&1 || exit 2
50+
fi
51+
}
52+
53+
ensure_typos
54+
exec "${ROOT}/bin/.cache/typos-${VERSION}/typos" "$@"

resources/public/stylesheets/screen.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ a.login-button {
767767
color: #ffffff;
768768
padding: 5px 10px;
769769
display: block;
770-
-webkit-appearence: button;
770+
-webkit-appearance: button;
771771
text-align: center;
772772

773773
margin-top: 15px;

0 commit comments

Comments
 (0)