From 3fe158a14ec90be5d204e1e13924db47ec41a0a9 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 3 Jan 2022 10:12:56 +0100 Subject: [PATCH 1/2] Add lint step for ambiguous list literals Copy https://github.com/whatwg/whatwg.org/commit/33ad837c0dc53b68865f4a35ccdc1c68dc07fce6 and adjust formatting slightly. --- lint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lint.sh b/lint.sh index dbd38e19..3dd15ee5 100755 --- a/lint.sh +++ b/lint.sh @@ -7,7 +7,8 @@ if [ "$#" -ne 1 ]; then fi # show potential problems -MATCHES=$(grep -niE '( (code|span|var)(>| data-x=)|[^<;]/(code|span|var)>)' "$1" | perl -lpe 'print "\nPossible copypasta:" if $. == 1' +MATCHES=$( + grep -niE '( (code|span|var)(>| data-x=)|[^<;]/(code|span|var)>)' "$1" | perl -lpe 'print "\nPossible copypasta:" if $. == 1' perl -ne '$/ = "\n\n"; print "$_" if (/chosing|approprate|occured|elemenst|\bteh\b|\blabelled\b|\blabelling\b|\bhte\b|taht|linx\b|speciication|attribue|kestern|horiontal|\battribute\s+attribute\b|\bthe\s+the\b|\bthe\s+there\b|\bfor\s+for\b|\bor\s+or\b|\bany\s+any\b|\bbe\s+be\b|\bwith\s+with\b|\bis\s+is\b/si)' "$1" | perl -lpe 'print "\nPossible typos:" if $. == 1' grep -niE '((anonym|author|categor|custom|emphas|initial|local|minim|neutral|normal|optim|raster|real|recogn|roman|serial|standard|summar|synchron|synthes|token|optim)is(e|ing|ation|ability)|(col|behavi|hono|fav)our)' "$1" | grep -vE "\ben-GB\b" | perl -lpe 'print "\nen-GB spelling (use lang=\"en-GB\", or , on the same line to override):" if $. == 1' perl -ne '$/ = "\n\n"; print "$_" if (/\ban\s+(<[^>]*>)*(?!(L\b|http|https|href|hgroup|rb|rp|rt|rtc|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html)[b-df-hj-np-tv-z]/si or /\b(?)(<[^>]*>)*(?!>|one)(?:(L\b|http|https|href|hgroup|rt|rp|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html|[aeio])/si)' "$1" | perl -lpe 'print "\nPossible grammar problem: \"a\" instead of \"an\" or vice versa (to override, use e.g. \"a apple\"):" if $. == 1' @@ -15,9 +16,10 @@ MATCHES=$(grep -niE '( (code|span|var)(>| data-x=)|[^<;]/(code|span|var)>)' "$1" grep -niE '\s+$' "$1" | perl -lpe 'print "\nTrailing whitespace:" if $. == 1' grep $'\t' "$1" | perl -lpe 'print "\nTab:" if $. == 1' grep $'\xc2\xa0' "$1" | perl -lpe 'print "\nUnescaped nonbreaking space:" if $. == 1' + grep $'[\u226a\u226b]' "$1" | perl -lpe 'print "\nWrong list literals, use \uAB\uBB instead:" if $. == 1' perl -ne '$/ = "\n\n"; print "$_" if (/class="?(note|example).+(\n.+)*\s+(should|must|may|optional|recommended)(\s|$)/mi)' "$1" | perl -lpe 'print "\nRFC2119 keyword in example or note (use: might, can, has to, or override with must):" if $. == 1' perl -ne '$line++; $in_domintro = 1 if (/^
$/); print "$line: $_" if ($in_domintro && /\s+(should|must|may|optional|recommended)(\s|$)/i); $in_domintro = 0 if (/^ <\/dl>$/)' "$1" | perl -lpe 'print "\nRFC2119 keyword in domintro (use: might, can, has to, or override with must):" if $. == 1' - ) +) if [ -n "$MATCHES" ]; then echo "$MATCHES" From ba073940d1891b0e216fe4e415931e047d19ff23 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 5 Jan 2022 14:46:51 +0100 Subject: [PATCH 2/2] incorperate suggestion from noamr --- lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint.sh b/lint.sh index 3dd15ee5..9d63e9e5 100755 --- a/lint.sh +++ b/lint.sh @@ -16,7 +16,7 @@ MATCHES=$( grep -niE '\s+$' "$1" | perl -lpe 'print "\nTrailing whitespace:" if $. == 1' grep $'\t' "$1" | perl -lpe 'print "\nTab:" if $. == 1' grep $'\xc2\xa0' "$1" | perl -lpe 'print "\nUnescaped nonbreaking space:" if $. == 1' - grep $'[\u226a\u226b]' "$1" | perl -lpe 'print "\nWrong list literals, use \uAB\uBB instead:" if $. == 1' + grep $'[\u226a\u226b]' "$1" | perl -CSDA -lpe 'print "\nWrong list literals, use \xAB\xBB instead:" if $. == 1' perl -ne '$/ = "\n\n"; print "$_" if (/class="?(note|example).+(\n.+)*\s+(should|must|may|optional|recommended)(\s|$)/mi)' "$1" | perl -lpe 'print "\nRFC2119 keyword in example or note (use: might, can, has to, or override with must):" if $. == 1' perl -ne '$line++; $in_domintro = 1 if (/^
$/); print "$line: $_" if ($in_domintro && /\s+(should|must|may|optional|recommended)(\s|$)/i); $in_domintro = 0 if (/^ <\/dl>$/)' "$1" | perl -lpe 'print "\nRFC2119 keyword in domintro (use: might, can, has to, or override with must):" if $. == 1' )