Files
zulip/tools/run-codespell
rht a3a71487b0 CI: Add Codespell linter.
This tool helps catch common typos in code and documentation, which is
particularly useful for our many contributors who are not native
English speakers.

The config is based on the codespell that I ran in
https://github.com/zulip/zulip/pull/18535.
2021-10-27 16:49:30 -07:00

23 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fix common misspellings in text files (config: .codespellignore)
# Based on
# https://github.com/bitcoin/bitcoin/blob/master/test/lint/lint-spelling.sh
#
# We plan to replace this script with the `tools/lint` system as soon as we can.
IGNORE_WORDS_FILE=.codespellignore
FILES_TO_BE_CHECKED=$*
if [ -z "$FILES_TO_BE_CHECKED" ]; then
echo "No argument specified. Checking on the entire repo..."
FILES_TO_BE_CHECKED="$(git ls-files -- ':(exclude)locale' ':(exclude)*fixtures*' ':(exclude)*.svg' ':(exclude)docs/translating' ':(exclude)yarn.lock' ':(exclude)docs/THIRDPARTY' ':(exclude)*postgresql.conf.template.erb' ':(exclude)tools/setup/emoji/emoji_names.py' ':(exclude)tools/setup/emoji/emoji_map.json' ':(exclude)zerver/management/data/unified_reactions.json')"
else
echo "Checking $FILES_TO_BE_CHECKED"
fi
mapfile -t FILES_TO_BE_CHECKED <<<"$FILES_TO_BE_CHECKED"
if ! codespell --ignore-words=$IGNORE_WORDS_FILE "${FILES_TO_BE_CHECKED[@]}"; then
echo "You may check the files for typo again using ./tools/run-codespell <file 1> <file 2> ... <file n>"
exit 1
fi