Repository navigation
Expand file tree
/
Copy pathlint-html
More file actions
executable file
·107 lines (97 loc) · 3.51 KB
/
Copy pathlint-html
File metadata and controls
executable file
·107 lines (97 loc) · 3.51 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# Echo commands to console.
set -x
# Exit on first failing command.
set -e
# Exit on unset variable.
set -u
readonly BUILD_DIR="public"
# Skips validation checks that take a long time.
htmlproofer_args_extra=""
if [ "${1-}" = "--quick" ]; then
htmlproofer_args_extra="--disable-external"
else
htmlproofer_args_extra="--check-external-hash"
fi
function join_by {
local IFS="$1"
shift
echo "$*"
}
# Ignore the following URLs because they get 403 errors from CI intermittently.
IGNORE_PATTERNS=()
IGNORE_PATTERNS+=("/adage.com/")
IGNORE_PATTERNS+=("/ark.intel.com/")
IGNORE_PATTERNS+=("/calculator.aws/")
IGNORE_PATTERNS+=("/community.bloggingfordevs.com/")
IGNORE_PATTERNS+=("/cypress.io/")
IGNORE_PATTERNS+=("/docs.github.com/")
IGNORE_PATTERNS+=("/fdc.nal.usda.gov/")
IGNORE_PATTERNS+=("/feinternational.com/")
IGNORE_PATTERNS+=("/github.com/")
IGNORE_PATTERNS+=("/gitlab.gnome.org/")
IGNORE_PATTERNS+=("/gusto.com/")
IGNORE_PATTERNS+=("/help.shipstation.com/")
IGNORE_PATTERNS+=("/indiebound.org/")
IGNORE_PATTERNS+=("/isitketo.org/")
IGNORE_PATTERNS+=("/mediagoblin-v5lmqis51k.herokuapp.com/")
IGNORE_PATTERNS+=("/medium.com/")
IGNORE_PATTERNS+=("/newegg.com/")
IGNORE_PATTERNS+=("/opensource.org/")
IGNORE_PATTERNS+=("/pcpartpicker.com/")
IGNORE_PATTERNS+=("/playwright.dev/")
IGNORE_PATTERNS+=("/redd.it/")
IGNORE_PATTERNS+=("/reddit.com/")
IGNORE_PATTERNS+=("/servernope.com/")
IGNORE_PATTERNS+=("/splashthat.com/")
IGNORE_PATTERNS+=("/typeform.com/")
IGNORE_PATTERNS+=("/twitter.com/")
IGNORE_PATTERNS+=("/upwork.com/")
IGNORE_PATTERNS+=("/vimeo.com/")
IGNORE_PATTERNS+=("/vmware.com/")
IGNORE_PATTERNS+=("/wpengine.com/")
IGNORE_PATTERNS+=("/www.amd.com/")
IGNORE_PATTERNS+=("/www.bls.gov/")
IGNORE_PATTERNS+=("/www.buzzfeednews.com/")
IGNORE_PATTERNS+=("/www.bhphotovideo.com/")
IGNORE_PATTERNS+=("/www.digitalfaq.com/")
IGNORE_PATTERNS+=("/www.kissmyketo.com/")
IGNORE_PATTERNS+=("/www.investopedia.com/")
IGNORE_PATTERNS+=("/www.irs.gov/")
IGNORE_PATTERNS+=("/www.linkedin.com/")
IGNORE_PATTERNS+=("/www.nber.org/")
IGNORE_PATTERNS+=("/www.nccgroup.com/")
IGNORE_PATTERNS+=("/www.raspberrypi.com/")
IGNORE_PATTERNS+=("/www.raspberrypi.org/")
IGNORE_PATTERNS+=("/www.reddit.com/")
IGNORE_PATTERNS+=("/www.sciencedirect.com/")
IGNORE_PATTERNS+=("/www.servicenow.com/")
IGNORE_PATTERNS+=("/www.usta.com/")
# Ignore links to comments that only load in production.
IGNORE_PATTERNS+=("/mtlynch.io\/.*#comment-.*/")
URL_IGNORE="$(join_by , "${IGNORE_PATTERNS[@]}")"
IGNORED_FILES_ARR=()
IGNORED_FILES_ARR+=("public/collect-debt/full-emails/index.html")
IGNORED_FILES_ARR+=("public/notes/archivebox/reddit-singlefile.html")
IGNORED_FILES="$(join_by , "${IGNORED_FILES_ARR[@]}")"
# Run HTMLProofer
htmlproofer \
--only-4xx \
--checks 'Links,Images,Scripts,Favicon,OpenGraph' \
--allow-missing-href \
--allow-hash-href \
--ignore-empty-alt \
--ignore-missing-alt \
--ignore-files "${IGNORED_FILES}" \
`# Swap URLs https://mtlynch.io/ for / so that htmlproofer checks the local` \
`# build rather than the production URLs. At the time this check runs, the` \
`# site has not yet deployed, so htmlproofer shouldn't try to hit the real` \
`# mtlynch.io server to verify that URLs are present.` \
--swap-urls "https\://mtlynch.io/:/" \
--ignore-urls "${URL_IGNORE}" \
`# Some sites return HTTP 400/429 - No Error when HTMLProofer sends ` \
`# requests, so ignore those. Ignore 403s because it's mostly CI noise.` \
--ignore-status-codes "400,403,429" \
--no-enforce-https \
"$htmlproofer_args_extra" \
"${BUILD_DIR}"