util, test: improve inspect escaping by BridgeAR · Pull Request #21624 · nodejs/node

added 3 commits

July 2, 2018 22:49
Right now util.inspect will always escape single quotes. That is not
necessary though in case the string that will be escaped does not
contain double quotes. In that case the string can simply be wrapped
in double quotes instead.
This reduces the amount of quotes util.inspect escapes by falling
back to backticks in case a string contains single and double quotes.
That makes sure only very few strings have to escape quotes at all.
Thus it increases the readability of these strings.
The string escaping is hard to read. This changes all those escaped
strings to use double quotes instead so no escaping is necessary.

@BridgeAR BridgeAR added the semver-major

PRs that contain breaking changes and should be released in the next major version.

label

Jul 2, 2018

@BridgeAR

mcollina

BridgeAR added a commit to BridgeAR/node that referenced this pull request

Jul 16, 2018
Right now util.inspect will always escape single quotes. That is not
necessary though in case the string that will be escaped does not
contain double quotes. In that case the string can simply be wrapped
in double quotes instead.
If the string contains single and double quotes and it does not
contain `${` as part of the string, backticks will be used instead.
That makes sure only very few strings have to escape quotes at all.
Thus it increases the readability of these strings.

PR-URL: nodejs#21624
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

BridgeAR added a commit to BridgeAR/node that referenced this pull request

Jul 16, 2018
The string escaping is hard to read. This changes all those escaped
strings to use double quotes instead so no escaping is necessary.

PR-URL: nodejs#21624
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

targos pushed a commit that referenced this pull request

Jul 31, 2018
The string escaping is hard to read. This changes all those escaped
strings to use double quotes instead so no escaping is necessary.

PR-URL: #21624
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

This was referenced

Aug 1, 2018

@bnb bnb mentioned this pull request

Sep 12, 2019

@BridgeAR BridgeAR deleted the improve-inspect-escaping branch

January 20, 2020 11:34

Open

@sttk sttk mentioned this pull request

Dec 5, 2021