Add lint for filenames

We have established a pattern of Alpha and underscores for filenames.
This adds a hook to keep this pattern going. Also fixes a misnamed file
I found in the process.

Resolves #456
This commit is contained in:
Sean DuBois
2019-02-27 23:05:45 -08:00
parent 07e5c4e07e
commit 71053c1e16
3 changed files with 15 additions and 0 deletions

14
.github/lint-filename.sh vendored Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
GO_REGEX="^[a-zA-Z_]+\.go$"
find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do
filename=$(basename -- "$fullpath")
if ! [[ $filename =~ $GO_REGEX ]]; then
echo "$filename is not a valid filename for Go code, only alpha and underscores are supported"
exit 1
fi
done

View File

@@ -26,3 +26,4 @@ script:
- bash .github/assert-contributors.sh
- bash .github/lint-disallowed-functions-in-library.sh
- bash .github/lint-commit-message.sh
- bash .github/lint-filename.sh