-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlint
More file actions
executable file
·76 lines (66 loc) · 1.49 KB
/
lint
File metadata and controls
executable file
·76 lines (66 loc) · 1.49 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
#!/bin/bash
set -eu
validate-links() {
echo "validate-links: RUN"
# If the support/dist directory does not exist, build it
if [ ! -d "support/dist" ]; then
echo "Building project before running linting scripts"
npm run build
fi
if npm exec -- node support/dist/validateLinks.js ; then
echo validate-links: PASS
else
echo validate-links: FAIL
return 1
fi
}
markdownlint() {
echo "markdownlint: RUN"
if npm exec -- markdownlint --rules markdownlint-rule-search-replace '**/*.md' ; then
echo "markdownlint: PASS"
else
echo "markdownlint: FAIL"
return 1
fi
}
prettier() {
echo "prettier: RUN"
if npm exec -- prettier --check . ; then
echo "prettier: PASS"
else
echo "prettier: FAIL"
return 1
fi
}
lint-git-tree() {
echo "lint-git-tree: RUN"
if npx @blaahaj/lint-git-tree ; then
echo "lint-git-tree: PASS"
else
echo "lint-git-tree: FAIL"
return 1
fi
}
all() {
local rc=0
echo "lint: RUN"
validate-links || rc=1
markdownlint || rc=1
prettier || rc=1
lint-git-tree || rc=1
if [ $rc -eq 0 ] ; then
echo "lint: PASS"
else
echo "lint: FAIL"
echo "Try './lint --fix' to see if any automatic fixes are possible"
fi
return $rc
}
if [ "${1:-}" == "--fix" ] ; then
npm exec -- markdownlint --rules markdownlint-rule-search-replace --fix '**/*.md' || :
npm exec -- prettier --write --list-different . || :
elif [ "${1:-}" == "validate-links" ] ; then
validate-links
else
all
fi