Add lint step for ambiguous list literals#267
Conversation
Copy whatwg/whatwg.org@33ad837 and adjust formatting slightly.
|
@noamr @zcorpan it seems that this list literal check isn't working as expected, at least the error message isn't. See the output at https://github.com/whatwg/html-build/runs/4689408108.
|
| 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' |
There was a problem hiding this comment.
grep $'[\u226a\u226b]' "$1" | perl -CSDA -lpe 'print "\nWrong list literals, use \xAB\xBB instead:" if $. == 1'
should work in the context of html-build
Not sure why it shows an error though, the grep on source doesn't find anything
There was a problem hiding this comment.
What's the difference? Why would perl require different arguments for this particular line and not the others?
There was a problem hiding this comment.
Because Perl doesn't handle UTF8 by default. The other commands don't have unicode characters
There was a problem hiding this comment.
I see, so should we change the other script as well then?
There was a problem hiding this comment.
So when I run grep $'[\u226a\u226b]' source locally on macOS it seems to return every line in the file, essentially. That's probably why this goes wrong.
There was a problem hiding this comment.
Strange, doesn't on my Mac
Will try to reproduce
There was a problem hiding this comment.
OK it was a bash vs zsh thing. The next line works and seems portable:
perl -CSDA -ne '$/ = "\n\n"; print "$_" if (/[\x{226A}\x{226B}]/si)' $1 | perl -CSDA -lpe 'print "\nWrong list literals, use \xAB\xBB instead:" if $. == 1'
Copy whatwg/whatwg.org@33ad837 and adjust formatting slightly.