Skip to content
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

Rule proposal: no-useless-nesting-in-template-literals #1652

Closed
dimaMachina opened this issue Dec 21, 2021 · 2 comments
Closed

Rule proposal: no-useless-nesting-in-template-literals #1652

dimaMachina opened this issue Dec 21, 2021 · 2 comments

Comments

@dimaMachina
Copy link
Contributor

dimaMachina commented Dec 21, 2021

Description

Reports nested instances of a string or a template literal. Suggests inlining the nested instances into the containing template string.
inspired by JetBrains https://www.jetbrains.com/help/phpstorm/javascript-and-typescript-redundant-nesting-in-template-literal.html

Fail

`Hello, ${`Brave ${"New"}`} ${"World"}!`

`${2021} year!`

`${true} or ${false}`

`${String(someVar)} foo` // redundant call String as .toString() will be applied automatically

Pass

`Hello, Brave New World!`

`2021 year!`

`true or false`

`${someVar} foo`
@sindresorhus
Copy link
Owner

For consistency, it should be called no-useless-nesting-in-template-literals (also note the s at the end)

@dimaMachina dimaMachina changed the title Rule proposal: no-redundant-nesting-in-template-literal Rule proposal: no-useless-nesting-in-template-literals Dec 21, 2021
@fisker
Copy link
Collaborator

fisker commented Dec 22, 2021

Is this duplicate of #1261?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants