Skip to content

Reduce quote escaping by using template literals #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nfischer opened this issue Oct 18, 2017 · 4 comments
Closed

Reduce quote escaping by using template literals #788

nfischer opened this issue Oct 18, 2017 · 4 comments

Comments

@nfischer
Copy link
Member

I noticed that we're escaping quote characters in some of our test descriptions (example). We should be able to avoid this by preferring template literals for such scenarios. The motivation is to improve readability.

We should also consider:

  1. Prefer template literals over string concatenation (eslint rule)
  2. Prefer template literals everywhere (I don't think there's any real downside) (eslint rule)
@nfischer
Copy link
Member Author

To clarify, this should be limited to only our tests (because those use ES6). Once we drop support for node 4/5, we can expand this to cover the whole source tree.

Preferring template literals for all of the tests might be a bit harsh, but preferring them over string concatenation sound reasonable.

@blubrick
Copy link

blubrick commented Oct 7, 2019

I would be happy to have a crack at this gruntwork. It seems pretty simple, if a little tedious(hence the 'chore' label, I guess).

So I cloned the repo and ran npm install

Is that right - 51 package vulnerabilities? I figure I gotta be doing something wrong. (Ubuntu 18.04, node 12.7.0, npm 6.11.3)

Fortunately, it seems that only one of them is considered to be a SEMVER WARNING. The remaining 50 (lots of dupes) can be resolved via npm audit fix upgrading 6 packages, but then my build env will not not be the same as the repo.

Do you think I should raise this as a separate issue?

@nfischer
Copy link
Member Author

nfischer commented Oct 8, 2019

@blubrick yes, please file a separate issue. I'm happy to take a look at the report (and would also appreciate PRs to update flagged packages if doing so does not break the project).

@nfischer
Copy link
Member Author

nfischer commented Oct 8, 2019

Do you think I should raise this as a separate issue?

Filed as #969

nfischer added a commit that referenced this issue Feb 20, 2025
This swaps out quote characters to limit how often we need to escape
strings. This is just to improve code readability.

Almost all of the changes could be done without changes to .eslintrc,
however this amends the lint rule to also permit backtick strings which
can be useful to eliminate a few extra instances of quote escaping.

Fixes issue #788
Test: npm run lint
nfischer added a commit that referenced this issue Feb 20, 2025
This swaps out quote characters to limit how often we need to escape
strings. This is just to improve code readability.

Almost all of the changes could be done without changes to .eslintrc,
however this amends the lint rule to also permit backtick strings which
can be useful to eliminate a few extra instances of quote escaping.

Fixes issue #788
Test: npm run lint
kmashint pushed a commit to kmashint/shelljs that referenced this issue Apr 10, 2025
This swaps out quote characters to limit how often we need to escape
strings. This is just to improve code readability.

Almost all of the changes could be done without changes to .eslintrc,
however this amends the lint rule to also permit backtick strings which
can be useful to eliminate a few extra instances of quote escaping.

Fixes issue shelljs#788
Test: npm run lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy