From 3cdb08c5104ac140bfeecf6a2deca79a47544bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 27 Jun 2023 14:34:17 -0400 Subject: [PATCH] add basic lint checks for all git-tracked text files, assert that: - No trainling whitespaces at EOLs - No tab characters - a newline at EOF --- .github/workflows/lint.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d1604f6..be83f24 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,3 +13,21 @@ jobs: node-version: '18' - run: npm install -g markdownlint-cli - run: markdownlint '**/*.md' --ignore-path=.gitignore + - name: "No trailing whitespaces at EOLs" + run: | + EXIT_CODE=0 + git --no-pager grep --full-name -I -n -e ' $' . && EXIT_CODE=1 + exit $EXIT_CODE + - name: "No tab characters" + run: | + EXIT_CODE=0 + git --no-pager grep --full-name -I -n -P '\t' . && EXIT_CODE=1 + exit $EXIT_CODE + - name: "Newline at EOF" + run: | + EXIT_CODE=0 + for f in $(git --no-pager grep --full-name -I -l ''); do + tail -c1 "$f" | read -r _ || echo "$f" + tail -c1 "$f" | read -r _ || EXIT_CODE=1 + done + exit $EXIT_CODE