diff --git a/linter-configs/vnu_filter.jq b/linter-configs/vnu_filter.jq index cde7cb1..7aa7ef4 100644 --- a/linter-configs/vnu_filter.jq +++ b/linter-configs/vnu_filter.jq @@ -1,26 +1,27 @@ # Filter false positives from the .messages entry of Nu Validator output .messages |= map( . | select( + .type == "info" and ( + .message == "Trailing slash on void elements has no effect and interacts badly with unquoted attribute values." + and (.url | test(".html")) + ) or .type == "error" and ( - ( # See https://github.com/w3c/css-validator/issues/361 - .message == "CSS: Parse Error." - and .extract == "){outline:none}}@media(prefers" - and .hiliteLength == 1 - ) - or ( # See https://github.com/validator/validator/issues/1166 # This false-positive has been fixed; will remove once validator.nu updates # validator.w3.org/nu is up-to-date. .message == "Attribute “media” not allowed on element “meta” at this point." and (.extract | test(" name=\"theme-color\"")) - ) - or + ) or ( # see https://github.com/w3c/css-validator/issues/369 .message == "CSS: “contain-intrinsic-size”: Property “contain-intrinsic-size” doesn't exist." - ) - or + ) or ( # see https://github.com/w3c/css-validator/issues/370 .message == "CSS: “contain”: “inline-size” is not a “contain” value." + ) or + ( # See https://github.com/w3c/css-validator/issues/361 + .message == "CSS: Parse Error." + and .extract == "){outline:none}}@media(prefers" + and .hiliteLength == 1 ) ) | not ) diff --git a/scripts/vnu.sh b/scripts/vnu.sh index 34b7bba..6370c50 100644 --- a/scripts/vnu.sh +++ b/scripts/vnu.sh @@ -1,16 +1,28 @@ #!/bin/sh + +# Runs the Nu HTML checker (assumed to be available on your $PATH as `vnu`) on all pages. + +#shellcheck disable=SC3040 # This only sets pipefail if it's available and otherwise does nothing +set -o pipefail 2>/dev/null || true set -e -u dirname="$(dirname "$0")" output_dir="$1" +# List all HTML, XHTML, and SVG files we wish to check. +# We test both XHTML and HTML files, despite the fact that they are identical, because we want to validate under both an HTML and XML parser. VNU has some HTML-only checks. find_files_to_analyze() { - find "$output_dir" -type f -name '*.xhtml' -o -name '*.svg' \ + find "$output_dir" -type f -name '*.html' -o -name '*.xhtml' -o -name '*.svg' \ | grep -Ev '(bimi\.svg|search/index\.x?html)$' } +# Force a non-zero exit code for vnu. We'll decide the exit status after filtering out false-posives. +vnu_nofail() { + xargs vnu --stdout --format json --also-check-svg || true +} + # files_to_analyze="$(find_files_to_analyze)" # we skip the BIMI icon (VNU can't handle SVG 1.2) and the search page (it has raw templates). find_files_to_analyze \ - | xargs vnu --stdout --format json --also-check-svg \ + | vnu_nofail \ | sh "$dirname/filter-vnu.sh"