~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/lint-all -rwxr-xr-x 1.1 KiB
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 2 months ago
                                                                                
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
#!/usr/bin/env bash
# lint-all -- run all prose linters on a file and summarize
set -euo pipefail

file="${1:?Usage: lint-all <file>}"
total=0

run_linter() {
    local name="$1" cmd="$2"
    echo "========== $name =========="
    local output
    output=$(eval "$cmd" 2>/dev/null) || true
    if [ -n "$output" ]; then
        echo "$output"
        local count
        count=$(echo "$output" | wc -l)
        total=$((total + count))
    else
        echo "(clean)"
    fi
    echo ""
}

if command -v vale &>/dev/null; then
    run_linter "VALE" "vale '$file'"
fi

if command -v proselint &>/dev/null; then
    run_linter "PROSELINT" "proselint '$file'"
fi

if command -v write-good &>/dev/null; then
    run_linter "WRITE-GOOD" "write-good '$file'"
fi

if command -v alex &>/dev/null; then
    run_linter "ALEX" "alex '$file'"
fi

if command -v diction &>/dev/null; then
    run_linter "DICTION" "diction -s '$file'"
fi

if command -v harper &>/dev/null; then
    run_linter "HARPER" "harper lint '$file'"
fi

echo "========== SUMMARY =========="
echo "Total issues: ~$total"