~kris/dots

srice

ref: e98f3b030dc24445bd55c68d95d2d81933fd68b3 srice/.local/bin/lint-all -rw-r--r-- 1.1 KiB
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month 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"