Files
AdGuardHome/scripts/make/txt-lint.sh
Ainar Garipov 295b2fefb1 Pull request 2380: ADG-9744-node-20
Squashed commit of the following:

commit 16e43b10edc8218f3d1ccec711d965c654dd851d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 28 12:32:58 2025 +0300

    all: upd chlog

commit 2a8dcab14e9cf43fe941f67f215efe2801f2aa65
Merge: 95a4ea8cc 8b4768aad
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 28 12:32:05 2025 +0300

    Merge branch 'master' into ADG-9744-node-20

commit 95a4ea8ccbcc8cb5911b6c33007e36a04b03e616
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Mar 24 14:06:25 2025 +0300

    bamboo-specs: fix test

commit c535028cd16bf2100b45828fe7f7693b938aaeb5
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Mar 24 14:02:47 2025 +0300

    all: imp npm cache

commit bfc9d11153446b865b9756f35753e791d4040595
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 21 19:06:37 2025 +0300

    all: fix specs

commit 7127498d6aa0e0ca4585d79a15ed5f3c5e643e3a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 21 18:50:57 2025 +0300

    all: upd node; rm outdated openapi lint
2025-03-28 14:54:02 +03:00

117 lines
2.4 KiB
Bash

#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a remarkable change is made to this script.
#
# AdGuard-Project-Version: 8
verbose="${VERBOSE:-0}"
readonly verbose
if [ "$verbose" -gt '0' ]; then
set -x
fi
# Set $EXIT_ON_ERROR to zero to see all errors.
if [ "${EXIT_ON_ERROR:-1}" -eq '0' ]; then
set +e
else
set -e
fi
# We don't need glob expansions and we want to see errors about unset variables.
set -f -u
# Source the common helpers, including not_found.
. ./scripts/make/helper.sh
# Simple analyzers
# trailing_newlines is a simple check that makes sure that all plain-text files
# have a trailing newlines to make sure that all tools work correctly with them.
trailing_newlines() (
nl="$(printf '\n')"
readonly nl
find . \
'(' \
-type 'd' \
'(' \
-name 'node_modules' \
-o -path './.git' \
-o -path './bin' \
-o -path './build' \
-o -path './client/playwright-report' \
')' \
-prune \
')' \
-o \
-type 'f' \
'!' '(' \
-name '*.db' \
-o -name '*.exe' \
-o -name '*.out' \
-o -name '*.png' \
-o -name '*.svg' \
-o -name '*.tar.gz' \
-o -name '*.test' \
-o -name '*.zip' \
-o -name 'AdGuardHome' \
-o -name 'adguard-home' \
')' \
-print \
| while read -r f; do
final_byte="$(tail -c -1 "$f")"
if [ "$final_byte" != "$nl" ]; then
printf '%s: must have a trailing newline\n' "$f"
fi
done
)
# trailing_whitespace is a simple check that makes sure that there are no
# trailing whitespace in plain-text files.
trailing_whitespace() {
find . \
-type 'f' \
'!' '(' \
-name '*.db' \
-o -name '*.exe' \
-o -name '*.out' \
-o -name '*.png' \
-o -name '*.svg' \
-o -name '*.tar.gz' \
-o -name '*.test' \
-o -name '*.zip' \
-o -name 'AdGuardHome' \
-o -name 'adguard-home' \
-o -path '*/node_modules/*' \
-o -path './.git/*' \
-o -path './bin/*' \
-o -path './build/*' \
')' \
| while read -r f; do
grep -e '[[:space:]]$' -n -- "$f" \
| sed -e "s:^:${f}\::" -e 's/ \+$/>>>&<<</'
done
}
run_linter -e trailing_newlines
run_linter -e trailing_whitespace
find . \
-type 'f' \
'!' '(' \
-path '*/node_modules/*' \
-o -path './data/filters/*' \
')' \
'(' \
-name 'Makefile' \
-o -name '*.conf' \
-o -name '*.md' \
-o -name '*.txt' \
-o -name '*.yaml' \
-o -name '*.yml' \
')' \
-exec 'misspell' '--error' '{}' '+'