Adguardhome/scripts/make/txt-lint.sh
Ildar Kamalov e8e3287091
Some checks are pending
build / test (macOS-latest) (push) Waiting to run
build / test (ubuntu-latest) (push) Waiting to run
build / test (windows-latest) (push) Waiting to run
build / build-release (push) Blocked by required conditions
build / notify (push) Blocked by required conditions
lint / go-lint (push) Waiting to run
lint / eslint (push) Waiting to run
lint / notify (push) Blocked by required conditions
Pull request 2729: AGDNS-4282 add rubik font
Squashed commit of the following:

commit 6320d299fbe732f88af0f57b2e12956f7ecb64dc
Merge: 0c42ecbe6 599cfa9eb
Author: Ildar Kamalov <ik@adguard.com>
Date:   Thu Jul 23 17:23:14 2026 +0300

    Merge branch 'master' into AGDNS-4282

commit 0c42ecbe641958e5a7e23e243281281a6f928e4d
Author: Ildar Kamalov <ik@adguard.com>
Date:   Thu Jul 23 17:14:29 2026 +0300

    fix txt-lint sort

commit 433330d4f9
Author: Ildar Kamalov <ik@adguard.com>
Date:   Wed Jul 22 17:21:50 2026 +0300

    fix

commit e611cd21be
Author: Ildar Kamalov <ik@adguard.com>
Date:   Wed Jul 22 17:19:37 2026 +0300

    fix

commit b07ad6e630
Author: Ildar Kamalov <ik@adguard.com>
Date:   Wed Jul 22 17:17:56 2026 +0300

    fix

commit f5819feb09
Author: Ildar Kamalov <ik@adguard.com>
Date:   Wed Jul 22 17:15:56 2026 +0300

    fix

commit 227e95912a
Author: Ildar Kamalov <ik@adguard.com>
Date:   Wed Jul 22 17:13:55 2026 +0300

    AGDNS-4282 add rubik font
2026-07-23 14:29:11 +00:00

135 lines
2.8 KiB
Bash

#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 12
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_with_ignore \
-type 'f' \
'!' '(' \
-name '*.db' \
-o -name '*.exe' \
-o -name '*.ico' \
-o -name '*.out' \
-o -name '*.png' \
-o -name '*.svg' \
-o -name '*.tar.gz' \
-o -name '*.test' \
-o -name '*.woff2' \
-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_with_ignore \
-type 'f' \
'!' '(' \
-name '*.db' \
-o -name '*.exe' \
-o -name '*.ico' \
-o -name '*.out' \
-o -name '*.png' \
-o -name '*.svg' \
-o -name '*.tar.gz' \
-o -name '*.test' \
-o -name '*.woff2' \
-o -name '*.zip' \
-o -name 'AdGuardHome' \
-o -name 'adguard-home' \
')' \
-print \
| while read -r f; do
grep -e '[[:space:]]$' -n -- "$f" \
| sed -e "s:^:${f}\::" -e 's/ \+$/>>>&<<</'
done
}
# valid_json check ensures that all the .json files in the project are valid and
# well-formatted according to the jq.
#
# TODO(e.burkov): Include tsconfig.json when it stop containing comments.
valid_json() {
find_with_ignore \
-type 'f' \
-name '*.json' \
'!' '(' \
-name 'tsconfig.json' \
')' \
-print \
| while read -r f; do
validation_msg="$(jq empty "$f" 2>&1)"
exitcode="$?"
if [ "$exitcode" -ne '0' ]; then
printf 'file %s: %s\n' "$f" "$validation_msg"
continue
fi
if ! jq . "$f" | diff -u "$f" - >/dev/null 2>&1; then
printf 'file %s has formatting issues\n' "$f"
fi
done
}
run_linter -e trailing_newlines
run_linter -e trailing_whitespace
run_linter -e valid_json
go="${GO:-go}"
readonly go
find_with_ignore \
-type 'f' \
'(' \
-name 'Makefile' \
-o -name '*.conf' \
-o -name '*.md' \
-o -name '*.txt' \
-o -name '*.yaml' \
-o -name '*.yml' \
')' \
-exec "$go" 'tool' 'misspell' '--error' '{}' '+' \
;