Uh oh!
There was an error while loading. Please reload this page.
tools: non-Ascii linter for /lib only - #18043
Conversation
addaleax
left a comment
There was a problem hiding this comment.
I would make it clear somewhere in a comment that this only catches characters in literals, not the source code itself (which is what we would eventually want to have instead)
SirR4T
commented
Jan 8, 2018
oh? then @hkal 's approach of parsing all tokens would be preferred? I had assumed the eslint selector would select the source code too, i see where i might have gone wrong 😅 Also, doubts:
|
addaleax
commented
Jan 8, 2018
@SirR4T I’m not sure how to do it, but yes, you want all tokens and even comments.
It’s fine to have the escape sequences spelled out as escape sequences in the source code. What matters is whether the files themselves contain characters that don’t fit into the ASCII range, because that’s what the script that bakes those files into the I hope that’s helpful. :) |
SirR4T
commented
Jan 8, 2018
now I'm running into a very peculiar error, while doing I'm unable to disable the below error, via the regular methods ( |
SirR4T
commented
Jan 9, 2018
not-an-aardvark
commented
Jan 10, 2018
I'm a bit confused about why non-ascii characters would bloat the binary size. Aren't the files encoded as UTF-8? |
SirR4T
commented
Jan 10, 2018
@not-an-aardvark that is what I understood, from #11129 (comment) :
Is that not correct? |
addaleax
commented
Jan 10, 2018
addaleax
left a comment
There was a problem hiding this comment.
I mean, this still looks fine to me, but I’m not an expert for eslint anyway.
If it doesn’t catch the diagram in lib/timers.js and the check mark in lib/internal/test/unicode.js (for both of which we’ll want eslint-disable comments), it’s probably not quite strict enough, though.
There was a problem hiding this comment.
Any reason not to use a RegExp literal like this?:
constnonAsciiRegexPattern=/[^\r\n\x20-\x7e]/;Seems more readable to me and also more in line with our general coding style. (I'm kind of surprised this isn't caught by a lint rule itself, to be honest. Or maybe it is?)
There was a problem hiding this comment.
It might be better to match on source.text rather than each individual token, to ensure that non-ascii whitespace is detected (which would not be part of any token or comment).
SirR4T
commented
Jan 11, 2018
Yay! 🎉 Could catch the Any ideas? @Trott@not-an-aardvark |
SirR4T
commented
Jan 19, 2018
cc: @Trott@not-an-aardvark@addaleax can someone help me out here? I'm unable to skip the lint checks, inside |
not-an-aardvark
commented
Jan 19, 2018
I think there are a few issues:
If you make both of those changes, I think the disable comments will work as expected. |
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. Fixes: nodejs#11209
the linter should detect not just literals, but also source code and all comments too.
SirR4T
commented
Jan 19, 2018
Thanks @not-an-aardvark ! worked like a charm! pushing the latest changes, once the build is done. |
BridgeAR
commented
Feb 2, 2018
addaleax
commented
Feb 4, 2018
Landed in c45afe8 |
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: #18043Fixes: #11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: #18043Fixes: #11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: #18043Fixes: #11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: #18043Fixes: #11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
MylesBorins
commented
Mar 20, 2018
Should this be backported to |
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: nodejs#18043Fixes: nodejs#11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: nodejs#18043Fixes: nodejs#11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: #18043 Backport-PR-URL: #19499Fixes: #11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: nodejs#18043Fixes: nodejs#11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Non-ASCII characters in /lib get compiled into the node binary,
and may bloat the binary size unnecessarily. A linter rule may
help prevent this.
Fixes: #11209
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
eslint